updating mana through cues
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Gamesmiths.Forge.Core;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.tools;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
|
||||
public partial class PlayerUi : Control
|
||||
public partial class PlayerUi : Control, ICueHandler
|
||||
{
|
||||
internal TextureRect[] DashIcons = new TextureRect[3];
|
||||
private TextureRect _enemyTarget = null!;
|
||||
@@ -33,11 +37,17 @@ public partial class PlayerUi : Control
|
||||
_enemyTarget = GetNode<TextureRect>("%EnemyTarget");
|
||||
_healthbar = GetNode<Healthbar>("%Healthbar");
|
||||
_manabar = GetNode<Healthbar>("%Manabar");
|
||||
|
||||
var forgeManager = GetTree().Root.GetNode<ForgeManager>("ForgeManager")!;
|
||||
var tagsManager = forgeManager.TagsManager;
|
||||
var cuesManager = forgeManager.CuesManager;
|
||||
cuesManager.RegisterCue(Tag.RequestTag(tagsManager, "cues.resources.mana"), this);
|
||||
}
|
||||
|
||||
public void Initialize(float initialHealth)
|
||||
public void Initialize(float initialHealth, float initialMana)
|
||||
{
|
||||
_healthbar.Initialize(initialHealth);
|
||||
_manabar.Initialize(initialMana);
|
||||
}
|
||||
|
||||
public void SetEnemyTargetProperties(TargetProperties targetProperties)
|
||||
@@ -77,4 +87,38 @@ public partial class PlayerUi : Control
|
||||
{
|
||||
_manabar.CurrentHealth = newValue;
|
||||
}
|
||||
|
||||
public void OnExecute(IForgeEntity? target, CueParameters? parameters)
|
||||
{
|
||||
// One-shot effect (like impact)
|
||||
// Called when an instant effect with this cue is applied
|
||||
// Also called when a periodic effect with this cue executes its period
|
||||
|
||||
if (target == null || !parameters.HasValue) return;
|
||||
|
||||
// Extract parameters
|
||||
float magnitude = parameters.Value.Magnitude;
|
||||
float normalizedMagnitude = parameters.Value.NormalizedMagnitude;
|
||||
|
||||
// Play effects scaled by magnitude
|
||||
// PlayFireImpactSound(normalizedMagnitude);
|
||||
// SpawnFireImpactParticles(target, magnitude);
|
||||
GD.Print(_manabar.CurrentHealth);
|
||||
_manabar.CurrentHealth += magnitude;
|
||||
}
|
||||
|
||||
public void OnApply(IForgeEntity? target, CueParameters? parameters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void OnRemove(IForgeEntity? target, bool interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void OnUpdate(IForgeEntity? target, CueParameters? parameters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user