diff --git a/OpenRa.Game/Graphics/Animation.cs b/OpenRa.Game/Graphics/Animation.cs index 563f1d478e..8ef35e229c 100644 --- a/OpenRa.Game/Graphics/Animation.cs +++ b/OpenRa.Game/Graphics/Animation.cs @@ -49,6 +49,11 @@ namespace OpenRa.Game.Graphics frame = f % CurrentSequence.Length; } + public void ReplaceAnim(string sequenceName) + { + CurrentSequence = SequenceProvider.GetSequence(name, sequenceName); + } + public void PlayThen( string sequenceName, Action after ) { backwards = false; diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index 8cac5aae68..f0fdc3ece3 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -59,7 +59,7 @@ namespace OpenRa.Game.Traits yield return Pair.New(anim.Image, 24f * (float2)self.Location); } - void INotifyDamage.Damaged(Actor self, DamageState state) + public virtual void Damaged(Actor self, DamageState state) { switch( state ) { diff --git a/OpenRa.Game/Traits/RenderBuildingTurreted.cs b/OpenRa.Game/Traits/RenderBuildingTurreted.cs index ca2bcfe259..e5fb905343 100644 --- a/OpenRa.Game/Traits/RenderBuildingTurreted.cs +++ b/OpenRa.Game/Traits/RenderBuildingTurreted.cs @@ -5,7 +5,7 @@ using System.Text; namespace OpenRa.Game.Traits { - class RenderBuildingTurreted : RenderBuilding, INotifyDamage + class RenderBuildingTurreted : RenderBuilding { public RenderBuildingTurreted(Actor self) : base(self) @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits () => self.traits.Get().turretFacing / 8); } - void INotifyDamage.Damaged(Actor self, DamageState ds) + public override void Damaged(Actor self, DamageState ds) { switch (ds) { diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index 2d1acb1ad0..e9cbf21fe0 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -13,6 +13,7 @@ namespace OpenRa.Game.Traits bool doneBuilding; bool isOpen; public readonly Actor self; + string prefix = ""; public RenderWarFactory(Actor self) : base(self) @@ -24,7 +25,7 @@ namespace OpenRa.Game.Traits { doneBuilding = true; anim.Play("idle"); - roof.Play("idle-top"); + roof.Play(prefix + "idle-top"); }); } @@ -46,15 +47,30 @@ namespace OpenRa.Game.Traits new float2(b.Right, b.Bottom)).Any(a => a.traits.Contains())) { isOpen = false; - roof.PlayBackwardsThen("build-top", () => roof.Play("idle-top")); + roof.PlayBackwardsThen(prefix + "build-top", () => roof.Play(prefix + "idle-top")); } } public void EjectUnit() { - /* todo: hold the door open */ + roof.PlayThen(prefix + "build-top", () => isOpen = true); + } - roof.PlayThen("build-top", () => isOpen = true); + public override void Damaged(Actor self, DamageState ds) + { + base.Damaged(self, ds); + + switch (ds) + { + case DamageState.Normal: + prefix = ""; + roof.ReplaceAnim(roof.CurrentSequence.Name.Replace("damaged-","")); + break; + case DamageState.Half: + prefix = "damaged-"; + roof.ReplaceAnim("damaged-" + roof.CurrentSequence.Name); + break; + } } } } diff --git a/sequences.xml b/sequences.xml index dd5bc85b49..9c1a83451e 100644 --- a/sequences.xml +++ b/sequences.xml @@ -107,9 +107,9 @@ - + - +