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