Increase IMove.MoveTo call flexibility.

This commit is contained in:
tovl
2019-09-06 21:48:15 +02:00
committed by abcdefg30
parent 28dbda29e3
commit 3236499fb7
7 changed files with 14 additions and 22 deletions

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Activities
// HACK: Repairable needs the actor to move to host center.
// TODO: Get rid of this or at least replace it with something less hacky.
if (repairableNear == null)
QueueChild(move.MoveTo(targetCell, host.Actor));
QueueChild(move.MoveTo(targetCell, ignoreActor: host.Actor));
var delta = (self.CenterPosition - host.CenterPosition).LengthSquared;
var transport = transportCallers.FirstOrDefault(t => t.MinimumDistance.LengthSquared < delta);
@@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Activities
if (wasRepaired || isHostInvalid || (!stayOnResupplier && aircraft.Info.TakeOffOnResupply))
{
if (self.CurrentActivity.NextActivity == null && rp != null)
QueueChild(move.MoveTo(rp.Location, repairableNear != null ? null : host.Actor, targetLineColor: Color.Green));
QueueChild(move.MoveTo(rp.Location, ignoreActor: repairableNear != null ? null : host.Actor, targetLineColor: Color.Green));
else
QueueChild(new TakeOff(self));
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.Activities
if (self.CurrentActivity.NextActivity == null)
{
if (rp != null)
QueueChild(move.MoveTo(rp.Location, repairableNear != null ? null : host.Actor));
QueueChild(move.MoveTo(rp.Location, ignoreActor: repairableNear != null ? null : host.Actor));
else if (repairableNear == null)
QueueChild(move.MoveToTarget(self, host));
}

View File

@@ -814,16 +814,12 @@ namespace OpenRA.Mods.Common.Traits
#region Implement IMove
public Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null)
public Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = null)
{
return new Fly(self, Target.FromCell(self.World, cell), WDist.FromCells(nearEnough), targetLineColor: targetLineColor);
}
public Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null)
{
return new Fly(self, Target.FromCell(self.World, cell), targetLineColor: targetLineColor);
}
public Activity MoveWithinRange(Target target, WDist range,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{

View File

@@ -589,14 +589,10 @@ namespace OpenRA.Mods.Common.Traits
return inner;
}
public Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null)
public Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = null)
{
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), targetLineColor: targetLineColor));
}
public Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null)
{
return WrapMove(new Move(self, cell, WDist.Zero, ignoreActor, targetLineColor: targetLineColor));
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), ignoreActor, evaluateNearestMovableCell, targetLineColor));
}
public Activity MoveWithinRange(Target target, WDist range,

View File

@@ -425,8 +425,8 @@ namespace OpenRA.Mods.Common.Traits
public interface IMove
{
Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null);
Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null);
Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = null);
Activity MoveWithinRange(Target target, WDist range,
WPos? initialTargetPosition = null, Color? targetLineColor = null);
Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,