Files
MovementTests/forge/abilities/ForgeEffectApplicationBehavior.cs
Minimata 585c2302d6
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 30s
Create tag and build when new code gets to main / Export (push) Successful in 6m46s
actually calling update effects
2026-04-14 19:29:43 +02:00

44 lines
1.4 KiB
C#

using Gamesmiths.Forge.Abilities;
using Gamesmiths.Forge.Core;
using Gamesmiths.Forge.Effects;
using Gamesmiths.Forge.Godot.Resources;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
namespace Movementtests.forge.abilities;
public class EffectApplicationBehavior(EffectData effectData) : IAbilityBehavior
{
private Effect? _effect;
private ActiveEffectHandle? _effectHandle;
public void OnStarted(AbilityBehaviorContext context)
{
GD.Print("This is applying the periodic effect to the flying weapon");
_effect = new Effect(effectData, new EffectOwnership(context.Owner, context.Owner));
_effectHandle = context.Owner.EffectsManager.ApplyEffect(_effect);
context.AbilityHandle.CommitAbility();
}
public void OnEnded(AbilityBehaviorContext context)
{
GD.Print("This is removing the periodic effect from the flying weapon");
if (_effectHandle is not null)
context.Owner.EffectsManager.RemoveEffect(_effectHandle);
context.InstanceHandle.End();
}
}
[Tool]
[GlobalClass]
public partial class ForgeEffectApplicationBehavior : ForgeAbilityBehavior
{
[Export] public ForgeEffectData? EffectData { get; set; }
public override IAbilityBehavior GetBehavior()
{
if (EffectData == null)
throw new System.ArgumentException("EffectData is null");
return new EffectApplicationBehavior(EffectData.GetEffectData());
}
}