blaster/Source/Blaster/PlayerController/BlasterPlayerController.h

105 lines
2.8 KiB
C
Raw Normal View History

2022-05-05 15:57:57 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "BlasterPlayerController.generated.h"
/**
*
*/
UCLASS()
class BLASTER_API ABlasterPlayerController : public APlayerController
{
GENERATED_BODY()
2022-05-07 10:03:33 +00:00
public:
2022-05-10 20:34:28 +00:00
virtual void Tick(float DeltaTime) override;
2022-05-10 08:40:23 +00:00
virtual void OnPossess(APawn* InPawn) override;
2022-05-10 09:14:54 +00:00
virtual void ReceivedPlayer() override; // Sync with server clock as soon as possible
2022-05-10 10:42:09 +00:00
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
2022-05-10 17:05:04 +00:00
2022-05-07 10:03:33 +00:00
void SetHUDHealth(float Health, float MaxHealth);
2022-05-09 14:33:48 +00:00
void SetHUDScore(float Score);
2022-05-09 15:16:41 +00:00
void SetHUDDefeats(int32 Defeats);
2022-05-09 16:39:41 +00:00
void SetHUDWeaponAmmo(int32 Ammo);
2022-05-09 17:35:28 +00:00
void SetHUDCarriedAmmo(int32 Ammo);
2022-05-10 08:40:23 +00:00
void SetHUDMatchCountdown(float CountdownTime);
2022-05-10 12:23:23 +00:00
void SetHUDAnnouncementCountdown(float CountdownTime);
2022-05-11 19:02:33 +00:00
void SetDebugMsg1(FString Key, FString Value);
void SetDebugMsg2(FString Key, FString Value);
void SetDebugMsg3(FString Key, FString Value);
void SetDebugMsg4(FString Key, FString Value);
void SetDebugMsg5(FString Key, FString Value);
void SetDebugMsg6(FString Key, FString Value);
2022-05-10 09:14:54 +00:00
// Synced with server world clock
virtual float GetServerTime();
2022-05-10 10:42:09 +00:00
void OnMatchStateSet(FName State);
2022-05-10 12:55:02 +00:00
void HandleCooldown();
2022-05-07 10:03:33 +00:00
2022-05-10 17:05:04 +00:00
protected:
2022-05-07 10:03:33 +00:00
virtual void BeginPlay() override;
2022-05-10 09:14:54 +00:00
void CheckTimeSync(float DeltaSeconds);
2022-05-10 11:31:39 +00:00
void HandleMatchHasStarted();
2022-05-10 08:40:23 +00:00
void SetHUDTime();
2022-05-10 10:42:09 +00:00
void PollInit();
2022-05-10 09:14:54 +00:00
// Sync time between client and server
// Requests the current server time, passing in the client's time when the request was sent
UFUNCTION(Server, Reliable)
void ServerRequestServerTime(float TimeOfClientRequest);
// Reports the current server time to the client in response to ServerRequestServerTime
UFUNCTION(Client, Reliable)
void ClientReportServerTime(float TimeOfClientRequest, float TimeServerReceivedClientRequest);
// Difference between client and server time
2022-05-10 17:05:04 +00:00
float ClientServerDelta = 0.f;
2022-05-10 09:14:54 +00:00
UPROPERTY(EditAnywhere, Category = Time)
2022-05-10 10:15:22 +00:00
float TimeSyncFrequency = 5.f;
2022-05-10 09:14:54 +00:00
float TimeSyncRunningTime = 0.f;
2022-05-10 12:23:23 +00:00
UFUNCTION(Server, Reliable)
void ServerCheckMatchState();
UFUNCTION(Client, Reliable)
2022-05-10 20:34:28 +00:00
void ClientJoinMidgame(FName StateOfMatch, float Warmup, float Match, float Cooldown, float StartingTime);
2022-05-07 10:03:33 +00:00
2022-05-10 17:05:04 +00:00
private:
2022-05-09 15:16:41 +00:00
UPROPERTY()
2022-05-07 10:03:33 +00:00
class ABlasterHUD* BlasterHUD;
2022-05-10 08:40:23 +00:00
2022-05-10 13:29:00 +00:00
UPROPERTY()
class ABlasterGameMode* BlasterGameMode;
2022-05-10 17:05:04 +00:00
2022-05-10 12:23:23 +00:00
float LevelStartingTime = 0.f;
float MatchTime = 0.f;
float WarmupTime = 0.f;
2022-05-10 13:29:00 +00:00
float CooldownTime = 0.f;
2022-05-10 08:40:23 +00:00
uint32 CountdownInt = 0;
2022-05-10 10:42:09 +00:00
2022-05-10 17:05:04 +00:00
UPROPERTY(ReplicatedUsing = OnRep_MatchState)
2022-05-10 10:42:09 +00:00
FName MatchState;
UFUNCTION()
void OnRep_MatchState();
2022-05-11 19:02:33 +00:00
UPROPERTY()
class UDebugWidget* DebugWidget;
2022-05-10 10:42:09 +00:00
UPROPERTY()
class UCharacterOverlay* CharacterOverlay;
bool bInitializeCharacterOverlay = false;
float HUDHealth;
float HUDMaxHealth;
float HUDScore;
int32 HUDDefeats;
2022-05-05 15:57:57 +00:00
};