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/OLSModularCharacter.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(LogOLSModularCharacter);
|
|
|
|
|
|
|
|
|
|
AOLSModularCharacter::AOLSModularCharacter(const FObjectInitializer& objectInitializer) : Super(objectInitializer)
|
2025-01-04 16:41:49 +00:00
|
|
|
|
{
|
|
|
|
|
// 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 AOLSModularCharacter::PreInitializeComponents()
|
|
|
|
|
{
|
|
|
|
|
Super::PreInitializeComponents();
|
|
|
|
|
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AOLSModularCharacter::BeginPlay()
|
|
|
|
|
{
|
|
|
|
|
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(
|
|
|
|
|
this, UGameFrameworkComponentManager::NAME_GameActorReady);
|
|
|
|
|
Super::BeginPlay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AOLSModularCharacter::EndPlay(const EEndPlayReason::Type endPlayReason)
|
|
|
|
|
{
|
|
|
|
|
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
|
|
|
|
|
Super::EndPlay(endPlayReason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AOLSModularCharacter::PostInitProperties()
|
|
|
|
|
{
|
|
|
|
|
Super::PostInitProperties();
|
|
|
|
|
|
|
|
|
|
if (AbilitySystemComponent)
|
|
|
|
|
{
|
2025-01-16 21:24:05 +00:00
|
|
|
|
OLS_LOG(LogOLSModularCharacter, 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* AOLSModularCharacter::GetAbilitySystemComponent() const
|
|
|
|
|
{
|
|
|
|
|
return AbilitySystemComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AOLSModularCharacter::GetOwnedGameplayTags(FGameplayTagContainer& outTagContainer) const
|
|
|
|
|
{
|
|
|
|
|
if (AbilitySystemComponent)
|
|
|
|
|
{
|
|
|
|
|
FGameplayTagContainer ownedTags;
|
|
|
|
|
AbilitySystemComponent->GetOwnedGameplayTags(ownedTags);
|
|
|
|
|
outTagContainer = MoveTemp(ownedTags);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AOLSModularCharacter::HasMatchingGameplayTag(FGameplayTag tagToCheck) const
|
|
|
|
|
{
|
|
|
|
|
if (AbilitySystemComponent)
|
|
|
|
|
{
|
|
|
|
|
return AbilitySystemComponent->HasMatchingGameplayTag(tagToCheck);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AOLSModularCharacter::HasAllMatchingGameplayTags(const FGameplayTagContainer& tagContainer) const
|
|
|
|
|
{
|
|
|
|
|
if (AbilitySystemComponent)
|
|
|
|
|
{
|
|
|
|
|
return AbilitySystemComponent->HasAllMatchingGameplayTags(tagContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AOLSModularCharacter::HasAnyMatchingGameplayTags(const FGameplayTagContainer& tagContainer) const
|
|
|
|
|
{
|
|
|
|
|
if (AbilitySystemComponent)
|
|
|
|
|
{
|
|
|
|
|
return AbilitySystemComponent->HasAnyMatchingGameplayTags(tagContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|