feature/fix-time-sync #1
|
@ -75,4 +75,7 @@ Intermediate/*
|
|||
Plugins/*/Intermediate/*
|
||||
|
||||
# Cache files for the editor to use
|
||||
DerivedDataCache/*
|
||||
DerivedDataCache/*
|
||||
|
||||
#Config files
|
||||
Config/User*.ini
|
|
@ -22,6 +22,14 @@
|
|||
"Editor"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "OnlineSubsystemSteam",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "OnlineSubsystemEOS",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "Bridge",
|
||||
"Enabled": true,
|
||||
|
|
|
@ -45,19 +45,25 @@ bUseManualIPAddress=False
|
|||
ManualIPAddress=
|
||||
|
||||
[/Script/Engine.GameEngine]
|
||||
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
|
||||
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemEOS.NetDriverEOS",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
|
||||
|
||||
[OnlineSubsystem]
|
||||
DefaultPlatformService=Steam
|
||||
DefaultPlatformService=EOS
|
||||
|
||||
[OnlineSubsystemSteam]
|
||||
bEnabled=true
|
||||
bEnabled=false
|
||||
SteamDevAppId=480
|
||||
bInitServerOnClient=true
|
||||
|
||||
[/Script/OnlineSubsystemSteam.SteamNetDriver]
|
||||
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
|
||||
|
||||
[OnlineSubsystemEOS]
|
||||
bEnabled=true
|
||||
|
||||
[/Script/OnlineSubsystemEOS.NetDriverEOS]
|
||||
bIsUsingP2PSockets=true
|
||||
|
||||
[/Script/OnlineSubsystemUtils.IpNetDriver]
|
||||
NetServerMaxTickRate=120
|
||||
|
||||
|
@ -118,3 +124,18 @@ NetServerMaxTickRate=120
|
|||
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
|
||||
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
|
||||
|
||||
[/Script/OnlineSubsystemEOS.EOSSettings]
|
||||
CacheDir=CacheDir
|
||||
DefaultArtifactName=Blaster
|
||||
TickBudgetInMilliseconds=0
|
||||
bEnableOverlay=True
|
||||
bEnableSocialOverlay=True
|
||||
bShouldEnforceBeingLaunchedByEGS=False
|
||||
TitleStorageReadChunkLength=0
|
||||
bUseEAS=False
|
||||
bUseEOSConnect=False
|
||||
bMirrorStatsToEOS=False
|
||||
bMirrorAchievementsToEOS=False
|
||||
bUseEOSSessions=False
|
||||
bMirrorPresenceToEAS=False
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -29,6 +29,10 @@
|
|||
{
|
||||
"Name": "OnlineSubsystemSteam",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "OnlineSubsystemEOS",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -28,6 +28,7 @@ public class MultiplayerSessions : ModuleRules
|
|||
"Core",
|
||||
"OnlineSubsystem",
|
||||
"OnlineSubsystemSteam",
|
||||
"OnlineSubsystemEOS",
|
||||
"UMG",
|
||||
"Slate",
|
||||
"SlateCore"
|
||||
|
|
|
@ -32,7 +32,7 @@ void UMenu::MenuSetup(int32 NumberOfPublicConnections, FString TypeOfMatch, FStr
|
|||
}
|
||||
|
||||
UGameInstance* GameInstance = GetGameInstance();
|
||||
if (GetGameInstance())
|
||||
if (GameInstance)
|
||||
{
|
||||
MultiplayerSessionsSubsystem = GameInstance->GetSubsystem<UMultiplayerSessionsSubsystem>();
|
||||
}
|
||||
|
@ -44,6 +44,20 @@ void UMenu::MenuSetup(int32 NumberOfPublicConnections, FString TypeOfMatch, FStr
|
|||
MultiplayerSessionsSubsystem->MultiplayerOnJoinSessionComplete.AddUObject(this, &ThisClass::OnJoinSession);
|
||||
MultiplayerSessionsSubsystem->MultiplayerOnDestroySessionComplete.AddDynamic(this, &ThisClass::OnDestroySession);
|
||||
MultiplayerSessionsSubsystem->MultiplayerOnStartSessionComplete.AddDynamic(this, &ThisClass::OnStartSession);
|
||||
MultiplayerSessionsSubsystem->MultiplayerOnLoginComplete.AddDynamic(this, &ThisClass::OnLoginComplete);
|
||||
|
||||
if (!MultiplayerSessionsSubsystem->IsLoggedIn())
|
||||
{
|
||||
LoginButton->SetIsEnabled(true);
|
||||
HostButton->SetIsEnabled(false);
|
||||
JoinButton->SetIsEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginButton->SetIsEnabled(false);
|
||||
HostButton->SetIsEnabled(true);
|
||||
JoinButton->SetIsEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +78,11 @@ bool UMenu::Initialize()
|
|||
JoinButton->OnClicked.AddDynamic(this, &UMenu::JoinButtonClicked);
|
||||
}
|
||||
|
||||
if (LoginButton)
|
||||
{
|
||||
LoginButton->OnClicked.AddDynamic(this, &UMenu::LoginButtonClicked);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -164,6 +183,13 @@ void UMenu::OnStartSession(bool bWasSuccessful)
|
|||
{
|
||||
}
|
||||
|
||||
void UMenu::OnLoginComplete(bool bWasSuccessful)
|
||||
{
|
||||
JoinButton->SetIsEnabled(!bWasSuccessful);
|
||||
HostButton->SetIsEnabled(bWasSuccessful);
|
||||
JoinButton->SetIsEnabled(bWasSuccessful);
|
||||
}
|
||||
|
||||
void UMenu::HostButtonClicked()
|
||||
{
|
||||
HostButton->SetIsEnabled(false);
|
||||
|
@ -184,6 +210,16 @@ void UMenu::JoinButtonClicked()
|
|||
}
|
||||
}
|
||||
|
||||
void UMenu::LoginButtonClicked()
|
||||
{
|
||||
LoginButton->SetIsEnabled(false);
|
||||
|
||||
if (MultiplayerSessionsSubsystem)
|
||||
{
|
||||
MultiplayerSessionsSubsystem->Login();
|
||||
}
|
||||
}
|
||||
|
||||
void UMenu::MenuTearDown()
|
||||
{
|
||||
RemoveFromParent();
|
||||
|
|
|
@ -13,15 +13,74 @@ UMultiplayerSessionsSubsystem::UMultiplayerSessionsSubsystem():
|
|||
DestroySessionCompleteDelegate(FOnDestroySessionCompleteDelegate::CreateUObject(this, &ThisClass::OnDestroySessionComplete)),
|
||||
StartSessionCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartSessionComplete))
|
||||
{
|
||||
IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get();
|
||||
Subsystem = IOnlineSubsystem::Get();
|
||||
if (Subsystem)
|
||||
{
|
||||
Identity = Subsystem->GetIdentityInterface();
|
||||
SessionInterface = Subsystem->GetSessionInterface();
|
||||
if (GetSubsystemName() != EOS_SUBSYSTEM) // Non EOS OSS don't need to login
|
||||
{
|
||||
bIsLoggedIn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FName UMultiplayerSessionsSubsystem::GetSubsystemName()
|
||||
{
|
||||
return Subsystem ? Subsystem->GetSubsystemName() : FName("NULL");
|
||||
}
|
||||
|
||||
void UMultiplayerSessionsSubsystem::Login()
|
||||
{
|
||||
if (IsLoggedIn())
|
||||
{
|
||||
MultiplayerOnLoginComplete.Broadcast(true);
|
||||
return;
|
||||
}
|
||||
|
||||
EOSLogin();
|
||||
}
|
||||
|
||||
void UMultiplayerSessionsSubsystem::EOSLogin()
|
||||
{
|
||||
if (!Identity.IsValid()) return;
|
||||
|
||||
LoginDelegateHandle = Identity->OnLoginCompleteDelegates->AddUObject(this, &UMultiplayerSessionsSubsystem::HandleLoginComplete);
|
||||
|
||||
FOnlineAccountCredentials Credentials;
|
||||
Credentials.Id = FString();
|
||||
Credentials.Token = FString();
|
||||
Credentials.Type = FString("accountportal");
|
||||
|
||||
if (!Identity->Login(0, Credentials))
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Unable to perform EOS Login"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Performed EOS Login successful"));
|
||||
}
|
||||
}
|
||||
|
||||
void UMultiplayerSessionsSubsystem::HandleLoginComplete(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error)
|
||||
{
|
||||
bIsLoggedIn = bWasSuccessful;
|
||||
|
||||
if (Identity)
|
||||
{
|
||||
// Deregister the event handler.
|
||||
Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, LoginDelegateHandle);
|
||||
LoginDelegateHandle.Reset();
|
||||
}
|
||||
|
||||
// Broadcast our own custom delegate
|
||||
MultiplayerOnLoginComplete.Broadcast(bWasSuccessful);
|
||||
}
|
||||
|
||||
void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FString MatchType)
|
||||
{
|
||||
if (!IsLoggedIn()) return;
|
||||
|
||||
DesiredNumPublicConnections = NumPublicConnections;
|
||||
DesiredMatchType = MatchType;
|
||||
if (!SessionInterface.IsValid())
|
||||
|
@ -43,12 +102,14 @@ void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FS
|
|||
CreateSessionCompleteDelegateHandle = SessionInterface->AddOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegate);
|
||||
|
||||
LastSessionSettings = MakeShareable(new FOnlineSessionSettings());
|
||||
LastSessionSettings->bIsLANMatch = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL" ? true : false;
|
||||
LastSessionSettings->bIsDedicated = false;
|
||||
LastSessionSettings->bIsLANMatch = GetSubsystemName() == "NULL" || GetSubsystemName() == "LAN" ? true : false;
|
||||
LastSessionSettings->NumPublicConnections = NumPublicConnections;
|
||||
LastSessionSettings->bAllowJoinInProgress = true;
|
||||
LastSessionSettings->bAllowJoinViaPresence = true;
|
||||
LastSessionSettings->bShouldAdvertise = true;
|
||||
LastSessionSettings->bUsesPresence = true;
|
||||
LastSessionSettings->Set(SEARCH_KEYWORDS, FString("BlasterLobby"), EOnlineDataAdvertisementType::ViaOnlineService);
|
||||
LastSessionSettings->Set(FName("MatchType"), MatchType, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);
|
||||
LastSessionSettings->BuildUniqueId = 1;
|
||||
LastSessionSettings->bUseLobbiesIfAvailable = true;
|
||||
|
@ -65,6 +126,11 @@ void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FS
|
|||
|
||||
void UMultiplayerSessionsSubsystem::FindSessions(int32 MaxSearchResults)
|
||||
{
|
||||
if (!IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
return;
|
||||
|
@ -75,6 +141,8 @@ void UMultiplayerSessionsSubsystem::FindSessions(int32 MaxSearchResults)
|
|||
LastSessionSearch = MakeShareable(new FOnlineSessionSearch());
|
||||
LastSessionSearch->MaxSearchResults = MaxSearchResults;
|
||||
LastSessionSearch->bIsLanQuery = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL" ? true : false;
|
||||
LastSessionSearch->QuerySettings.Set(SEARCH_KEYWORDS, FString("BlasterLobby"), EOnlineComparisonOp::Equals);
|
||||
LastSessionSearch->QuerySettings.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
|
||||
LastSessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController();
|
||||
|
@ -88,6 +156,8 @@ void UMultiplayerSessionsSubsystem::FindSessions(int32 MaxSearchResults)
|
|||
|
||||
void UMultiplayerSessionsSubsystem::JoinSession(const FOnlineSessionSearchResult& SessionResult)
|
||||
{
|
||||
if (!IsLoggedIn()) return;
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
MultiplayerOnJoinSessionComplete.Broadcast(EOnJoinSessionCompleteResult::UnknownError);
|
||||
|
@ -124,19 +194,19 @@ void UMultiplayerSessionsSubsystem::DestroySession()
|
|||
|
||||
void UMultiplayerSessionsSubsystem::StartSession()
|
||||
{
|
||||
// if (!SessionInterface.IsValid())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// StartSessionCompleteDelegateHandle = SessionInterface->AddOnStartSessionCompleteDelegate_Handle(StartSessionCompleteDelegate);
|
||||
//
|
||||
// if (!SessionInterface->StartSession(NAME_GameSession))
|
||||
// {
|
||||
// SessionInterface->ClearOnStartSessionCompleteDelegate_Handle(StartSessionCompleteDelegateHandle);
|
||||
//
|
||||
// MultiplayerOnStartSessionComplete.Broadcast(false);
|
||||
// }
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StartSessionCompleteDelegateHandle = SessionInterface->AddOnStartSessionCompleteDelegate_Handle(StartSessionCompleteDelegate);
|
||||
|
||||
if (!SessionInterface->StartSession(NAME_GameSession))
|
||||
{
|
||||
SessionInterface->ClearOnStartSessionCompleteDelegate_Handle(StartSessionCompleteDelegateHandle);
|
||||
|
||||
MultiplayerOnStartSessionComplete.Broadcast(false);
|
||||
}
|
||||
}
|
||||
|
||||
void UMultiplayerSessionsSubsystem::OnCreateSessionComplete(FName SessionName, bool bWasSuccessful)
|
||||
|
@ -191,10 +261,10 @@ void UMultiplayerSessionsSubsystem::OnDestroySessionComplete(FName SessionName,
|
|||
|
||||
void UMultiplayerSessionsSubsystem::OnStartSessionComplete(FName SessionName, bool bWasSuccessful)
|
||||
{
|
||||
// if (SessionInterface)
|
||||
// {
|
||||
// SessionInterface->ClearOnStartSessionCompleteDelegate_Handle(StartSessionCompleteDelegateHandle);
|
||||
// }
|
||||
//
|
||||
// MultiplayerOnStartSessionComplete.Broadcast(bWasSuccessful);
|
||||
if (SessionInterface)
|
||||
{
|
||||
SessionInterface->ClearOnStartSessionCompleteDelegate_Handle(StartSessionCompleteDelegateHandle);
|
||||
}
|
||||
|
||||
MultiplayerOnStartSessionComplete.Broadcast(bWasSuccessful);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class MULTIPLAYERSESSIONS_API UMenu : public UUserWidget
|
|||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void MenuSetup(int32 NumberOfPublicConnections = 4, FString TypeOfMatch = FString(TEXT("FreeForAll")), FString LobbyPath = FString(TEXT("/Game/ThirdPerson/Maps/Lobby")));
|
||||
void MenuSetup(int32 NumberOfPublicConnections = 4, FString TypeOfMatch = FString(TEXT("FreeForAll")), FString LobbyPath = FString(TEXT("/Game/Maps/Lobby")));
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -36,6 +36,8 @@ protected:
|
|||
void OnDestroySession(bool bWasSuccessful);
|
||||
UFUNCTION()
|
||||
void OnStartSession(bool bWasSuccessful);
|
||||
UFUNCTION()
|
||||
void OnLoginComplete(bool bWasSuccessful);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -44,6 +46,9 @@ private:
|
|||
|
||||
UPROPERTY(meta=(BindWidget))
|
||||
UButton* JoinButton;
|
||||
|
||||
UPROPERTY(meta=(BindWidget))
|
||||
UButton* LoginButton;
|
||||
|
||||
UFUNCTION()
|
||||
void HostButtonClicked();
|
||||
|
@ -51,9 +56,13 @@ private:
|
|||
UFUNCTION()
|
||||
void JoinButtonClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void LoginButtonClicked();
|
||||
|
||||
void MenuTearDown();
|
||||
|
||||
// The subsystem designed to handle all online session functionality
|
||||
UPROPERTY()
|
||||
class UMultiplayerSessionsSubsystem* MultiplayerSessionsSubsystem;
|
||||
|
||||
int32 NumPublicConnections {4};
|
||||
|
|
|
@ -4,18 +4,21 @@
|
|||
|
||||
#include "CoreMinimal.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "Interfaces/OnlineIdentityInterface.h"
|
||||
#include "Subsystems/GameInstanceSubsystem.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "MultiplayerSessionsSubsystem.generated.h"
|
||||
|
||||
//
|
||||
// Delcaring our own custom delegates for the Menu class to bind callbacks to
|
||||
// Declaring our own custom delegates for the Menu class to bind callbacks to
|
||||
//
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMultiplayerOnCreateSessionComplete, bool, bWasSuccessful);
|
||||
DECLARE_MULTICAST_DELEGATE_TwoParams(FMultiplayerOnFindSessionsComplete, const TArray<FOnlineSessionSearchResult>& SessionResults, bool bWasSuccessful);
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FMultiplayerOnJoinSessionComplete, EOnJoinSessionCompleteResult::Type Result)
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMultiplayerOnDestroySessionComplete, bool, bWasSuccessful);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMultiplayerOnStartSessionComplete, bool, bWasSuccessful);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMultiplayerOnLoginComplete, bool, bWasSuccessful);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -28,7 +31,9 @@ class MULTIPLAYERSESSIONS_API UMultiplayerSessionsSubsystem : public UGameInstan
|
|||
public:
|
||||
|
||||
UMultiplayerSessionsSubsystem();
|
||||
|
||||
void Login();
|
||||
FORCEINLINE bool IsLoggedIn() const { return bIsLoggedIn; }
|
||||
|
||||
/*
|
||||
* To handle session functionality. The Menu class will call these
|
||||
*/
|
||||
|
@ -46,6 +51,7 @@ public:
|
|||
FMultiplayerOnJoinSessionComplete MultiplayerOnJoinSessionComplete;
|
||||
FMultiplayerOnDestroySessionComplete MultiplayerOnDestroySessionComplete;
|
||||
FMultiplayerOnStartSessionComplete MultiplayerOnStartSessionComplete;
|
||||
FMultiplayerOnLoginComplete MultiplayerOnLoginComplete;
|
||||
|
||||
int32 DesiredNumPublicConnections{};
|
||||
FString DesiredMatchType{};
|
||||
|
@ -62,7 +68,9 @@ protected:
|
|||
void OnStartSessionComplete(FName SessionName, bool bWasSuccessful);
|
||||
|
||||
private:
|
||||
|
||||
IOnlineSubsystem* Subsystem;
|
||||
IOnlineIdentityPtr Identity;
|
||||
|
||||
IOnlineSessionPtr SessionInterface;
|
||||
TSharedPtr<FOnlineSessionSettings> LastSessionSettings;
|
||||
TSharedPtr<FOnlineSessionSearch> LastSessionSearch;
|
||||
|
@ -85,4 +93,12 @@ private:
|
|||
bool bCreateSessionOnDestroy { false };
|
||||
int32 LastNumPublicConnections;
|
||||
FString LastMatchType;
|
||||
|
||||
void EOSLogin();
|
||||
|
||||
FDelegateHandle LoginDelegateHandle;
|
||||
void HandleLoginComplete(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error);
|
||||
|
||||
FName GetSubsystemName();
|
||||
bool bIsLoggedIn = false;
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@ void ABlasterGameMode::Tick(float DeltaTime)
|
|||
|
||||
if (MatchState == MatchState::WaitingToStart)
|
||||
{
|
||||
CountdownTime = WarmupTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
|
||||
CountdownTime = WarmupTime - GetWorld()->GetTimeSeconds(); // + LevelStartingTime;
|
||||
if (CountdownTime <= 0.f)
|
||||
{
|
||||
StartMatch();
|
||||
|
@ -41,7 +41,7 @@ void ABlasterGameMode::Tick(float DeltaTime)
|
|||
}
|
||||
else if (MatchState == MatchState::InProgress)
|
||||
{
|
||||
CountdownTime = WarmupTime + MatchTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
|
||||
CountdownTime = WarmupTime + MatchTime - GetWorld()->GetTimeSeconds(); // + LevelStartingTime;
|
||||
if (CountdownTime <= 0.f)
|
||||
{
|
||||
SetMatchState(MatchState::Cooldown);
|
||||
|
@ -49,7 +49,7 @@ void ABlasterGameMode::Tick(float DeltaTime)
|
|||
}
|
||||
else if (MatchState == MatchState::Cooldown)
|
||||
{
|
||||
CountdownTime = CooldownTime + WarmupTime + MatchTime - GetWorld()->GetTimeSeconds() + LevelStartingTime;
|
||||
CountdownTime = WarmupTime + MatchTime + CooldownTime - GetWorld()->GetTimeSeconds(); // + LevelStartingTime;
|
||||
if (CountdownTime <= 0.f)
|
||||
{
|
||||
RestartGame();
|
||||
|
|
|
@ -42,13 +42,11 @@ void ABlasterPlayerController::Tick(float DeltaTime)
|
|||
|
||||
if (DebugWidget)
|
||||
{
|
||||
SetDebugMsg1(TEXT("GetServerTime(): "), FString::Printf(TEXT("%02f"), GetServerTime()));
|
||||
SetDebugMsg2(TEXT("ClientServerDelta: "), FString::Printf(TEXT("%f"), ClientServerDelta));
|
||||
SetDebugMsg3(TEXT("LevelStartingTime: "), FString::Printf(TEXT("%f"), LevelStartingTime));
|
||||
SetDebugMsg4(TEXT("WarmupTime: "), FString::Printf(TEXT("%f"), WarmupTime));
|
||||
SetDebugMsg5(TEXT("MatchTime: "), FString::Printf(TEXT("%f"), MatchTime));
|
||||
SetDebugMsg6(TEXT("CooldownTime: "), FString::Printf(TEXT("%f"), CooldownTime));
|
||||
SetDebugMsg7(TEXT("CountdownInt: "), FString::Printf(TEXT("%d"), CountdownInt));
|
||||
SetDebugMsg1(TEXT("GetWorld()->GetTimeSeconds(): "), FString::Printf(TEXT("%02f"), GetWorld()->GetTimeSeconds()));
|
||||
SetDebugMsg2(TEXT("GetServerTime(): "), FString::Printf(TEXT("%02f"), GetServerTime()));
|
||||
SetDebugMsg3(TEXT("ClientServerDelta: "), FString::Printf(TEXT("%f"), ClientServerDelta));
|
||||
SetDebugMsg4(TEXT("LevelStartingTime: "), FString::Printf(TEXT("%f"), LevelStartingTime));
|
||||
SetDebugMsg5(TEXT("CountdownInt: "), FString::Printf(TEXT("%d"), CountdownInt));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +126,6 @@ void ABlasterPlayerController::ClientJoinMidgame_Implementation(FName StateOfMat
|
|||
OnMatchStateSet(MatchState);
|
||||
if (BlasterHUD && MatchState == MatchState::WaitingToStart)
|
||||
{
|
||||
BlasterHUD->AddDebugWidget();
|
||||
BlasterHUD->AddAnnouncementOverlay();
|
||||
}
|
||||
}
|
||||
|
@ -275,9 +272,9 @@ void ABlasterPlayerController::SetHUDAnnouncementCountdown(float CountdownTime)
|
|||
void ABlasterPlayerController::SetHUDTime()
|
||||
{
|
||||
float TimeLeft = 0.f;
|
||||
if (MatchState == MatchState::WaitingToStart) TimeLeft = WarmupTime - GetServerTime() + LevelStartingTime;
|
||||
else if (MatchState == MatchState::InProgress) TimeLeft = WarmupTime + MatchTime - GetServerTime() + LevelStartingTime;
|
||||
else if (MatchState == MatchState::Cooldown) TimeLeft = CooldownTime +WarmupTime + MatchTime - GetServerTime() + LevelStartingTime;
|
||||
if (MatchState == MatchState::WaitingToStart) TimeLeft = WarmupTime - GetServerTime(); // + LevelStartingTime;
|
||||
else if (MatchState == MatchState::InProgress) TimeLeft = WarmupTime + MatchTime - GetServerTime(); // + LevelStartingTime;
|
||||
else if (MatchState == MatchState::Cooldown) TimeLeft = WarmupTime + MatchTime + CooldownTime - GetServerTime(); // + LevelStartingTime;
|
||||
|
||||
uint32 SecondsLeft = FMath::CeilToInt(TimeLeft);
|
||||
|
||||
|
@ -286,7 +283,7 @@ void ABlasterPlayerController::SetHUDTime()
|
|||
BlasterGameMode = BlasterGameMode == nullptr ? Cast<ABlasterGameMode>(UGameplayStatics::GetGameMode(this)) : BlasterGameMode;
|
||||
if (BlasterGameMode)
|
||||
{
|
||||
SecondsLeft = FMath::CeilToInt(BlasterGameMode->GetCountdownTime() + LevelStartingTime);
|
||||
SecondsLeft = FMath::CeilToInt(BlasterGameMode->GetCountdownTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,14 +304,15 @@ void ABlasterPlayerController::SetHUDTime()
|
|||
|
||||
void ABlasterPlayerController::PollInit()
|
||||
{
|
||||
if (DebugWidget == nullptr)
|
||||
if (BlasterHUD && BlasterHUD->DebugWidget == nullptr)
|
||||
{
|
||||
if (BlasterHUD && BlasterHUD->DebugWidget)
|
||||
BlasterHUD->AddDebugWidget();
|
||||
if (BlasterHUD->DebugWidget)
|
||||
{
|
||||
DebugWidget = BlasterHUD->DebugWidget;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CharacterOverlay == nullptr)
|
||||
{
|
||||
if (BlasterHUD && BlasterHUD->CharacterOverlay)
|
||||
|
@ -402,8 +400,12 @@ void ABlasterPlayerController::HandleCooldown()
|
|||
BlasterHUD = BlasterHUD == nullptr ? Cast<ABlasterHUD>(GetHUD()) : BlasterHUD;
|
||||
if (BlasterHUD)
|
||||
{
|
||||
BlasterHUD->CharacterOverlay->RemoveFromParent();
|
||||
bool bHUDValid =BlasterHUD->Announcement &&
|
||||
if (BlasterHUD->CharacterOverlay)
|
||||
{
|
||||
BlasterHUD->CharacterOverlay->RemoveFromParent();
|
||||
}
|
||||
|
||||
bool bHUDValid = BlasterHUD->Announcement &&
|
||||
BlasterHUD->Announcement->AnnouncementText &&
|
||||
BlasterHUD->Announcement->AnnouncementMessage;
|
||||
|
||||
|
|
Loading…
Reference in New Issue