FGAEffectHandle UGABlueprintLibrary::ApplyEffectSpec(const FHitResult& Target, APawn* Instigator, UObject* Causer, TSubclassOf<class UGAEffectSpecification> SpecIn) { FGAEffectHandle ReturnHandle; IIGAAttributes* targetAttr = Cast<IIGAAttributes>(Target.Actor.Get()); IIGAAttributes* instiAttr = Cast<IIGAAttributes>(Instigator); if (!targetAttr || !instiAttr) return ReturnHandle; UGAAttributeComponent* targetComp = targetAttr->GetAttributeComponent(); UGAAttributeComponent* instiComp = instiAttr->GetAttributeComponent(); FGAEffectContext context(Target.Location, Target.Actor, Causer, Instigator, targetComp, instiComp); FName EffectName; if (SpecIn.GetDefaultObject()->Policy.Type != EGAEffectType::Instant) { if (SpecIn.GetDefaultObject()->EffectName.CustomName) EffectName = SpecIn.GetDefaultObject()->EffectName.EffectName; else EffectName = SpecIn->GetFName();// Causer->GetClass()->GetFName(); } ReturnHandle = instiComp->ApplyEffectToTarget(SpecIn, context, EffectName); return ReturnHandle; }
void UGAAttributesBlueprintFunctionLibrary::ModifyAttributes(TArray<FGAAttributeModifier> AttributesIn) { for (FGAAttributeModifier& attributeMod : AttributesIn) { IIGAAttributes* instAttr = Cast<IIGAAttributes>(attributeMod.Instigator.Get()); IIGAAttributes* targetAttr = Cast<IIGAAttributes>(attributeMod.Target.Get()); if (!instAttr || !targetAttr) { return; } UGAAttributeComponent* attributes = instAttr->GetAttributeComponent(); //float newValue = attributes->AttributeOperation(attributeMod.Attribute, attributeMod.Value, attributeMod.Operation); //if (bSetAttribute) //{ attributes->ModifyAttributesOnTarget(targetAttr->GetAttributeComponent(), attributeMod); //} } }
FGAEffectHandle UGAAttributeComponent::ApplySelfEffect(AActor* Target, APawn* Instigator, UObject* Causer, FGAEffectSpec SpecIn) { //this is bad btw. I need to change it. LAter. IIGAAttributes* targetAttr = Cast<IIGAAttributes>(Target); IIGAAttributes* instiAttr = Cast<IIGAAttributes>(Instigator); if (!targetAttr || !instiAttr) return FGAEffectHandle(); UGAAttributeComponent* targetComp = targetAttr->GetAttributeComponent(); UGAAttributeComponent* instiComp = instiAttr->GetAttributeComponent(); FGAEffectContext context(Target->GetActorLocation(), Target, Causer, Instigator, targetComp, instiComp); SpecIn.Context = context; //SpecIn.GetModifiers(); return ActiveEffects.ApplyEffect(SpecIn, context); }
FGAEffectHandle UGAAttributeComponent::ApplySelfEffect(AActor* Target, APawn* Instigator, UObject* Causer, FGAEffectSpec SpecIn) { UE_LOG(GameAttributesEffects, Log, TEXT("Apply effect to self: %f , Effect: %d"), *GetOwner()->GetName(), *SpecIn.GetNameAsString()); //this is bad btw. I need to change it. LAter. IIGAAttributes* targetAttr = Cast<IIGAAttributes>(Target); IIGAAttributes* instiAttr = Cast<IIGAAttributes>(Instigator); if (!targetAttr || !instiAttr) return FGAEffectHandle(); UGAAttributeComponent* targetComp = targetAttr->GetAttributeComponent(); UGAAttributeComponent* instiComp = instiAttr->GetAttributeComponent(); FGAEffectContext context(Target->GetActorLocation(), Target, Causer, Instigator, targetComp, instiComp); SpecIn.Context = context; //SpecIn.GetModifiers(); return FGAEffectHandle(); // ActiveEffects.ApplyEffect(SpecIn, context); }