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 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)
|
||||
|
||||
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="Infiltrates.cs" />
|
||||
<Compile Include="Armament.cs" />
|
||||
<Compile Include="DebugMuzzlePositions.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
fastChargeCheckbox.IsChecked = () => devTrait.FastCharge;
|
||||
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");
|
||||
allTechCheckbox.IsChecked = () => devTrait.AllTech;
|
||||
allTechCheckbox.OnClick = () => Order(world, "DevEnableTech");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -47,6 +47,12 @@ Container@CHEATS_PANEL:
|
||||
Width:200
|
||||
Height:20
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -260,3 +264,4 @@
|
||||
Sellable:
|
||||
GivesBounty:
|
||||
C4Demolishable:
|
||||
DebugMuzzlePositions:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user