hitting is now an ability

This commit is contained in:
2026-05-02 11:19:56 +02:00
parent 24f057c15f
commit fb30a08b89
19 changed files with 588 additions and 395 deletions

View File

@@ -9,7 +9,7 @@ using Gamesmiths.Forge.Godot.Core;
using Gamesmiths.Forge.Tags;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_heart.png"), Meta(typeof(IAutoNode))]
public partial class ResourceBar : ProgressBar, ICueHandler
public partial class ResourceBar : ProgressBar
{
public override void _Notification(int what) => this.Notify(what);
@@ -34,16 +34,17 @@ public partial class ResourceBar : ProgressBar, ICueHandler
AddThemeStyleboxOverride("fill", BarStyle);
}
public void Init(EntityAttribute attribute, Tag cueTag)
public void Init(EntityAttribute attribute)
{
_currentValue = attribute.BaseValue;
MaxValue = attribute.Max;
// Should be Max but it's bugged
// Therefore we just assume that the base value is the max value, i.e. entities spawn at full health
MaxValue = attribute.BaseValue; // MaxValue = attribute.Max;
Value = attribute.BaseValue;
DamageBar.MaxValue = attribute.Max;
DamageBar.Value = attribute.BaseValue;
var cuesManager = ForgeManagers.Instance.CuesManager;
cuesManager.RegisterCue(cueTag, this);
attribute.OnValueChanged += (entityAttribute, i) => CurrentValue = entityAttribute.CurrentValue;
}
public void SetValue(float newValue)
@@ -69,24 +70,4 @@ public partial class ResourceBar : ProgressBar, ICueHandler
{
DamageBar.Value = _currentValue;
}
public void OnExecute(IForgeEntity? target, CueParameters? parameters)
{
if (target == null || !parameters.HasValue) return;
float magnitude = parameters.Value.Magnitude;
CurrentValue += magnitude;
}
public void OnApply(IForgeEntity? target, CueParameters? parameters)
{
}
public void OnRemove(IForgeEntity? target, bool interrupted)
{
}
public void OnUpdate(IForgeEntity? target, CueParameters? parameters)
{
}
}