Fix
This commit is contained in:
parent
d256973d2d
commit
116ebff0c2
1 changed files with 16 additions and 6 deletions
|
|
@ -14,22 +14,22 @@ public partial class RuntimePlantData : Node2D, IEntity
|
||||||
private int _hp;
|
private int _hp;
|
||||||
public int Hp => _hp;
|
public int Hp => _hp;
|
||||||
public int MaxHp => _maxHP;
|
public int MaxHp => _maxHP;
|
||||||
public int Line {get; set;}
|
public int Line { get; set; }
|
||||||
public PlantResource Resource;
|
public PlantResource Resource;
|
||||||
|
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void OnHPChangedEventHandler(int amount,Node origin);
|
public delegate void OnHPChangedEventHandler(int amount, Node origin);
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_hp = _maxHP;
|
_hp = _maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Heal(int amount,Node origin)
|
public void Heal(int amount, Node origin)
|
||||||
{
|
{
|
||||||
_hp += amount;
|
_hp += amount;
|
||||||
|
|
||||||
EmitSignal(SignalName.OnHPChanged,amount,origin);
|
EmitSignal(SignalName.OnHPChanged, amount, origin);
|
||||||
|
|
||||||
if (MaxHp > 0)
|
if (MaxHp > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -37,11 +37,11 @@ public partial class RuntimePlantData : Node2D, IEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TakeDamage(int amount,Node origin, Utility.DamageTypes damageType = Utility.DamageTypes.PHYSICAL)
|
public void TakeDamage(int amount, Node origin, Utility.DamageTypes damageType = Utility.DamageTypes.PHYSICAL)
|
||||||
{
|
{
|
||||||
_hp -= amount;
|
_hp -= amount;
|
||||||
|
|
||||||
EmitSignal(SignalName.OnHPChanged,-amount, origin);
|
EmitSignal(SignalName.OnHPChanged, -amount, origin);
|
||||||
|
|
||||||
if (_hp <= 0)
|
if (_hp <= 0)
|
||||||
{
|
{
|
||||||
|
|
@ -53,4 +53,14 @@ public partial class RuntimePlantData : Node2D, IEntity
|
||||||
PoolContainer.Instance.EntityField[Resource.Layer].Remove(GlobalPosition);
|
PoolContainer.Instance.EntityField[Resource.Layer].Remove(GlobalPosition);
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DisableBrain()
|
||||||
|
{
|
||||||
|
GetNode<Node>("Behaviour").ProcessMode = ProcessModeEnum.Disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableBrain()
|
||||||
|
{
|
||||||
|
GetNode<Node>("Behaviour").ProcessMode = ProcessModeEnum.Inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue