Pass target line color to inner move activities.

This commit is contained in:
Paul Chote
2019-01-13 16:36:30 +00:00
parent 62102b9f77
commit b2d960ec19
32 changed files with 127 additions and 68 deletions

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Cnc.Traits; using OpenRA.Mods.Cnc.Traits;
@@ -25,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Activities
readonly INotifyInfiltration[] notifiers; readonly INotifyInfiltration[] notifiers;
public Infiltrate(Actor self, Actor target, Infiltrates infiltrate) public Infiltrate(Actor self, Actor target, Infiltrates infiltrate)
: base(self, target, infiltrate.Info.EnterBehaviour) : base(self, target, infiltrate.Info.EnterBehaviour, targetLineColor: Color.Red)
{ {
this.target = target; this.target = target;
infiltrates = infiltrate; infiltrates = infiltrate;

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Cnc.Traits; using OpenRA.Mods.Cnc.Traits;
@@ -73,7 +74,7 @@ namespace OpenRA.Mods.Cnc.Activities
if (!allowMovement) if (!allowMovement)
return NextActivity; return NextActivity;
QueueChild(new MoveWithinRange(self, target, minRange, maxRange)); QueueChild(mobile.MoveWithinRange(target, minRange, maxRange, targetLineColor: Color.Red));
return this; return this;
} }

View File

