diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index ec35cb5415..b26b575d78 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -129,7 +129,7 @@ namespace OpenRa.Game } public float2 CenterLocation; - public float2 SelectedSize { get { return Render().FirstOrDefault().First.size; } } + public float2 SelectedSize { get { return Render().LastOrDefault().First.size; } } public IEnumerable> Render() { diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 1b87aaa0ca..25b1813c74 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -43,7 +43,8 @@ namespace OpenRa.Game game = new Game(settings.GetValue("map", "scg11eb.ini"), renderer, new int2(ClientSize)); - SequenceProvider.ForcePrecache(); + SequenceProvider.ForcePrecache(); + Traits.RenderBuilding.Prefetch(); game.world.Add( new Actor( "mcv", new int2( 5, 5 ), game.players[ 3 ]) ); game.world.Add( new Actor( "mcv", new int2( 7, 5 ), game.players[ 2 ] ) ); diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index 4abb5877f4..0b68d31c2a 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -4,19 +4,48 @@ using System.Linq; using System.Text; using IjwFramework.Types; using OpenRa.Game.Graphics; +using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { class RenderBuilding : RenderSimple { + static Sprite[] largeBib; + static Sprite[] smallBib; + + static int2[] largeBibPos = new[] { new int2(0,0), new int2(1,0), new int2(2,0), + new int2(0,1), new int2(1,1), new int2(2,1) }; + + static int2[] smallBibPos = new[] { new int2(0,0), new int2(1,0), + new int2(0,1), new int2(1,1)}; + public RenderBuilding(Actor self) : base(self) { anim.PlayThen("make", () => anim.PlayRepeating("idle")); } + public static void Prefetch() + { + largeBib = SpriteSheetBuilder.LoadAllSprites("bib2.", "tem", "sno", "int"); + smallBib = SpriteSheetBuilder.LoadAllSprites("bib3.", "tem", "sno", "int"); + } + public override IEnumerable> Render(Actor self) { + if (((UnitInfo.BuildingInfo)self.unitInfo).Bib) + { + var fp = Rules.Footprint.GetFootprint(self.unitInfo.Name ); + var bibOffset = new int2(0, fp.Length - 2); + var hasSmallBib = fp.First().Length == 2; + + var bib = hasSmallBib ? smallBib : largeBib; + var bibPos = hasSmallBib ? smallBibPos : largeBibPos; + + for (int i = 0; i < bib.Length; i++) + yield return Pair.New(bib[i], 24f * (float2)(self.Location + bibOffset + bibPos[i])); + } + yield return Pair.New(anim.Image, 24f * (float2)self.Location); } } diff --git a/footprint.txt b/footprint.txt index 69900d848c..77cc734342 100644 --- a/footprint.txt +++ b/footprint.txt @@ -7,8 +7,8 @@ x : ftur sbag brik fenc gun pbox hbox silo gap kenn * _ x : tsla agun xx xx == : powr dome barr tent domf hpad atek -xxx xxx === : fact facf weap weaf apwr stek -xxx xxx xxx : syrf syrd spen spef +xxx xxx === : weap weaf apwr stek +xxx xxx xxx : syrf syrd spen spef fact facf xx : sam mslo _x_ xxx x== === : proc xxx xxx : afld