Overhaul target line rendering:
- Targets are now defined by the activities - Queued activities are shown - Support custom attack colors
This commit is contained in:
@@ -31,6 +31,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly IFacing facing;
|
||||
readonly IPositionable positionable;
|
||||
readonly bool forceAttack;
|
||||
readonly Color? targetLineColor;
|
||||
|
||||
protected Target target;
|
||||
Target lastVisibleTarget;
|
||||
@@ -44,9 +45,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
WDist maxRange;
|
||||
AttackStatus attackStatus = AttackStatus.UnableToAttack;
|
||||
|
||||
public Attack(Actor self, Target target, bool allowMovement, bool forceAttack)
|
||||
public Attack(Actor self, Target target, bool allowMovement, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
this.target = target;
|
||||
this.targetLineColor = targetLineColor;
|
||||
this.forceAttack = forceAttack;
|
||||
|
||||
attackTraits = self.TraitsImplementing<AttackFrontal>().ToArray();
|
||||
@@ -100,7 +102,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
||||
}
|
||||
|
||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||
|
||||
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
||||
@@ -108,10 +109,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (wasMovingWithinRange && targetIsHiddenActor)
|
||||
return true;
|
||||
|
||||
// Update target lines if required
|
||||
if (useLastVisibleTarget != oldUseLastVisibleTarget)
|
||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, Color.Red, false);
|
||||
|
||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||
return true;
|
||||
@@ -231,5 +228,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
||||
target = Target.Invalid;
|
||||
}
|
||||
|
||||
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||
{
|
||||
if (targetLineColor != null)
|
||||
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user