From 6d55161043f0386c0bca070e9403474a9f256d5b Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 30 May 2021 20:54:33 +0200 Subject: [PATCH] Show disabled HitShapes in gray Instead of disabling their debug overlay entirely. --- OpenRA.Mods.Common/HitShapes/Capsule.cs | 23 +++++++++++-------- OpenRA.Mods.Common/HitShapes/Circle.cs | 8 ++++--- OpenRA.Mods.Common/HitShapes/IHitShape.cs | 3 ++- OpenRA.Mods.Common/HitShapes/Polygon.cs | 11 +++++---- OpenRA.Mods.Common/HitShapes/Rectangle.cs | 15 +++++++----- .../Traits/CombatDebugOverlay.cs | 3 +-- OpenRA.Mods.Common/Traits/HitShape.cs | 2 +- 7 files changed, 38 insertions(+), 27 deletions(-) diff --git a/OpenRA.Mods.Common/HitShapes/Capsule.cs b/OpenRA.Mods.Common/HitShapes/Capsule.cs index 5925908ca5..683812e21e 100644 --- a/OpenRA.Mods.Common/HitShapes/Capsule.cs +++ b/OpenRA.Mods.Common/HitShapes/Capsule.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Mods.Common.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; namespace OpenRA.Mods.Common.HitShapes @@ -92,7 +93,7 @@ namespace OpenRA.Mods.Common.HitShapes return DistanceFromEdge((pos - new WPos(origin.X, origin.Y, pos.Z)).Rotate(-orientation)); } - IEnumerable IHitShape.RenderDebugOverlay(WorldRenderer wr, WPos origin, WRot orientation) + IEnumerable IHitShape.RenderDebugOverlay(HitShape hs, WorldRenderer wr, WPos origin, WRot orientation) { var a = origin + new WVec(PointA.X, PointA.Y, VerticalTopOffset).Rotate(orientation); var b = origin + new WVec(PointB.X, PointB.Y, VerticalTopOffset).Rotate(orientation); @@ -104,15 +105,17 @@ namespace OpenRA.Mods.Common.HitShapes var offset2 = new WVec(aa.Y - bb.Y, bb.X - aa.X, 0); offset2 = offset2 * Radius.Length / offset2.Length; - yield return new CircleAnnotationRenderable(a, Radius, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(b, Radius, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(aa, Radius, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(bb, Radius, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(origin, OuterRadius, 1, Color.LimeGreen); - yield return new LineAnnotationRenderable(a - offset1, b - offset1, 1, Color.Yellow); - yield return new LineAnnotationRenderable(a + offset1, b + offset1, 1, Color.Yellow); - yield return new LineAnnotationRenderable(aa - offset2, bb - offset2, 1, Color.Yellow); - yield return new LineAnnotationRenderable(aa + offset2, bb + offset2, 1, Color.Yellow); + var shapeColor = hs.IsTraitDisabled ? Color.LightGray : Color.Yellow; + + yield return new CircleAnnotationRenderable(a, Radius, 1, shapeColor); + yield return new CircleAnnotationRenderable(b, Radius, 1, shapeColor); + yield return new CircleAnnotationRenderable(aa, Radius, 1, shapeColor); + yield return new CircleAnnotationRenderable(bb, Radius, 1, shapeColor); + yield return new CircleAnnotationRenderable(origin, OuterRadius, 1, hs.IsTraitDisabled ? Color.Gray : Color.LimeGreen); + yield return new LineAnnotationRenderable(a - offset1, b - offset1, 1, shapeColor); + yield return new LineAnnotationRenderable(a + offset1, b + offset1, 1, shapeColor); + yield return new LineAnnotationRenderable(aa - offset2, bb - offset2, 1, shapeColor); + yield return new LineAnnotationRenderable(aa + offset2, bb + offset2, 1, shapeColor); } } } diff --git a/OpenRA.Mods.Common/HitShapes/Circle.cs b/OpenRA.Mods.Common/HitShapes/Circle.cs index 3b8bfa4b1d..94130535c1 100644 --- a/OpenRA.Mods.Common/HitShapes/Circle.cs +++ b/OpenRA.Mods.Common/HitShapes/Circle.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Mods.Common.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; namespace OpenRA.Mods.Common.HitShapes @@ -56,10 +57,11 @@ namespace OpenRA.Mods.Common.HitShapes return DistanceFromEdge(pos - new WPos(origin.X, origin.Y, pos.Z)); } - IEnumerable IHitShape.RenderDebugOverlay(WorldRenderer wr, WPos origin, WRot orientation) + IEnumerable IHitShape.RenderDebugOverlay(HitShape hs, WorldRenderer wr, WPos origin, WRot orientation) { - yield return new CircleAnnotationRenderable(origin + new WVec(0, 0, VerticalTopOffset), Radius, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(origin + new WVec(0, 0, VerticalBottomOffset), Radius, 1, Color.Yellow); + var shapeColor = hs.IsTraitDisabled ? Color.LightGray : Color.Yellow; + yield return new CircleAnnotationRenderable(origin + new WVec(0, 0, VerticalTopOffset), Radius, 1, shapeColor); + yield return new CircleAnnotationRenderable(origin + new WVec(0, 0, VerticalBottomOffset), Radius, 1, shapeColor); } } } diff --git a/OpenRA.Mods.Common/HitShapes/IHitShape.cs b/OpenRA.Mods.Common/HitShapes/IHitShape.cs index 13b3cd8739..11e83e2a69 100644 --- a/OpenRA.Mods.Common/HitShapes/IHitShape.cs +++ b/OpenRA.Mods.Common/HitShapes/IHitShape.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using OpenRA.Graphics; +using OpenRA.Mods.Common.Traits; namespace OpenRA.Mods.Common.HitShapes { @@ -22,6 +23,6 @@ namespace OpenRA.Mods.Common.HitShapes WDist DistanceFromEdge(WPos pos, WPos origin, WRot orientation); void Initialize(); - IEnumerable RenderDebugOverlay(WorldRenderer wr, WPos origin, WRot orientation); + IEnumerable RenderDebugOverlay(HitShape hs, WorldRenderer wr, WPos origin, WRot orientation); } } diff --git a/OpenRA.Mods.Common/HitShapes/Polygon.cs b/OpenRA.Mods.Common/HitShapes/Polygon.cs index c526916650..57ca8ec75d 100644 --- a/OpenRA.Mods.Common/HitShapes/Polygon.cs +++ b/OpenRA.Mods.Common/HitShapes/Polygon.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.Common.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; namespace OpenRA.Mods.Common.HitShapes @@ -112,15 +113,17 @@ namespace OpenRA.Mods.Common.HitShapes return DistanceFromEdge((pos - new WPos(origin.X, origin.Y, pos.Z)).Rotate(-orientation)); } - IEnumerable IHitShape.RenderDebugOverlay(WorldRenderer wr, WPos actorPos, WRot orientation) + IEnumerable IHitShape.RenderDebugOverlay(HitShape hs, WorldRenderer wr, WPos actorPos, WRot orientation) { orientation += WRot.FromYaw(LocalYaw); var vertsTop = combatOverlayVertsTop.Select(v => actorPos + v.Rotate(orientation)).ToArray(); var vertsBottom = combatOverlayVertsBottom.Select(v => actorPos + v.Rotate(orientation)).ToArray(); - yield return new PolygonAnnotationRenderable(vertsTop, actorPos, 1, Color.Yellow); - yield return new PolygonAnnotationRenderable(vertsBottom, actorPos, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(actorPos, OuterRadius, 1, Color.LimeGreen); + var shapeColor = hs.IsTraitDisabled ? Color.LightGray : Color.Yellow; + + yield return new PolygonAnnotationRenderable(vertsTop, actorPos, 1, shapeColor); + yield return new PolygonAnnotationRenderable(vertsBottom, actorPos, 1, shapeColor); + yield return new CircleAnnotationRenderable(actorPos, OuterRadius, 1, hs.IsTraitDisabled ? Color.Gray : Color.LimeGreen); } } } diff --git a/OpenRA.Mods.Common/HitShapes/Rectangle.cs b/OpenRA.Mods.Common/HitShapes/Rectangle.cs index e151f44d50..f7f5aabef5 100644 --- a/OpenRA.Mods.Common/HitShapes/Rectangle.cs +++ b/OpenRA.Mods.Common/HitShapes/Rectangle.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.Common.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; namespace OpenRA.Mods.Common.HitShapes @@ -125,7 +126,7 @@ namespace OpenRA.Mods.Common.HitShapes return DistanceFromEdge((pos - new WPos(origin.X, origin.Y, pos.Z)).Rotate(-orientation)); } - IEnumerable IHitShape.RenderDebugOverlay(WorldRenderer wr, WPos origin, WRot orientation) + IEnumerable IHitShape.RenderDebugOverlay(HitShape hs, WorldRenderer wr, WPos origin, WRot orientation) { orientation += WRot.FromYaw(LocalYaw); @@ -134,11 +135,13 @@ namespace OpenRA.Mods.Common.HitShapes var side1 = combatOverlayVertsSide1.Select(v => origin + v.Rotate(orientation)).ToArray(); var side2 = combatOverlayVertsSide2.Select(v => origin + v.Rotate(orientation)).ToArray(); - yield return new PolygonAnnotationRenderable(vertsTop, origin, 1, Color.Yellow); - yield return new PolygonAnnotationRenderable(vertsBottom, origin, 1, Color.Yellow); - yield return new PolygonAnnotationRenderable(side1, origin, 1, Color.Yellow); - yield return new PolygonAnnotationRenderable(side2, origin, 1, Color.Yellow); - yield return new CircleAnnotationRenderable(origin, OuterRadius, 1, Color.LimeGreen); + var shapeColor = hs.IsTraitDisabled ? Color.LightGray : Color.Yellow; + + yield return new PolygonAnnotationRenderable(vertsTop, origin, 1, shapeColor); + yield return new PolygonAnnotationRenderable(vertsBottom, origin, 1, shapeColor); + yield return new PolygonAnnotationRenderable(side1, origin, 1, shapeColor); + yield return new PolygonAnnotationRenderable(side2, origin, 1, shapeColor); + yield return new CircleAnnotationRenderable(origin, OuterRadius, 1, hs.IsTraitDisabled ? Color.Gray : Color.LimeGreen); } } } diff --git a/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs b/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs index f1c42ca8e1..fc6a4a5081 100644 --- a/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs +++ b/OpenRA.Mods.Common/Traits/CombatDebugOverlay.cs @@ -69,8 +69,7 @@ namespace OpenRA.Mods.Common.Traits yield return new LineAnnotationRenderable(self.CenterPosition, self.CenterPosition + height, 1, Color.Orange); } - var activeShapes = shapes.Where(Exts.IsTraitEnabled); - foreach (var s in activeShapes) + foreach (var s in shapes) foreach (var r in s.RenderDebugOverlay(self, wr)) yield return r; diff --git a/OpenRA.Mods.Common/Traits/HitShape.cs b/OpenRA.Mods.Common/Traits/HitShape.cs index d65ccfd1da..917010c72c 100644 --- a/OpenRA.Mods.Common/Traits/HitShape.cs +++ b/OpenRA.Mods.Common/Traits/HitShape.cs @@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits { var origin = turret != null ? self.CenterPosition + turret.Position(self) : self.CenterPosition; var orientation = turret != null ? turret.WorldOrientation : self.Orientation; - return Info.Type.RenderDebugOverlay(wr, origin, orientation); + return Info.Type.RenderDebugOverlay(this, wr, origin, orientation); } } }