Implemented mana regeneration
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 40s
Create tag and build when new code gets to main / Export (push) Successful in 5m18s

This commit is contained in:
2026-03-11 16:29:09 +01:00
parent b15a4fef95
commit 95616f61fc
8 changed files with 83 additions and 10 deletions

View File

@@ -3,9 +3,6 @@ using System.Collections.Generic;
using Gamesmiths.Forge.Abilities;
using Gamesmiths.Forge.Core;
using Gamesmiths.Forge.Effects;
using Gamesmiths.Forge.Effects.Components;
using Gamesmiths.Forge.Effects.Duration;
using Gamesmiths.Forge.Effects.Magnitudes;
using Gamesmiths.Forge.Events;
using Gamesmiths.Forge.Tags;
@@ -19,7 +16,7 @@ using Movementtests.player_controller.Scripts;
using Movementtests.scenes.player_controller.scripts;
using Movementtests.tools;
using Movementtests.forge.abilities;
using Movementtests.tools.effects;
using RustyOptions;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png")]
@@ -100,6 +97,12 @@ public partial class PlayerController : CharacterBody3D,
[Export] public bool HasSword { get; set; } = true;
[Export] public bool HasParry { get; set; } = true;
// Forge stuff
[ExportCategory("Forge")]
[ExportGroup("General")]
[Export] public REmpoweredAction EmpoweredAction = null!;
[Export] public RManaRegen ManaRegen = null!;
// Combat stuff
[ExportCategory("Combat")]
[ExportGroup("General")]
@@ -408,8 +411,7 @@ public partial class PlayerController : CharacterBody3D,
private Camera3D _camera = null!;
private AbilityHandle? _empoweredActionHandle;
[Export] public REmpoweredAction EmpoweredAction = null!;
private ActiveEffectHandle? _manaRegenEffectHandle;
public override void _Ready()
{
@@ -454,6 +456,9 @@ public partial class PlayerController : CharacterBody3D,
abilityLevel: 1,
levelOverridePolicy: LevelComparison.None,
sourceEntity: this);
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(), new EffectOwnership(this, this));
_manaRegenEffectHandle = EffectsManager.ApplyEffect(manaRegenEffect);
var health = Attributes["PlayerAttributeSet.Health"].CurrentValue; // 100
var mana = Attributes["PlayerAttributeSet.Mana"].CurrentValue; // 100
@@ -1967,6 +1972,7 @@ public partial class PlayerController : CharacterBody3D,
public void PerformEmpoweredAction()
{
if(_empoweredActionHandle == null) return;
var canActivate = _empoweredActionHandle.Activate(out var failures);
if (!canActivate)
{
@@ -1979,6 +1985,11 @@ public partial class PlayerController : CharacterBody3D,
GD.Print($"Remaining mana: {Attributes["PlayerAttributeSet.Mana"].CurrentValue}");
}
// Inhibit Mana Regeneration for a while after using an empowered action
// TODO: Use Forge events instead of relying on direct referencing
_manaRegenEffectHandle!.SetInhibit(true);
GetTree().CreateTimer(EmpoweredAction.ManaRegenPause).Timeout += () => {_manaRegenEffectHandle!.SetInhibit(false);};
_isWallJumpAvailable = true;
_canDashAirborne = true;
EmpoweredActionsLeft--;
@@ -2304,6 +2315,7 @@ public partial class PlayerController : CharacterBody3D,
LookAround(delta);
EffectsManager.UpdateEffects(delta);
GD.Print(Attributes["PlayerAttributeSet.Mana"].CurrentValue);
}
///////////////////////////