Replace DecorationPosition with mod-defined string ids.

This commit is contained in:
Paul Chote
2020-08-14 18:49:47 +01:00
committed by abcdefg30
parent b16cbeacb6
commit 9cd6df2929
9 changed files with 81 additions and 98 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly string GroupSequence = "groups";
[Desc("Position in the actor's selection box to draw the decoration.")]
public readonly DecorationPosition Position = DecorationPosition.TopLeft;
public readonly string Position = "TopLeft";
[Desc("Offset sprite center position from the selection box edge.")]
public readonly int2 Margin = int2.Zero;
@@ -51,13 +51,9 @@ namespace OpenRA.Mods.Common.Traits.Render
anim = new Animation(self.World, Info.Image);
}
DecorationPosition IDecoration.Position { get { return Info.Position; } }
bool IDecoration.Enabled { get { return self.Owner == self.World.LocalPlayer && self.World.Selection.GetControlGroupForActor(self) != null; } }
bool IDecoration.RequiresSelection { get { return true; } }
IEnumerable<IRenderable> IDecoration.RenderDecoration(Actor self, WorldRenderer wr, int2 pos)
IEnumerable<IRenderable> IDecoration.RenderDecoration(Actor self, WorldRenderer wr, ISelectionDecorations container)
{
var group = self.World.Selection.GetControlGroupForActor(self);
if (group == null)
@@ -65,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render
anim.PlayFetchIndex(Info.GroupSequence, () => (int)group);
var screenPos = wr.Viewport.WorldToViewPx(pos) + Info.Position.CreateMargin(Info.Margin) - (0.5f * anim.Image.Size.XY).ToInt2();
var screenPos = container.GetDecorationOrigin(self, wr, Info.Position, Info.Margin) - (0.5f * anim.Image.Size.XY).ToInt2();
var palette = wr.Palette(Info.Palette);
return new IRenderable[]
{