// © 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/OLSModularPawn.h" #include "AbilitySystem/OLSAbilitySystemComponent.h" #include "Components/GameFrameworkComponentManager.h" AOLSModularPawn::AOLSModularPawn(const FObjectInitializer& objectInitializer) : Super(objectInitializer) { AbilitySystemComponent = CreateDefaultSubobject(TEXT("AbilitySystemComponent")); AbilitySystemComponent->SetIsReplicated(true); ReplicationMode = EGameplayEffectReplicationMode::Mixed; } void AOLSModularPawn::PreInitializeComponents() { Super::PreInitializeComponents(); UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this); } void AOLSModularPawn::BeginPlay() { UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(this, UGameFrameworkComponentManager::NAME_GameActorReady); Super::BeginPlay(); } void AOLSModularPawn::EndPlay(const EEndPlayReason::Type endPlayReason) { UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this); Super::EndPlay(endPlayReason); } void AOLSModularPawn::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* AOLSModularPawn::GetAbilitySystemComponent() const { return AbilitySystemComponent; } void AOLSModularPawn::GetOwnedGameplayTags(FGameplayTagContainer& outTagContainer) const { if (AbilitySystemComponent) { FGameplayTagContainer ownedTags; AbilitySystemComponent->GetOwnedGameplayTags(ownedTags); outTagContainer = MoveTemp(ownedTags); } } bool AOLSModularPawn::HasMatchingGameplayTag(FGameplayTag tagToCheck) const { if (AbilitySystemComponent) { return AbilitySystemComponent->HasMatchingGameplayTag(tagToCheck); } return false; } bool AOLSModularPawn::HasAllMatchingGameplayTags(const FGameplayTagContainer& tagContainer) const { if (AbilitySystemComponent) { return AbilitySystemComponent->HasAllMatchingGameplayTags(tagContainer); } return false; } bool AOLSModularPawn::HasAnyMatchingGameplayTags(const FGameplayTagContainer& tagContainer) const { if (AbilitySystemComponent) { return AbilitySystemComponent->HasAnyMatchingGameplayTags(tagContainer); } return false; }