// REALMS IN RUIN. Copyright (c) 2025 Trevor Edwards. All rights reserved. #include "Actors/RIREffectActor.h" #include "GameplayEffect.h" #include "AbilitySystemComponent.h" #include "AbilitySystemBlueprintLibrary.h" // Sets default values ARIREffectActor::ARIREffectActor() { // 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; SetRootComponent(CreateDefaultSubobject("SceneRoot")); } // Called when the game starts or when spawned void ARIREffectActor::BeginPlay() { Super::BeginPlay(); } void ARIREffectActor::ApplyEffectToTarget(AActor* TargetActor, TSubclassOf GamePlayEffectClass) { UAbilitySystemComponent* TargetAbilitySystemComponent = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(TargetActor); if (TargetAbilitySystemComponent == nullptr) return; check (GamePlayEffectClass); FGameplayEffectContextHandle EffectContextHandle = TargetAbilitySystemComponent->MakeEffectContext(); EffectContextHandle.AddSourceObject(this); const FGameplayEffectSpecHandle EffectSpecHandle = TargetAbilitySystemComponent->MakeOutgoingSpec(GamePlayEffectClass, 1.f, EffectContextHandle); TargetAbilitySystemComponent->ApplyGameplayEffectSpecToSelf(*EffectSpecHandle.Data.Get()); }