Draw targeting lines for player-issued orders. Can force-display targets with [alt].

This commit is contained in:
Paul Chote
2010-07-26 12:01:13 +12:00
parent 130b4d29b4
commit e8adc357e9
14 changed files with 189 additions and 18 deletions

View File

@@ -15,6 +15,7 @@ using OpenRA.Effects;
using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Traits;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -246,8 +247,17 @@ namespace OpenRA.Mods.RA
self.CancelActivity();
QueueAttack(self, order);
if (self.Owner == self.World.LocalPlayer && order.TargetActor != null)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w =>
{
if (order.TargetActor != null)
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
if (order.TargetActor != null) line.SetTarget(self, order.TargetActor, Color.Red);
else line.SetTarget(self, order.TargetLocation, Color.Red);
});
}
else
target = Target.None;

View File

@@ -12,6 +12,7 @@ using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -37,7 +38,13 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "C4")
{
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Red);
});
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));

View File

@@ -12,6 +12,7 @@ using OpenRA.Mods.RA.Activities;
using OpenRA.Effects;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -43,7 +44,13 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "CaptureBuilding")
{
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Red);
});
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));

View File

@@ -12,6 +12,7 @@ using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using OpenRA.Effects;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -53,7 +54,13 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "EngineerRepair" && order.TargetActor.Health < order.TargetActor.GetMaxHP())
{
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Yellow);
});
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));

View File

@@ -13,7 +13,8 @@ using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using OpenRA.Traits.Activities;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -122,7 +123,13 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "Harvest")
{
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new MoveFlash(self.World, order.TargetLocation)));
self.World.AddFrameEndTask(w =>
{
w.Add(new MoveFlash(self.World, order.TargetLocation));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetLocation, Color.Red);
});
self.CancelActivity();
self.QueueActivity(new Move(order.TargetLocation, 0));
@@ -142,7 +149,13 @@ namespace OpenRA.Mods.RA
return;
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new DeliverResources());

View File

@@ -15,6 +15,7 @@ using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -74,7 +75,13 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "Move")
{
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new MoveFlash(self.World, order.TargetLocation)));
self.World.AddFrameEndTask(w =>
{
w.Add(new MoveFlash(self.World, order.TargetLocation));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetLocation, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation)));
@@ -98,7 +105,13 @@ namespace OpenRA.Mods.RA
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec));

View File

@@ -12,6 +12,7 @@ using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -67,7 +68,13 @@ namespace OpenRA.Mods.RA
if (!CanEnter(self, order.TargetActor)) return;
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor.Location, 1));

View File

@@ -13,6 +13,7 @@ using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -90,7 +91,13 @@ namespace OpenRA.Mods.RA
UnReserve();
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new MoveFlash(self.World, order.TargetLocation)));
self.World.AddFrameEndTask(w =>
{
w.Add(new MoveFlash(self.World, order.TargetLocation));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetLocation, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
@@ -109,8 +116,14 @@ namespace OpenRA.Mods.RA
var info = self.Info.Traits.Get<PlaneInfo>();
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
self.QueueActivity(

View File

@@ -13,6 +13,7 @@ using OpenRA.Mods.RA.Activities;
using OpenRA.Effects;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
using System.Drawing;
namespace OpenRA.Mods.RA
{
@@ -59,7 +60,13 @@ namespace OpenRA.Mods.RA
var rp = order.TargetActor.traits.GetOrDefault<RallyPoint>();
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.World.AddFrameEndTask(w =>
{
w.Add(new FlashTarget(order.TargetActor));
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTarget(self, order.TargetActor, Color.Green);
});
self.CancelActivity();
self.QueueActivity(new Move(Util.CellContaining(order.TargetActor.CenterLocation), order.TargetActor));