added pathing debug
This commit is contained in:
@@ -42,8 +42,11 @@ namespace OpenRa.Game
|
||||
Projectile = Rules.ProjectileInfo[Weapon.Projectile];
|
||||
Warhead = Rules.WarheadInfo[Weapon.Warhead];
|
||||
|
||||
anim = new Animation(Projectile.Image);
|
||||
anim.PlayRepeating("idle");
|
||||
if (Projectile.Image != null && Projectile.Image != "none")
|
||||
{
|
||||
anim = new Animation(Projectile.Image);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
}
|
||||
|
||||
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
|
||||
@@ -70,11 +73,12 @@ namespace OpenRa.Game
|
||||
|
||||
public IEnumerable<Pair<Sprite, float2>> Render()
|
||||
{
|
||||
yield return Pair.New(anim.Image,
|
||||
float2.Lerp(
|
||||
Src.ToFloat2(),
|
||||
Dest.ToFloat2(),
|
||||
(float)t / TotalTime()) - 0.5f * anim.Image.size);
|
||||
if (anim != null)
|
||||
yield return Pair.New(anim.Image,
|
||||
float2.Lerp(
|
||||
Src.ToFloat2(),
|
||||
Dest.ToFloat2(),
|
||||
(float)t / TotalTime()) - 0.5f * anim.Image.size);
|
||||
}
|
||||
|
||||
float GetMaximumSpread()
|
||||
|
||||
@@ -13,6 +13,17 @@ namespace OpenRa.Game
|
||||
{
|
||||
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;
|
||||
public void HandleMouseInput(MouseInput mi)
|
||||
{
|
||||
@@ -22,10 +33,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
if (!(orderGenerator is PlaceBuilding))
|
||||
dragStart = dragEnd = xy;
|
||||
|
||||
if (orderGenerator != null)
|
||||
foreach (var order in orderGenerator.Order(xy.ToInt2(), true))
|
||||
order.Apply();
|
||||
ApplyOrders(xy, true);
|
||||
}
|
||||
|
||||
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
|
||||
@@ -53,10 +61,8 @@ namespace OpenRa.Game
|
||||
dragStart = dragEnd = xy;
|
||||
}
|
||||
|
||||
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
||||
if( orderGenerator != null )
|
||||
foreach( var order in orderGenerator.Order( xy.ToInt2(), false ) )
|
||||
order.Apply();
|
||||
if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down)
|
||||
ApplyOrders(xy, false);
|
||||
}
|
||||
|
||||
public Pair<float2, float2>? SelectionBox
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using IjwFramework.Types;
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Traits;
|
||||
|
||||
namespace OpenRa.Game.Graphics
|
||||
{
|
||||
@@ -13,6 +14,8 @@ namespace OpenRa.Game.Graphics
|
||||
public readonly Region region;
|
||||
public readonly UiOverlay uiOverlay;
|
||||
|
||||
public static bool ShowUnitPaths = false;
|
||||
|
||||
public WorldRenderer(Renderer renderer)
|
||||
{
|
||||
// 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),
|
||||
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);
|
||||
|
||||
UiOverlay.ShowUnitDebug = settings.GetValue("udebug", false);
|
||||
WorldRenderer.ShowUnitPaths = settings.GetValue("pathdebug", false);
|
||||
|
||||
Game.Initialize(settings.GetValue("map", "scg11eb.ini"), renderer, new int2(ClientSize),
|
||||
settings.GetValue("player", 1));
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
abstract class Order
|
||||
{
|
||||
public abstract void Apply();
|
||||
public abstract void Apply(bool doVoice);
|
||||
}
|
||||
|
||||
class MoveOrder : Order
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game
|
||||
public readonly Actor Unit;
|
||||
public readonly int2 Destination;
|
||||
|
||||
public MoveOrder( Actor unit, int2 destination )
|
||||
public MoveOrder(Actor unit, int2 destination)
|
||||
{
|
||||
this.Unit = unit;
|
||||
this.Destination = destination;
|
||||
@@ -28,14 +28,14 @@ namespace OpenRa.Game
|
||||
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);
|
||||
|
||||
var mobile = Unit.traits.Get<Mobile>();
|
||||
mobile.Cancel(Unit);
|
||||
mobile.QueueActivity( new Mobile.MoveTo( Destination ) );
|
||||
mobile.QueueActivity(new Mobile.MoveTo(Destination));
|
||||
|
||||
var attackBase = Unit.traits.WithInterface<AttackBase>().FirstOrDefault();
|
||||
if (attackBase != null)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game
|
||||
this.xy = xy;
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
public override void Apply(bool doVoice)
|
||||
{
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits
|
||||
var weapon = Rules.WeaponInfo[ weaponName ];
|
||||
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,
|
||||
self.CenterLocation.ToInt2(),
|
||||
@@ -90,7 +90,7 @@ namespace OpenRa.Game.Traits
|
||||
this.Target = target;
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
public override void Apply( bool doVoice )
|
||||
{
|
||||
var mobile = Attacker.traits.GetOrDefault<Mobile>();
|
||||
if (mobile != null)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits
|
||||
Location = location;
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
public override void Apply( bool doVoice )
|
||||
{
|
||||
var mobile = Unit.traits.Get<Mobile>();
|
||||
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace OpenRa.Game.Traits
|
||||
public CurrentActivity NextActivity { get; set; }
|
||||
|
||||
int2? destination;
|
||||
List<int2> path;
|
||||
public List<int2> path;
|
||||
Func<Actor, Mobile, List<int2>> getPath;
|
||||
|
||||
MovePart move;
|
||||
@@ -314,5 +314,12 @@ namespace OpenRa.Game.Traits
|
||||
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