migrating most things to use the Target struct rather than Actor directly.

This commit is contained in:
Chris Forbes
2010-07-05 18:25:10 +12:00
parent 88b705c8ef
commit 5c61c9d3a9
14 changed files with 57 additions and 49 deletions

View File

@@ -17,10 +17,10 @@ namespace OpenRA.Mods.RA.Activities
/* non-turreted attack */
public class Attack : IActivity
{
Actor Target;
Target Target;
int Range;
public Attack(Actor target, int range)
public Attack(Target target, int range)
{
Target = target;
Range = range;
@@ -32,13 +32,15 @@ namespace OpenRA.Mods.RA.Activities
{
var unit = self.traits.Get<Unit>();
if (Target == null || Target.IsDead)
if (!Target.IsValid)
return NextActivity;
if ((Target.Location - self.Location).LengthSquared >= Range * Range)
return new Move( Target, Range ) { NextActivity = this };
var targetCell = Util.CellContaining(Target.CenterLocation);
var desiredFacing = Util.GetFacing((Target.Location - self.Location).ToFloat2(), 0);
if ((targetCell - self.Location).LengthSquared >= Range * Range)
return new Move( targetCell, Range ) { NextActivity = this };
var desiredFacing = Util.GetFacing((targetCell - self.Location).ToFloat2(), 0);
var renderUnit = self.traits.GetOrDefault<RenderUnit>();
var numDirs = (renderUnit != null)
? renderUnit.anim.CurrentSequence.Facings : 8;
@@ -57,7 +59,7 @@ namespace OpenRA.Mods.RA.Activities
public void Cancel(Actor self)
{
Target = null;
Target = new Target();
}
}
}