pushed bibs down into the smudge layer; made Game static
This commit is contained in:
@@ -5,47 +5,43 @@ using System.Text;
|
||||
using IjwFramework.Types;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.FileFormats;
|
||||
using OpenRa.Game;
|
||||
|
||||
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)};
|
||||
const int SmallBibStart = 1;
|
||||
const int LargeBibStart = 5;
|
||||
|
||||
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");
|
||||
// at this point, we already know where we are, so we can safely place the bib in the smudge
|
||||
if (((UnitInfo.BuildingInfo)self.unitInfo).Bib)
|
||||
{
|
||||
var fp = Rules.Footprint.GetFootprint(self.unitInfo.Name);
|
||||
var bibOffset = fp.Length - 2;
|
||||
var hasSmallBib = fp.First().Length == 2;
|
||||
|
||||
if (hasSmallBib)
|
||||
for (int i = 0; i < 4; i++)
|
||||
Game.map.MapTiles[
|
||||
self.Location.X + i % 2 + Game.map.Offset.X,
|
||||
self.Location.Y + i / 2 + Game.map.Offset.Y + bibOffset].smudge = (byte)(i + SmallBibStart);
|
||||
else
|
||||
for (int i = 0; i < 6; i++)
|
||||
Game.map.MapTiles[
|
||||
self.Location.X + i % 3 + Game.map.Offset.X,
|
||||
self.Location.Y + i / 3 + Game.map.Offset.Y + bibOffset].smudge = (byte)(i + LargeBibStart);
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<Pair<Sprite, float2>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user