From 3050cff67cc93a213aa502ee75c177cb3f861c17 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 9 Dec 2013 22:09:10 +1300 Subject: [PATCH] Support concrete bibs in D2K. --- OpenRA.Mods.RA/Buildings/Bib.cs | 19 +++- mods/d2k/sequences/structures.yaml | 148 +++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.RA/Buildings/Bib.cs b/OpenRA.Mods.RA/Buildings/Bib.cs index 6f7dd14d70..87d0364135 100755 --- a/OpenRA.Mods.RA/Buildings/Bib.cs +++ b/OpenRA.Mods.RA/Buildings/Bib.cs @@ -23,31 +23,40 @@ namespace OpenRA.Mods.RA.Buildings public object Create(ActorInitializer init) { return new Bib(init.self, this); } } - public class Bib : IRender + public class Bib : IRender, INotifyAddedToWorld { readonly BibInfo info; - readonly List tiles; + List tiles; public Bib(Actor self, BibInfo info) { this.info = info; + } + public void AddedToWorld(Actor self) + { var rs = self.Trait(); var building = self.Info.Traits.Get(); var width = building.Dimensions.X; var bibOffset = building.Dimensions.Y - 1; var centerOffset = FootprintUtils.CenterOffset(building); - + var location = self.Location; tiles = new List(); for (var i = 0; i < 2*width; i++) { var index = i; var anim = new Animation(rs.GetImage(self)); - anim.PlayFetchIndex(info.Sequence, () => index); + var cellOffset = new CVec(i % width, i / width + bibOffset); + + // Some mods may define terrain-specific bibs + var terrain = self.World.GetTerrainType(location + cellOffset); + var testSequence = info.Sequence + "-" + terrain; + var sequence = anim.HasSequence(testSequence) ? testSequence : info.Sequence; + anim.PlayFetchIndex(sequence, () => index); anim.IsDecoration = true; // Z-order is one set to the top of the footprint - var offset = new CVec(i % width, i / width + bibOffset).ToWVec() - centerOffset; + var offset = cellOffset.ToWVec() - centerOffset; tiles.Add(new AnimationWithOffset(anim, () => offset, null, -(offset.Y + centerOffset.Y + 512))); } } diff --git a/mods/d2k/sequences/structures.yaml b/mods/d2k/sequences/structures.yaml index 61995dceb0..5718e1fa0e 100644 --- a/mods/d2k/sequences/structures.yaml +++ b/mods/d2k/sequences/structures.yaml @@ -254,6 +254,10 @@ conyarda: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4046 Offset: -30,-24 @@ -388,6 +392,10 @@ starporta: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4092 Offset: -30,-24 @@ -422,6 +430,10 @@ pwra: Frames: 617, 618, 637, 638 Length: 4 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 649, 650, 669, 670 + Length: 4 + Offset: -16,-16 icon: DATA Start: 4056 Offset: -30,-24 @@ -446,6 +458,10 @@ barra: Frames: 617, 618, 637, 638 Length: 4 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 649, 650, 669, 670 + Length: 4 + Offset: -16,-16 icon: DATA Start: 4059 Offset: -30,-24 @@ -474,6 +490,10 @@ radara: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4072 Offset: -30,-24 @@ -505,6 +525,10 @@ refa: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4066 Offset: -30,-24 @@ -557,6 +581,10 @@ hightecha: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4078 Offset: -30,-24 @@ -586,6 +614,10 @@ researcha: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4099 Offset: -30,-24 @@ -615,6 +647,10 @@ researchh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4100 Offset: -30,-24 @@ -644,6 +680,10 @@ researcho: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4101 Offset: -30,-24 @@ -668,6 +708,10 @@ palacea: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4102 Offset: -30,-24 @@ -713,6 +757,10 @@ lighta: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4081 Offset: -30,-24 @@ -758,6 +806,10 @@ heavya: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4087 Offset: -30,-24 @@ -790,6 +842,10 @@ conyardh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4047 Offset: -30,-24 @@ -825,6 +881,10 @@ starporth: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4093 Offset: -30,-24 @@ -859,6 +919,10 @@ pwrh: Frames: 617, 618, 637, 638 Length: 4 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 649, 650, 669, 670 + Length: 4 + Offset: -16,-16 icon: DATA Start: 4057 Offset: -30,-24 @@ -883,6 +947,10 @@ barrh: Frames: 617, 618, 637, 638 Length: 4 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 649, 650, 669, 670 + Length: 4 + Offset: -16,-16 icon: DATA Start: 4060 Offset: -30,-24 @@ -911,6 +979,10 @@ radarh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4073 Offset: -30,-24 @@ -942,6 +1014,10 @@ refh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4067 Offset: -30,-24 @@ -994,6 +1070,10 @@ hightechh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4079 Offset: -30,-24 @@ -1026,6 +1106,10 @@ palaceh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4103 Offset: -30,-24 @@ -1071,6 +1155,10 @@ lighth: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4082 Offset: -30,-24 @@ -1116,6 +1204,10 @@ heavyh: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4088 Offset: -30,-24 @@ -1148,6 +1240,10 @@ conyardo: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4048 Offset: -30,-24 @@ -1183,6 +1279,10 @@ starporto: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4094 Offset: -30,-24 @@ -1218,6 +1318,10 @@ pwro: Frames: 617, 618, 637, 638 Length: 4 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 649, 650, 669, 670 + Length: 4 + Offset: -16,-16 icon: DATA Start: 4058 Offset: -30,-24 @@ -1242,6 +1346,10 @@ barro: Frames: 617, 618, 637, 638 Length: 4 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 649, 650, 669, 670 + Length: 4 + Offset: -16,-16 icon: DATA Start: 4061 Offset: -30,-24 @@ -1270,6 +1378,10 @@ radaro: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4074 Offset: -30,-24 @@ -1301,6 +1413,10 @@ refo: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4068 Offset: -30,-24 @@ -1353,6 +1469,10 @@ hightecho: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4080 Offset: -30,-24 @@ -1377,6 +1497,10 @@ palaceo: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4104 Offset: -30,-24 @@ -1422,6 +1546,10 @@ lighto: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4083 Offset: -30,-24 @@ -1467,6 +1595,10 @@ heavyo: Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4089 Offset: -30,-24 @@ -1482,6 +1614,10 @@ palacec: # TODO: unused Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: palacecicon Start: 0 make: DATA @@ -1525,6 +1661,10 @@ starportc: # TODO: unused Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA # TODO: blank Start: 4020 Offset: -30,-24 @@ -1570,6 +1710,10 @@ heavyc: # TODO: unused Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA # TODO: blank Start: 4020 Offset: -30,-24 @@ -1602,6 +1746,10 @@ conyardc: # TODO: unused Frames: 611, 612, 613, 631, 632, 633 Length: 6 Offset: -16,-16 + bib-Concrete: BLOXBASE + Frames: 643, 644, 645, 663, 664, 665 + Length: 6 + Offset: -16,-16 icon: DATA Start: 4049 Offset: -30,-24