|
|
|
|
| #include "LyraGamePhaseAbility.h"
|
| #include "AbilitySystemComponent.h"
|
| #include "Engine/World.h"
|
| #include "LyraGamePhaseSubsystem.h"
|
|
|
| #if WITH_EDITOR
|
| #include "Misc/DataValidation.h"
|
| #endif
|
|
|
| #include UE_INLINE_GENERATED_CPP_BY_NAME(LyraGamePhaseAbility)
|
|
|
| #define LOCTEXT_NAMESPACE "ULyraGamePhaseAbility"
|
|
|
| ULyraGamePhaseAbility::ULyraGamePhaseAbility(const FObjectInitializer& ObjectInitializer)
|
| : Super(ObjectInitializer)
|
| {
|
| ReplicationPolicy = EGameplayAbilityReplicationPolicy::ReplicateNo;
|
| InstancingPolicy = EGameplayAbilityInstancingPolicy::InstancedPerActor;
|
| NetExecutionPolicy = EGameplayAbilityNetExecutionPolicy::ServerInitiated;
|
| NetSecurityPolicy = EGameplayAbilityNetSecurityPolicy::ServerOnly;
|
| }
|
|
|
| void ULyraGamePhaseAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
|
| {
|
| if (ActorInfo->IsNetAuthority())
|
| {
|
| UWorld* World = ActorInfo->AbilitySystemComponent->GetWorld();
|
| ULyraGamePhaseSubsystem* PhaseSubsystem = UWorld::GetSubsystem<ULyraGamePhaseSubsystem>(World);
|
| PhaseSubsystem->OnBeginPhase(this, Handle);
|
| }
|
|
|
| Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);
|
| }
|
|
|
| void ULyraGamePhaseAbility::EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled)
|
| {
|
| if (ActorInfo->IsNetAuthority())
|
| {
|
| UWorld* World = ActorInfo->AbilitySystemComponent->GetWorld();
|
| ULyraGamePhaseSubsystem* PhaseSubsystem = UWorld::GetSubsystem<ULyraGamePhaseSubsystem>(World);
|
| PhaseSubsystem->OnEndPhase(this, Handle);
|
| }
|
|
|
| Super::EndAbility(Handle, ActorInfo, ActivationInfo, bReplicateEndAbility, bWasCancelled);
|
| }
|
|
|
| #if WITH_EDITOR
|
| EDataValidationResult ULyraGamePhaseAbility::IsDataValid(FDataValidationContext& Context) const
|
| {
|
| EDataValidationResult Result = CombineDataValidationResults(Super::IsDataValid(Context), EDataValidationResult::Valid);
|
|
|
| if (!GamePhaseTag.IsValid())
|
| {
|
| Result = EDataValidationResult::Invalid;
|
| Context.AddError(LOCTEXT("GamePhaseTagNotSet", "GamePhaseTag must be set to a tag representing the current phase."));
|
| }
|
|
|
| return Result;
|
| }
|
| #endif
|
|
|
| #undef LOCTEXT_NAMESPACE
|
|
|