2025-01-04 16:41:49 +00:00
|
|
|
|
// © 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"
|
|
|
|
|
|
2025-01-16 21:24:05 +00:00
|
|
|
|
#include "OLSLog.h"
|
2025-01-04 16:41:49 +00:00
|
|
|
|
#include "AbilitySystem/OLSAbilitySystemComponent.h"
|
|
|
|
|
#include "Components/GameFrameworkComponentManager.h"
|
|
|
|
|
|
2025-01-16 21:24:05 +00:00
|
|
|
|
DEFINE_LOG_CATEGORY(LogOLSModularDefaultPawn);
|
2025-01-04 16:41:49 +00:00
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
{
|
2025-01-16 21:24:05 +00:00
|
|
|
|
OLS_LOG(LogOLSModularDefaultPawn, Verbose,
|
|
|
|
|
TEXT("PostInitProperties for %s - Setting up ASC Replication Mode to: %d"), GET_UOBJECT_NAME(this),
|
|
|
|
|
ReplicationMode);
|
2025-01-04 16:41:49 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|