further unhacking to localise extended damage state stuff to JUST WALLS
This commit is contained in:
@@ -28,8 +28,6 @@ namespace OpenRA.Traits
|
||||
public WarheadInfo Warhead;
|
||||
public int Damage;
|
||||
public DamageState DamageState;
|
||||
public ExtendedDamageState ExtendedDamageState; // for 3,4-state stuff
|
||||
public bool DamageStateChanged;
|
||||
public bool ExtendedDamageStateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,36 @@ namespace OpenRA.Traits
|
||||
this.self = self;
|
||||
this.damageStates = self.Info.Traits.Get<RenderBuildingWallInfo>().DamageStates;
|
||||
}
|
||||
|
||||
|
||||
enum ExtendedDamageState { Normal, ThreeQuarter, Half, Quarter, Dead };
|
||||
|
||||
ExtendedDamageState GetExtendedState( Actor self, int damage )
|
||||
{
|
||||
var effectiveHealth = self.Health + damage;
|
||||
|
||||
if (effectiveHealth <= 0)
|
||||
return ExtendedDamageState.Dead;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * Rules.General.ConditionRed)
|
||||
return ExtendedDamageState.Quarter;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * Rules.General.ConditionYellow)
|
||||
return ExtendedDamageState.Half;
|
||||
|
||||
if (effectiveHealth < self.GetMaxHP() * 0.75)
|
||||
return ExtendedDamageState.ThreeQuarter;
|
||||
|
||||
return ExtendedDamageState.Normal;
|
||||
}
|
||||
|
||||
public override void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!e.ExtendedDamageStateChanged) return;
|
||||
var oldState = GetExtendedState(self, e.Damage);
|
||||
var newState = GetExtendedState(self, 0);
|
||||
|
||||
switch (e.ExtendedDamageState)
|
||||
if (oldState == newState) return;
|
||||
|
||||
switch (newState)
|
||||
{
|
||||
case ExtendedDamageState.Normal:
|
||||
seqName = "idle";
|
||||
|
||||
@@ -28,7 +28,6 @@ using OpenRA.Traits.Activities;
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public enum DamageState { Normal, Half, Dead };
|
||||
public enum ExtendedDamageState { Normal, ThreeQuarter, Half, Quarter, Dead };
|
||||
|
||||
// depends on the order of pips in WorldRenderer.cs!
|
||||
public enum PipType { Transparent, Green, Yellow, Red, Gray };
|
||||
|
||||
Reference in New Issue
Block a user