make Activities.Land work with Targets.
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc
|
||||
|
||||
a.CancelActivity();
|
||||
|
||||
a.QueueActivity(new Land(self));
|
||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||
a.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
if (self.IsDead())
|
||||
|
||||
@@ -16,26 +16,21 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Land : IActivity
|
||||
{
|
||||
readonly float2 Pos;
|
||||
bool isCanceled;
|
||||
Actor Structure;
|
||||
Target Target;
|
||||
|
||||
public Land(float2 pos) { Pos = pos; }
|
||||
public Land(Actor structure) { Structure = structure; Pos = Structure.CenterLocation; }
|
||||
public Land(Target t) { Target = t; }
|
||||
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (Structure != null && Structure.IsDead())
|
||||
{
|
||||
Structure = null;
|
||||
isCanceled = true;
|
||||
}
|
||||
if (!Target.IsValid)
|
||||
Cancel(self);
|
||||
|
||||
if (isCanceled) return NextActivity;
|
||||
|
||||
var d = Pos - self.CenterLocation;
|
||||
var d = Target.CenterLocation - self.CenterLocation;
|
||||
if (d.LengthSquared < 50) /* close enough */
|
||||
return NextActivity;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
Actor dest;
|
||||
|
||||
float2 w1, w2, w3; /* tangent points to turn circles */
|
||||
float2 landPoint;
|
||||
|
||||
public static Actor ChooseAirfield(Actor self)
|
||||
{
|
||||
@@ -79,7 +78,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
w1 = c1 + f;
|
||||
w2 = c2 + f;
|
||||
w3 = approachStart;
|
||||
landPoint = landPos;
|
||||
|
||||
isCalculated = true;
|
||||
}
|
||||
@@ -99,7 +97,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
new Fly(w1),
|
||||
new Fly(w2),
|
||||
new Fly(w3),
|
||||
new Land(landPoint),
|
||||
new Land(Target.FromActor(dest)),
|
||||
NextActivity);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user