@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Cnc.Traits
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(target, Color.Red); self.SetTargetLine(target, Color.Red);
self.QueueActivity(new MoveAdjacentTo(self, target)); self.QueueActivity(new MoveAdjacentTo(self, target, targetLineColor: Color.Red));
self.QueueActivity(new CallFunc(StartDetonationSequence)); self.QueueActivity(new CallFunc(StartDetonationSequence));
} }
else if (order.OrderString == "Detonate") else if (order.OrderString == "Detonate")

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common; using OpenRA.Mods.Common;
@@ -181,11 +182,11 @@ 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) { return null; } public Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null) { return null; }
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange) { return null; } public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null) { return null; }
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) { return null; } public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, 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) { return null; } public Activity MoveToTarget(Actor self, Target target, 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; }

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -24,13 +25,13 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist minRange; readonly WDist minRange;
bool soundPlayed; bool soundPlayed;
public Fly(Actor self, Target t) public Fly(Actor self, Target t, 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) public Fly(Actor self, Target t, WDist minRange, WDist maxRange, Color? targetLineColor = null)
: this(self, t) : this(self, t)
{ {
this.maxRange = maxRange; this.maxRange = maxRange;

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -17,17 +18,19 @@ namespace OpenRA.Mods.Common.Activities
{ {
public class FlyFollow : Activity public class FlyFollow : Activity
{ {
readonly Aircraft aircraft;
readonly WDist minRange;
readonly WDist maxRange;
readonly Color? targetLineColor;
Target target; Target target;
Aircraft aircraft;
WDist minRange;
WDist maxRange;
public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange) public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
{ {
this.target = target; this.target = target;
aircraft = self.Trait<Aircraft>(); aircraft = self.Trait<Aircraft>();
this.minRange = minRange; this.minRange = minRange;
this.maxRange = maxRange; this.maxRange = maxRange;
this.targetLineColor = targetLineColor;
} }
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
@@ -48,7 +51,7 @@ namespace OpenRA.Mods.Common.Activities
return this; return this;
} }
return ActivityUtils.SequenceActivities(new Fly(self, target, minRange, maxRange), this); return ActivityUtils.SequenceActivities(new Fly(self, target, minRange, maxRange, targetLineColor: targetLineColor), this);
} }
} }
} }

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -24,13 +25,13 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist minRange; readonly WDist minRange;
bool soundPlayed; bool soundPlayed;
public HeliFly(Actor self, Target t) public HeliFly(Actor self, Target t, 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) public HeliFly(Actor self, Target t, WDist minRange, WDist maxRange, Color? targetLineColor = null)
: this(self, t) : this(self, t)
{ {
this.maxRange = maxRange; this.maxRange = maxRange;

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -89,7 +90,9 @@ namespace OpenRA.Mods.Common.Activities
var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition); var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition);
return ActivityUtils.SequenceActivities(new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase), this); return ActivityUtils.SequenceActivities(
new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green),
this);
} }
return this; return this;

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -140,7 +141,7 @@ namespace OpenRA.Mods.Common.Activities
if (nearestResupplier != null) if (nearestResupplier != null)
return ActivityUtils.SequenceActivities( return ActivityUtils.SequenceActivities(
new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase), new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green),
new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport),
this); this);
else else

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -104,7 +105,7 @@ namespace OpenRA.Mods.Common.Activities
var sightRange = rs != null ? rs.Range : WDist.FromCells(2); var sightRange = rs != null ? rs.Range : WDist.FromCells(2);
attackStatus |= AttackStatus.NeedsToMove; attackStatus |= AttackStatus.NeedsToMove;
moveActivity = ActivityUtils.SequenceActivities(move.MoveWithinRange(target, sightRange), this); moveActivity = ActivityUtils.SequenceActivities(move.MoveWithinRange(target, sightRange, targetLineColor: Color.Red), this);
return AttackStatus.NeedsToMove; return AttackStatus.NeedsToMove;
} }
@@ -128,7 +129,7 @@ namespace OpenRA.Mods.Common.Activities
return AttackStatus.UnableToAttack; return AttackStatus.UnableToAttack;
attackStatus |= AttackStatus.NeedsToMove; attackStatus |= AttackStatus.NeedsToMove;
moveActivity = ActivityUtils.SequenceActivities(move.MoveWithinRange(target, minRange, maxRange), this); moveActivity = ActivityUtils.SequenceActivities(move.MoveWithinRange(target, minRange, maxRange, targetLineColor: Color.Red), this);
return AttackStatus.NeedsToMove; return AttackStatus.NeedsToMove;
} }

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
readonly CaptureManager manager; readonly CaptureManager manager;
public CaptureActor(Actor self, Actor target) public CaptureActor(Actor self, Actor target)
: base(self, target, EnterBehaviour.Exit) : base(self, target, EnterBehaviour.Exit, targetLineColor: Color.Red)
{ {
actor = target; actor = target;
manager = self.Trait<CaptureManager>(); manager = self.Trait<CaptureManager>();

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -27,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
public Demolish(Actor self, Actor target, EnterBehaviour enterBehaviour, int delay, public Demolish(Actor self, Actor target, EnterBehaviour enterBehaviour, int delay,
int flashes, int flashesDelay, int flashInterval) int flashes, int flashesDelay, int flashInterval)
: base(self, target, enterBehaviour) : base(self, target, enterBehaviour, targetLineColor: Color.Red)
{ {
this.target = target; this.target = target;
demolishables = target.TraitsImplementing<IDemolishable>().ToArray(); demolishables = target.TraitsImplementing<IDemolishable>().ToArray();

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
readonly int experience; readonly int experience;
public DonateCash(Actor self, Actor target, int payload, int playerExperience) public DonateCash(Actor self, Actor target, int payload, int playerExperience)
: base(self, target, EnterBehaviour.Dispose) : base(self, target, EnterBehaviour.Dispose, targetLineColor: Color.Yellow)
{ {
this.target = target; this.target = target;
this.payload = payload; this.payload = payload;

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
readonly int playerExperience; readonly int playerExperience;
public DonateExperience(Actor self, Actor target, int level, int playerExperience, GainsExperience targetGainsExperience) public DonateExperience(Actor self, Actor target, int level, int playerExperience, GainsExperience targetGainsExperience)
: base(self, target, EnterBehaviour.Dispose) : base(self, target, EnterBehaviour.Dispose, targetLineColor: Color.Yellow)
{ {
this.target = target; this.target = target;
this.level = level; this.level = level;

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
@@ -28,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
readonly int maxTries = 0; readonly int maxTries = 0;
readonly EnterBehaviour enterBehaviour; readonly EnterBehaviour enterBehaviour;
readonly bool repathWhileMoving; readonly bool repathWhileMoving;
readonly Color? targetLineColor;
public Target Target { get { return target; } } public Target Target { get { return target; } }
Target target; Target target;
@@ -37,13 +39,15 @@ namespace OpenRA.Mods.Common.Activities
Activity inner; Activity inner;
bool firstApproach = true; bool firstApproach = true;
protected Enter(Actor self, Actor target, EnterBehaviour enterBehaviour, int maxTries = 1, bool repathWhileMoving = true) protected Enter(Actor self, Actor target, EnterBehaviour enterBehaviour, int maxTries = 1,
bool repathWhileMoving = true, Color? targetLineColor = null)
{ {
move = self.Trait<IMove>(); move = self.Trait<IMove>();
this.target = Target.FromActor(target); this.target = Target.FromActor(target);
this.maxTries = maxTries; this.maxTries = maxTries;
this.enterBehaviour = enterBehaviour; this.enterBehaviour = enterBehaviour;
this.repathWhileMoving = repathWhileMoving; this.repathWhileMoving = repathWhileMoving;
this.targetLineColor = targetLineColor;
} }
// CanEnter(target) should to be true; otherwise, Enter may abort. // CanEnter(target) should to be true; otherwise, Enter may abort.
@@ -183,7 +187,7 @@ namespace OpenRA.Mods.Common.Activities
case ReserveStatus.TooFar: case ReserveStatus.TooFar:
{ {
var moveTarget = repathWhileMoving ? target : Target.FromPos(target.Positions.PositionClosestTo(self.CenterPosition)); var moveTarget = repathWhileMoving ? target : Target.FromPos(target.Positions.PositionClosestTo(self.CenterPosition));
inner = move.MoveToTarget(self, moveTarget); // Approach inner = move.MoveToTarget(self, moveTarget, targetLineColor: targetLineColor); // Approach
return EnterState.ApproachingOrEntering; return EnterState.ApproachingOrEntering;
} }

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Drawing;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -23,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities
Cargo cargo; Cargo cargo;
public EnterTransport(Actor self, Actor transport, int maxTries = 0, bool repathWhileMoving = true) public EnterTransport(Actor self, Actor transport, int maxTries = 0, bool repathWhileMoving = true)
: base(self, transport, EnterBehaviour.Exit, maxTries, repathWhileMoving) : base(self, transport, EnterBehaviour.Exit, maxTries, repathWhileMoving, Color.Green)
{ {
this.transport = transport; this.transport = transport;
this.maxTries = maxTries; this.maxTries = maxTries;

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -21,12 +22,14 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist minRange; readonly WDist minRange;
readonly WDist maxRange; readonly WDist maxRange;
readonly IMove move; readonly IMove move;
readonly Color? targetLineColor;
public Follow(Actor self, Target target, WDist minRange, WDist maxRange) public Follow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
{ {
this.target = target; this.target = target;
this.minRange = minRange; this.minRange = minRange;
this.maxRange = maxRange; this.maxRange = maxRange;
this.targetLineColor = targetLineColor;
move = self.Trait<IMove>(); move = self.Trait<IMove>();
} }
@@ -37,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
var cachedPosition = target.CenterPosition; var cachedPosition = target.CenterPosition;
var path = move.MoveWithinRange(target, minRange, maxRange); var path = move.MoveWithinRange(target, minRange, maxRange, targetLineColor: targetLineColor);
// We are already in range, so wait until the target moves before doing anything // We are already in range, so wait until the target moves before doing anything
if (target.IsInRange(self.CenterPosition, maxRange) && !target.IsInRange(self.CenterPosition, minRange)) if (target.IsInRange(self.CenterPosition, maxRange) && !target.IsInRange(self.CenterPosition, minRange))

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
Activity inner; Activity inner;
bool repath; bool repath;
public MoveAdjacentTo(Actor self, Target target) public MoveAdjacentTo(Actor self, Target target, Color? targetLineColor = null)
{ {
Target = target; Target = target;

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;
@@ -20,8 +21,8 @@ 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) public MoveWithinRange(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
: base(self, target) : base(self, target, targetLineColor)
{ {
this.minRange = minRange; this.minRange = minRange;
this.maxRange = maxRange; this.maxRange = maxRange;

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -72,7 +73,8 @@ namespace OpenRA.Mods.Common.Activities
switch (state) switch (state)
{ {
case PickupState.Intercept: case PickupState.Intercept:
innerActivity = movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4)); innerActivity = movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4),
targetLineColor: Color.Yellow);
state = PickupState.LockCarryable; state = PickupState.LockCarryable;
return this; return this;

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
readonly string notification; readonly string notification;
public RepairBridge(Actor self, Actor target, EnterBehaviour enterBehaviour, string notification) public RepairBridge(Actor self, Actor target, EnterBehaviour enterBehaviour, string notification)
: base(self, target, enterBehaviour) : base(self, target, enterBehaviour, targetLineColor: Color.Yellow)
{ {
this.target = target; this.target = target;
legacyHut = target.TraitOrDefault<LegacyBridgeHut>(); legacyHut = target.TraitOrDefault<LegacyBridgeHut>();

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities namespace OpenRA.Mods.Common.Activities
@@ -20,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Stance validStances; readonly Stance validStances;
public RepairBuilding(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances) public RepairBuilding(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances)
: base(self, target, enterBehaviour) : base(self, target, enterBehaviour, targetLineColor: Color.Yellow)
{ {
this.target = target; this.target = target;
this.validStances = validStances; this.validStances = validStances;

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common
/// <summary> /// <summary>
/// DEPRECATED: Write code that can handle FrozenActors correctly instead. /// DEPRECATED: Write code that can handle FrozenActors correctly instead.
/// </summary> /// </summary>
public static Target ResolveFrozenActorOrder(this Actor self, Order order, Color targetLine) public static Target ResolveFrozenActorOrder(this Actor self, Order order, Color targetLineColor)
{ {
// Not targeting a frozen actor // Not targeting a frozen actor
if (order.Target.Type != TargetType.FrozenActor) if (order.Target.Type != TargetType.FrozenActor)
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common
var frozen = order.Target.FrozenActor; var frozen = order.Target.FrozenActor;
self.SetTargetLine(order.Target, targetLine, true); self.SetTargetLine(order.Target, targetLineColor, true);
// Target is still alive - resolve the real order // Target is still alive - resolve the real order
if (frozen.Actor != null && frozen.Actor.IsInWorld) if (frozen.Actor != null && frozen.Actor.IsInWorld)
@@ -89,7 +89,8 @@ namespace OpenRA.Mods.Common
.Append(WDist.FromCells(2)) .Append(WDist.FromCells(2))
.Max(); .Max();
self.QueueActivity(move.MoveWithinRange(Target.FromPos(frozen.CenterPosition), range)); self.QueueActivity(move.MoveWithinRange(Target.FromPos(frozen.CenterPosition), range,
targetLineColor: targetLineColor));
} }
return Target.Invalid; return Target.Invalid;

View File

@@ -605,28 +605,28 @@ 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) public Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null)
{ {
if (!Info.CanHover) if (!Info.CanHover)
return new Fly(self, target, WDist.Zero, range); return new Fly(self, target, WDist.Zero, range, targetLineColor);
return new HeliFly(self, target, WDist.Zero, range); return new HeliFly(self, target, WDist.Zero, range, targetLineColor);
} }
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange) public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
{ {
if (!Info.CanHover) if (!Info.CanHover)
return new Fly(self, target, minRange, maxRange); return new Fly(self, target, minRange, maxRange, targetLineColor);
return new HeliFly(self, target, minRange, maxRange); return new HeliFly(self, target, minRange, maxRange, targetLineColor);
} }
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
{ {
if (!Info.CanHover) if (!Info.CanHover)
return new FlyFollow(self, target, minRange, maxRange); return new FlyFollow(self, target, minRange, maxRange, targetLineColor);
return new Follow(self, target, minRange, maxRange); return new Follow(self, target, minRange, maxRange, 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 +637,12 @@ 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) public Activity MoveToTarget(Actor self, Target target, Color? targetLineColor = null)
{ {
if (!Info.CanHover) if (!Info.CanHover)
return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5)); return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5), targetLineColor);
return ActivityUtils.SequenceActivities(new HeliFly(self, target), new Turn(self, Info.InitialFacing)); return ActivityUtils.SequenceActivities(new HeliFly(self, target, targetLineColor), new Turn(self, Info.InitialFacing));
} }
public Activity MoveIntoTarget(Actor self, Target target) public Activity MoveIntoTarget(Actor self, Target target)

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
@@ -122,7 +123,10 @@ namespace OpenRA.Mods.Common.Traits
hasTicked = true; hasTicked = true;
if (move != null) if (move != null)
return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this); return ActivityUtils.SequenceActivities(
move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange, targetLineColor: Color.Red),
this);
if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) && if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) &&
!target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange)) !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange))
return this; return this;

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
self.SetTargetLine(target, Color.Red); self.SetTargetLine(target, Color.Red);
self.QueueActivity(move.MoveToTarget(self, target)); self.QueueActivity(move.MoveToTarget(self, target, targetLineColor: Color.Red));
self.QueueActivity(new CallFunc(() => self.Kill(self, Info.DamageTypes))); self.QueueActivity(new CallFunc(() => self.Kill(self, Info.DamageTypes)));
} }

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
self.SetTargetLine(target, Color.Yellow); self.SetTargetLine(target, Color.Yellow);
var range = target.Actor.Info.TraitInfo<GuardableInfo>().Range; var range = target.Actor.Info.TraitInfo<GuardableInfo>().Range;
self.QueueActivity(new AttackMoveActivity(self, move.MoveFollow(self, target, WDist.Zero, range))); self.QueueActivity(new AttackMoveActivity(self, move.MoveFollow(self, target, WDist.Zero, range, targetLineColor: Color.Yellow)));
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)

