Define plumbing to pass initial target positions to inner move activities.
This commit is contained in:
@@ -182,11 +182,15 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public Activity MoveTo(CPos cell, int nearEnough) { return null; }
|
public Activity MoveTo(CPos cell, int nearEnough) { return null; }
|
||||||
public Activity MoveTo(CPos cell, Actor ignoreActor) { return null; }
|
public Activity MoveTo(CPos cell, Actor ignoreActor) { return null; }
|
||||||
public Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null) { return null; }
|
public Activity MoveWithinRange(Target target, WDist range,
|
||||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null) { return null; }
|
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
|
||||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null) { return null; }
|
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
|
||||||
|
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
|
||||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return null; }
|
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return null; }
|
||||||
public Activity MoveToTarget(Actor self, Target target, Color? targetLineColor = null) { return null; }
|
public Activity MoveToTarget(Actor self, Target target,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
|
||||||
public Activity MoveIntoTarget(Actor self, Target target) { return null; }
|
public Activity MoveIntoTarget(Actor self, Target target) { return null; }
|
||||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return null; }
|
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return null; }
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly WDist minRange;
|
readonly WDist minRange;
|
||||||
bool soundPlayed;
|
bool soundPlayed;
|
||||||
|
|
||||||
public Fly(Actor self, Target t, Color? targetLineColor = null)
|
public Fly(Actor self, Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
target = t;
|
target = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fly(Actor self, Target t, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public Fly(Actor self, Target t, WDist minRange, WDist maxRange,
|
||||||
: this(self, t)
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
|
: this(self, t, initialTargetPosition, targetLineColor)
|
||||||
{
|
{
|
||||||
this.maxRange = maxRange;
|
this.maxRange = maxRange;
|
||||||
this.minRange = minRange;
|
this.minRange = minRange;
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly Color? targetLineColor;
|
readonly Color? targetLineColor;
|
||||||
Target target;
|
Target target;
|
||||||
|
|
||||||
public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
|
|||||||
@@ -25,14 +25,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly WDist minRange;
|
readonly WDist minRange;
|
||||||
bool soundPlayed;
|
bool soundPlayed;
|
||||||
|
|
||||||
public HeliFly(Actor self, Target t, Color? targetLineColor = null)
|
public HeliFly(Actor self, Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
target = t;
|
target = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeliFly(Actor self, Target t, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public HeliFly(Actor self, Target t, WDist minRange, WDist maxRange,
|
||||||
: this(self, t)
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
|
: this(self, t, initialTargetPosition, targetLineColor)
|
||||||
{
|
{
|
||||||
this.maxRange = maxRange;
|
this.maxRange = maxRange;
|
||||||
this.minRange = minRange;
|
this.minRange = minRange;
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly IMove move;
|
readonly IMove move;
|
||||||
readonly Color? targetLineColor;
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
public Follow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public Follow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.minRange = minRange;
|
this.minRange = minRange;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
Activity inner;
|
Activity inner;
|
||||||
bool repath;
|
bool repath;
|
||||||
|
|
||||||
public MoveAdjacentTo(Actor self, Target target, Color? targetLineColor = null)
|
public MoveAdjacentTo(Actor self, Target target, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
Target = target;
|
Target = target;
|
||||||
|
|
||||||
@@ -56,7 +56,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
|
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
|
||||||
domainIndex = self.World.WorldActor.Trait<DomainIndex>();
|
domainIndex = self.World.WorldActor.Trait<DomainIndex>();
|
||||||
|
|
||||||
if (target.IsValidFor(self))
|
if (initialTargetPosition.HasValue)
|
||||||
|
targetPosition = self.World.Map.CellContaining(initialTargetPosition.Value);
|
||||||
|
else if (target.IsValidFor(self) && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||||
targetPosition = self.World.Map.CellContaining(target.CenterPosition);
|
targetPosition = self.World.Map.CellContaining(target.CenterPosition);
|
||||||
|
|
||||||
repath = true;
|
repath = true;
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly WDist maxRange;
|
readonly WDist maxRange;
|
||||||
readonly WDist minRange;
|
readonly WDist minRange;
|
||||||
|
|
||||||
public MoveWithinRange(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public MoveWithinRange(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
: base(self, target, targetLineColor)
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
|
: base(self, target, initialTargetPosition, targetLineColor)
|
||||||
{
|
{
|
||||||
this.minRange = minRange;
|
this.minRange = minRange;
|
||||||
this.maxRange = maxRange;
|
this.maxRange = maxRange;
|
||||||
|
|||||||
@@ -605,28 +605,35 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null)
|
public Activity MoveWithinRange(Target target, WDist range,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
if (!Info.CanHover)
|
if (!Info.CanHover)
|
||||||
return new Fly(self, target, WDist.Zero, range, targetLineColor);
|
return new Fly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
|
||||||
|
|
||||||
return new HeliFly(self, target, WDist.Zero, range, targetLineColor);
|
return new HeliFly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
if (!Info.CanHover)
|
if (!Info.CanHover)
|
||||||
return new Fly(self, target, minRange, maxRange, targetLineColor);
|
return new Fly(self, target, minRange, maxRange,
|
||||||
|
initialTargetPosition, targetLineColor);
|
||||||
|
|
||||||
return new HeliFly(self, target, minRange, maxRange, targetLineColor);
|
return new HeliFly(self, target, minRange, maxRange,
|
||||||
|
initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
if (!Info.CanHover)
|
if (!Info.CanHover)
|
||||||
return new FlyFollow(self, target, minRange, maxRange, targetLineColor);
|
return new FlyFollow(self, target, minRange, maxRange,
|
||||||
|
initialTargetPosition, targetLineColor);
|
||||||
|
|
||||||
return new Follow(self, target, minRange, maxRange, targetLineColor);
|
return new Follow(self, target, minRange, maxRange,
|
||||||
|
initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
||||||
@@ -637,12 +644,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new HeliFly(self, Target.FromCell(self.World, cell, subCell));
|
return new HeliFly(self, Target.FromCell(self.World, cell, subCell));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveToTarget(Actor self, Target target, Color? targetLineColor = null)
|
public Activity MoveToTarget(Actor self, Target target,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
if (!Info.CanHover)
|
if (!Info.CanHover)
|
||||||
return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5), targetLineColor);
|
return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5),
|
||||||
|
initialTargetPosition, targetLineColor);
|
||||||
|
|
||||||
return ActivityUtils.SequenceActivities(new HeliFly(self, target, targetLineColor), new Turn(self, Info.InitialFacing));
|
return ActivityUtils.SequenceActivities(
|
||||||
|
new HeliFly(self, target, initialTargetPosition, targetLineColor),
|
||||||
|
new Turn(self, Info.InitialFacing));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveIntoTarget(Actor self, Target target)
|
public Activity MoveIntoTarget(Actor self, Target target)
|
||||||
|
|||||||
@@ -467,19 +467,22 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Move(self, cell, WDist.Zero, ignoreActor);
|
return new Move(self, cell, WDist.Zero, ignoreActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null)
|
public Activity MoveWithinRange(Target target, WDist range,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new MoveWithinRange(self, target, WDist.Zero, range, targetLineColor);
|
return new MoveWithinRange(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new MoveWithinRange(self, target, minRange, maxRange, targetLineColor);
|
return new MoveWithinRange(self, target, minRange, maxRange, initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
|
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new Follow(self, target, minRange, maxRange, targetLineColor);
|
return new Follow(self, target, minRange, maxRange, initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
||||||
@@ -500,12 +503,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return VisualMove(self, pos, self.World.Map.CenterOfSubCell(cell, subCell), cell);
|
return VisualMove(self, pos, self.World.Map.CenterOfSubCell(cell, subCell), cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveToTarget(Actor self, Target target, Color? targetLineColor = null)
|
public Activity MoveToTarget(Actor self, Target target,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
if (target.Type == TargetType.Invalid)
|
if (target.Type == TargetType.Invalid)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new MoveAdjacentTo(self, target, targetLineColor);
|
return new MoveAdjacentTo(self, target, initialTargetPosition, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveIntoTarget(Actor self, Target target)
|
public Activity MoveIntoTarget(Actor self, Target target)
|
||||||
|
|||||||
@@ -397,11 +397,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
Activity MoveTo(CPos cell, int nearEnough);
|
Activity MoveTo(CPos cell, int nearEnough);
|
||||||
Activity MoveTo(CPos cell, Actor ignoreActor);
|
Activity MoveTo(CPos cell, Actor ignoreActor);
|
||||||
Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null);
|
Activity MoveWithinRange(Target target, WDist range,
|
||||||
Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null);
|
WPos? initialTargetPosition = null, Color? targetLineColor = null);
|
||||||
Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null);
|
Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null);
|
||||||
|
Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null);
|
||||||
|
Activity MoveToTarget(Actor self, Target target,
|
||||||
|
WPos? initialTargetPosition = null, Color? targetLineColor = null);
|
||||||
Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any);
|
Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any);
|
||||||
Activity MoveToTarget(Actor self, Target target, Color? targetLineColor = null);
|
|
||||||
Activity MoveIntoTarget(Actor self, Target target);
|
Activity MoveIntoTarget(Actor self, Target target);
|
||||||
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
||||||
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
|
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
|
||||||
|
|||||||
Reference in New Issue
Block a user