WIP: integrating forge systems into the game, now trying periodic abilities
This commit is contained in:
@@ -24,7 +24,7 @@ public partial class RAbilityBase(float cost, float cooldown) : Resource, IAbili
|
||||
{
|
||||
}
|
||||
|
||||
public virtual AbilityData Ability(TagsManager tagsManager, Node3D owner)
|
||||
public virtual AbilityData Ability(TagsManager tagsManager, TagContainer? tags, Node3D owner)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
@@ -7,27 +8,28 @@ using Gamesmiths.Forge.Effects.Magnitudes;
|
||||
using Gamesmiths.Forge.Effects.Modifiers;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.forge.abilities;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_projectile.png")]
|
||||
public partial class RExplodingSwordThrow(PackedScene? explosion, float cost, float cooldown) : RAbilityBase(cost, cooldown)
|
||||
public partial class RExplodingSword(PackedScene? explosion, float cost, float cooldown) : RAbilityBase(cost, cooldown)
|
||||
{
|
||||
[Export] public PackedScene? Explosion { get; set; } = explosion;
|
||||
|
||||
public RExplodingSwordThrow() : this(null, 20.0f, 0.0f)
|
||||
public RExplodingSword() : this(null, 20.0f, 0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
public override AbilityData Ability(TagsManager tagsManager, Node3D owner)
|
||||
public override AbilityData Ability(TagsManager tagsManager, TagContainer? tags, Node3D owner)
|
||||
{
|
||||
return new AbilityData(
|
||||
name: "Exploding Sword Throw",
|
||||
costEffect: CostEffect(tagsManager),
|
||||
cooldownEffects: [CooldownEffect(tagsManager)],
|
||||
abilityTags: Tag.RequestTag(tagsManager, "abilities.weapon.land").GetSingleTagContainer(),
|
||||
abilityTags: tags,
|
||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior(owner, Explosion));
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior<WeaponLeftPayload>(owner, Explosion));
|
||||
}
|
||||
|
||||
public override EffectData CostEffect(TagsManager tagsManager)
|
||||
@@ -77,21 +79,28 @@ public partial class RExplodingSwordThrow(PackedScene? explosion, float cost, fl
|
||||
}
|
||||
}
|
||||
|
||||
public class ExplodingSwordThrowBehavior(Node3D owner, PackedScene? explosion) : IAbilityBehavior
|
||||
public class ExplodingSwordThrowBehavior<TPayload>(Node3D owner, PackedScene? explosion) : IAbilityBehavior<TPayload>
|
||||
{
|
||||
private Node3D _owner = owner;
|
||||
private PackedScene? _explosion = explosion;
|
||||
public void OnStarted(AbilityBehaviorContext context)
|
||||
public void OnStarted(AbilityBehaviorContext context, TPayload payload)
|
||||
{
|
||||
GD.Print(payload);
|
||||
if (_explosion?.Instantiate() is not Explosion explosion)
|
||||
{
|
||||
context.InstanceHandle.End();
|
||||
return;
|
||||
}
|
||||
if (!_owner.IsInsideTree())
|
||||
{
|
||||
context.InstanceHandle.End();
|
||||
return;
|
||||
}
|
||||
|
||||
explosion.Radius = 6f;
|
||||
|
||||
explosion.Radius = 10f;
|
||||
_owner.GetTree().GetRoot().AddChild(explosion);
|
||||
explosion.GlobalPosition = _owner.GlobalPosition;
|
||||
_owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explosion);
|
||||
explosion.CallDeferred(Node3D.MethodName.SetGlobalPosition, _owner.GlobalPosition);
|
||||
|
||||
context.AbilityHandle.CommitAbility();
|
||||
context.InstanceHandle.End();
|
||||
@@ -99,6 +108,17 @@ public class ExplodingSwordThrowBehavior(Node3D owner, PackedScene? explosion) :
|
||||
|
||||
public void OnEnded(AbilityBehaviorContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class TestBehavior<TPayload>(
|
||||
Action<AbilityBehaviorContext, TPayload> callback) : IAbilityBehavior<TPayload>
|
||||
{
|
||||
public void OnStarted(AbilityBehaviorContext context, TPayload data)
|
||||
{
|
||||
callback(context, data);
|
||||
context.InstanceHandle.End();
|
||||
}
|
||||
|
||||
public void OnEnded(AbilityBehaviorContext context){}
|
||||
}
|
||||
Reference in New Issue
Block a user