SetTargetSilently for DrawLineToTarget

This commit is contained in:
alzeih
2010-07-26 13:57:53 +12:00
parent 526bb3e042
commit 925ca2bb73
10 changed files with 89 additions and 7 deletions

View File

@@ -38,6 +38,12 @@ namespace OpenRA.Traits
this.c = c;
}
public void SetTargetSilently(Actor self, Target target, Color c)
{
this.target = target;
this.c = c;
}
public void Render (Actor self)
{
var force = Game.controller.GetModifiers().HasModifier(Modifiers.Alt);

View File

@@ -286,6 +286,13 @@ namespace OpenRA.Traits
if (moveTo.HasValue)
{
self.CancelActivity();
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w =>
{
var line = self.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTargetSilently(self, Target.FromCell(moveTo.Value), Color.Green);
});
self.QueueActivity(new Move(moveTo.Value, 0));
}
}

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using System.Drawing;
namespace OpenRA.Traits
{
@@ -63,11 +64,28 @@ namespace OpenRA.Traits
var mobile = newUnit.traits.GetOrDefault<Mobile>();
if (mobile != null)
{
int2? target = null;
if (pi.ExitOffset != null)
newUnit.QueueActivity(new Activities.Move(ExitLocation(self, producee).Value, 1));
{
target = ExitLocation(self, producee).Value;
newUnit.QueueActivity(new Activities.Move(target.Value, 1));
}
if (rp != null)
newUnit.QueueActivity(new Activities.Move(rp.rallyPoint, 1));
{
target = rp.rallyPoint;
newUnit.QueueActivity(new Activities.Move(target.Value, 1));
}
if (target != null && newUnit.Owner == self.World.LocalPlayer)
{
self.World.AddFrameEndTask(w =>
{
var line = newUnit.traits.GetOrDefault<DrawLineToTarget>();
if (line != null)
line.SetTargetSilently(newUnit, Target.FromCell(target.Value), Color.Green);
});
}
}
}