Move up Undamaged check in DamageState
A mere int comparison is obviously cheaper than a comparison between two multiplications, so pulling this above the checks of other damage states allows us to bail early for undamaged actors.
This commit is contained in:
@@ -88,6 +88,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (hp == MaxHP)
|
||||||
|
return DamageState.Undamaged;
|
||||||
|
|
||||||
if (hp <= 0)
|
if (hp <= 0)
|
||||||
return DamageState.Dead;
|
return DamageState.Dead;
|
||||||
|
|
||||||
@@ -100,9 +103,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (hp * 100L < MaxHP * 75L)
|
if (hp * 100L < MaxHP * 75L)
|
||||||
return DamageState.Medium;
|
return DamageState.Medium;
|
||||||
|
|
||||||
if (hp == MaxHP)
|
|
||||||
return DamageState.Undamaged;
|
|
||||||
|
|
||||||
return DamageState.Light;
|
return DamageState.Light;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user