Theater specific artwork done properly

This commit is contained in:
Paul Chote
2010-06-28 12:38:35 +12:00
parent b46cec91a8
commit 915c9460cf
6 changed files with 165 additions and 137 deletions

View File

@@ -27,6 +27,8 @@ namespace OpenRA.Traits
public abstract class RenderSimpleInfo : ITraitInfo
{
public readonly string Image = null;
public readonly string[] OverrideTheater = null;
public readonly string[] OverrideImage = null;
public readonly string Palette = null;
public abstract object Create(ActorInitializer init);
}
@@ -36,9 +38,19 @@ namespace OpenRA.Traits
public Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
public Animation anim { get { return anims[""].Animation; } protected set { anims[""].Animation = value; } }
string cachedImage = null;
public string GetImage(Actor self)
{
return self.Info.Traits.Get<RenderSimpleInfo>().Image ?? self.Info.Name;
if (cachedImage != null)
return cachedImage;
var Info = self.Info.Traits.Get<RenderSimpleInfo>();
if (Info.OverrideTheater != null)
for (int i = 0; i < Info.OverrideTheater.Length; i++)
if (Info.OverrideTheater[i] == self.World.Map.Theater)
return cachedImage = Info.OverrideImage[i];
return cachedImage = Info.Image ?? self.Info.Name;
}
public RenderSimple(Actor self, Func<int> baseFacing)