cap health at minimum 0
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||||
@@ -25,7 +26,7 @@ public static class FightUtils
|
|||||||
|
|
||||||
public static bool IsAlive(this FightWorld.Fighter self)
|
public static bool IsAlive(this FightWorld.Fighter self)
|
||||||
{
|
{
|
||||||
return self.GetHealth() >= 0;
|
return self.GetHealth() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDead(this FightWorld.Fighter self)
|
public static bool IsDead(this FightWorld.Fighter self)
|
||||||
@@ -35,7 +36,7 @@ public static class FightUtils
|
|||||||
|
|
||||||
public static int GetHealth(this FightWorld.Fighter self)
|
public static int GetHealth(this FightWorld.Fighter self)
|
||||||
{
|
{
|
||||||
return self.health ?? self.maxHealth;
|
return Math.Max(self.health ?? self.maxHealth, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddHealth(this FightWorld.Fighter self, int addHealth)
|
public static void AddHealth(this FightWorld.Fighter self, int addHealth)
|
||||||
|
|||||||
Reference in New Issue
Block a user