diff --git a/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs b/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs index b3121a99b0..91660fb215 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderDetectionCircle.cs @@ -19,14 +19,35 @@ namespace OpenRA.Mods.Common.Traits { class RenderDetectionCircleInfo : ITraitInfo, Requires { - public object Create(ActorInitializer init) { return new RenderDetectionCircle(init.Self); } + [Desc("Draw a rotating radar scanner update line, disabled by default.")] + public readonly bool DrawUpdateLine = false; + + [Desc("WAngle the Radar update line advances per tick.")] + public readonly WAngle UpdateLineTick = new WAngle(-1); + + [Desc("Number of trailing Radar update lines, will only draw one line if zero.")] + public readonly int LineTrailLength = 3; + + [Desc("Color of the circle and scanner update line.")] + public readonly Color Color = Color.FromArgb(128, Color.LimeGreen); + + [Desc("Contrast color of the circle and scanner update line.")] + public readonly Color ContrastColor = Color.FromArgb(96, Color.Black); + + public object Create(ActorInitializer init) { return new RenderDetectionCircle(init.Self, this); } } - class RenderDetectionCircle : IPostRenderSelection + class RenderDetectionCircle : ITick, IPostRenderSelection { + readonly RenderDetectionCircleInfo info; readonly Actor self; + WAngle lineAngle; - public RenderDetectionCircle(Actor self) { this.self = self; } + public RenderDetectionCircle(Actor self, RenderDetectionCircleInfo info) + { + this.info = info; + this.self = self; + } public IEnumerable RenderAfterWorld(WorldRenderer wr) { @@ -45,8 +66,35 @@ namespace OpenRA.Mods.Common.Traits self.CenterPosition, range, 0, - Color.FromArgb(128, Color.LimeGreen), - Color.FromArgb(96, Color.Black)); + info.Color, + info.ContrastColor); + + if (info.DrawUpdateLine) + { + for (var i = info.LineTrailLength; i >= 0; i--) + { + var angle = lineAngle - new WAngle(i * (info.UpdateLineTick.Angle <= 512 ? 1 : -1)); + var length = range.Length * new WVec(angle.Cos(), angle.Sin(), 0) / 1024; + var alpha = info.Color.A - (info.LineTrailLength > 0 ? i * info.Color.A / info.LineTrailLength : 0); + yield return new BeamRenderable( + self.CenterPosition, + 0, + length, + 3, + Color.FromArgb(alpha, info.ContrastColor)); + yield return new BeamRenderable( + self.CenterPosition, + 0, + length, + 1, + Color.FromArgb(alpha, info.Color)); + } + } + } + + public void Tick(Actor self) + { + lineAngle += info.UpdateLineTick; } } } diff --git a/mods/ts/rules/shared-vehicles.yaml b/mods/ts/rules/shared-vehicles.yaml index 2228e80280..b779ea67bd 100644 --- a/mods/ts/rules/shared-vehicles.yaml +++ b/mods/ts/rules/shared-vehicles.yaml @@ -148,4 +148,5 @@ LPST: UpgradeMinEnabledLevel: 1 Range: 18c0 RenderDetectionCircle: + DrawUpdateLine: true