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