Moved the exploding sword forge object from the code only hardcoded stuff to the resource based stuff
This commit is contained in:
42
forge/abilities/ForgeEffectApplicationBehavior.cs
Normal file
42
forge/abilities/ForgeEffectApplicationBehavior.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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 ActiveEffectHandle? _effectHandle;
|
||||
public void OnStarted(AbilityBehaviorContext context)
|
||||
{
|
||||
GD.Print("This is applying the periodic effect to the flying weapon");
|
||||
_effectHandle = context.Owner.EffectsManager.ApplyEffect(new Effect(effectData, new EffectOwnership(context.Owner, context.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)
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user