Setup the base for abilities and events
This commit is contained in:
41
forge/abilities/RAbilityBase.cs
Normal file
41
forge/abilities/RAbilityBase.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Effects.Components;
|
||||
using Gamesmiths.Forge.Effects.Duration;
|
||||
using Gamesmiths.Forge.Effects.Magnitudes;
|
||||
using Gamesmiths.Forge.Effects.Modifiers;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Godot;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
namespace Movementtests.forge.abilities;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RAbilityBase(float cost, float cooldown) : Resource, IAbilityBase
|
||||
{
|
||||
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
||||
public float Cost { get; set; } = cost;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
|
||||
public RAbilityBase() : this(20.0f, 0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual AbilityData Ability(TagsManager tagsManager, Node3D owner)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual EffectData CostEffect(TagsManager tagsManager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual EffectData CooldownEffect(TagsManager tagsManager)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
1
forge/abilities/RAbilityBase.cs.uid
Normal file
1
forge/abilities/RAbilityBase.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://4eosgwb3h528
|
||||
@@ -26,6 +26,16 @@ public partial class REmpoweredAction(float cost, float cooldown, float manaRege
|
||||
{
|
||||
}
|
||||
|
||||
public AbilityData Ability(TagsManager tagsManager)
|
||||
{
|
||||
return new AbilityData(
|
||||
name: "Empowered Action",
|
||||
costEffect: CostEffect(tagsManager),
|
||||
cooldownEffects: [CooldownEffect(tagsManager)],
|
||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||
behaviorFactory: () => new EmpoweredActionBehavior());
|
||||
}
|
||||
|
||||
public EffectData CostEffect(TagsManager tagsManager)
|
||||
{
|
||||
return new(
|
||||
|
||||
104
forge/abilities/RExplodingSwordThrow.cs
Normal file
104
forge/abilities/RExplodingSwordThrow.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Effects.Components;
|
||||
using Gamesmiths.Forge.Effects.Duration;
|
||||
using Gamesmiths.Forge.Effects.Magnitudes;
|
||||
using Gamesmiths.Forge.Effects.Modifiers;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Godot;
|
||||
|
||||
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)
|
||||
{
|
||||
[Export] public PackedScene? Explosion { get; set; } = explosion;
|
||||
|
||||
public RExplodingSwordThrow() : this(null, 20.0f, 0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
public override AbilityData Ability(TagsManager tagsManager, Node3D owner)
|
||||
{
|
||||
return new AbilityData(
|
||||
name: "Exploding Sword Throw",
|
||||
costEffect: CostEffect(tagsManager),
|
||||
cooldownEffects: [CooldownEffect(tagsManager)],
|
||||
abilityTags: Tag.RequestTag(tagsManager, "abilities.weapon.land").GetSingleTagContainer(),
|
||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior(owner, Explosion));
|
||||
}
|
||||
|
||||
public override EffectData CostEffect(TagsManager tagsManager)
|
||||
{
|
||||
return new(
|
||||
"Exploding Sword Throw Mana Cost",
|
||||
new DurationData(DurationType.Instant),
|
||||
new[]
|
||||
{
|
||||
new Modifier(
|
||||
"PlayerAttributeSet.Mana",
|
||||
ModifierOperation.FlatBonus,
|
||||
new ModifierMagnitude(
|
||||
MagnitudeCalculationType.ScalableFloat,
|
||||
new ScalableFloat(-Cost)
|
||||
)
|
||||
)
|
||||
},
|
||||
cues: new []
|
||||
{
|
||||
new CueData(
|
||||
CueTags: Tag.RequestTag(tagsManager, "cues.resources.mana").GetSingleTagContainer(),
|
||||
MinValue: 0,
|
||||
MaxValue: 100,
|
||||
MagnitudeType: CueMagnitudeType.AttributeValueChange,
|
||||
MagnitudeAttribute: "PlayerAttributeSet.Mana"
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public override EffectData CooldownEffect(TagsManager tagsManager)
|
||||
{
|
||||
return new(
|
||||
"Exploding Sword Throw Cooldown",
|
||||
new DurationData(
|
||||
DurationType.HasDuration,
|
||||
new ModifierMagnitude(
|
||||
MagnitudeCalculationType.ScalableFloat,
|
||||
new ScalableFloat(Cooldown))),
|
||||
effectComponents: new[]
|
||||
{
|
||||
new ModifierTagsEffectComponent(
|
||||
tagsManager.RequestTagContainer(new[] { "cooldown.empoweredSwordThrow" })
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class ExplodingSwordThrowBehavior(Node3D owner, PackedScene? explosion) : IAbilityBehavior
|
||||
{
|
||||
private Node3D _owner = owner;
|
||||
private PackedScene? _explosion = explosion;
|
||||
public void OnStarted(AbilityBehaviorContext context)
|
||||
{
|
||||
if (_explosion?.Instantiate() is not Explosion explosion)
|
||||
{
|
||||
context.InstanceHandle.End();
|
||||
return;
|
||||
}
|
||||
|
||||
explosion.Radius = 10f;
|
||||
_owner.GetTree().GetRoot().AddChild(explosion);
|
||||
explosion.GlobalPosition = _owner.GlobalPosition;
|
||||
|
||||
context.AbilityHandle.CommitAbility();
|
||||
context.InstanceHandle.End();
|
||||
}
|
||||
|
||||
public void OnEnded(AbilityBehaviorContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
1
forge/abilities/RExplodingSwordThrow.cs.uid
Normal file
1
forge/abilities/RExplodingSwordThrow.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://rux15j7q78e8
|
||||
Reference in New Issue
Block a user