Add a debug visualization for muzzle positions.
This commit is contained in:
@@ -21,6 +21,7 @@ namespace OpenRA.Traits
|
|||||||
public bool PathDebug = false;
|
public bool PathDebug = false;
|
||||||
public bool UnlimitedPower;
|
public bool UnlimitedPower;
|
||||||
public bool BuildAnywhere;
|
public bool BuildAnywhere;
|
||||||
|
public bool ShowMuzzles;
|
||||||
|
|
||||||
public object Create (ActorInitializer init) { return new DeveloperMode(this); }
|
public object Create (ActorInitializer init) { return new DeveloperMode(this); }
|
||||||
}
|
}
|
||||||
@@ -36,6 +37,9 @@ namespace OpenRA.Traits
|
|||||||
[Sync] public bool UnlimitedPower;
|
[Sync] public bool UnlimitedPower;
|
||||||
[Sync] public bool BuildAnywhere;
|
[Sync] public bool BuildAnywhere;
|
||||||
|
|
||||||
|
// Client size only
|
||||||
|
public bool ShowMuzzles;
|
||||||
|
|
||||||
public DeveloperMode(DeveloperModeInfo info)
|
public DeveloperMode(DeveloperModeInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
@@ -45,6 +49,7 @@ namespace OpenRA.Traits
|
|||||||
PathDebug = info.PathDebug;
|
PathDebug = info.PathDebug;
|
||||||
UnlimitedPower = info.UnlimitedPower;
|
UnlimitedPower = info.UnlimitedPower;
|
||||||
BuildAnywhere = info.BuildAnywhere;
|
BuildAnywhere = info.BuildAnywhere;
|
||||||
|
ShowMuzzles = info.ShowMuzzles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResolveOrder (Actor self, Order order)
|
public void ResolveOrder (Actor self, Order order)
|
||||||
|
|||||||
62
OpenRA.Mods.RA/DebugMuzzlePositions.cs
Executable file
62
OpenRA.Mods.RA/DebugMuzzlePositions.cs
Executable file
@@ -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<IEnumerable<Armament>> armaments;
|
||||||
|
|
||||||
|
public DebugFiringOffsets(Actor self)
|
||||||
|
{
|
||||||
|
armaments = Lazy.New(() => self.TraitsImplementing<Armament>()
|
||||||
|
.Where(a => a.Info.OffsetModel == CoordinateModel.World));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||||
|
{
|
||||||
|
if (self.World.LocalPlayer == null || !self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -420,6 +420,7 @@
|
|||||||
<Compile Include="FogPalette.cs" />
|
<Compile Include="FogPalette.cs" />
|
||||||
<Compile Include="Infiltrates.cs" />
|
<Compile Include="Infiltrates.cs" />
|
||||||
<Compile Include="Armament.cs" />
|
<Compile Include="Armament.cs" />
|
||||||
|
<Compile Include="DebugMuzzlePositions.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
|
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
|
||||||
fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge");
|
fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge");
|
||||||
|
|
||||||
|
var showMuzzlesCheckbox = widget.Get<CheckboxWidget>("SHOW_MUZZLES");
|
||||||
|
showMuzzlesCheckbox.IsChecked = () => devTrait.ShowMuzzles;
|
||||||
|
showMuzzlesCheckbox.OnClick = () => devTrait.ShowMuzzles ^= true;
|
||||||
|
|
||||||
var allTechCheckbox = widget.Get<CheckboxWidget>("ENABLE_TECH");
|
var allTechCheckbox = widget.Get<CheckboxWidget>("ENABLE_TECH");
|
||||||
allTechCheckbox.IsChecked = () => devTrait.AllTech;
|
allTechCheckbox.IsChecked = () => devTrait.AllTech;
|
||||||
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
|
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
WithSmoke:
|
WithSmoke:
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
WithSmoke:
|
WithSmoke:
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -81,6 +83,7 @@
|
|||||||
Queue: Aircraft
|
Queue: Aircraft
|
||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Notification: unitlost.aud
|
Notification: unitlost.aud
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -127,6 +130,7 @@
|
|||||||
CrushableInfantry:
|
CrushableInfantry:
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
Range: 1
|
Range: 1
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^CivInfantry:
|
^CivInfantry:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
@@ -173,6 +177,7 @@
|
|||||||
TargetTypes: Air
|
TargetTypes: Air
|
||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Notification: unitlost.aud
|
Notification: unitlost.aud
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Ship:
|
^Ship:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -188,6 +193,7 @@
|
|||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Notification: unitlost.aud
|
Notification: unitlost.aud
|
||||||
AttackMove:
|
AttackMove:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -236,6 +242,7 @@
|
|||||||
Capturable:
|
Capturable:
|
||||||
CaptureCompleteTime: 0
|
CaptureCompleteTime: 0
|
||||||
CapturableBar:
|
CapturableBar:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^CivBuilding:
|
^CivBuilding:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -46,7 +46,13 @@ Container@CHEATS_PANEL:
|
|||||||
Y:45
|
Y:45
|
||||||
Width:200
|
Width:200
|
||||||
Height:20
|
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:
|
Checkbox@DISABLE_SHROUD:
|
||||||
X:400
|
X:400
|
||||||
Y:15
|
Y:15
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
AttackMove:
|
AttackMove:
|
||||||
AcceptsCloakCrate:
|
AcceptsCloakCrate:
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -68,6 +69,7 @@
|
|||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -93,6 +95,7 @@
|
|||||||
Explodes:
|
Explodes:
|
||||||
Weapon: HeliExplode
|
Weapon: HeliExplode
|
||||||
EmptyWeapon: HeliExplode
|
EmptyWeapon: HeliExplode
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -143,6 +146,7 @@
|
|||||||
RepairableNear:
|
RepairableNear:
|
||||||
Buildings: hosp
|
Buildings: hosp
|
||||||
CloseEnough: 1
|
CloseEnough: 1
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^CivInfantry:
|
^CivInfantry:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
@@ -193,6 +197,7 @@
|
|||||||
DrawLineToTarget:
|
DrawLineToTarget:
|
||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Notification: unitlost.aud
|
Notification: unitlost.aud
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Ship:
|
^Ship:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -212,6 +217,7 @@
|
|||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Notification: unitlost.aud
|
Notification: unitlost.aud
|
||||||
AttackMove:
|
AttackMove:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -260,6 +266,7 @@
|
|||||||
Capturable:
|
Capturable:
|
||||||
CapturableBar:
|
CapturableBar:
|
||||||
C4Demolishable:
|
C4Demolishable:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^CivBuilding:
|
^CivBuilding:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
RepairBuildings: repair
|
RepairBuildings: repair
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
Range: 1
|
Range: 1
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -81,6 +82,7 @@
|
|||||||
#WithSmoke:
|
#WithSmoke:
|
||||||
Repairable:
|
Repairable:
|
||||||
RepairBuildings: repair
|
RepairBuildings: repair
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Husk:
|
^Husk:
|
||||||
Health:
|
Health:
|
||||||
@@ -171,6 +173,7 @@
|
|||||||
CloseEnough: 1
|
CloseEnough: 1
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
Range: 2
|
Range: 2
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -201,6 +204,7 @@
|
|||||||
ProximityCaptor:
|
ProximityCaptor:
|
||||||
Types:Plane
|
Types:Plane
|
||||||
GivesBounty:
|
GivesBounty:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
@@ -259,4 +263,5 @@
|
|||||||
Types:Building
|
Types:Building
|
||||||
Sellable:
|
Sellable:
|
||||||
GivesBounty:
|
GivesBounty:
|
||||||
C4Demolishable:
|
C4Demolishable:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
String:Vehicle
|
String:Vehicle
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
String:Vehicle
|
String:Vehicle
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -99,6 +101,7 @@
|
|||||||
CrushableInfantry:
|
CrushableInfantry:
|
||||||
CrushSound: squishy2.aud
|
CrushSound: squishy2.aud
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Ship:
|
^Ship:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -122,6 +125,7 @@
|
|||||||
String:Ship
|
String:Ship
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -147,6 +151,7 @@
|
|||||||
GpsDot:
|
GpsDot:
|
||||||
String:Plane
|
String:Plane
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
@@ -186,6 +191,7 @@
|
|||||||
ProximityCaptor:
|
ProximityCaptor:
|
||||||
Types:Building
|
Types:Building
|
||||||
Sellable:
|
Sellable:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Wall:
|
^Wall:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
|||||||
@@ -81,9 +81,15 @@ Background@CHEATS_PANEL:
|
|||||||
Width:PARENT_RIGHT - 30
|
Width:PARENT_RIGHT - 30
|
||||||
Height:20
|
Height:20
|
||||||
Text:Show A* Cost
|
Text:Show A* Cost
|
||||||
|
Checkbox@SHOW_MUZZLES:
|
||||||
|
X:30
|
||||||
|
Y:350
|
||||||
|
Height:20
|
||||||
|
Width:200
|
||||||
|
Text:Show Muzzle Positions
|
||||||
Button@CLOSE:
|
Button@CLOSE:
|
||||||
X:30
|
X:30
|
||||||
Y:360
|
Y:390
|
||||||
Width:PARENT_RIGHT - 60
|
Width:PARENT_RIGHT - 60
|
||||||
Height:25
|
Height:25
|
||||||
Text:Close
|
Text:Close
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
String:Vehicle
|
String:Vehicle
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -71,6 +72,7 @@
|
|||||||
String:Vehicle
|
String:Vehicle
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
Buildings: hosp
|
Buildings: hosp
|
||||||
CloseEnough: 1
|
CloseEnough: 1
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Ship:
|
^Ship:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -150,6 +153,7 @@
|
|||||||
String:Ship
|
String:Ship
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -179,6 +183,7 @@
|
|||||||
GpsDot:
|
GpsDot:
|
||||||
String:Plane
|
String:Plane
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
@@ -223,6 +228,7 @@
|
|||||||
GivesBounty:
|
GivesBounty:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
C4Demolishable:
|
C4Demolishable:
|
||||||
|
DebugMuzzlePositions:
|
||||||
|
|
||||||
^Wall:
|
^Wall:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
|||||||
Reference in New Issue
Block a user