empowered action as a forge ability

This commit is contained in:
2026-03-11 15:56:17 +01:00
parent 14d29d68bb
commit b15a4fef95
8 changed files with 94 additions and 66 deletions

View File

@@ -125,6 +125,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="addons\" />
<Folder Include="forge\" />
<Folder Include="tests\" />
<Folder Include="tools\" />
</ItemGroup>

View File

@@ -1,56 +0,0 @@
using Gamesmiths.Forge.Abilities;
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;
namespace Movementtests.forge.abilities;
public class EmpoweredAction(TagsManager tagsManager)
{
public EffectData EmpoweredActionCostEffect = new(
"Empowered Action Mana Cost",
new DurationData(DurationType.Instant),
new[] {
new Modifier(
"PlayerAttributeSet.Mana",
ModifierOperation.FlatBonus,
new ModifierMagnitude(
MagnitudeCalculationType.ScalableFloat,
new ScalableFloat(-20)
)
)
});
public EffectData EmpoweredActionCooldown = new(
"Empowered Action Cooldown",
new DurationData(
DurationType.HasDuration,
new ModifierMagnitude(
MagnitudeCalculationType.ScalableFloat,
new ScalableFloat(1.0f))),
effectComponents: new[] {
new ModifierTagsEffectComponent(
tagsManager.RequestTagContainer(new[] { "cooldown.empoweredAction" })
)
});
}
public class EmpoweredActionBehavior : IAbilityBehavior
{
public void OnStarted(AbilityBehaviorContext context)
{
// Apply costs and cooldowns
context.AbilityHandle.CommitAbility();
context.InstanceHandle.End();
}
public void OnEnded(AbilityBehaviorContext context)
{
// Do any necessary cleanups
}
}

View File

@@ -0,0 +1,75 @@
using Gamesmiths.Forge.Abilities;
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_animation.png")]
public partial class REmpoweredAction(float cost, float cooldown) : Resource
{
[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 REmpoweredAction() : this(20.0f, 1.0f)
{
}
public EffectData CostEffect()
{
return new(
"Empowered Action Mana Cost",
new DurationData(DurationType.Instant),
new[]
{
new Modifier(
"PlayerAttributeSet.Mana",
ModifierOperation.FlatBonus,
new ModifierMagnitude(
MagnitudeCalculationType.ScalableFloat,
new ScalableFloat(-Cost)
)
)
});
}
public EffectData CooldownEffect(TagsManager tagsManager)
{
return new(
"Empowered Action Cooldown",
new DurationData(
DurationType.HasDuration,
new ModifierMagnitude(
MagnitudeCalculationType.ScalableFloat,
new ScalableFloat(Cooldown))),
effectComponents: new[]
{
new ModifierTagsEffectComponent(
tagsManager.RequestTagContainer(new[] { "cooldown.empoweredAction" })
)
});
}
}
public class EmpoweredActionBehavior : IAbilityBehavior
{
public void OnStarted(AbilityBehaviorContext context)
{
// Apply costs and cooldowns
context.AbilityHandle.CommitAbility();
context.InstanceHandle.End();
}
public void OnEnded(AbilityBehaviorContext context)
{
// Do any necessary cleanups
}
}

View File

@@ -3,14 +3,10 @@ using System;
using Movementtests.interfaces;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_heart.png")]
public partial class RHealth : Resource
public partial class RHealth(float startingHealth) : Resource
{
[Export]
public float StartingHealth { get; set;}
public float StartingHealth { get; set;} = startingHealth;
public RHealth() : this(100.0f) {}
public RHealth(float startingHealth)
{
StartingHealth = startingHealth;
}
}

View File

@@ -17,6 +17,7 @@
[ext_resource type="Resource" uid="uid://t612lts1wi1s" path="res://inputs/base_mode/move_right.tres" id="6_q7bng"]
[ext_resource type="Script" uid="uid://cwbvxlfvmocc1" path="res://scenes/player_controller/scripts/StairsSystem.cs" id="7_bmt5a"]
[ext_resource type="Resource" uid="uid://brswsknpgwal2" path="res://inputs/base_mode/move_front.tres" id="7_m8gvy"]
[ext_resource type="Resource" uid="uid://7dpkk5rk3di5" path="res://scenes/player_controller/resources/forge_empowered_action.tres" id="7_qheee"]
[ext_resource type="PackedScene" uid="uid://bctpe34ddamg5" path="res://scenes/components/knockback/CKnockback.tscn" id="7_x835q"]
[ext_resource type="Resource" uid="uid://s1l0n1iitc6m" path="res://inputs/base_mode/move_back.tres" id="8_jb43f"]
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://inputs/base_mode/aim_release.tres" id="8_lhb11"]
@@ -162,6 +163,7 @@ MinimumWallRunUpwardSpeed = 4.0
MinimumWallRunHorizontalSpeed = 8.0
WallRunAltitudeLossSpeed = 8.0
WallRunSpeedThreshold = 1.0
EmpoweredAction = ExtResource("7_qheee")
[node name="CHealth" parent="." unique_id=1244478698 instance=ExtResource("3_q7bng")]
RHealth = ExtResource("4_m8gvy")

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="REmpoweredAction" format=3 uid="uid://7dpkk5rk3di5"]
[ext_resource type="Script" uid="uid://d0l07gcx1ef18" path="res://forge/abilities/REmpoweredAction.cs" id="1_1rxoq"]
[resource]
script = ExtResource("1_1rxoq")
Cost = 50.0
Cooldown = 1.0
metadata/_custom_type_script = "uid://d0l07gcx1ef18"

View File

@@ -409,6 +409,8 @@ public partial class PlayerController : CharacterBody3D,
private AbilityHandle? _empoweredActionHandle;
[Export] public REmpoweredAction EmpoweredAction = null!;
public override void _Ready()
{
LoadSettings();
@@ -439,11 +441,10 @@ public partial class PlayerController : CharacterBody3D,
Abilities = new(this);
Events = new();
var empoweredAction = new EmpoweredAction(forgeManager.TagsManager);
var empoweredActionData = new AbilityData(
name: "Empowered Action",
costEffect: empoweredAction.EmpoweredActionCostEffect,
cooldownEffects: [empoweredAction.EmpoweredActionCooldown],
costEffect: EmpoweredAction.CostEffect(),
cooldownEffects: [EmpoweredAction.CooldownEffect(forgeManager.TagsManager)],
instancingPolicy: AbilityInstancingPolicy.PerEntity,
behaviorFactory: () => new EmpoweredActionBehavior());