From 5da2c319c17d4c4f5a38049d089222c5852fcd17 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 14 Oct 2013 20:29:48 +1300 Subject: [PATCH 1/6] Fix inconsistent naming in DebugMuzzlePositions. --- ...bugMuzzlePositions.cs => CombatDebugOverlay.cs} | 8 ++++---- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 2 +- mods/cnc/rules/defaults.yaml | 14 +++++++------- mods/d2k/rules/defaults.yaml | 10 +++++----- mods/ra/rules/defaults.yaml | 12 ++++++------ mods/ts/rules/defaults.yaml | 8 ++++---- 6 files changed, 27 insertions(+), 27 deletions(-) rename OpenRA.Mods.RA/{DebugMuzzlePositions.cs => CombatDebugOverlay.cs} (88%) diff --git a/OpenRA.Mods.RA/DebugMuzzlePositions.cs b/OpenRA.Mods.RA/CombatDebugOverlay.cs similarity index 88% rename from OpenRA.Mods.RA/DebugMuzzlePositions.cs rename to OpenRA.Mods.RA/CombatDebugOverlay.cs index 931561a00b..f0def58dbb 100755 --- a/OpenRA.Mods.RA/DebugMuzzlePositions.cs +++ b/OpenRA.Mods.RA/CombatDebugOverlay.cs @@ -20,17 +20,17 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - public class DebugMuzzlePositionsInfo : ITraitInfo + public class CombatDebugOverlayInfo : ITraitInfo { - public object Create(ActorInitializer init) { return new DebugFiringOffsets(init.self); } + public object Create(ActorInitializer init) { return new CombatDebugOverlay(init.self); } } - public class DebugFiringOffsets : IPostRender + public class CombatDebugOverlay : IPostRender { Lazy> armaments; DeveloperMode devMode; - public DebugFiringOffsets(Actor self) + public CombatDebugOverlay(Actor self) { armaments = Lazy.New(() => self.TraitsImplementing()); diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 14aa9d463b..49598d245e 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -429,7 +429,6 @@ - @@ -471,6 +470,7 @@ + diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 38686db5c4..f253dc3b83 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -29,7 +29,7 @@ ActorLostNotification: AttackMove: WithSmoke: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -75,7 +75,7 @@ Explodes: Weapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -110,7 +110,7 @@ Explodes: Weapon: HeliExplode EmptyWeapon: HeliExplode - DebugMuzzlePositions: + CombatDebugOverlay: BodyOrientation: UpdatesPlayerStatistics: @@ -159,7 +159,7 @@ Probability: 2 CrushableInfantry: WarnProbability: 60 - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -261,7 +261,7 @@ GivesExperience: DrawLineToTarget: ActorLostNotification: - DebugMuzzlePositions: + CombatDebugOverlay: BodyOrientation: ^Ship: @@ -281,7 +281,7 @@ DrawLineToTarget: ActorLostNotification: AttackMove: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -329,7 +329,7 @@ ShakeOnDeath: Sellable: LegacyCapturable: - DebugMuzzlePositions: + CombatDebugOverlay: Guardable: Range: 3 BodyOrientation: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index d59a8f5b35..492fd4f45e 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -29,7 +29,7 @@ GivesBounty: Repairable: RepairBuildings: repaira,repairo,repairh - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: RenderUnit: @@ -67,7 +67,7 @@ GivesBounty: Repairable: RepairBuildings: repaira,repairo,repairh - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: RenderUnit: @@ -162,7 +162,7 @@ RepairableNear: Buildings: barra, barro CloseEnough: 1 - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -185,7 +185,7 @@ ProximityCaptor: Types:Plane GivesBounty: - DebugMuzzlePositions: + CombatDebugOverlay: BodyOrientation: UpdatesPlayerStatistics: @@ -231,7 +231,7 @@ Types:Building Sellable: GivesBounty: - DebugMuzzlePositions: + CombatDebugOverlay: Guardable: Range: 3 BodyOrientation: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index c8eb7e9935..76f90d1f70 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -33,7 +33,7 @@ String:Vehicle WithSmoke: UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -78,7 +78,7 @@ String:Vehicle WithSmoke: UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -132,7 +132,7 @@ CrushableInfantry: CrushSound: squishy2.aud UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -170,7 +170,7 @@ String:Ship WithSmoke: UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -201,7 +201,7 @@ GpsDot: String:Plane UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: BodyOrientation: ^Helicopter: @@ -245,7 +245,7 @@ AcceptsSupplies: GivesBounty: UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guardable: Range: 3 BodyOrientation: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 1bdb1a7818..d4050f8c90 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -33,7 +33,7 @@ AcceptsSupplies: GivesBounty: UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guardable: Range: 3 BodyOrientation: @@ -77,7 +77,7 @@ CrushableInfantry: CrushSound: squish6.aud UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -142,7 +142,7 @@ GivesBounty: # WithSmoke: UpdatesPlayerStatistics: - DebugMuzzlePositions: + CombatDebugOverlay: Guard: Guardable: BodyOrientation: @@ -197,5 +197,5 @@ GivesExperience: DrawLineToTarget: ActorLostNotification: - DebugMuzzlePositions: + CombatDebugOverlay: BodyOrientation: \ No newline at end of file From d2eb42fbd2cafb56e30a6629930e21ae5b0bc7cc Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 14 Oct 2013 20:50:08 +1300 Subject: [PATCH 2/6] Add Health radius to CombatDebugOverlay. Fixes #3862. --- OpenRA.Mods.RA/CombatDebugOverlay.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/CombatDebugOverlay.cs b/OpenRA.Mods.RA/CombatDebugOverlay.cs index f0def58dbb..2d4bf79c06 100755 --- a/OpenRA.Mods.RA/CombatDebugOverlay.cs +++ b/OpenRA.Mods.RA/CombatDebugOverlay.cs @@ -28,11 +28,13 @@ namespace OpenRA.Mods.RA public class CombatDebugOverlay : IPostRender { Lazy> armaments; + Lazy health; DeveloperMode devMode; public CombatDebugOverlay(Actor self) { armaments = Lazy.New(() => self.TraitsImplementing()); + health = Lazy.New(() => self.TraitOrDefault()); var localPlayer = self.World.LocalPlayer; devMode = localPlayer != null ? localPlayer.PlayerActor.Trait() : null; @@ -43,6 +45,9 @@ namespace OpenRA.Mods.RA if (devMode == null || !devMode.ShowMuzzles) return; + if (health.Value != null) + wr.DrawRangeCircle(Color.Red, wr.ScreenPxPosition(self.CenterPosition), health.Value.Info.Radius / Game.CellSize); + var wlr = Game.Renderer.WorldLineRenderer; var c = Color.White; @@ -50,7 +55,7 @@ namespace OpenRA.Mods.RA foreach (var b in a.Barrels) { var muzzle = self.CenterPosition + a.MuzzleOffset(self, b); - var dirOffset = new WVec(0,-224,0).Rotate(a.MuzzleOrientation(self, b)); + var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b)); var sm = wr.ScreenPosition(muzzle); var sd = wr.ScreenPosition(muzzle + dirOffset); From f3c7c0e957d19abfc3da80e98c7f8bfd20722fb3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 14 Oct 2013 21:01:47 +1300 Subject: [PATCH 3/6] Update ingame label to match new behaviour. --- mods/cnc/chrome/cheats.yaml | 2 +- mods/ra/chrome/cheats.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/cnc/chrome/cheats.yaml b/mods/cnc/chrome/cheats.yaml index 665d7985aa..bc6797d874 100644 --- a/mods/cnc/chrome/cheats.yaml +++ b/mods/cnc/chrome/cheats.yaml @@ -98,7 +98,7 @@ Container@CHEATS_PANEL: Y:235 Height:20 Width:200 - Text:Show Muzzle Positions + Text:Show Combat Geometry Checkbox@SHOW_GEOMETRY: X:290 Y:265 diff --git a/mods/ra/chrome/cheats.yaml b/mods/ra/chrome/cheats.yaml index 28382c6d2a..f3a600fc9f 100644 --- a/mods/ra/chrome/cheats.yaml +++ b/mods/ra/chrome/cheats.yaml @@ -86,7 +86,7 @@ Background@CHEATS_PANEL: Y:350 Height:20 Width:200 - Text:Show Muzzle Positions + Text:Show Combat Geometry Checkbox@SHOW_GEOMETRY: X:30 Y:380 From 97a42e7d43110aad80c8a2eaf86ceb9a63d85b63 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 14 Oct 2013 21:14:21 +1300 Subject: [PATCH 4/6] Fix A* debug overlay in D2K. --- OpenRA.Mods.RA/World/DebugOverlay.cs | 5 +++-- mods/d2k/rules/system.yaml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/World/DebugOverlay.cs b/OpenRA.Mods.RA/World/DebugOverlay.cs index e3258f74a7..29d2692edc 100644 --- a/OpenRA.Mods.RA/World/DebugOverlay.cs +++ b/OpenRA.Mods.RA/World/DebugOverlay.cs @@ -72,8 +72,9 @@ namespace OpenRA.Mods.RA layer [i, j] = layer [i, j] * 5 / 6; // TODO: This doesn't make sense for isometric terrain - var tl = wr.ScreenPxPosition(new CPos(i, j).CenterPosition) - new int2(Game.CellSize, Game.CellSize); - qr.FillRect(new RectangleF(tl.X, tl.Y, Game.CellSize, Game.CellSize), Color.FromArgb(w, c)); + var tl = wr.ScreenPxPosition(new CPos(i, j).TopLeft); + var br = wr.ScreenPxPosition(new CPos(i, j).BottomRight); + qr.FillRect(RectangleF.FromLTRB(tl.X, tl.Y, br.X, br.Y), Color.FromArgb(w, c)); } } } diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index f719298a56..40b7f186d5 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -441,6 +441,7 @@ World: Name: Ordos Race: ordos DomainIndex: + DebugOverlay: ResourceLayer: ResourceClaimLayer: ResourceType@Spice: From 68cd537c9b4b32438102204ff124f6fd75e3cbd0 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 14 Oct 2013 21:16:34 +1300 Subject: [PATCH 5/6] Rename DebugOverlay -> PathfinderDebugOverlay. --- OpenRA.Mods.RA/Move/PathFinder.cs | 4 ++-- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 2 +- OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs | 2 +- .../World/{DebugOverlay.cs => PathfinderDebugOverlay.cs} | 7 ++----- mods/cnc/rules/system.yaml | 2 +- mods/d2k/rules/system.yaml | 2 +- mods/ra/rules/system.yaml | 2 +- mods/ts/rules/system.yaml | 2 +- 8 files changed, 10 insertions(+), 13 deletions(-) rename OpenRA.Mods.RA/World/{DebugOverlay.cs => PathfinderDebugOverlay.cs} (93%) diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs index c09e6d8126..5b1abc9f26 100755 --- a/OpenRA.Mods.RA/Move/PathFinder.cs +++ b/OpenRA.Mods.RA/Move/PathFinder.cs @@ -134,7 +134,7 @@ namespace OpenRA.Mods.RA.Move } } - var dbg = world.WorldActor.TraitOrDefault(); + var dbg = world.WorldActor.TraitOrDefault(); if (dbg != null) { dbg.AddLayer(search.considered.Select(p => new Pair(p, search.cellInfo[p.X, p.Y].MinCost)), search.maxCost, search.owner); @@ -199,7 +199,7 @@ namespace OpenRA.Mods.RA.Move } } - var dbg = world.WorldActor.TraitOrDefault(); + var dbg = world.WorldActor.TraitOrDefault(); if (dbg != null) { dbg.AddLayer(fromSrc.considered.Select(p => new Pair(p, fromSrc.cellInfo[p.X, p.Y].MinCost)), fromSrc.maxCost, fromSrc.owner); diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 49598d245e..beb37e3946 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -414,7 +414,6 @@ - @@ -471,6 +470,7 @@ + diff --git a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs index 85ebe8fa68..890f3dc677 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs @@ -107,7 +107,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic noexplorationButton.OnClick = () => world.IssueOrder(new Order("DevResetExploration", world.LocalPlayer.PlayerActor, false)); - var dbgOverlay = world.WorldActor.TraitOrDefault(); + var dbgOverlay = world.WorldActor.TraitOrDefault(); var showAstarCostCheckbox = widget.GetOrNull("SHOW_ASTAR"); if (showAstarCostCheckbox != null) { diff --git a/OpenRA.Mods.RA/World/DebugOverlay.cs b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs similarity index 93% rename from OpenRA.Mods.RA/World/DebugOverlay.cs rename to OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs index 29d2692edc..b5a7249f77 100644 --- a/OpenRA.Mods.RA/World/DebugOverlay.cs +++ b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs @@ -9,11 +9,8 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class DebugOverlayInfo : Traits.TraitInfo - { - } - - class DebugOverlay : IRenderOverlay, IWorldLoaded + class PathfinderDebugOverlayInfo : Traits.TraitInfo { } + class PathfinderDebugOverlay : IRenderOverlay, IWorldLoaded { Dictionary layers; int refreshTick; diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 748199d14b..32013bfabb 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -311,7 +311,7 @@ World: Type:Crater Types:cr1,cr2,cr3,cr4,cr5,cr6 Depths:5,5,5,5,5,5 - DebugOverlay: + PathfinderDebugOverlay: SpawnMapActors: MPStartLocations: CreateMPPlayers: diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index 40b7f186d5..0e0e9a991d 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -441,7 +441,7 @@ World: Name: Ordos Race: ordos DomainIndex: - DebugOverlay: + PathfinderDebugOverlay: ResourceLayer: ResourceClaimLayer: ResourceType@Spice: diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index bb49a56c1b..286ea3d788 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -645,7 +645,7 @@ World: Type:Crater Types:cr1,cr2,cr3,cr4,cr5,cr6 Depths:5,5,5,5,5,5 - DebugOverlay: + PathfinderDebugOverlay: SpawnMapActors: CreateMPPlayers: MPStartUnits@mcvonly: diff --git a/mods/ts/rules/system.yaml b/mods/ts/rules/system.yaml index d0567f83e1..0625b3ce46 100644 --- a/mods/ts/rules/system.yaml +++ b/mods/ts/rules/system.yaml @@ -116,7 +116,7 @@ World: Race: nod ResourceLayer: ResourceClaimLayer: - DebugOverlay: + PathfinderDebugOverlay: SpawnMapActors: CreateMPPlayers: MPStartUnits: From d864989c19e745c0c7a36ce8a730b06321300f8a Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 14 Oct 2013 21:18:50 +1300 Subject: [PATCH 6/6] Tidy PathfinderDebugOverlay. --- .../World/PathfinderDebugOverlay.cs | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs index b5a7249f77..7917c00cea 100644 --- a/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs +++ b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs @@ -1,4 +1,14 @@ -using System; +#region Copyright & License Information +/* + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -19,11 +29,12 @@ namespace OpenRA.Mods.RA public void WorldLoaded(World w, WorldRenderer wr) { - this.world = w; - this.refreshTick = 0; - this.layers = new Dictionary(8); + world = w; + refreshTick = 0; + layers = new Dictionary(8); + // Enabled via Cheats menu - this.Visible = false; + Visible = false; } public void AddLayer(IEnumerable> cellWeights, int maxWeight, Player pl) @@ -38,7 +49,7 @@ namespace OpenRA.Mods.RA } foreach (var p in cellWeights) - layer[p.First.X, p.First.Y] = Math.Min(128, (layer[p.First.X, p.First.Y]) + ((maxWeight - p.Second) * 64 / maxWeight)); + layer[p.First.X, p.First.Y] = Math.Min(128, layer[p.First.X, p.First.Y] + (maxWeight - p.Second) * 64 / maxWeight); } public void Render(WorldRenderer wr) @@ -61,12 +72,12 @@ namespace OpenRA.Mods.RA { for (var i = viewBounds.Left; i <= viewBounds.Right; ++i) { - if (layer [i, j] <= 0) + if (layer[i, j] <= 0) continue; - var w = Math.Max(0, Math.Min(layer [i, j], 128)); + var w = Math.Max(0, Math.Min(layer[i, j], 128)); if (doDim) - layer [i, j] = layer [i, j] * 5 / 6; + layer[i, j] = layer[i, j] * 5 / 6; // TODO: This doesn't make sense for isometric terrain var tl = wr.ScreenPxPosition(new CPos(i, j).TopLeft);