本文整理汇总了C++中FGAGameEffectHandle::GetEffectRef方法的典型用法代码示例。如果您正苦于以下问题:C++ FGAGameEffectHandle::GetEffectRef方法的具体用法?C++ FGAGameEffectHandle::GetEffectRef怎么用?C++ FGAGameEffectHandle::GetEffectRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FGAGameEffectHandle
的用法示例。
在下文中一共展示了FGAGameEffectHandle::GetEffectRef方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InternalApplyDuration
void FGAGameEffectContainer::InternalApplyDuration(const FGAGameEffectHandle& HandleIn)
{
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
HandleIn.GetEffectSpec()->Duration, false, HandleIn.GetEffectSpec()->Duration);
TArray<FGAEffectMod> Modifiers = HandleIn.GetEffectRef().GetAttributeModifiers();
EGAEffectStacking Stacking = HandleIn.GetEffectSpec()->EffectStacking;
InternalApplyEffectTags(HandleIn);
for (FGAEffectMod& Modifier : Modifiers)
{
if (Modifier.Attribute.IsValid())
{
UGAAttributesBase* attr = HandleIn.GetContextRef().GetTargetAttributes();
FGAAttributeBase* Attribute = attr->GetAttribute(Modifier.Attribute);
if (Attribute)
{
Attribute->AddBonus(FGAModifier(Modifier.AttributeMod, Modifier.Value), HandleIn, Stacking);
}
}
}
}
示例2: InternalRemoveEffect
void UGAAttributeComponent::InternalRemoveEffect(FGAGameEffectHandle& HandleIn)
{
FTimerManager& timer = GetWorld()->GetTimerManager();
timer.ClearTimer(HandleIn.GetEffectRef().PeriodTimerHandle);
timer.ClearTimer(HandleIn.GetEffectRef().DurationTimerHandle);
UE_LOG(GameAttributesEffects, Log, TEXT("UGAAttributeComponent:: Reset Timers and Remove Effect"));
FGAGameEffect& Effect = HandleIn.GetEffectRef();
TArray<FGAEffectMod> Mods = Effect.GetOnAppliedMods();
for (FGAEffectMod& mod : Mods)
{
FGAAttributeBase* attr = DefaultAttributes->GetAttribute(mod.Attribute);
if (attr)
{
UE_LOG(GameAttributes, Log, TEXT("Value Before bonus of attribute = %f"), attr->GetFinalValue());
attr->RemoveBonus(HandleIn);
UE_LOG(GameAttributes, Log, TEXT("Value After bonus of attribute = %f"), attr->GetFinalValue());
}
}
GameEffectContainer.RemoveEffect(HandleIn);
}
示例3: InternalApplyPeriodic
void FGAGameEffectContainer::InternalApplyPeriodic(const FGAGameEffectHandle& HandleIn)
{
FTimerDelegate delPeriod = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExecuteEffect, HandleIn);
FTimerManager& PeriodicTimer = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
PeriodicTimer.SetTimer(HandleIn.GetEffectRef().PeriodTimerHandle, delPeriod,
HandleIn.GetEffectSpec()->Period, true, 0);
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
}
示例4: InternalApplyEffectByAggregation
void FGAGameEffectContainer::InternalApplyEffectByAggregation(const FGAGameEffectHandle& HandleIn)
{
EGAEffectAggregation Aggregation = HandleIn.GetEffectRef().GameEffect->EffectAggregation;
switch (Aggregation)
{
case EGAEffectAggregation::AggregateByInstigator:
{
TMap<FGAGameEffectHandle, TSharedPtr<FGAGameEffect>>& EffectMap = InstigatorEffects.FindOrAdd(HandleIn.GetContextRef().Instigator.Get());
EffectMap.Add(HandleIn, HandleIn.GetEffectPtr());
TMap<FName, TSet<FGAGameEffectHandle>>& EffectByClass = InstigatorEffectHandles.FindOrAdd(HandleIn.GetContextRef().Instigator.Get());
TSet<FGAGameEffectHandle>& EffectSet = EffectByClass.FindOrAdd(HandleIn.GetEffectSpec()->GetFName());
EffectSet.Add(HandleIn);
break;
}
case EGAEffectAggregation::AggregateByTarget:
{
TSet<FGAGameEffectHandle>& Handles = TargetEffectByType.FindOrAdd(HandleIn.GetEffectSpec()->GetFName());
Handles.Add(HandleIn);
//TargetEffects.Add(HandleIn, HandleIn.GetEffectPtr());
break;
}
}
ActiveEffects.Add(HandleIn, HandleIn.GetEffectPtr());
}
示例5: InternalApplyEffect
void FGAGameEffectContainer::InternalApplyEffect(const FGAGameEffectHandle& HandleIn)
{
UE_LOG(GameAttributesEffects, Log, TEXT("InternalApplyEffect"));
if (HandleIn.GetEffectSpec()->EffectType == EGAEffectType::Periodic)
{
FTimerDelegate delPeriod = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExecuteEffect, HandleIn);
FTimerManager& PeriodicTimer = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
PeriodicTimer.SetTimer(HandleIn.GetEffectRef().PeriodTimerHandle, delPeriod,
HandleIn.GetEffectSpec()->Period, true, 0);
}
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
HandleIn.GetEffectSpec()->Duration, false);
}
示例6: InternalApplyEffectTags
void FGAGameEffectContainer::InternalApplyEffectTags(const FGAGameEffectHandle& HandleIn)
{
//wayt to few dereferences!
UGAAttributeComponent* Target = HandleIn.GetContextRef().TargetComp.Get();
FGAGameEffect& Effect = HandleIn.GetEffectRef();
Target->AppliedTags.AddTagContainer(Effect.ApplyTags);
}
示例7: InternalExtendEffectDuration
void FGAGameEffectContainer::InternalExtendEffectDuration(const FGAGameEffectHandle& HandleIn, const FGAGameEffectHandle& ExtendingHandleIn)
{
if (ExtendingHandleIn.IsValid())
{
FTimerManager& DurationTimer = HandleIn.GetContextRef().TargetComp->GetWorld()->GetTimerManager();
float RemainingTime = DurationTimer.GetTimerRemaining(HandleIn.GetEffectRef().DurationTimerHandle);
float NewDuration = RemainingTime + ExtendingHandleIn.GetEffectSpec()->Duration;
DurationTimer.ClearTimer(HandleIn.GetEffectRef().DurationTimerHandle);
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
DurationTimer.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
NewDuration, false);
}
else
{
InternalApplyEffect(HandleIn);
}
}
示例8: RemoveEffect
void FGAGameEffectContainer::RemoveEffect(FGAGameEffectHandle& HandleIn)
{
EGAEffectAggregation aggregatiopn = HandleIn.GetEffectRef().GameEffect->EffectAggregation;
UObject* Instigator = HandleIn.GetContextRef().Instigator.Get();
TSharedPtr<FGAGameEffect> effect = ActiveEffects.FindAndRemoveChecked(HandleIn);
if (effect.IsValid())
{
switch (aggregatiopn)
{
case EGAEffectAggregation::AggregateByInstigator:
{
TMap<FGAGameEffectHandle, TSharedPtr<FGAGameEffect>>* effects = InstigatorEffects.Find(Instigator);
TMap<FName, TSet<FGAGameEffectHandle>>* EffectByClass = InstigatorEffectHandles.Find(Instigator);
if (EffectByClass)
{
//Probabaly need another path for removing just single effect from stack.
EffectByClass->Remove(HandleIn.GetEffectSpec()->GetFName());
}
if (effects)
{
effects->FindAndRemoveChecked(HandleIn);
if (effects->Num() == 0)
{
InstigatorEffects.Remove(Instigator);
}
}
break;
}
case EGAEffectAggregation::AggregateByTarget:
{
//TargetEffects.FindAndRemoveChecked(HandleIn);
TSet<FGAGameEffectHandle>* Handles = TargetEffectByType.Find(HandleIn.GetEffectSpec()->GetFName());
//check aggregation type to know which effect to remove exactly ?
TargetEffectByType.Remove(HandleIn.GetEffectSpec()->GetFName());
break;
}
}
for (FGAGameEffectModifier& Modifier : effect->GameEffect->Modifiers)
{
if (Modifier.Attribute.IsValid())
{
FGAAttributeBase* Attribute = OwningComp->GetAttribute(Modifier.Attribute);
if (Attribute)
{
Attribute->RemoveBonus(HandleIn);
}
}
}
UE_LOG(GameAttributesEffects, Log, TEXT("FGAGameEffectContainer:: Removing Effect"))
effect.Reset();
}
}
示例9: RemoveEffect
void FGAGameEffectContainer::RemoveEffect(FGAGameEffectHandle& HandleIn)
{
EGAEffectAggregation aggregatiopn = HandleIn.GetEffectRef().GameEffect->EffectAggregation;
UObject* Instigator = HandleIn.GetContextRef().Instigator.Get();
TSharedPtr<FGAGameEffect> effect = ActiveEffects.FindAndRemoveChecked(HandleIn);
if (effect.IsValid())
{
switch (aggregatiopn)
{
case EGAEffectAggregation::AggregateByInstigator:
{
TMap<FGAGameEffectHandle, TSharedPtr<FGAGameEffect>>* effects = InstigatorEffects.Find(Instigator);
TMap<UClass*, FGAGameEffectHandle>* EffectByClass = InstigatorEffectHandles.Find(Instigator);
if (EffectByClass)
{
EffectByClass->Remove(HandleIn.GetEffectSpec()->StaticClass());
}
if (effects)
{
effects->FindAndRemoveChecked(HandleIn);
if (effects->Num() == 0)
{
InstigatorEffects.Remove(Instigator);
}
}
break;
}
case EGAEffectAggregation::AggregateByTarget:
{
TargetEffects.FindAndRemoveChecked(HandleIn);
break;
}
}
for (FGAGameEffectModifier& Modifier : effect->GameEffect->Modifiers)
{
if (Modifier.Attribute.IsValid())
{
FGAAttributeBase* Attribute = OwningComp->GetAttribute(Modifier.Attribute);
if (Attribute)
{
Attribute->RemoveBonus(HandleIn);
}
}
}
UE_LOG(GameAttributesEffects, Log, TEXT("FGAGameEffectContainer:: Removing Effect"))
effect.Reset();
}
}
示例10: ApplyEffectForDuration
void UGAAttributeComponent::ApplyEffectForDuration(FGAGameEffectHandle& HandleIn)
{
FGAGameEffect& Effect = HandleIn.GetEffectRef();
TArray<FGAEffectMod> Mods = Effect.GetOnAppliedMods();
for (FGAEffectMod& mod : Mods)
{
FGAAttributeBase* attr = DefaultAttributes->GetAttribute(mod.Attribute);
if (attr)
{
FGAModifier Modifier(mod.AttributeMod, mod.Value);
float val = attr->GetFinalValue();
UE_LOG(GameAttributes, Log, TEXT("Value Before bonus of attribute = %f"), val);
attr->AddBonus(Modifier, HandleIn, EGAEffectStacking::Override);
val = attr->GetFinalValue();
UE_LOG(GameAttributes, Log, TEXT("Value After bonus of attribute = %f"), val);
}
}
}
示例11: ApplyEffect
void FGAGameEffectContainer::ApplyEffect(const FGAGameEffect& EffectIn
, const FGAGameEffectHandle& HandleIn)
{
//instant effect goes trough simplest application path
//just make effect and run it trough modifiers.
//FGAGameEffect Effect = EfNoConst.Calculation->ModiifyEffect(EffectIn);
switch (EffectIn.GameEffect->EffectType)
{
case EGAEffectType::Instant:
{
//dont do anything fancy now simply execute effect and forget about it.
HandleIn.GetContext().TargetComp->ExecuteEffect(HandleIn);
break;
}
case EGAEffectType::Periodic:
{
UE_LOG(GameAttributesEffects, Log, TEXT("UGAAttributeComponent:: Apply periodic effect"));
/*FTimerDelegate del = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExecuteEffect, HandleIn);
FTimerManager& timer = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
timer.SetTimer(HandleIn.GetEffectRef().PeriodTimerHandle, del,
EffectIn.GameEffect->Period, true, 0);
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
EffectIn.GameEffect->Duration, false);*/
InternalCheckEffectStacking(HandleIn);
InternalApplyModifiers(HandleIn);
break;
}
case EGAEffectType::Duration:
{
UE_LOG(GameAttributesEffects, Log, TEXT("UGAAttributeComponent:: Apply effect for duration"));
HandleIn.GetContextRef().TargetComp->ApplyEffectForDuration(HandleIn);
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
EffectIn.GameEffect->Duration, false);
InternalCheckEffectStacking(HandleIn);
InternalApplyModifiers(HandleIn);
break;
}
default:
break;
}
//apply additonal effect applied with this effect.
for (TSubclassOf<UGAGameEffectSpec> Spec : EffectIn.GameEffect->OnAppliedEffects)
{
FGAGameEffectHandle Handle = EffectIn.Context.TargetComp->MakeGameEffect(Spec, EffectIn.Context);
EffectIn.Context.TargetComp->ApplyEffectToSelf(Handle.GetEffect(), Handle);
}
//regardless of what happen try to apply effect modifiers
for (FGAGameEffectModifier& mod : EffectIn.GameEffect->Modifiers)
{
ApplyModifier(mod, EffectIn);
}
}