Replaced the entire mana usage and inhibition with the provided forge resources

This commit is contained in:
2026-04-03 16:35:15 +02:00
parent 673368a200
commit bfa1f251dd
17 changed files with 356 additions and 389 deletions

View File

@@ -28,9 +28,10 @@ using Movementtests.scenes.player_controller.scripts;
using Movementtests.tools;
using Movementtests.forge.abilities;
using Movementtests.tools.calculators;
using Movementtests.tools.effects;
using RustyOptions;
public record struct EmpoweredActionPayload;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png")]
public partial class PlayerController : CharacterBody3D,
IDamageable,
@@ -114,7 +115,7 @@ public partial class PlayerController : CharacterBody3D,
[ExportGroup("General")]
[Export]
public ForgeTagContainer BaseTags { get; set; } = new();
[Export] public RManaRegen ManaRegen = null!;
[Export] public ForgeTag EmpoweredActionUsed;
[ExportGroup("Abilities")]
[ExportSubgroup("Common and defaults")]
@@ -126,6 +127,8 @@ public partial class PlayerController : CharacterBody3D,
[ExportGroup("Effects")]
[ExportSubgroup("Common and defaults")]
[Export] public ForgeEffectData[] DefaultPermanentEffects = [];
[ExportSubgroup("Applied on Empowered Action used")]
[Export] public ForgeEffectData[] EmpoweredActionEffects = [];
// Combat stuff
[ExportCategory("Combat")]
@@ -435,7 +438,6 @@ public partial class PlayerController : CharacterBody3D,
private Camera3D _camera = null!;
private AbilityHandle? _empoweredActionHandle;
private ActiveEffectHandle? _manaRegenEffectHandle;
public override void _Ready()
{
@@ -488,11 +490,21 @@ public partial class PlayerController : CharacterBody3D,
levelOverridePolicy: LevelComparison.None,
sourceEntity: this);
}
// var empoweredActionData = EmpoweredAction.Ability(tagsManager);
// // Grant permanently
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(tagsManager), new EffectOwnership(this, this));
_manaRegenEffectHandle = EffectsManager.ApplyEffect(manaRegenEffect);
// Apply all default effects
foreach (var effect in DefaultPermanentEffects)
{
EffectsManager.ApplyEffect(new Effect(effect.GetEffectData(), new EffectOwnership(this, this)));
}
// Subscribe default empowered actions effects to the Empowered Action Used event
foreach (var effect in EmpoweredActionEffects)
{
Events.Subscribe<EmpoweredActionPayload>(EmpoweredActionUsed.GetTag(), data =>
{
EffectsManager.ApplyEffect(new Effect(effect.GetEffectData(), new EffectOwnership(this, this)));
});
}
// DashIndicator = GetNode<TextureRect>("%DashIndicator");
PowerCooldownIndicator = GetNode<ColorRect>("%DashCooldownIndicator");
@@ -2089,6 +2101,13 @@ public partial class PlayerController : CharacterBody3D,
_canDashAirborne = true;
EmpoweredActionsLeft--;
_playerState.SendEvent(EmpoweredActionsLeft <= 0 ? "expired" : "power_used");
Events.Raise(new EventData<EmpoweredActionPayload>
{
EventTags = EmpoweredActionUsed.GetTag().GetSingleTagContainer()!,
Source = this,
Payload = new EmpoweredActionPayload()
});
}
///////////////////////////