add explicit Z to Renderable. eating my hat, etc.

This commit is contained in:
Chris Forbes
2010-09-17 20:05:50 +12:00
parent 99e225c279
commit 83eae029b7
20 changed files with 30 additions and 28 deletions

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Effects
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow");
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
}
}
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Effects
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image,
a.CenterLocation - .5f * anim.Image.size, "chrome");
a.CenterLocation - .5f * anim.Image.size, "chrome", (int)a.CenterLocation.Y);
}
}
}

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Graphics
{
public int Compare(Renderable x, Renderable y)
{
return (x.Pos.Y + x.Sprite.size.Y + x.ZOffset).CompareTo(y.Pos.Y + y.Sprite.size.Y + y.ZOffset);
return (x.Z + x.ZOffset).CompareTo(y.Z + y.ZOffset);
}
}

View File

@@ -138,22 +138,24 @@ namespace OpenRA.Traits
public readonly Sprite Sprite;
public readonly float2 Pos;
public readonly string Palette;
public readonly int Z;
public readonly int ZOffset;
public Renderable(Sprite sprite, float2 pos, string palette, int zOffset)
public Renderable(Sprite sprite, float2 pos, string palette, int z, int zOffset)
{
Sprite = sprite;
Pos = pos;
Palette = palette;
Z = z;
ZOffset = zOffset;
}
public Renderable(Sprite sprite, float2 pos, string palette)
: this(sprite, pos, palette, 0) { }
public Renderable(Sprite sprite, float2 pos, string palette, int z)
: this(sprite, pos, palette, z, 0) { }
public Renderable WithPalette(string newPalette) { return new Renderable(Sprite, Pos, newPalette, ZOffset); }
public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, newOffset); }
public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, ZOffset); }
public Renderable WithPalette(string newPalette) { return new Renderable(Sprite, Pos, newPalette, Z, ZOffset); }
public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, Z, newOffset); }
public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, Z, ZOffset); }
}
public interface ITraitInfo { object Create(ActorInitializer init); }

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Traits
{
var pal = self.Owner == null ? "player0" : self.Owner.Palette;
var loc = location - 0.5f * s.size;
return new Renderable(s, loc.Round(), pal);
return new Renderable(s, loc.Round(), pal, (int)self.CenterLocation.Y);
}
public static IActivity SequenceActivities(params IActivity[] acts)