Added warhead visualization to combat debug overlay.
This commit is contained in:
@@ -528,6 +528,7 @@
|
|||||||
<Compile Include="Traits\World\SpawnMPUnits.cs" />
|
<Compile Include="Traits\World\SpawnMPUnits.cs" />
|
||||||
<Compile Include="Traits\World\StartGameNotification.cs" />
|
<Compile Include="Traits\World\StartGameNotification.cs" />
|
||||||
<Compile Include="Traits\World\TerrainGeometryOverlay.cs" />
|
<Compile Include="Traits\World\TerrainGeometryOverlay.cs" />
|
||||||
|
<Compile Include="Traits\World\WarheadDebugOverlay.cs" />
|
||||||
<Compile Include="Traits\World\WeatherOverlay.cs" />
|
<Compile Include="Traits\World\WeatherOverlay.cs" />
|
||||||
<Compile Include="UtilityCommands\CheckYaml.cs" />
|
<Compile Include="UtilityCommands\CheckYaml.cs" />
|
||||||
<Compile Include="UtilityCommands\CheckCodeStyle.cs" />
|
<Compile Include="UtilityCommands\CheckCodeStyle.cs" />
|
||||||
|
|||||||
87
OpenRA.Mods.Common/Traits/World/WarheadDebugOverlay.cs
Normal file
87
OpenRA.Mods.Common/Traits/World/WarheadDebugOverlay.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 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.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Part of the combat overlay from DeveloperMode. Attach this to the world actor.")]
|
||||||
|
public class WarheadDebugOverlayInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly int DisplayDuration = 25;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WarheadDebugOverlay(this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WarheadDebugOverlay : IPostRender
|
||||||
|
{
|
||||||
|
class WHImpact
|
||||||
|
{
|
||||||
|
public readonly WPos CenterPosition;
|
||||||
|
public readonly WDist[] Range;
|
||||||
|
public int Time;
|
||||||
|
|
||||||
|
public WDist OuterRange
|
||||||
|
{
|
||||||
|
get { return Range[Range.Length - 1]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public WHImpact(WPos pos, WDist[] range, int time)
|
||||||
|
{
|
||||||
|
CenterPosition = pos;
|
||||||
|
Range = range;
|
||||||
|
Time = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly WarheadDebugOverlayInfo info;
|
||||||
|
readonly List<WHImpact> impacts = new List<WHImpact>();
|
||||||
|
|
||||||
|
public WarheadDebugOverlay(WarheadDebugOverlayInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddImpact(WPos pos, WDist[] range)
|
||||||
|
{
|
||||||
|
impacts.Add(new WHImpact(pos, range, info.DisplayDuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||||
|
{
|
||||||
|
foreach (var i in impacts)
|
||||||
|
{
|
||||||
|
var alpha = 255.0f * i.Time / info.DisplayDuration;
|
||||||
|
var rangeStep = alpha / i.Range.Length;
|
||||||
|
|
||||||
|
wr.DrawRangeCircle(i.CenterPosition, i.OuterRange, Color.FromArgb((int)alpha, Color.Red));
|
||||||
|
|
||||||
|
foreach (var r in i.Range)
|
||||||
|
{
|
||||||
|
var tl = wr.ScreenPosition(i.CenterPosition - new WVec(r.Length, r.Length, 0));
|
||||||
|
var br = wr.ScreenPosition(i.CenterPosition + new WVec(r.Length, r.Length, 0));
|
||||||
|
var rect = RectangleF.FromLTRB(tl.X, tl.Y, br.X, br.Y);
|
||||||
|
|
||||||
|
Game.Renderer.WorldLineRenderer.FillEllipse(rect, Color.FromArgb((int)alpha, Color.Red));
|
||||||
|
|
||||||
|
alpha -= rangeStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wr.World.Paused)
|
||||||
|
i.Time--;
|
||||||
|
}
|
||||||
|
|
||||||
|
impacts.RemoveAll(i => i.Time == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Warheads
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
@@ -22,6 +23,14 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
public override void DoImpact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers)
|
public override void DoImpact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers)
|
||||||
{
|
{
|
||||||
var world = firedBy.World;
|
var world = firedBy.World;
|
||||||
|
|
||||||
|
if (world.LocalPlayer != null)
|
||||||
|
{
|
||||||
|
var devMode = world.LocalPlayer.PlayerActor.TraitOrDefault<DeveloperMode>();
|
||||||
|
if (devMode != null && devMode.ShowCombatGeometry)
|
||||||
|
world.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(pos, Spread);
|
||||||
|
}
|
||||||
|
|
||||||
var range = Spread[0];
|
var range = Spread[0];
|
||||||
var hitActors = world.FindActorsInCircle(pos, range);
|
var hitActors = world.FindActorsInCircle(pos, range);
|
||||||
if (Spread.Length > 1 && Spread[1].Length > 0)
|
if (Spread.Length > 1 && Spread[1].Length > 0)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Warheads
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
@@ -50,6 +51,13 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
|
|
||||||
var world = firedBy.World;
|
var world = firedBy.World;
|
||||||
|
|
||||||
|
if (world.LocalPlayer != null)
|
||||||
|
{
|
||||||
|
var devMode = world.LocalPlayer.PlayerActor.TraitOrDefault<DeveloperMode>();
|
||||||
|
if (devMode != null && devMode.ShowCombatGeometry)
|
||||||
|
world.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(pos, Range);
|
||||||
|
}
|
||||||
|
|
||||||
// This only finds actors where the center is within the search radius,
|
// This only finds actors where the center is within the search radius,
|
||||||
// so we need to search beyond the maximum spread to account for actors with large health radius
|
// so we need to search beyond the maximum spread to account for actors with large health radius
|
||||||
var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1] + TargetExtraSearchRadius);
|
var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1] + TargetExtraSearchRadius);
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ World:
|
|||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
|
WarheadDebugOverlay:
|
||||||
SpawnMapActors:
|
SpawnMapActors:
|
||||||
MPStartLocations:
|
MPStartLocations:
|
||||||
CreateMPPlayers:
|
CreateMPPlayers:
|
||||||
@@ -152,4 +153,3 @@ EditorWorld:
|
|||||||
Inherits: ^BaseWorld
|
Inherits: ^BaseWorld
|
||||||
EditorActorLayer:
|
EditorActorLayer:
|
||||||
EditorResourceLayer:
|
EditorResourceLayer:
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ World:
|
|||||||
ValidGround: Sand, Dune, Rock
|
ValidGround: Sand, Dune, Rock
|
||||||
DomainIndex:
|
DomainIndex:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
|
WarheadDebugOverlay:
|
||||||
BuildableTerrainLayer:
|
BuildableTerrainLayer:
|
||||||
D2kResourceLayer:
|
D2kResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
@@ -146,4 +147,3 @@ EditorWorld:
|
|||||||
Inherits: ^BaseWorld
|
Inherits: ^BaseWorld
|
||||||
EditorActorLayer:
|
EditorActorLayer:
|
||||||
D2kEditorResourceLayer:
|
D2kEditorResourceLayer:
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ World:
|
|||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
|
WarheadDebugOverlay:
|
||||||
SpawnMapActors:
|
SpawnMapActors:
|
||||||
CreateMPPlayers:
|
CreateMPPlayers:
|
||||||
MPStartUnits@mcvonly:
|
MPStartUnits@mcvonly:
|
||||||
@@ -171,4 +172,3 @@ EditorWorld:
|
|||||||
Inherits: ^BaseWorld
|
Inherits: ^BaseWorld
|
||||||
EditorActorLayer:
|
EditorActorLayer:
|
||||||
EditorResourceLayer:
|
EditorResourceLayer:
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ World:
|
|||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
|
WarheadDebugOverlay:
|
||||||
SpawnMapActors:
|
SpawnMapActors:
|
||||||
CreateMPPlayers:
|
CreateMPPlayers:
|
||||||
MPStartUnits@MCV:
|
MPStartUnits@MCV:
|
||||||
@@ -173,4 +174,3 @@ EditorWorld:
|
|||||||
Inherits: ^BaseWorld
|
Inherits: ^BaseWorld
|
||||||
EditorActorLayer:
|
EditorActorLayer:
|
||||||
EditorResourceLayer:
|
EditorResourceLayer:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user