Make RenderUnit require IFacing; RenderSimple can be used for crates, mines, etc; fix husk facing init

This commit is contained in:
Chris Forbes
2011-07-28 21:20:31 +12:00
parent 7044d81a40
commit ddc1311d87
11 changed files with 36 additions and 21 deletions

View File

@@ -92,7 +92,7 @@ namespace OpenRA
while (t.Count != 0)
{
var prereqs = PrerequisitesOf(t[index]);
var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || x.GetType().IsSubclassOf(n)));
var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || n.IsAssignableFrom(x.GetType())));
if (!unsatisfied.Any())
{
ret.Add(t[index]);

View File

@@ -14,13 +14,14 @@ using OpenRA.Graphics;
namespace OpenRA.Traits
{
public abstract class RenderSimpleInfo : ITraitInfo
public class RenderSimpleInfo : ITraitInfo
{
public readonly string Image = null;
public readonly string Palette = null;
public readonly string PlayerPalette = "player";
public readonly float Scale = 1f;
public abstract object Create(ActorInitializer init);
public virtual object Create(ActorInitializer init) { return new RenderSimple(init.self); }
public virtual IEnumerable<Renderable> RenderPreview(ActorInfo building, Player owner)
{
@@ -30,7 +31,7 @@ namespace OpenRA.Traits
}
}
public abstract class RenderSimple : IRender, ITick
public class RenderSimple : IRender, ITick
{
public Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
@@ -70,6 +71,11 @@ namespace OpenRA.Traits
Info = self.Info.Traits.Get<RenderSimpleInfo>();
}
public RenderSimple(Actor self) : this( self, MakeFacingFunc(self) )
{
anim.PlayRepeating("idle");
}
public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.InternalName; }
public virtual IEnumerable<Renderable> Render(Actor self)

View File

@@ -132,12 +132,14 @@ namespace OpenRA.Traits
public interface IMove : ITeleportable { int Altitude { get; set; } }
public interface IFacing
{
int ROT { get; }
int Facing { get; set; }
int InitialFacing { get; }
}
public interface IFacing
{
int ROT { get; }
int Facing { get; set; }
int InitialFacing { get; }
}
public interface IFacingInfo {} /* tag interface for infoclasses whose corresponding trait has IFacing */
public interface ICrushable
{
@@ -181,7 +183,7 @@ namespace OpenRA.Traits
public class TraitInfo<T> : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } }
public interface Requires<T> where T : ITraitInfo { }
public interface Requires<T> where T : class { }
public interface INotifySelection { void SelectionChanged(); }
public interface IWorldLoaded { void WorldLoaded(World w); }

View File

@@ -10,6 +10,7 @@
using OpenRA.FileFormats;
using OpenRA.Graphics;
namespace OpenRA.Traits
{
public class PlayerColorPaletteInfo : ITraitInfo
@@ -25,6 +26,7 @@ namespace OpenRA.Traits
{
readonly Player owner;
readonly PlayerColorPaletteInfo info;
public PlayerColorPalette( Player owner, PlayerColorPaletteInfo info )
{
this.owner = owner;