101 lines
2.9 KiB
C++
101 lines
2.9 KiB
C++
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
|
|
|
|
|
|
#include "ModularGameplayActors/OLSModularDefaultPawn.h"
|
|
|
|
#include "AbilitySystem/OLSAbilitySystemComponent.h"
|
|
#include "Components/GameFrameworkComponentManager.h"
|
|
|
|
|
|
// Sets default values
|
|
AOLSModularDefaultPawn::AOLSModularDefaultPawn(const FObjectInitializer& objectInitializer) : Super(objectInitializer)
|
|
{
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
// Set this actor to replicate like a Pawn would
|
|
bReplicates = true;
|
|
|
|
// Set Ability System Companion with GAS Companion subclass
|
|
AbilitySystemComponent = CreateDefaultSubobject<UOLSAbilitySystemComponent>(TEXT("AbilitySystemComponent"));
|
|
AbilitySystemComponent->SetIsReplicated(true);
|
|
|
|
ReplicationMode = EGameplayEffectReplicationMode::Mixed;
|
|
}
|
|
|
|
void AOLSModularDefaultPawn::PreInitializeComponents()
|
|
{
|
|
Super::PreInitializeComponents();
|
|
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
|
|
}
|
|
|
|
void AOLSModularDefaultPawn::BeginPlay()
|
|
{
|
|
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(
|
|
this, UGameFrameworkComponentManager::NAME_GameActorReady);
|
|
Super::BeginPlay();
|
|
}
|
|
|
|
void AOLSModularDefaultPawn::EndPlay(const EEndPlayReason::Type endPlayReason)
|
|
{
|
|
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
|
|
Super::EndPlay(endPlayReason);
|
|
}
|
|
|
|
void AOLSModularDefaultPawn::PostInitProperties()
|
|
{
|
|
Super::PostInitProperties();
|
|
if (AbilitySystemComponent)
|
|
{
|
|
//@Todo replace this log by our custom log.
|
|
UE_LOG(LogTemp, Verbose, TEXT("PostInitProperties for %s - Setting up ASC Replication Mode to: %d"), *GetName(),
|
|
ReplicationMode);
|
|
AbilitySystemComponent->SetReplicationMode(ReplicationMode);
|
|
}
|
|
}
|
|
|
|
UAbilitySystemComponent* AOLSModularDefaultPawn::GetAbilitySystemComponent() const
|
|
{
|
|
return AbilitySystemComponent;
|
|
}
|
|
|
|
void AOLSModularDefaultPawn::GetOwnedGameplayTags(FGameplayTagContainer& outTagContainer) const
|
|
{
|
|
if (AbilitySystemComponent)
|
|
{
|
|
FGameplayTagContainer ownedTags;
|
|
AbilitySystemComponent->GetOwnedGameplayTags(ownedTags);
|
|
outTagContainer = MoveTemp(ownedTags);
|
|
}
|
|
}
|
|
|
|
bool AOLSModularDefaultPawn::HasMatchingGameplayTag(FGameplayTag tagToCheck) const
|
|
{
|
|
if (AbilitySystemComponent)
|
|
{
|
|
return AbilitySystemComponent->HasMatchingGameplayTag(tagToCheck);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AOLSModularDefaultPawn::HasAllMatchingGameplayTags(const FGameplayTagContainer& tagContainer) const
|
|
{
|
|
if (AbilitySystemComponent)
|
|
{
|
|
return AbilitySystemComponent->HasAllMatchingGameplayTags(tagContainer);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AOLSModularDefaultPawn::HasAnyMatchingGameplayTags(const FGameplayTagContainer& tagContainer) const
|
|
{
|
|
if (AbilitySystemComponent)
|
|
{
|
|
return AbilitySystemComponent->HasAnyMatchingGameplayTags(tagContainer);
|
|
}
|
|
|
|
return false;
|
|
}
|