diff --git a/OpenRA.Mods.RA/DebugMuzzlePositions.cs b/OpenRA.Mods.RA/CombatDebugOverlay.cs similarity index 75% rename from OpenRA.Mods.RA/DebugMuzzlePositions.cs rename to OpenRA.Mods.RA/CombatDebugOverlay.cs index 931561a00b..2d4bf79c06 100755 --- a/OpenRA.Mods.RA/DebugMuzzlePositions.cs +++ b/OpenRA.Mods.RA/CombatDebugOverlay.cs @@ -20,19 +20,21 @@ 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; + Lazy health; DeveloperMode devMode; - public DebugFiringOffsets(Actor self) + 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); 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 14aa9d463b..beb37e3946 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -414,7 +414,6 @@ - @@ -429,7 +428,6 @@ - @@ -471,6 +469,8 @@ + + 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 57% rename from OpenRA.Mods.RA/World/DebugOverlay.cs rename to OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs index e3258f74a7..7917c00cea 100644 --- a/OpenRA.Mods.RA/World/DebugOverlay.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; @@ -9,11 +19,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; @@ -22,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) @@ -41,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) @@ -64,16 +72,17 @@ 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).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/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/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/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/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/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index f719298a56..0e0e9a991d 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -441,6 +441,7 @@ World: Name: Ordos Race: ordos DomainIndex: + PathfinderDebugOverlay: ResourceLayer: ResourceClaimLayer: ResourceType@Spice: 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 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/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/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 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: