Allow usage of different palette for WithSpriteTurret
This commit is contained in:
@@ -25,6 +25,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
[Desc("Sequence name to use")]
|
[Desc("Sequence name to use")]
|
||||||
[SequenceReference] public readonly string Sequence = "turret";
|
[SequenceReference] public readonly string Sequence = "turret";
|
||||||
|
|
||||||
|
[Desc("Custom palette name")]
|
||||||
|
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
|
||||||
|
|
||||||
|
[Desc("Palette is a player palette BaseName")]
|
||||||
|
public readonly bool IsPlayerPalette = false;
|
||||||
|
|
||||||
[Desc("Turreted 'Turret' key to display")]
|
[Desc("Turreted 'Turret' key to display")]
|
||||||
public readonly string Turret = "primary";
|
public readonly string Turret = "primary";
|
||||||
|
|
||||||
@@ -55,6 +61,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
return -(tmpOffset.Y + tmpOffset.Z) + 1;
|
return -(tmpOffset.Y + tmpOffset.Z) + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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, offset, zOffset, p, rs.Scale);
|
yield return new SpriteActorPreview(anim, offset, zOffset, p, rs.Scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
rs.Add(new AnimationWithOffset(DefaultAnimation,
|
rs.Add(new AnimationWithOffset(DefaultAnimation,
|
||||||
() => TurretOffset(self),
|
() => TurretOffset(self),
|
||||||
() => IsTraitDisabled || !buildComplete,
|
() => IsTraitDisabled || !buildComplete,
|
||||||
p => RenderUtils.ZOffsetFromCenter(self, p, 1)));
|
p => RenderUtils.ZOffsetFromCenter(self, p, 1)), info.Palette, info.IsPlayerPalette);
|
||||||
|
|
||||||
// Restrict turret facings to match the sprite
|
// Restrict turret facings to match the sprite
|
||||||
t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||||
|
|||||||
Reference in New Issue
Block a user