Atrocities

This commit is contained in:
Rendo 2025-06-14 21:20:28 +05:00
commit 9680b21792
90 changed files with 324 additions and 69 deletions

View file

@ -0,0 +1,54 @@
using Godot;
namespace Newlon.Components;
[GlobalClass]
public partial class Armor : Node
{
[Signal]
public delegate void ArmorDamagedEventHandler(int hp);
[Signal]
public delegate void ArmorLostEventHandler();
[Export]
private int _maxHP;
private int _hp;
private bool _lost = false;
public override void _Ready()
{
_hp = _maxHP;
}
public int RecieveDamage(int damage)
{
if(_lost)
return damage;
int returnAmount = 0;
_hp -= damage;
if(_hp <= 0)
{
returnAmount = _hp;
_hp = 0;
EmitSignal(SignalName.ArmorLost);
_lost = true;
}
EmitSignal(SignalName.ArmorDamaged,_hp);
return returnAmount;
}
public int Heal(int amount)
{
if(_lost)
return amount;
int returnAmount = 0;
_hp += amount;
if (_hp >= _maxHP)
{
returnAmount = _hp-_maxHP;
_hp = _maxHP;
}
EmitSignal(SignalName.ArmorDamaged,_hp);
return returnAmount;
}
}