Adjust GetImage plumbing in preparation for race-specific sequences.

This commit is contained in:
Paul Chote
2014-07-09 18:44:25 +12:00
committed by Paul Chote
parent 4c3a95ebc0
commit 00a2146299
18 changed files with 62 additions and 48 deletions

View File

@@ -102,4 +102,14 @@ namespace OpenRA
return world.Players.First(x => x.InternalName == PlayerName);
}
}
// Allows maps / transformations to specify the race variant of an actor.
public class RaceInit : IActorInit<string>
{
[FieldFromYamlKey] public readonly string Race;
public RaceInit() { }
public RaceInit(string race) { Race = race; }
public string Value(World world) { return Race; }
}
}

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Traits
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
}
public object Create(ActorInitializer init) { return new BodyOrientation(init.Self, this); }
public object Create(ActorInitializer init) { return new BodyOrientation(init, this); }
}
public class BodyOrientation : IBodyOrientation
@@ -50,9 +50,11 @@ namespace OpenRA.Traits
[Sync] public int QuantizedFacings { get { return quantizedFacings.Value; } }
public BodyOrientation(Actor self, BodyOrientationInfo info)
public BodyOrientation(ActorInitializer init, BodyOrientationInfo info)
{
this.info = info;
var self = init.Self;
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
quantizedFacings = Exts.Lazy(() =>
{
@@ -64,7 +66,7 @@ namespace OpenRA.Traits
if (qboi == null)
throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation.");
return qboi.QuantizedBodyFacings(self.World.Map.SequenceProvider, self.Info);
return qboi.QuantizedBodyFacings(self.Info, self.World.Map.SequenceProvider, race);
});
}

View File

@@ -289,7 +289,7 @@ namespace OpenRA.Traits
WRot QuantizeOrientation(WRot orientation, int facings);
}
public interface IQuantizeBodyOrientationInfo { int QuantizedBodyFacings(SequenceProvider sequenceProvider, ActorInfo ai); }
public interface IQuantizeBodyOrientationInfo { int QuantizedBodyFacings(ActorInfo ai, SequenceProvider sequenceProvider, string race); }
public interface ITargetableInfo
{
@@ -334,6 +334,6 @@ namespace OpenRA.Traits
public interface ILegacyEditorRenderInfo
{
string EditorPalette { get; }
string EditorImage(ActorInfo actor);
string EditorImage(ActorInfo actor, SequenceProvider sequenceProvider, string race);
}
}