mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 08:25:54 +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
|
|
@ -12,11 +12,23 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
public bool Invulnerable { get; private set; } = false;
|
||||
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
||||
|
||||
[ExportCategory("Extensions")]
|
||||
[Export] public StringName HealthExtendName { get; private set; } = "HEALTH_EXTEND";
|
||||
[Export] public StringName ShieldExtendName { get; private set; } = "SHIELD_EXTEND";
|
||||
|
||||
[Export] public float BaseHealth { get; private set; } = 32f;
|
||||
[Export] public float BaseShield { get; private set; } = 32f;
|
||||
|
||||
[Export] public float HealthExtendAmount { get; private set; } = 4f;
|
||||
[Export] public float ShieldExtendAmount { get; private set; } = 4f;
|
||||
|
||||
[ExportCategory("Providers")]
|
||||
[Export]
|
||||
private ActorResourceProvider _healthProvider;
|
||||
[Export]
|
||||
private ActorResourceProvider _shieldProvider;
|
||||
|
||||
|
||||
[ExportCategory("Damage Types")]
|
||||
[Export] public StringName AcidGroupName { get; private set; } = "Acid";
|
||||
|
||||
[Signal]
|
||||
|
|
@ -81,6 +93,27 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
//if (!Enabled) return;
|
||||
EmitSignal(SignalName.Death);
|
||||
};
|
||||
|
||||
// Set max resources based on inventory
|
||||
SetMaxResources();
|
||||
|
||||
InventoryManager.Instance.ItemAdded += (item, amount) =>
|
||||
{
|
||||
if (item.ItemKey != HealthExtendName && item.ItemKey != ShieldExtendName) return;
|
||||
|
||||
SetMaxResources();
|
||||
};
|
||||
}
|
||||
|
||||
private void SetMaxResources()
|
||||
{
|
||||
var healthExtends = InventoryManager.Instance.GetItemCount(HealthExtendName);
|
||||
|
||||
var shieldExtends = InventoryManager.Instance.GetItemCount(ShieldExtendName);
|
||||
|
||||
_healthProvider.MaxResource = BaseHealth + (healthExtends * HealthExtendAmount);
|
||||
|
||||
_shieldProvider.MaxResource = BaseShield + (shieldExtends * ShieldExtendAmount);
|
||||
}
|
||||
|
||||
public void RefillHealth()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue