FGAEffectHandle FGAActiveEffectContainer::HandleInstigatorEffectDuration(FGAEffectSpec& EffectIn, const FGAEffectContext& Ctx) { FGAEffectHandle foundHandle; FGAInstigatorEffectContainer& instCont = InstigatorEffects.FindOrAdd(Ctx.InstigatorComp); for (FGAEffectTagHandle& eff : instCont.Effects) { if (EffectIn.EffectName == eff.EffectName) { foundHandle = eff.Handle; break; } } if (foundHandle.IsValid()) { TSharedPtr<FGAActiveDuration> durationEffect = ActiveEffects.FindRef(foundHandle); if (durationEffect.IsValid()) { durationEffect->StackDuration(EffectIn.EffectDuration.Duration); } } else { //if handle is not valid, it means there is no effect, //and this means we have to add new effect. foundHandle = AddActiveEffect(EffectIn, Ctx); instCont.Effects.Add(FGAEffectTagHandle(EffectIn.EffectName, foundHandle)); } return foundHandle; }
void UGAAttributeComponent::ModifyAttributesOnSelf(const FGAAttributeData& EvalData, const FGAEffectContext& Context, const FGameplayTagContainer& EffectTags, FGAEffectHandle& HandleIn) { //incoming ModifiedAttribute.Mods.Empty(); FGAAttributeData FinalData = DefaultAttributes->PreModifyAttribute(EvalData); FGAAttributeBase* attr = DefaultAttributes->GetAttribute(FinalData.Attribute); float newValue = 0; if (attr) { if (HandleIn.IsValid()) { DefaultAttributes->SetAttributeAdditiveBonus(FinalData.Attribute, FinalData.Value); } } else { //newValue = DefaultAttributes->AttributeOperation(FinalData.Attribute, FinalData.Value, FinalData.Mod); FGAEvalData evalData(FinalData.Attribute, FinalData.Mod, FinalData.AttributeTag, FinalData.Value); float finalValue = DefaultAttributes->UpdateAttributes(evalData, FinalData.Value); FGAModifiedAttribute ModdedAttrRep; ModdedAttrRep.Attribute = FinalData.Attribute; ModdedAttrRep.InstigatorLocation = Context.Instigator->GetActorLocation(); ModdedAttrRep.TargetLocation = Context.TargetHitLocation;//AttributeIn.Target->GetActorLocation(); ModdedAttrRep.ModifiedByValue = finalValue; ModdedAttrRep.ReplicationCounter = FMath::RandRange(0,255); ModdedAttrRep.Causer = Context.InstigatorComp; ModifiedAttribute.ForceUpdate++; ModifiedAttribute.Mods.Add(ModdedAttrRep); } if (GetNetMode() == ENetMode::NM_Standalone) { for (FGAModifiedAttribute& attr : ModifiedAttribute.Mods) { Context.InstigatorComp->OnAttributeModifed.Broadcast(attr); } } }