diff --git a/OpenRA.Mods.Common/Traits/ProximityCapturable.cs b/OpenRA.Mods.Common/Traits/ProximityCapturable.cs index 74ff2d87af..c75c752719 100644 --- a/OpenRA.Mods.Common/Traits/ProximityCapturable.cs +++ b/OpenRA.Mods.Common/Traits/ProximityCapturable.cs @@ -9,6 +9,10 @@ */ #endregion +using OpenRA.Graphics; +using OpenRA.Mods.Common.Graphics; +using OpenRA.Primitives; + namespace OpenRA.Mods.Common.Traits { [Desc("Actor can be captured by units within a certain range.")] @@ -44,5 +48,10 @@ namespace OpenRA.Mods.Common.Traits { self.World.ActorMap.UpdateProximityTrigger(trigger, self.CenterPosition, Info.Range, WDist.Zero); } + + protected override IRenderable GetRenderable(Actor self, WorldRenderer wr) + { + return new RangeCircleAnnotationRenderable(self.CenterPosition, Info.Range, 0, self.Owner.Color, 1, Color.Black, 3); + } } } diff --git a/OpenRA.Mods.Common/Traits/ProximityCapturableBase.cs b/OpenRA.Mods.Common/Traits/ProximityCapturableBase.cs index ebbb19dc5d..7e0eb7605d 100644 --- a/OpenRA.Mods.Common/Traits/ProximityCapturableBase.cs +++ b/OpenRA.Mods.Common/Traits/ProximityCapturableBase.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Mods.Common.Effects; using OpenRA.Primitives; using OpenRA.Traits; @@ -33,6 +34,9 @@ namespace OpenRA.Mods.Common.Traits "This option implies the `" + nameof(Sticky) + "` behaviour as well.")] public readonly bool Permanent = false; + [Desc("If set, will draw a border in the owner's color around the capturable area.")] + public readonly bool DrawDecoration = true; + public void RulesetLoaded(Ruleset rules, ActorInfo info) { var pci = rules.Actors[SystemActors.Player].TraitInfoOrDefault(); @@ -43,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits public abstract override object Create(ActorInitializer init); } - public abstract class ProximityCapturableBase : ITick, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged + public abstract class ProximityCapturableBase : ITick, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged, IRenderAnnotations { public readonly Player OriginalOwner; public bool Captured => Self.Owner != OriginalOwner; @@ -66,6 +70,7 @@ namespace OpenRA.Mods.Common.Traits protected abstract int CreateTrigger(Actor self); protected abstract void RemoveTrigger(Actor self, int trigger); protected abstract void TickInner(Actor self); + protected abstract IRenderable GetRenderable(Actor self, WorldRenderer wr); void INotifyAddedToWorld.AddedToWorld(Actor self) { @@ -192,5 +197,15 @@ namespace OpenRA.Mods.Common.Traits { Game.RunAfterTick(() => skipTriggerUpdate = false); } + + IEnumerable IRenderAnnotations.RenderAnnotations(Actor self, WorldRenderer wr) + { + if (!self.IsInWorld || !Info.DrawDecoration) + return Enumerable.Empty(); + + return new[] { GetRenderable(self, wr) }; + } + + bool IRenderAnnotations.SpatiallyPartitionable { get { return false; } } } } diff --git a/OpenRA.Mods.Common/Traits/RegionProximityCapturable.cs b/OpenRA.Mods.Common/Traits/RegionProximityCapturable.cs index 98b9bdc03c..c7b4841b5d 100644 --- a/OpenRA.Mods.Common/Traits/RegionProximityCapturable.cs +++ b/OpenRA.Mods.Common/Traits/RegionProximityCapturable.cs @@ -12,6 +12,9 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; +using OpenRA.Mods.Common.Graphics; +using OpenRA.Primitives; namespace OpenRA.Mods.Common.Traits { @@ -53,6 +56,11 @@ namespace OpenRA.Mods.Common.Traits } protected override void TickInner(Actor self) { } + + protected override IRenderable GetRenderable(Actor self, WorldRenderer wr) + { + return new BorderedRegionRenderable(region, self.Owner.Color, 1, Color.Black, 3); + } } public class RegionInit : ValueActorInit