diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index 5f774d6587..f6492a58af 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -21,6 +21,7 @@ namespace OpenRA.Traits public bool PathDebug = false; public bool UnlimitedPower; public bool BuildAnywhere; + public bool ShowMuzzles; public object Create (ActorInitializer init) { return new DeveloperMode(this); } } @@ -36,6 +37,9 @@ namespace OpenRA.Traits [Sync] public bool UnlimitedPower; [Sync] public bool BuildAnywhere; + // Client size only + public bool ShowMuzzles; + public DeveloperMode(DeveloperModeInfo info) { Info = info; @@ -45,6 +49,7 @@ namespace OpenRA.Traits PathDebug = info.PathDebug; UnlimitedPower = info.UnlimitedPower; BuildAnywhere = info.BuildAnywhere; + ShowMuzzles = info.ShowMuzzles; } public void ResolveOrder (Actor self, Order order) diff --git a/OpenRA.Mods.RA/DebugMuzzlePositions.cs b/OpenRA.Mods.RA/DebugMuzzlePositions.cs new file mode 100755 index 0000000000..9cdc8a32c3 --- /dev/null +++ b/OpenRA.Mods.RA/DebugMuzzlePositions.cs @@ -0,0 +1,62 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 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; +using OpenRA.FileFormats; +using OpenRA.GameRules; +using OpenRA.Graphics; +using OpenRA.Mods.RA.Render; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + public class DebugMuzzlePositionsInfo : ITraitInfo + { + public object Create(ActorInitializer init) { return new DebugFiringOffsets(init.self); } + } + + public class DebugFiringOffsets : IPostRender + { + Lazy> armaments; + + public DebugFiringOffsets(Actor self) + { + armaments = Lazy.New(() => self.TraitsImplementing() + .Where(a => a.Info.OffsetModel == CoordinateModel.World)); + } + + public void RenderAfterWorld(WorldRenderer wr, Actor self) + { + if (self.World.LocalPlayer == null || !self.World.LocalPlayer.PlayerActor.Trait().ShowMuzzles) + return; + + var wlr = Game.Renderer.WorldLineRenderer; + var c = Color.White; + + foreach (var a in armaments.Value) + 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 sm = wr.ScreenPosition(muzzle); + var sd = wr.ScreenPosition(muzzle + dirOffset); + wlr.DrawLine(sm, sd, c, c); + wlr.DrawLine(sm + new float2(-1, -1), sm + new float2(-1, 1), c, c); + wlr.DrawLine(sm + new float2(-1, 1), sm + new float2(1, 1), c, c); + wlr.DrawLine(sm + new float2(1, 1), sm + new float2(1, -1), c, c); + wlr.DrawLine(sm + new float2(1, -1), sm + new float2(-1, -1), c, c); + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 4d8584b9a2..dc9333a948 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -420,6 +420,7 @@ + diff --git a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs index c42ceaca0f..e459adf356 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs @@ -41,6 +41,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic fastChargeCheckbox.IsChecked = () => devTrait.FastCharge; fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge"); + var showMuzzlesCheckbox = widget.Get("SHOW_MUZZLES"); + showMuzzlesCheckbox.IsChecked = () => devTrait.ShowMuzzles; + showMuzzlesCheckbox.OnClick = () => devTrait.ShowMuzzles ^= true; + var allTechCheckbox = widget.Get("ENABLE_TECH"); allTechCheckbox.IsChecked = () => devTrait.AllTech; allTechCheckbox.OnClick = () => Order(world, "DevEnableTech"); diff --git a/mods/cnc-classic/rules/defaults.yaml b/mods/cnc-classic/rules/defaults.yaml index d92283d1de..0def3c6031 100644 --- a/mods/cnc-classic/rules/defaults.yaml +++ b/mods/cnc-classic/rules/defaults.yaml @@ -31,6 +31,7 @@ WithSmoke: Explodes: Weapon: UnitExplodeSmall + DebugMuzzlePositions: ^Tank: AppearsOnRadar: @@ -64,6 +65,7 @@ WithSmoke: Explodes: Weapon: UnitExplodeSmall + DebugMuzzlePositions: ^Helicopter: AppearsOnRadar: @@ -81,6 +83,7 @@ Queue: Aircraft ActorLostNotification: Notification: unitlost.aud + DebugMuzzlePositions: ^Infantry: AppearsOnRadar: @@ -127,6 +130,7 @@ CrushableInfantry: DetectCloaked: Range: 1 + DebugMuzzlePositions: ^CivInfantry: Inherits: ^Infantry @@ -173,6 +177,7 @@ TargetTypes: Air ActorLostNotification: Notification: unitlost.aud + DebugMuzzlePositions: ^Ship: AppearsOnRadar: @@ -188,6 +193,7 @@ ActorLostNotification: Notification: unitlost.aud AttackMove: + DebugMuzzlePositions: ^Building: AppearsOnRadar: @@ -236,6 +242,7 @@ Capturable: CaptureCompleteTime: 0 CapturableBar: + DebugMuzzlePositions: ^CivBuilding: Inherits: ^Building diff --git a/mods/cnc/chrome/cheats.yaml b/mods/cnc/chrome/cheats.yaml index d3789c7d4b..47c8dadff2 100644 --- a/mods/cnc/chrome/cheats.yaml +++ b/mods/cnc/chrome/cheats.yaml @@ -46,7 +46,13 @@ Container@CHEATS_PANEL: Y:45 Width:200 Height:20 - Text:Instant Charge Time + Text:Instant Charge Time + Checkbox@SHOW_MUZZLES: + X:200 + Y:75 + Height:20 + Width:200 + Text:Show Muzzle Positions Checkbox@DISABLE_SHROUD: X:400 Y:15 diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 17bbbee19f..9a3ef74237 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -31,6 +31,7 @@ AttackMove: AcceptsCloakCrate: WithSmoke: + DebugMuzzlePositions: ^Tank: AppearsOnRadar: @@ -68,6 +69,7 @@ Explodes: Weapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall + DebugMuzzlePositions: ^Helicopter: AppearsOnRadar: @@ -93,6 +95,7 @@ Explodes: Weapon: HeliExplode EmptyWeapon: HeliExplode + DebugMuzzlePositions: ^Infantry: AppearsOnRadar: @@ -143,6 +146,7 @@ RepairableNear: Buildings: hosp CloseEnough: 1 + DebugMuzzlePositions: ^CivInfantry: Inherits: ^Infantry @@ -193,6 +197,7 @@ DrawLineToTarget: ActorLostNotification: Notification: unitlost.aud + DebugMuzzlePositions: ^Ship: AppearsOnRadar: @@ -212,6 +217,7 @@ ActorLostNotification: Notification: unitlost.aud AttackMove: + DebugMuzzlePositions: ^Building: AppearsOnRadar: @@ -260,6 +266,7 @@ Capturable: CapturableBar: C4Demolishable: + DebugMuzzlePositions: ^CivBuilding: Inherits: ^Building diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 39f39ddaf7..4753869b0d 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -40,6 +40,7 @@ RepairBuildings: repair DetectCloaked: Range: 1 + DebugMuzzlePositions: ^Tank: AppearsOnRadar: @@ -81,6 +82,7 @@ #WithSmoke: Repairable: RepairBuildings: repair + DebugMuzzlePositions: ^Husk: Health: @@ -171,6 +173,7 @@ CloseEnough: 1 DetectCloaked: Range: 2 + DebugMuzzlePositions: ^Plane: AppearsOnRadar: @@ -201,6 +204,7 @@ ProximityCaptor: Types:Plane GivesBounty: + DebugMuzzlePositions: ^Helicopter: Inherits: ^Plane @@ -259,4 +263,5 @@ Types:Building Sellable: GivesBounty: - C4Demolishable: \ No newline at end of file + C4Demolishable: + DebugMuzzlePositions: diff --git a/mods/ra-classic/rules/defaults.yaml b/mods/ra-classic/rules/defaults.yaml index 5c7bd24429..35bfbca04e 100644 --- a/mods/ra-classic/rules/defaults.yaml +++ b/mods/ra-classic/rules/defaults.yaml @@ -28,6 +28,7 @@ String:Vehicle WithSmoke: UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Tank: AppearsOnRadar: @@ -59,6 +60,7 @@ String:Vehicle WithSmoke: UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Infantry: AppearsOnRadar: @@ -99,6 +101,7 @@ CrushableInfantry: CrushSound: squishy2.aud UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Ship: AppearsOnRadar: @@ -122,6 +125,7 @@ String:Ship WithSmoke: UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Plane: AppearsOnRadar: @@ -147,6 +151,7 @@ GpsDot: String:Plane UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Helicopter: Inherits: ^Plane @@ -186,6 +191,7 @@ ProximityCaptor: Types:Building Sellable: + DebugMuzzlePositions: ^Wall: AppearsOnRadar: diff --git a/mods/ra/chrome/cheats.yaml b/mods/ra/chrome/cheats.yaml index fe47dfc7af..73d9afdd8c 100644 --- a/mods/ra/chrome/cheats.yaml +++ b/mods/ra/chrome/cheats.yaml @@ -81,9 +81,15 @@ Background@CHEATS_PANEL: Width:PARENT_RIGHT - 30 Height:20 Text:Show A* Cost + Checkbox@SHOW_MUZZLES: + X:30 + Y:350 + Height:20 + Width:200 + Text:Show Muzzle Positions Button@CLOSE: X:30 - Y:360 + Y:390 Width:PARENT_RIGHT - 60 Height:25 Text:Close diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index db16339346..30e3298f59 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -34,6 +34,7 @@ String:Vehicle WithSmoke: UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Tank: AppearsOnRadar: @@ -71,6 +72,7 @@ String:Vehicle WithSmoke: UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Infantry: AppearsOnRadar: @@ -122,6 +124,7 @@ Buildings: hosp CloseEnough: 1 UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Ship: AppearsOnRadar: @@ -150,6 +153,7 @@ String:Ship WithSmoke: UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Plane: AppearsOnRadar: @@ -179,6 +183,7 @@ GpsDot: String:Plane UpdatesPlayerStatistics: + DebugMuzzlePositions: ^Helicopter: Inherits: ^Plane @@ -223,6 +228,7 @@ GivesBounty: UpdatesPlayerStatistics: C4Demolishable: + DebugMuzzlePositions: ^Wall: AppearsOnRadar: