more encapsulated effect application
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Core;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Effects.Components;
|
||||
@@ -70,4 +71,25 @@ public class ExplodingSwordThrowBehavior<TPayload>(Node3D owner, PackedScene? ex
|
||||
public void OnEnded(AbilityBehaviorContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class FlyingSwordBehavior(IForgeEntity owner, EffectData effectData) : IAbilityBehavior
|
||||
{
|
||||
private ActiveEffectHandle? _effectHandle;
|
||||
public void OnStarted(AbilityBehaviorContext context)
|
||||
{
|
||||
GD.Print("This is applying the periodic effect to the flying weapon");
|
||||
_effectHandle = owner.EffectsManager.ApplyEffect(new Effect(effectData, new EffectOwnership(owner, owner)));
|
||||
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)
|
||||
owner.EffectsManager.RemoveEffect(_effectHandle);
|
||||
context.InstanceHandle.End();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user