Rework decoration renderable traits:
- Removed implicit pip definitions and IPips interface. New decoration traits have been added to render them. Pip types are no longer hardcoded in OpenRA.Game. - Decoration rendering is now managed by SelectionDecorations(Base), which allows us to remove assumptions about the selection box geometry from the decoration traits. - RenderNameTag has been replaced by WithNameTagDecoration, which is an otherwise normal decoration trait. - Unify the configuration and reduce duplication between traits. - Removed hardcoded references to specific selection box renderables. - Remove legacy cruft.
This commit is contained in:
@@ -15,6 +15,7 @@ using OpenRA.Activities;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -642,4 +643,40 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
string Class { get; }
|
||||
}
|
||||
|
||||
public interface IDecoration
|
||||
{
|
||||
DecorationPosition Position { get; }
|
||||
bool RequiresSelection { get; }
|
||||
|
||||
bool Enabled { get; }
|
||||
|
||||
IEnumerable<IRenderable> RenderDecoration(Actor self, WorldRenderer wr, int2 pos);
|
||||
}
|
||||
|
||||
public enum DecorationPosition
|
||||
{
|
||||
Center,
|
||||
TopLeft,
|
||||
TopRight,
|
||||
BottomLeft,
|
||||
BottomRight,
|
||||
Top
|
||||
}
|
||||
|
||||
public static class DecorationExtensions
|
||||
{
|
||||
public static int2 CreateMargin(this DecorationPosition pos, int2 margin)
|
||||
{
|
||||
switch (pos)
|
||||
{
|
||||
case DecorationPosition.TopLeft: return margin;
|
||||
case DecorationPosition.TopRight: return new int2(-margin.X, margin.Y);
|
||||
case DecorationPosition.BottomLeft: return new int2(margin.X, -margin.Y);
|
||||
case DecorationPosition.BottomRight: return -margin;
|
||||
case DecorationPosition.Top: return new int2(0, margin.Y);
|
||||
default: return int2.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user