mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 07:45:55 +00:00
Health and shield extensions for player
This commit is contained in:
parent
62a77f5f78
commit
5dec57e711
6 changed files with 63 additions and 8 deletions
|
|
@ -7,11 +7,33 @@ public partial class ActorResourceProvider : Node2D
|
|||
[Export]
|
||||
public string ResourceName { get; private set; }
|
||||
|
||||
[Export]
|
||||
public float MaxResource { get; set; } = 10f;
|
||||
public float MaxResource
|
||||
{
|
||||
get => _maxResource;
|
||||
set
|
||||
{
|
||||
if (_maxResource == value) return;
|
||||
|
||||
if (value > _currentResource)
|
||||
{
|
||||
EmitSignal(SignalName.ResourceIncreased, _currentResource, _currentResource, value);
|
||||
}
|
||||
else if (value < _currentResource)
|
||||
{
|
||||
EmitSignal(SignalName.ResourceDecreased, _currentResource, _currentResource, value);
|
||||
}
|
||||
|
||||
_maxResource = value;
|
||||
|
||||
EmitSignal(SignalName.ResourceChanged, _currentResource, value);
|
||||
}
|
||||
}
|
||||
|
||||
private float _currentResource = 0f;
|
||||
|
||||
[Export]
|
||||
private float _maxResource = 10f;
|
||||
|
||||
[Signal]
|
||||
public delegate void ResourceChangedEventHandler(float newValue, float maxValue);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue