diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 67cd3ba7f6..3aee607451 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -120,6 +120,7 @@ namespace OpenRa public bool IsDead { get { return Health <= 0; } } public bool IsInWorld { get; set; } + public bool RemoveOnDeath = true; public DamageState GetDamageState() { @@ -145,7 +146,8 @@ namespace OpenRa if (attacker.Owner != null) attacker.Owner.Kills++; - Game.world.AddFrameEndTask(w => w.Remove(this)); + if (RemoveOnDeath) + Game.world.AddFrameEndTask(w => w.Remove(this)); } var maxHP = this.GetMaxHP(); diff --git a/OpenRa.Game/Traits/Bridge.cs b/OpenRa.Game/Traits/Bridge.cs index 43b5b5635a..cda11d1923 100644 --- a/OpenRa.Game/Traits/Bridge.cs +++ b/OpenRa.Game/Traits/Bridge.cs @@ -4,36 +4,37 @@ using System.Linq; using System.Text; using OpenRa.Graphics; using OpenRa.FileFormats; +using IjwFramework.Collections; +using System.Drawing; namespace OpenRa.Traits { class BridgeInfo : ITraitInfo { - public object Create(Actor self) { return new Bridge(); } + public object Create(Actor self) { return new Bridge(self); } } class Bridge : IRender, ITick, ICustomTerrain { - Animation anim; Dictionary Tiles; TileTemplate Template; + Dictionary TileSprites; + + public Bridge(Actor self) { self.RemoveOnDeath = false; } + + static Cache Sprites = + new Cache( + x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x), + new Size(Game.CellSize, Game.CellSize))); public IEnumerable Render(Actor self) { - if (anim != null) - return new[] { Util.Centered(self, anim.Image, self.CenterLocation) }; - else - return new Renderable[] { }; + if (Template == null) yield break; + foreach (var t in TileSprites) + yield return new Renderable(t.Value, Game.CellSize * t.Key, PaletteType.Gold); } - public void Tick(Actor self) - { - if (anim == null) - { - anim = new Animation("3tnk"); - anim.PlayRepeating("idle"); - } - } + public void Tick(Actor self) {} public void SetTiles(TileTemplate template, Dictionary replacedTiles) { @@ -42,12 +43,15 @@ namespace OpenRa.Traits foreach (var t in replacedTiles.Keys) Game.world.customTerrain[t.X, t.Y] = this; + + TileSprites = replacedTiles.ToDictionary( + a => a.Key, + a => Sprites[new TileReference { tile = (ushort)template.Index, image = (byte)a.Value }]); } public double GetCost(int2 p, UnitMovementType umt) { var origTile = Tiles[p]; // if this explodes, then SetTiles did something horribly wrong. - return 1.0; } }