本文整理汇总了C++中FGAGameEffectHandle类的典型用法代码示例。如果您正苦于以下问题:C++ FGAGameEffectHandle类的具体用法?C++ FGAGameEffectHandle怎么用?C++ FGAGameEffectHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FGAGameEffectHandle类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
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());
}
示例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: UE_LOG
void FGAGameEffectContainer::InternalCheckPeriodicEffectStacking(const FGAGameEffectHandle& HandleIn)
{
UGAGameEffectSpec* Spec = HandleIn.GetEffectSpec();
//sEGAEffectStacking Stacking = Spec->EffectStacking;
EGAEffectAggregation Aggregation = Spec->EffectAggregation;
EGAEffectStacking Stacking = HandleIn.GetEffectSpec()->EffectStacking;
UE_LOG(GameAttributes, Log, TEXT("Stacking Type: %s"), *EnumToString::GetStatckingAsString(Stacking));
FGAGameEffectHandle* Handle = nullptr;
switch (Aggregation)
{
case EGAEffectAggregation::AggregateByInstigator:
{
TMap<FName, TSet<FGAGameEffectHandle>>* EffectHandle = InstigatorEffectHandles.Find(HandleIn.GetContextRef().Instigator.Get());
TSet<FGAGameEffectHandle>* HandleSet = nullptr;
if (EffectHandle)
{
HandleSet = EffectHandle->Find(HandleIn.GetEffectSpec()->GetFName());
if (HandleSet)
{
Handle = HandleSet->Find(HandleIn);
}
}
}
case EGAEffectAggregation::AggregateByTarget:
{
TSet<FGAGameEffectHandle>* HandleSet = TargetEffectByType.Find(HandleIn.GetEffectSpec()->GetFName());
if (HandleSet)
{
Handle = HandleSet->Find(HandleIn);
}
break;
}
}
switch (Stacking)
{
case EGAEffectStacking::Add:
{
break;
}
case EGAEffectStacking::Duration:
{
break;
}
case EGAEffectStacking::Intensity:
{
break;
}
case EGAEffectStacking::Override:
{
break;
}
case EGAEffectStacking::StrongerOverride:
{
InternalApplyPeriodic(HandleIn);
break;
}
}
InternalApplyEffectByAggregation(HandleIn);
}
示例4: 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);
}
示例5: switch
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();
}
}
示例6: 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);
}
}
}
}
示例7: switch
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();
}
}
示例8: InternalApplyModifiers
void FGAGameEffectContainer::InternalApplyModifiers(const FGAGameEffectHandle& HandleIn)
{
TArray<FGAGameEffectModifier>& Modifiers = HandleIn.GetEffectSpec()->Modifiers;
EGAEffectStacking Stacking = HandleIn.GetEffectSpec()->EffectStacking;
for (FGAGameEffectModifier& Modifier : Modifiers)
{
if (Modifier.Attribute.IsValid())
{
UGAAttributesBase* attr = HandleIn.GetContextRef().GetTargetAttributes();
FGAAttributeBase* Attribute = attr->GetAttribute(Modifier.Attribute);
if (Attribute)
{
Attribute->AddBonus(FGAModifier(Modifier.ModType, Modifier.Value), HandleIn, Stacking);
}
}
}
}
示例9: ExecuteEffect
void UGAAttributeComponent::ExecuteEffect(FGAGameEffectHandle HandleIn)
{
/*
this patth will give effects chance to do any replicated events, like applying cues.
WE do not make any replication at the ApplyEffect because some effect might want to apply cues
on periods on expiration etc, and all those will go trouch ExecuteEffect path.
*/
OnEffectExecuted.Broadcast(HandleIn);
FGAGameEffect Effect = HandleIn.GetEffect();
TArray<FGAEffectMod> Mods = Effect.GetOnAppliedMods();
FGAExecutionContext ExecContext(Effect.Context.TargetComp.Get(), Effect.Context.TargetComp->DefaultAttributes,
Effect.Context.InstigatorComp.Get(), Effect.Context.InstigatorComp->DefaultAttributes);
for (FGAEffectMod& mod : Mods)
{
HandleIn.ExecuteEffect(HandleIn, mod, ExecContext);
}
//GameEffectContainer.ExecuteEffect(HandleIn, HandleIn.GetEffectRef());
}
示例10: 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);
}
示例11: 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();
float period = HandleIn.GetEffectSpec()->Period;
PeriodicTimer.SetTimer(HandleIn.GetEffectRef().PeriodTimerHandle, delPeriod,
period, true, 0);
FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();
float Duration = HandleIn.GetEffectSpec()->Duration;
timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
Duration, false, Duration);
InternalApplyEffectTags(HandleIn);
}
示例12: 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);
}
}
}
示例13: 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);
}
}
示例14: UE_LOG
void FGAGameEffectContainer::InternalCheckEffectStacking(const FGAGameEffectHandle& HandleIn)
{
UGAGameEffectSpec* Spec = HandleIn.GetEffectSpec();
//sEGAEffectStacking Stacking = Spec->EffectStacking;
EGAEffectAggregation Aggregation = Spec->EffectAggregation;
EGAEffectStacking Stacking = HandleIn.GetEffectSpec()->EffectStacking;
UE_LOG(GameAttributes, Log, TEXT("Stacking Type: %s"), *EnumToString::GetStatckingAsString(Stacking));
switch (Aggregation)
{
case EGAEffectAggregation::AggregateByInstigator:
{
TMap<UClass*, FGAGameEffectHandle>* EffectHandle = InstigatorEffectHandles.Find(HandleIn.GetContextRef().Instigator.Get());
FGAGameEffectHandle* Handle = nullptr;
if(EffectHandle)
Handle = EffectHandle->Find(HandleIn.GetEffectSpec()->StaticClass());
switch (Stacking)
{
case EGAEffectStacking::Add:
{
InternalApplyEffect(HandleIn);
break;
}
case EGAEffectStacking::Duration:
{
if (Handle)
{
InternalExtendEffectDuration(*Handle, HandleIn);
}
else
{
FGAGameEffectHandle InvalidHandle;
InternalExtendEffectDuration(HandleIn, InvalidHandle);
}
break;
}
case EGAEffectStacking::Intensity:
{
break;
}
case EGAEffectStacking::Override:
{
if (Handle)
{
RemoveEffect(*Handle);
}
InternalApplyEffect(HandleIn);
break;
}
case EGAEffectStacking::StrongerOverride:
{
if (Handle)
{
RemoveEffect(*Handle);
}
InternalApplyEffect(HandleIn);
break;
}
}
break;
}
case EGAEffectAggregation::AggregateByTarget:
{
break;
}
}
InternalApplyEffectByAggregation(HandleIn);
}