コード例 #1
0
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);
			}
		}
	}
}
void UGAAttributesBlueprintFunctionLibrary::AttributesOperation(TArray<FGAAttributeModifier> AttributesIn)
{
	for (const FGAAttributeModifier& attributeMod : AttributesIn)
	{
		IIGAAttributes* attributeInt = Cast<IIGAAttributes>(attributeMod.Target.Get());
		if (!attributeInt)
		{
			return;
		}
		UGAAttributesBase* attributes = attributeInt->GetAttributes();
		float newValue = attributes->AttributeOperation(attributeMod.Attribute, attributeMod.Value, attributeMod.Operation);
		//if (bSetAttribute)
		//{
		attributes->SetFloatValue(attributeMod.Attribute, newValue);
		//}
	}
}
コード例 #3
0
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);
			}
		}
	}
}
コード例 #4
0
void FGAGameEffectContainer::ApplyModifier(const FGAGameEffectModifier& ModifierIn,
	const FGAGameEffect& EffectIn)
{
	//if there is valid attribute specified, we go different path and ignore any tags modifiers.
	if (ModifierIn.Attribute.IsValid())
	{
		FGAGameEffect& effect = const_cast<FGAGameEffect&>(EffectIn);
		UGAAttributesBase* attr = effect.Context.GetTargetAttributes();
		//it shouldn't ever be null
		if (attr)
		{
			FGAAttributeBase* baseAttribute = attr->GetAttribute(ModifierIn.Attribute);
		}
	}
	else
	{
		int32 Index = static_cast<int32>(ModifierIn.Direction);
		Modifiers[Index].Add(ModifierIn);
	}
}
float UGAAttributesBlueprintFunctionLibrary::ChangeAttribute(AActor* Target, FGAAttribute AttributeIn, float ValueIn, EGAAttributeOp Operation, bool bSetAttribute)
{
	//check if actor have interface, if not, then this actor can't interact with attribute system.
	IIGAAttributes* attributeInt = Cast<IIGAAttributes>(Target);
	if (!attributeInt)
	{
		/*
			Probabaly should print some message, like 
			you need to implement proper interface to interact with this system
			and add component.
		*/
		return 0;
	}
	//shouldn't be null if we are past interface stage..
	UGAAttributesBase* attributes = attributeInt->GetAttributes();

	float newValue = attributes->AttributeOperation(AttributeIn, ValueIn, Operation);
	if (bSetAttribute)
	{
		attributes->SetFloatValue(AttributeIn, newValue);
	}

	return newValue;
}