added pathing debug
This commit is contained in:
@@ -42,8 +42,11 @@ namespace OpenRa.Game
|
|||||||
Projectile = Rules.ProjectileInfo[Weapon.Projectile];
|
Projectile = Rules.ProjectileInfo[Weapon.Projectile];
|
||||||
Warhead = Rules.WarheadInfo[Weapon.Warhead];
|
Warhead = Rules.WarheadInfo[Weapon.Warhead];
|
||||||
|
|
||||||
anim = new Animation(Projectile.Image);
|
if (Projectile.Image != null && Projectile.Image != "none")
|
||||||
anim.PlayRepeating("idle");
|
{
|
||||||
|
anim = new Animation(Projectile.Image);
|
||||||
|
anim.PlayRepeating("idle");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
|
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
|
||||||
@@ -70,11 +73,12 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public IEnumerable<Pair<Sprite, float2>> Render()
|
public IEnumerable<Pair<Sprite, float2>> Render()
|
||||||
{
|
{
|
||||||
yield return Pair.New(anim.Image,
|
if (anim != null)
|
||||||
float2.Lerp(
|
yield return Pair.New(anim.Image,
|
||||||
Src.ToFloat2(),
|
float2.Lerp(
|
||||||
Dest.ToFloat2(),
|
Src.ToFloat2(),
|
||||||
(float)t / TotalTime()) - 0.5f * anim.Image.size);
|
Dest.ToFloat2(),
|
||||||
|
(float)t / TotalTime()) - 0.5f * anim.Image.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetMaximumSpread()
|
float GetMaximumSpread()
|
||||||
|
|||||||
@@ -13,6 +13,17 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
public IOrderGenerator orderGenerator;
|
public IOrderGenerator orderGenerator;
|
||||||
|
|
||||||
|
void ApplyOrders(float2 xy, bool left)
|
||||||
|
{
|
||||||
|
var doVoice = true;
|
||||||
|
if (orderGenerator != null)
|
||||||
|
foreach (var order in orderGenerator.Order(xy.ToInt2(), left))
|
||||||
|
{
|
||||||
|
order.Apply(doVoice);
|
||||||
|
doVoice = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float2 dragStart, dragEnd;
|
float2 dragStart, dragEnd;
|
||||||
public void HandleMouseInput(MouseInput mi)
|
public void HandleMouseInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
@@ -22,10 +33,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
if (!(orderGenerator is PlaceBuilding))
|
if (!(orderGenerator is PlaceBuilding))
|
||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = xy;
|
||||||
|
ApplyOrders(xy, true);
|
||||||
if (orderGenerator != null)
|
|
||||||
foreach (var order in orderGenerator.Order(xy.ToInt2(), true))
|
|
||||||
order.Apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
|
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
|
||||||
@@ -53,10 +61,8 @@ namespace OpenRa.Game
|
|||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down)
|
||||||
if( orderGenerator != null )
|
ApplyOrders(xy, false);
|
||||||
foreach( var order in orderGenerator.Order( xy.ToInt2(), false ) )
|
|
||||||
order.Apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<float2, float2>? SelectionBox
|
public Pair<float2, float2>? SelectionBox
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Linq;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using IjwFramework.Types;
|
using IjwFramework.Types;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
namespace OpenRa.Game.Graphics
|
namespace OpenRa.Game.Graphics
|
||||||
{
|
{
|
||||||
@@ -13,6 +14,8 @@ namespace OpenRa.Game.Graphics
|
|||||||
public readonly Region region;
|
public readonly Region region;
|
||||||
public readonly UiOverlay uiOverlay;
|
public readonly UiOverlay uiOverlay;
|
||||||
|
|
||||||
|
public static bool ShowUnitPaths = false;
|
||||||
|
|
||||||
public WorldRenderer(Renderer renderer)
|
public WorldRenderer(Renderer renderer)
|
||||||
{
|
{
|
||||||
// TODO: this is layout policy. it belongs at a higher level than this.
|
// TODO: this is layout policy. it belongs at a higher level than this.
|
||||||
@@ -147,6 +150,25 @@ namespace OpenRa.Game.Graphics
|
|||||||
z + new float2(0, -4),
|
z + new float2(0, -4),
|
||||||
healthColor2, healthColor2);
|
healthColor2, healthColor2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ShowUnitPaths)
|
||||||
|
{
|
||||||
|
var mobile = selectedUnit.traits.GetOrDefault<Mobile>();
|
||||||
|
if (mobile != null)
|
||||||
|
{
|
||||||
|
var path = mobile.GetCurrentPath();
|
||||||
|
var start = selectedUnit.Location;
|
||||||
|
|
||||||
|
foreach (var step in path)
|
||||||
|
{
|
||||||
|
lineRenderer.DrawLine(
|
||||||
|
Game.CellSize * start + new float2(12, 12),
|
||||||
|
Game.CellSize * step + new float2(12, 12),
|
||||||
|
Color.Red, Color.Red);
|
||||||
|
start = step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace OpenRa.Game
|
|||||||
SheetBuilder.Initialize(renderer);
|
SheetBuilder.Initialize(renderer);
|
||||||
|
|
||||||
UiOverlay.ShowUnitDebug = settings.GetValue("udebug", false);
|
UiOverlay.ShowUnitDebug = settings.GetValue("udebug", false);
|
||||||
|
WorldRenderer.ShowUnitPaths = settings.GetValue("pathdebug", false);
|
||||||
|
|
||||||
Game.Initialize(settings.GetValue("map", "scg11eb.ini"), renderer, new int2(ClientSize),
|
Game.Initialize(settings.GetValue("map", "scg11eb.ini"), renderer, new int2(ClientSize),
|
||||||
settings.GetValue("player", 1));
|
settings.GetValue("player", 1));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
abstract class Order
|
abstract class Order
|
||||||
{
|
{
|
||||||
public abstract void Apply();
|
public abstract void Apply(bool doVoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MoveOrder : Order
|
class MoveOrder : Order
|
||||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game
|
|||||||
public readonly Actor Unit;
|
public readonly Actor Unit;
|
||||||
public readonly int2 Destination;
|
public readonly int2 Destination;
|
||||||
|
|
||||||
public MoveOrder( Actor unit, int2 destination )
|
public MoveOrder(Actor unit, int2 destination)
|
||||||
{
|
{
|
||||||
this.Unit = unit;
|
this.Unit = unit;
|
||||||
this.Destination = destination;
|
this.Destination = destination;
|
||||||
@@ -28,14 +28,14 @@ namespace OpenRa.Game
|
|||||||
return suffixes[Unit.traits.Get<Traits.Mobile>().Voice];
|
return suffixes[Unit.traits.Get<Traits.Mobile>().Voice];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply()
|
public override void Apply(bool doVoice)
|
||||||
{
|
{
|
||||||
if (Game.LocalPlayer == Unit.Owner)
|
if (doVoice && Game.LocalPlayer == Unit.Owner)
|
||||||
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false);
|
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false);
|
||||||
|
|
||||||
var mobile = Unit.traits.Get<Mobile>();
|
var mobile = Unit.traits.Get<Mobile>();
|
||||||
mobile.Cancel(Unit);
|
mobile.Cancel(Unit);
|
||||||
mobile.QueueActivity( new Mobile.MoveTo( Destination ) );
|
mobile.QueueActivity(new Mobile.MoveTo(Destination));
|
||||||
|
|
||||||
var attackBase = Unit.traits.WithInterface<AttackBase>().FirstOrDefault();
|
var attackBase = Unit.traits.WithInterface<AttackBase>().FirstOrDefault();
|
||||||
if (attackBase != null)
|
if (attackBase != null)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game
|
|||||||
this.xy = xy;
|
this.xy = xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply()
|
public override void Apply(bool doVoice)
|
||||||
{
|
{
|
||||||
Game.world.AddFrameEndTask( _ =>
|
Game.world.AddFrameEndTask( _ =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits
|
|||||||
var weapon = Rules.WeaponInfo[ weaponName ];
|
var weapon = Rules.WeaponInfo[ weaponName ];
|
||||||
if( weapon.Range * weapon.Range < ( target.Location - self.Location ).LengthSquared ) return false;
|
if( weapon.Range * weapon.Range < ( target.Location - self.Location ).LengthSquared ) return false;
|
||||||
|
|
||||||
fireDelay = 25 * weapon.ROF / 15;
|
fireDelay = weapon.ROF;
|
||||||
|
|
||||||
Game.world.Add( new Bullet( weaponName, self.Owner, self,
|
Game.world.Add( new Bullet( weaponName, self.Owner, self,
|
||||||
self.CenterLocation.ToInt2(),
|
self.CenterLocation.ToInt2(),
|
||||||
@@ -90,7 +90,7 @@ namespace OpenRa.Game.Traits
|
|||||||
this.Target = target;
|
this.Target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply()
|
public override void Apply( bool doVoice )
|
||||||
{
|
{
|
||||||
var mobile = Attacker.traits.GetOrDefault<Mobile>();
|
var mobile = Attacker.traits.GetOrDefault<Mobile>();
|
||||||
if (mobile != null)
|
if (mobile != null)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits
|
|||||||
Location = location;
|
Location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply()
|
public override void Apply( bool doVoice )
|
||||||
{
|
{
|
||||||
var mobile = Unit.traits.Get<Mobile>();
|
var mobile = Unit.traits.Get<Mobile>();
|
||||||
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace OpenRa.Game.Traits
|
|||||||
public CurrentActivity NextActivity { get; set; }
|
public CurrentActivity NextActivity { get; set; }
|
||||||
|
|
||||||
int2? destination;
|
int2? destination;
|
||||||
List<int2> path;
|
public List<int2> path;
|
||||||
Func<Actor, Mobile, List<int2>> getPath;
|
Func<Actor, Mobile, List<int2>> getPath;
|
||||||
|
|
||||||
MovePart move;
|
MovePart move;
|
||||||
@@ -314,5 +314,12 @@ namespace OpenRa.Game.Traits
|
|||||||
NextActivity = null;
|
NextActivity = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<int2> GetCurrentPath()
|
||||||
|
{
|
||||||
|
var move = currentActivity as MoveTo;
|
||||||
|
if (move == null || move.path == null) return new int2[] { };
|
||||||
|
return Enumerable.Reverse(move.path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user