diff --git a/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs b/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs index dd86d3bf25..75ee0f7fbc 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActorLayer.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new EditorActorLayer(init.Self, this); } } - public class EditorActorLayer : IWorldLoaded, ITickRender, IRender, IRadarSignature, ICreatePlayers + public class EditorActorLayer : IWorldLoaded, ITickRender, IRender, IRadarSignature, ICreatePlayers, IRenderAnnotations { readonly EditorActorLayerInfo info; readonly List previews = new List(); @@ -103,6 +103,17 @@ namespace OpenRA.Mods.Common.Traits yield break; } + public IEnumerable RenderAnnotations(Actor self, WorldRenderer wr) + { + if (wr.World.Type != WorldType.Editor) + return NoRenderables; + + return PreviewsInBox(wr.Viewport.TopLeft, wr.Viewport.BottomRight) + .SelectMany(p => p.RenderAnnotations()); + } + + bool IRenderAnnotations.SpatiallyPartitionable { get { return false; } } + public EditorActorPreview Add(ActorReference reference) { return Add(NextActorName(), reference); } public EditorActorPreview Add(string id, ActorReference reference, bool initialSetup = false) diff --git a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs index e2306b5d3c..f92950af6b 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs @@ -112,12 +112,18 @@ namespace OpenRA.Mods.Common.Traits var highlight = worldRenderer.Palette("highlight"); var overlay = items.Where(r => !r.IsDecoration) .Select(r => r.WithPalette(highlight)); - return items.Concat(overlay).Append(SelectionBox); + return items.Concat(overlay); } return items; } + public IEnumerable RenderAnnotations() + { + if (Selected) + yield return SelectionBox; + } + public void ReplaceInit(T init) { var original = Actor.InitDict.GetOrDefault();