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

@@ -10,6 +10,7 @@
#endregion
using System;
using System.Drawing;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;
@@ -28,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
readonly int maxTries = 0;
readonly EnterBehaviour enterBehaviour;
readonly bool repathWhileMoving;
readonly Color? targetLineColor;
public Target Target { get { return target; } }
Target target;
@@ -37,13 +39,15 @@ namespace OpenRA.Mods.Common.Activities
Activity inner;
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>();
this.target = Target.FromActor(target);
this.maxTries = maxTries;
this.enterBehaviour = enterBehaviour;
this.repathWhileMoving = repathWhileMoving;
this.targetLineColor = targetLineColor;
}
// CanEnter(target) should to be true; otherwise, Enter may abort.
@@ -183,7 +187,7 @@ namespace OpenRA.Mods.Common.Activities
case ReserveStatus.TooFar:
{
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;
}