View File

@@ -457,11 +457,30 @@ namespace OpenRA.Mods.Common.Traits
#region IMove #region IMove
public Activity MoveTo(CPos cell, int nearEnough) { return new Move(self, cell, WDist.FromCells(nearEnough)); } public Activity MoveTo(CPos cell, int nearEnough)
public Activity MoveTo(CPos cell, Actor ignoreActor) { return new Move(self, cell, WDist.Zero, ignoreActor); } {
public Activity MoveWithinRange(Target target, WDist range) { return new MoveWithinRange(self, target, WDist.Zero, range); } return new Move(self, cell, WDist.FromCells(nearEnough));
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange) { return new MoveWithinRange(self, target, minRange, maxRange); } }
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) { return new Follow(self, target, minRange, maxRange); }
public Activity MoveTo(CPos cell, Actor ignoreActor)
{
return new Move(self, cell, WDist.Zero, ignoreActor);
}
public Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null)
{
return new MoveWithinRange(self, target, WDist.Zero, range, targetLineColor);
}
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
{
return new MoveWithinRange(self, target, minRange, maxRange, targetLineColor);
}
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null)
{
return new Follow(self, target, minRange, maxRange, targetLineColor);
}
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
{ {
@@ -481,12 +500,12 @@ 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) public Activity MoveToTarget(Actor self, Target target, Color? targetLineColor = null)
{ {
if (target.Type == TargetType.Invalid) if (target.Type == TargetType.Invalid)
return null; return null;
return new MoveAdjacentTo(self, target); return new MoveAdjacentTo(self, target, targetLineColor);
} }
public Activity MoveIntoTarget(Actor self, Target target) public Activity MoveIntoTarget(Actor self, Target target)

View File

@@ -112,8 +112,12 @@ namespace OpenRA.Mods.Common.Traits
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(order.Target, Color.Green); self.SetTargetLine(order.Target, Color.Green);
self.QueueActivity(new WaitForTransport(self, ActivityUtils.SequenceActivities(movement.MoveToTarget(self, order.Target),
new CallFunc(() => AfterReachActivities(self, order, movement))))); var activities = ActivityUtils.SequenceActivities(
movement.MoveToTarget(self, order.Target, targetLineColor: Color.Green),
new CallFunc(() => AfterReachActivities(self, order, movement)));
self.QueueActivity(new WaitForTransport(self, activities));
TryCallTransport(self, order.Target, new CallFunc(() => AfterReachActivities(self, order, movement))); TryCallTransport(self, order.Target, new CallFunc(() => AfterReachActivities(self, order, movement)));
} }

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
if (!order.Queued) if (!order.Queued)
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(movement.MoveWithinRange(order.Target, info.CloseEnough)); self.QueueActivity(movement.MoveWithinRange(order.Target, info.CloseEnough, targetLineColor: Color.Green));
self.QueueActivity(new Repair(self, order.Target.Actor, info.CloseEnough)); self.QueueActivity(new Repair(self, order.Target.Actor, info.CloseEnough));
self.SetTargetLine(order.Target, Color.Green, false); self.SetTargetLine(order.Target, Color.Green, false);

View File

@@ -397,11 +397,11 @@ 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); Activity MoveWithinRange(Target target, WDist range, Color? targetLineColor = null);
Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange); Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange, Color? targetLineColor = null);
Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange); Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, 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); 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);

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -66,7 +67,7 @@ namespace OpenRA.Mods.D2k.Traits
if (IsMovingTowardTarget) if (IsMovingTowardTarget)
return; return;
self.QueueActivity(mobile.MoveWithinRange(Target.FromCell(self.World, targetCell, SubCell.Any), WDist.FromCells(1))); self.QueueActivity(mobile.MoveWithinRange(Target.FromCell(self.World, targetCell, SubCell.Any), WDist.FromCells(1), targetLineColor: Color.Red));
} }
void ITick.Tick(Actor self) void ITick.Tick(Actor self)