From b15a4fef95e093bc61ee6800ac22dc803f18c306 Mon Sep 17 00:00:00 2001 From: Minimata Date: Wed, 11 Mar 2026 15:56:17 +0100 Subject: [PATCH] empowered action as a forge ability --- Movement tests.csproj | 1 + forge/abilities/EmpoweredActionBehavior.cs | 56 -------------- forge/abilities/REmpoweredAction.cs | 75 +++++++++++++++++++ ...ehavior.cs.uid => REmpoweredAction.cs.uid} | 0 scenes/components/health/RHealth.cs | 10 +-- .../player_controller/PlayerController.tscn | 2 + .../resources/forge_empowered_action.tres | 9 +++ .../scripts/PlayerController.cs | 7 +- 8 files changed, 94 insertions(+), 66 deletions(-) delete mode 100644 forge/abilities/EmpoweredActionBehavior.cs create mode 100644 forge/abilities/REmpoweredAction.cs rename forge/abilities/{EmpoweredActionBehavior.cs.uid => REmpoweredAction.cs.uid} (100%) create mode 100644 scenes/player_controller/resources/forge_empowered_action.tres diff --git a/Movement tests.csproj b/Movement tests.csproj index 4cbe4366..52016d61 100644 --- a/Movement tests.csproj +++ b/Movement tests.csproj @@ -125,6 +125,7 @@ + diff --git a/forge/abilities/EmpoweredActionBehavior.cs b/forge/abilities/EmpoweredActionBehavior.cs deleted file mode 100644 index 3034e084..00000000 --- a/forge/abilities/EmpoweredActionBehavior.cs +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/forge/abilities/REmpoweredAction.cs b/forge/abilities/REmpoweredAction.cs new file mode 100644 index 00000000..b08e3654 --- /dev/null +++ b/forge/abilities/REmpoweredAction.cs @@ -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 + } +} \ No newline at end of file diff --git a/forge/abilities/EmpoweredActionBehavior.cs.uid b/forge/abilities/REmpoweredAction.cs.uid similarity index 100% rename from forge/abilities/EmpoweredActionBehavior.cs.uid rename to forge/abilities/REmpoweredAction.cs.uid diff --git a/scenes/components/health/RHealth.cs b/scenes/components/health/RHealth.cs index 0dcfb823..296d4bca 100644 --- a/scenes/components/health/RHealth.cs +++ b/scenes/components/health/RHealth.cs @@ -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; - } } diff --git a/scenes/player_controller/PlayerController.tscn b/scenes/player_controller/PlayerController.tscn index f2e0674b..44f9893e 100644 --- a/scenes/player_controller/PlayerController.tscn +++ b/scenes/player_controller/PlayerController.tscn @@ -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") diff --git a/scenes/player_controller/resources/forge_empowered_action.tres b/scenes/player_controller/resources/forge_empowered_action.tres new file mode 100644 index 00000000..dc935851 --- /dev/null +++ b/scenes/player_controller/resources/forge_empowered_action.tres @@ -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" diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index 09faea61..cae0f855 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -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());