Add custom palette support to WithInfantryBody.
This commit is contained in:
@@ -38,6 +38,13 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
[SequenceReference]
|
||||
public readonly string[] StandSequences = { "stand" };
|
||||
|
||||
[PaletteReference("IsPlayerPalette")]
|
||||
[Desc("Custom palette name")]
|
||||
public readonly string Palette = null;
|
||||
|
||||
[Desc("Palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new WithInfantryBody(init, this); }
|
||||
|
||||
public IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
@@ -47,6 +54,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
var anim = new Animation(init.World, image, init.GetFacing());
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First()));
|
||||
|
||||
if (IsPlayerPalette)
|
||||
p = init.WorldRenderer.Palette(Palette + init.Get<OwnerInit>().PlayerName);
|
||||
else if (Palette != null)
|
||||
p = init.WorldRenderer.Palette(Palette);
|
||||
|
||||
yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
|
||||
DefaultAnimation = new Animation(init.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self));
|
||||
rs.Add(new AnimationWithOffset(DefaultAnimation, null, () => IsTraitDisabled));
|
||||
rs.Add(new AnimationWithOffset(DefaultAnimation, null, () => IsTraitDisabled), info.Palette, info.IsPlayerPalette);
|
||||
PlayStandAnimation(self);
|
||||
|
||||
move = init.Self.Trait<IMove>();
|
||||
|
||||
Reference in New Issue
Block a user