Skip to content

Commit

Permalink
validity check for setHealth and setArmour
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Oct 20, 2024
1 parent 3e101db commit 0ee0f1a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Server/Components/NPCs/NPC/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,14 @@ void NPC::setVelocity(Vector3 velocity, bool update)

void NPC::setHealth(float health)
{
footSync_.HealthArmour.x = health;
if (health < 0.0f)
{
footSync_.HealthArmour.x = 0.0f;
}
else
{
footSync_.HealthArmour.x = health;
}
}

float NPC::getHealth() const
Expand All @@ -264,7 +271,14 @@ float NPC::getHealth() const

void NPC::setArmour(float armour)
{
footSync_.HealthArmour.y = armour;
if (armour < 0.0f)
{
footSync_.HealthArmour.y = 0.0f;
}
else
{
footSync_.HealthArmour.y = armour;
}
}

float NPC::getArmour() const
Expand Down

0 comments on commit 0ee0f1a

Please sign in to comment.