diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 158acad021..c35073408d 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -106,7 +106,7 @@ namespace OpenRa.Game public bool IsDead { get { return Health <= 0; } } - public void InflictDamage(Actor attacker, int damage) + public void InflictDamage(Actor attacker, int damage, WarheadInfo warhead) { /* todo: auto-retaliate, etc */ /* todo: death sequence for infantry based on inflictor */ @@ -138,7 +138,7 @@ namespace OpenRa.Game } foreach (var ndx in traits.WithInterface()) - ndx.Damaged(this, damage); + ndx.Damaged(this, damage, warhead); } public void QueueActivity( IActivity nextActivity ) diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index b487f2d3f5..4f48f169bd 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -34,7 +34,7 @@ namespace OpenRa.Game var hitActors = Game.FindUnitsInCircle(loc, maxSpread); foreach (var victim in hitActors) - victim.InflictDamage(firedBy, (int)GetDamageToInflict(victim, loc, weapon, warhead)); + victim.InflictDamage(firedBy, (int)GetDamageToInflict(victim, loc, weapon, warhead), warhead); } static float GetMaximumSpread(WeaponInfo weapon, WarheadInfo warhead) diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs new file mode 100644 index 0000000000..31d0427951 --- /dev/null +++ b/OpenRa.Game/Effects/Corpse.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Game.Graphics; + +namespace OpenRa.Game.Effects +{ + class Corpse : IEffect + { + readonly Animation anim; + readonly float2 pos; + readonly Player owner; + + public Corpse(Actor fromActor, int death) + { + anim = new Animation(fromActor.Info.Image ?? fromActor.Info.Name); + anim.PlayThen("die{0}".F(death + 1), + () => Game.world.AddFrameEndTask(w => w.Remove(this))); + + pos = fromActor.CenterLocation; + owner = fromActor.Owner; + } + + public void Tick() { anim.Tick(); } + + public IEnumerable> Render() + { + yield return Tuple.New(anim.Image, pos - .5f * anim.Image.size, owner.Palette); + } + } +} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 1a0a0e3c6f..3ad7116d4a 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -80,6 +80,7 @@ + diff --git a/OpenRa.Game/Traits/RenderInfantry.cs b/OpenRa.Game/Traits/RenderInfantry.cs index f11a27837f..e24f166ab3 100644 --- a/OpenRa.Game/Traits/RenderInfantry.cs +++ b/OpenRa.Game/Traits/RenderInfantry.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using OpenRa.Game.Graphics; +using OpenRa.Game.GameRules; +using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { - class RenderInfantry : RenderSimple, INotifyAttack + class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamageEx { public RenderInfantry(Actor self) : base(self) @@ -57,5 +59,13 @@ namespace OpenRa.Game.Traits { yield return Util.Centered(self, anim.Image, self.CenterLocation); } + + public void Damaged(Actor self, int damage, WarheadInfo warhead) + { + if (self.Health <= 0) + Game.world.AddFrameEndTask(w => w.Add(new Corpse(self, warhead.InfDeath))); + } + + public void Damaged(Actor self, DamageState ds) {} } } diff --git a/OpenRa.Game/Traits/RenderUnit.cs b/OpenRa.Game/Traits/RenderUnit.cs index 260bda3aec..d4bd96505c 100644 --- a/OpenRa.Game/Traits/RenderUnit.cs +++ b/OpenRa.Game/Traits/RenderUnit.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using OpenRa.Game.Graphics; +using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { @@ -37,7 +38,7 @@ namespace OpenRa.Game.Traits public void Damaged(Actor self, DamageState ds) { currentDs = ds; } - public void Damaged(Actor self, int damage) + public void Damaged(Actor self, int damage, WarheadInfo warhead) { if (currentDs != DamageState.Half) return; if (!isSmoking) diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index 13540c39c6..3a9842104b 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits interface ITick { void Tick(Actor self); } interface IRender { IEnumerable> Render(Actor self); } interface INotifyDamage { void Damaged(Actor self, DamageState ds); } - interface INotifyDamageEx : INotifyDamage { void Damaged(Actor self, int damage); } + interface INotifyDamageEx : INotifyDamage { void Damaged(Actor self, int damage, WarheadInfo warhead); } interface INotifyBuildComplete { void BuildingComplete (Actor self); } interface IOrder { diff --git a/SequenceEditor/Surface.cs b/SequenceEditor/Surface.cs index 015f0325f7..d2c63feb6a 100644 --- a/SequenceEditor/Surface.cs +++ b/SequenceEditor/Surface.cs @@ -205,7 +205,9 @@ namespace SequenceEditor e.Graphics.DrawString(toolText, Font, Brushes.Black, toolPoint.Value.X, toolPoint.Value.Y); } - Height = Math.Max( Parent.ClientSize.Height, y ); + var newHeight = Math.Max( Parent.ClientSize.Height, y ); + if (Height != newHeight) + Height = newHeight; } } diff --git a/sequences.xml b/sequences.xml index 4d366ebe4f..35559506ef 100644 --- a/sequences.xml +++ b/sequences.xml @@ -349,6 +349,7 @@ + @@ -415,6 +416,12 @@ + + + + + + @@ -432,6 +439,7 @@ + @@ -637,6 +645,12 @@ + + + + + + @@ -651,6 +665,12 @@ + + + + + + @@ -679,4 +699,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file