2022-05-23 18:41:30 +00:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
#include "LyraGameState.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "AbilitySystem/LyraAbilitySystemComponent.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "AbilitySystemComponent.h"
|
|
|
|
#include "Containers/Array.h"
|
|
|
|
#include "Engine/EngineBaseTypes.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "GameFramework/GameplayMessageSubsystem.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "GameModes/LyraExperienceManagerComponent.h"
|
|
|
|
#include "HAL/Platform.h"
|
|
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
#include "Net/UnrealNetwork.h"
|
|
|
|
|
|
|
|
class APlayerState;
|
|
|
|
class FLifetimeProperty;
|
2022-05-23 18:41:30 +00:00
|
|
|
|
|
|
|
extern ENGINE_API float GAverageFPS;
|
|
|
|
|
|
|
|
|
|
|
|
ALyraGameState::ALyraGameState(const FObjectInitializer& ObjectInitializer)
|
|
|
|
: Super(ObjectInitializer)
|
|
|
|
{
|
|
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
PrimaryActorTick.bStartWithTickEnabled = true;
|
|
|
|
|
|
|
|
AbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject<ULyraAbilitySystemComponent>(this, TEXT("AbilitySystemComponent"));
|
|
|
|
AbilitySystemComponent->SetIsReplicated(true);
|
|
|
|
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);
|
|
|
|
|
|
|
|
ExperienceManagerComponent = CreateDefaultSubobject<ULyraExperienceManagerComponent>(TEXT("ExperienceManagerComponent"));
|
|
|
|
|
|
|
|
ServerFPS = 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::PreInitializeComponents()
|
|
|
|
{
|
|
|
|
Super::PreInitializeComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::PostInitializeComponents()
|
|
|
|
{
|
|
|
|
Super::PostInitializeComponents();
|
|
|
|
|
|
|
|
check(AbilitySystemComponent);
|
|
|
|
AbilitySystemComponent->InitAbilityActorInfo(/*Owner=*/ this, /*Avatar=*/ this);
|
|
|
|
}
|
|
|
|
|
|
|
|
UAbilitySystemComponent* ALyraGameState::GetAbilitySystemComponent() const
|
|
|
|
{
|
|
|
|
return AbilitySystemComponent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
|
|
|
{
|
|
|
|
Super::EndPlay(EndPlayReason);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::AddPlayerState(APlayerState* PlayerState)
|
|
|
|
{
|
|
|
|
Super::AddPlayerState(PlayerState);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::RemovePlayerState(APlayerState* PlayerState)
|
|
|
|
{
|
|
|
|
//@TODO: This isn't getting called right now (only the 'rich' AGameMode uses it, not AGameModeBase)
|
|
|
|
// Need to at least comment the engine code, and possibly move things around
|
|
|
|
Super::RemovePlayerState(PlayerState);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
|
|
|
{
|
|
|
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
|
|
|
|
|
|
|
DOREPLIFETIME(ThisClass, ServerFPS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::Tick(float DeltaSeconds)
|
|
|
|
{
|
|
|
|
Super::Tick(DeltaSeconds);
|
|
|
|
|
|
|
|
if (GetLocalRole() == ROLE_Authority)
|
|
|
|
{
|
|
|
|
ServerFPS = GAverageFPS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::MulticastMessageToClients_Implementation(const FLyraVerbMessage Message)
|
|
|
|
{
|
|
|
|
if (GetNetMode() == NM_Client)
|
|
|
|
{
|
|
|
|
UGameplayMessageSubsystem::Get(this).BroadcastMessage(Message.Verb, Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ALyraGameState::MulticastReliableMessageToClients_Implementation(const FLyraVerbMessage Message)
|
|
|
|
{
|
|
|
|
MulticastMessageToClients_Implementation(Message);
|
|
|
|
}
|