Overhaul target line rendering:
- Targets are now defined by the activities - Queued activities are shown - Support custom attack colors
This commit is contained in:
@@ -12,12 +12,27 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Activities
|
namespace OpenRA.Activities
|
||||||
{
|
{
|
||||||
public enum ActivityState { Queued, Active, Canceling, Done }
|
public enum ActivityState { Queued, Active, Canceling, Done }
|
||||||
|
|
||||||
|
public class TargetLineNode
|
||||||
|
{
|
||||||
|
public readonly Target Target;
|
||||||
|
public readonly Color Color;
|
||||||
|
|
||||||
|
public TargetLineNode(Target target, Color color)
|
||||||
|
{
|
||||||
|
// Note: Not all activities are drawable. In that case, pass Target.Invalid as target,
|
||||||
|
// if "yield break" in TargetLineNode(Actor self) is not feasible.
|
||||||
|
Target = target;
|
||||||
|
Color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Things to be aware of when writing activities:
|
* Things to be aware of when writing activities:
|
||||||
*
|
*
|
||||||
@@ -204,6 +219,11 @@ namespace OpenRA.Activities
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<string> DebugLabelComponents()
|
public IEnumerable<string> DebugLabelComponents()
|
||||||
{
|
{
|
||||||
var act = this;
|
var act = this;
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
readonly IEnumerable<WPos> waypoints;
|
readonly IEnumerable<WPos> waypoints;
|
||||||
readonly Color color;
|
readonly Color color;
|
||||||
|
readonly int width;
|
||||||
|
readonly int markerSize;
|
||||||
|
|
||||||
public TargetLineRenderable(IEnumerable<WPos> waypoints, Color color)
|
public TargetLineRenderable(IEnumerable<WPos> waypoints, Color color, int width = 1, int markerSize = 1)
|
||||||
{
|
{
|
||||||
this.waypoints = waypoints;
|
this.waypoints = waypoints;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.width = width;
|
||||||
|
this.markerSize = markerSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WPos Pos { get { return waypoints.First(); } }
|
public WPos Pos { get { return waypoints.First(); } }
|
||||||
@@ -42,23 +46,23 @@ namespace OpenRA.Graphics
|
|||||||
if (!waypoints.Any())
|
if (!waypoints.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var iz = 1 / wr.Viewport.Zoom;
|
var sw = width / wr.Viewport.Zoom;
|
||||||
var first = wr.Screen3DPosition(waypoints.First());
|
var first = wr.Screen3DPosition(waypoints.First());
|
||||||
var a = first;
|
var a = first;
|
||||||
foreach (var b in waypoints.Skip(1).Select(pos => wr.Screen3DPosition(pos)))
|
foreach (var b in waypoints.Skip(1).Select(pos => wr.Screen3DPosition(pos)))
|
||||||
{
|
{
|
||||||
Game.Renderer.WorldRgbaColorRenderer.DrawLine(a, b, iz, color);
|
Game.Renderer.WorldRgbaColorRenderer.DrawLine(a, b, sw, color);
|
||||||
DrawTargetMarker(wr, color, b);
|
DrawTargetMarker(wr, color, b, markerSize);
|
||||||
a = b;
|
a = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawTargetMarker(wr, color, first);
|
DrawTargetMarker(wr, color, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawTargetMarker(WorldRenderer wr, Color color, float3 location)
|
public static void DrawTargetMarker(WorldRenderer wr, Color color, float3 location, int size = 1)
|
||||||
{
|
{
|
||||||
var iz = 1 / wr.Viewport.Zoom;
|
var sw = size / wr.Viewport.Zoom;
|
||||||
var offset = new float2(iz, iz);
|
var offset = new float2(sw, sw);
|
||||||
var tl = location - offset;
|
var tl = location - offset;
|
||||||
var br = location + offset;
|
var br = location + offset;
|
||||||
Game.Renderer.WorldRgbaColorRenderer.FillRect(tl, br, color);
|
Game.Renderer.WorldRgbaColorRenderer.FillRect(tl, br, color);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Cnc.Traits;
|
using OpenRA.Mods.Cnc.Traits;
|
||||||
@@ -27,6 +28,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
readonly Mobile mobile;
|
readonly Mobile mobile;
|
||||||
readonly bool allowMovement;
|
readonly bool allowMovement;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
Target target;
|
Target target;
|
||||||
Target lastVisibleTarget;
|
Target lastVisibleTarget;
|
||||||
@@ -36,9 +38,10 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
BitSet<TargetableType> lastVisibleTargetTypes;
|
BitSet<TargetableType> lastVisibleTargetTypes;
|
||||||
Player lastVisibleOwner;
|
Player lastVisibleOwner;
|
||||||
|
|
||||||
public LeapAttack(Actor self, Target target, bool allowMovement, bool forceAttack, AttackLeap attack, AttackLeapInfo info)
|
public LeapAttack(Actor self, Target target, bool allowMovement, bool forceAttack, AttackLeap attack, AttackLeapInfo info, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.attack = attack;
|
this.attack = attack;
|
||||||
this.allowMovement = allowMovement;
|
this.allowMovement = allowMovement;
|
||||||
@@ -88,13 +91,8 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
|
|
||||||
// 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
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -161,5 +159,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
||||||
target = Target.Invalid;
|
target = Target.Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Cnc.Activities;
|
using OpenRA.Mods.Cnc.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Traits
|
namespace OpenRA.Mods.Cnc.Traits
|
||||||
@@ -71,9 +72,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
leapToken = conditionManager.RevokeCondition(self, leapToken);
|
leapToken = conditionManager.RevokeCondition(self, leapToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||||
{
|
{
|
||||||
return new LeapAttack(self, newTarget, allowMove, forceAttack, this, info);
|
return new LeapAttack(self, newTarget, allowMove, forceAttack, this, info, targetLineColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Traits
|
namespace OpenRA.Mods.Cnc.Traits
|
||||||
@@ -27,9 +30,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info)
|
public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info)
|
||||||
: base(self, info) { }
|
: base(self, info) { }
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||||
{
|
{
|
||||||
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack);
|
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AttackTDGunboatTurretedActivity : Activity
|
class AttackTDGunboatTurretedActivity : Activity
|
||||||
@@ -37,13 +40,15 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
readonly AttackTDGunboatTurreted attack;
|
readonly AttackTDGunboatTurreted attack;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
bool hasTicked;
|
bool hasTicked;
|
||||||
|
|
||||||
public AttackTDGunboatTurretedActivity(Actor self, Target target, bool allowMove, bool forceAttack)
|
public AttackTDGunboatTurretedActivity(Actor self, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
attack = self.Trait<AttackTDGunboatTurreted>();
|
attack = self.Trait<AttackTDGunboatTurreted>();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
@@ -68,6 +73,12 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Traits
|
namespace OpenRA.Mods.Cnc.Traits
|
||||||
@@ -76,9 +78,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new ChargeAttack(this, newTarget, forceAttack);
|
return new ChargeAttack(this, newTarget, forceAttack, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChargeAttack : Activity, IActivityNotifyStanceChanged
|
class ChargeAttack : Activity, IActivityNotifyStanceChanged
|
||||||
@@ -86,12 +88,14 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
readonly AttackTesla attack;
|
readonly AttackTesla attack;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
public ChargeAttack(AttackTesla attack, Target target, bool forceAttack)
|
public ChargeAttack(AttackTesla attack, Target target, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
this.attack = attack;
|
this.attack = attack;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
@@ -132,6 +136,12 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
Cancel(self, true);
|
Cancel(self, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChargeFire : Activity
|
class ChargeFire : Activity
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Red);
|
|
||||||
self.QueueActivity(new Infiltrate(self, order.Target, this));
|
self.QueueActivity(new Infiltrate(self, order.Target, this));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
{
|
{
|
||||||
if (order.OrderString == "DetonateAttack")
|
if (order.OrderString == "DetonateAttack")
|
||||||
{
|
{
|
||||||
self.SetTargetLine(order.Target, Color.Red);
|
|
||||||
self.QueueActivity(order.Queued, new DetonationSequence(self, this, order.Target));
|
self.QueueActivity(order.Queued, new DetonationSequence(self, this, order.Target));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Detonate")
|
else if (order.OrderString == "Detonate")
|
||||||
self.QueueActivity(order.Queued, new DetonationSequence(self, this));
|
self.QueueActivity(order.Queued, new DetonationSequence(self, this));
|
||||||
@@ -248,6 +248,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield return new TargetLineNode(target, Color.Crimson);
|
||||||
|
}
|
||||||
|
|
||||||
void EjectDriver()
|
void EjectDriver()
|
||||||
{
|
{
|
||||||
var driver = self.World.CreateActor(mad.info.DriverActor.ToLowerInvariant(), new TypeDictionary
|
var driver = self.World.CreateActor(mad.info.DriverActor.ToLowerInvariant(), new TypeDictionary
|
||||||
|
|||||||
@@ -112,10 +112,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
Minefield = GetMinefieldCells(minefieldStart, cell, info.MinefieldDepth)
|
Minefield = GetMinefieldCells(minefieldStart, cell, info.MinefieldDepth)
|
||||||
.Where(p => movement.CanEnterCell(p, null, false)).ToArray();
|
.Where(p => movement.CanEnterCell(p, null, false)).ToArray();
|
||||||
|
|
||||||
if (Minefield.Length == 1 && Minefield[0] != self.Location)
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, Minefield[0]), Color.Red);
|
|
||||||
|
|
||||||
self.QueueActivity(order.Queued, new LayMines(self, Minefield));
|
self.QueueActivity(order.Queued, new LayMines(self, Minefield));
|
||||||
|
if (Minefield.Length == 1 && Minefield[0] != self.Location)
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,12 +114,12 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
var cell = self.World.Map.CellContaining(order.Target.CenterPosition);
|
var cell = self.World.Map.CellContaining(order.Target.CenterPosition);
|
||||||
self.SetTargetLine(order.Target, Color.LawnGreen);
|
|
||||||
if (maxDistance != null)
|
if (maxDistance != null)
|
||||||
self.QueueActivity(move.MoveWithinRange(order.Target, WDist.FromCells(maxDistance.Value)));
|
self.QueueActivity(move.MoveWithinRange(order.Target, WDist.FromCells(maxDistance.Value), targetLineColor: Color.LawnGreen));
|
||||||
|
|
||||||
self.QueueActivity(new Teleport(self, cell, maxDistance, Info.KillCargo, Info.FlashScreen, Info.ChronoshiftSound));
|
self.QueueActivity(new Teleport(self, cell, maxDistance, Info.KillCargo, Info.FlashScreen, Info.ChronoshiftSound));
|
||||||
self.QueueActivity(move.MoveTo(cell, 5));
|
self.QueueActivity(move.MoveTo(cell, 5, Color.LawnGreen));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
self.World.UpdateMaps(self, this);
|
self.World.UpdateMaps(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveTo(CPos cell, int nearEnough) { return null; }
|
public Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null) { return null; }
|
||||||
public Activity MoveTo(CPos cell, Actor ignoreActor) { return null; }
|
public Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null) { return null; }
|
||||||
public Activity MoveWithinRange(Target target, WDist range,
|
public Activity MoveWithinRange(Target target, WDist range,
|
||||||
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
|
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
|
||||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||||
|
|||||||
@@ -139,13 +139,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||||
lastVisibleTarget = Target.FromTargetPositions(target);
|
lastVisibleTarget = Target.FromTargetPositions(target);
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
|
|
||||||
// Update target lines if required
|
|
||||||
if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue)
|
|
||||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false);
|
|
||||||
|
|
||||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -228,6 +223,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
yield return target;
|
yield return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor.HasValue)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
|
|
||||||
public static int CalculateTurnRadius(int speed, int turnSpeed)
|
public static int CalculateTurnRadius(int speed, int turnSpeed)
|
||||||
{
|
{
|
||||||
// turnSpeed -> divide into 256 to get the number of ticks per complete rotation
|
// turnSpeed -> divide into 256 to get the number of ticks per complete rotation
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -24,6 +25,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly Rearmable rearmable;
|
readonly Rearmable rearmable;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
readonly int ticksUntilTurn;
|
readonly int ticksUntilTurn;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
Target target;
|
Target target;
|
||||||
Target lastVisibleTarget;
|
Target lastVisibleTarget;
|
||||||
@@ -32,11 +34,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
Player lastVisibleOwner;
|
Player lastVisibleOwner;
|
||||||
bool useLastVisibleTarget;
|
bool useLastVisibleTarget;
|
||||||
bool hasTicked;
|
bool hasTicked;
|
||||||
|
bool returnToBase;
|
||||||
|
|
||||||
public FlyAttack(Actor self, Target target, bool forceAttack)
|
public FlyAttack(Actor self, Target target, bool forceAttack, Color? targetLineColor)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
|
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
attackAircraft = self.Trait<AttackAircraft>();
|
attackAircraft = self.Trait<AttackAircraft>();
|
||||||
rearmable = self.TraitOrDefault<Rearmable>();
|
rearmable = self.TraitOrDefault<Rearmable>();
|
||||||
@@ -65,6 +70,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
returnToBase = false;
|
||||||
|
|
||||||
// Refuse to take off if it would land immediately again.
|
// Refuse to take off if it would land immediately again.
|
||||||
if (aircraft.ForceLanding)
|
if (aircraft.ForceLanding)
|
||||||
Cancel(self);
|
Cancel(self);
|
||||||
@@ -93,13 +100,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
|
|
||||||
// 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
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -109,6 +111,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
||||||
{
|
{
|
||||||
QueueChild(new ReturnToBase(self));
|
QueueChild(new ReturnToBase(self));
|
||||||
|
returnToBase = true;
|
||||||
return attackAircraft.Info.AbortOnResupply;
|
return attackAircraft.Info.AbortOnResupply;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,5 +172,17 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
||||||
attackAircraft.ClearRequestedTarget();
|
attackAircraft.ClearRequestedTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
{
|
||||||
|
if (returnToBase)
|
||||||
|
foreach (var n in ChildActivity.TargetLineNodes(self))
|
||||||
|
yield return n;
|
||||||
|
if (!returnToBase || !attackAircraft.Info.AbortOnResupply)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -59,7 +60,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||||
lastVisibleTarget = Target.FromTargetPositions(target);
|
lastVisibleTarget = Target.FromTargetPositions(target);
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
|
|
||||||
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
||||||
@@ -69,10 +69,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
wasMovingWithinRange = false;
|
wasMovingWithinRange = false;
|
||||||
|
|
||||||
// Update target lines if required
|
|
||||||
if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue)
|
|
||||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false);
|
|
||||||
|
|
||||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -94,5 +90,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
QueueChild(aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
QueueChild(aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -25,6 +26,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly bool assignTargetOnFirstRun;
|
readonly bool assignTargetOnFirstRun;
|
||||||
readonly CPos[] clearCells;
|
readonly CPos[] clearCells;
|
||||||
readonly WDist landRange;
|
readonly WDist landRange;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
Target target;
|
Target target;
|
||||||
WPos targetPosition;
|
WPos targetPosition;
|
||||||
@@ -32,28 +34,29 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
bool landingInitiated;
|
bool landingInitiated;
|
||||||
bool finishedApproach;
|
bool finishedApproach;
|
||||||
|
|
||||||
public Land(Actor self, int facing = -1)
|
public Land(Actor self, int facing = -1, Color? targetLineColor = null)
|
||||||
: this(self, Target.Invalid, new WDist(-1), WVec.Zero, facing, null)
|
: this(self, Target.Invalid, new WDist(-1), WVec.Zero, facing, null)
|
||||||
{
|
{
|
||||||
assignTargetOnFirstRun = true;
|
assignTargetOnFirstRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Land(Actor self, Target target, int facing = -1)
|
public Land(Actor self, Target target, int facing = -1, Color? targetLineColor = null)
|
||||||
: this(self, target, new WDist(-1), WVec.Zero, facing) { }
|
: this(self, target, new WDist(-1), WVec.Zero, facing, targetLineColor: targetLineColor) { }
|
||||||
|
|
||||||
public Land(Actor self, Target target, WDist landRange, int facing = -1)
|
public Land(Actor self, Target target, WDist landRange, int facing = -1, Color? targetLineColor = null)
|
||||||
: this(self, target, landRange, WVec.Zero, facing) { }
|
: this(self, target, landRange, WVec.Zero, facing, targetLineColor: targetLineColor) { }
|
||||||
|
|
||||||
public Land(Actor self, Target target, WVec offset, int facing = -1)
|
public Land(Actor self, Target target, WVec offset, int facing = -1, Color? targetLineColor = null)
|
||||||
: this(self, target, WDist.Zero, offset, facing) { }
|
: this(self, target, WDist.Zero, offset, facing, targetLineColor: targetLineColor) { }
|
||||||
|
|
||||||
public Land(Actor self, Target target, WDist landRange, WVec offset, int facing = -1, CPos[] clearCells = null)
|
public Land(Actor self, Target target, WDist landRange, WVec offset, int facing = -1, CPos[] clearCells = null, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.clearCells = clearCells ?? new CPos[0];
|
this.clearCells = clearCells ?? new CPos[0];
|
||||||
this.landRange = landRange.Length >= 0 ? landRange : aircraft.Info.LandRange;
|
this.landRange = landRange.Length >= 0 ? landRange : aircraft.Info.LandRange;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
|
|
||||||
// NOTE: desiredFacing = -1 means we should not prefer any particular facing and instead just
|
// NOTE: desiredFacing = -1 means we should not prefer any particular facing and instead just
|
||||||
// use whatever facing gives us the most direct path to the landing site.
|
// use whatever facing gives us the most direct path to the landing site.
|
||||||
@@ -256,5 +259,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,14 +119,22 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
facing = 192;
|
facing = 192;
|
||||||
|
|
||||||
aircraft.MakeReservation(dest);
|
aircraft.MakeReservation(dest);
|
||||||
QueueChild(new Land(self, Target.FromActor(dest), offset, facing));
|
QueueChild(new Land(self, Target.FromActor(dest), offset, facing, Color.Green));
|
||||||
QueueChild(new Resupply(self, dest, WDist.Zero, alwaysLand));
|
QueueChild(new Resupply(self, dest, WDist.Zero, alwaysLand));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueChild(new Fly(self, Target.FromActor(dest)));
|
QueueChild(new Fly(self, Target.FromActor(dest)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (ChildActivity == null)
|
||||||
|
yield return new TargetLineNode(Target.FromActor(dest), Color.Green);
|
||||||
|
else
|
||||||
|
foreach (var n in ChildActivity.TargetLineNodes(self))
|
||||||
|
yield return n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly IFacing facing;
|
readonly IFacing facing;
|
||||||
readonly IPositionable positionable;
|
readonly IPositionable positionable;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
protected Target target;
|
protected Target target;
|
||||||
Target lastVisibleTarget;
|
Target lastVisibleTarget;
|
||||||
@@ -44,9 +45,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
WDist maxRange;
|
WDist maxRange;
|
||||||
AttackStatus attackStatus = AttackStatus.UnableToAttack;
|
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.target = target;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
|
|
||||||
attackTraits = self.TraitsImplementing<AttackFrontal>().ToArray();
|
attackTraits = self.TraitsImplementing<AttackFrontal>().ToArray();
|
||||||
@@ -100,7 +102,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
|
|
||||||
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
// 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)
|
if (wasMovingWithinRange && targetIsHiddenActor)
|
||||||
return true;
|
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
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -231,5 +228,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
||||||
target = Target.Invalid;
|
target = Target.Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -24,6 +25,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly Actor targetActor;
|
readonly Actor targetActor;
|
||||||
readonly INotifyHarvesterAction[] notifyHarvesterActions;
|
readonly INotifyHarvesterAction[] notifyHarvesterActions;
|
||||||
|
|
||||||
|
Actor proc;
|
||||||
|
|
||||||
public DeliverResources(Actor self, Actor targetActor = null)
|
public DeliverResources(Actor self, Actor targetActor = null)
|
||||||
{
|
{
|
||||||
movement = self.Trait<IMove>();
|
movement = self.Trait<IMove>();
|
||||||
@@ -54,10 +57,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var proc = harv.LinkedProc;
|
proc = harv.LinkedProc;
|
||||||
var iao = proc.Trait<IAcceptResources>();
|
var iao = proc.Trait<IAcceptResources>();
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
|
|
||||||
if (self.Location != proc.Location + iao.DeliveryOffset)
|
if (self.Location != proc.Location + iao.DeliveryOffset)
|
||||||
{
|
{
|
||||||
foreach (var n in notifyHarvesterActions)
|
foreach (var n in notifyHarvesterActions)
|
||||||
@@ -79,5 +81,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
base.Cancel(self, keepQueue);
|
base.Cancel(self, keepQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (proc != null)
|
||||||
|
yield return new TargetLineNode(Target.FromActor(proc), Color.Green);
|
||||||
|
else
|
||||||
|
yield return new TargetLineNode(Target.FromActor(harv.LinkedProc), Color.Green);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -56,6 +58,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
QueueChild(new TakeOff(self));
|
QueueChild(new TakeOff(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield return new TargetLineNode(destination, Color.Yellow);
|
||||||
|
}
|
||||||
|
|
||||||
class ReleaseUnit : Activity
|
class ReleaseUnit : Activity
|
||||||
{
|
{
|
||||||
readonly Carryall carryall;
|
readonly Carryall carryall;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -75,10 +76,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
TickInner(self, target, useLastVisibleTarget);
|
TickInner(self, target, useLastVisibleTarget);
|
||||||
|
|
||||||
// Update target lines if required
|
|
||||||
if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue)
|
|
||||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false);
|
|
||||||
|
|
||||||
// We need to wait for movement to finish before transitioning to
|
// We need to wait for movement to finish before transitioning to
|
||||||
// the next state or next activity
|
// the next state or next activity
|
||||||
if (!TickChild(self))
|
if (!TickChild(self))
|
||||||
@@ -146,5 +143,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Activities;
|
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly ResourceClaimLayer claimLayer;
|
readonly ResourceClaimLayer claimLayer;
|
||||||
readonly IPathFinder pathFinder;
|
readonly IPathFinder pathFinder;
|
||||||
readonly DomainIndex domainIndex;
|
readonly DomainIndex domainIndex;
|
||||||
readonly Actor deliverActor;
|
|
||||||
|
|
||||||
|
Actor deliverActor;
|
||||||
CPos? orderLocation;
|
CPos? orderLocation;
|
||||||
CPos? lastHarvestedCell;
|
CPos? lastHarvestedCell;
|
||||||
bool hasDeliveredLoad;
|
bool hasDeliveredLoad;
|
||||||
@@ -73,6 +73,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
QueueChild(new DeliverResources(self, deliverActor));
|
QueueChild(new DeliverResources(self, deliverActor));
|
||||||
hasDeliveredLoad = true;
|
hasDeliveredLoad = true;
|
||||||
|
deliverActor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +140,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
var unblockCell = deliveryLoc + harv.Info.UnblockCell;
|
var unblockCell = deliveryLoc + harv.Info.UnblockCell;
|
||||||
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
|
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
|
||||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Green, false);
|
|
||||||
QueueChild(mobile.MoveTo(moveTo, 1));
|
QueueChild(mobile.MoveTo(moveTo, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,6 +205,18 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
yield return Target.FromCell(self.World, self.Location);
|
yield return Target.FromCell(self.World, self.Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (ChildActivity != null)
|
||||||
|
foreach (var n in ChildActivity.TargetLineNodes(self))
|
||||||
|
yield return n;
|
||||||
|
|
||||||
|
if (orderLocation != null)
|
||||||
|
yield return new TargetLineNode(Target.FromCell(self.World, orderLocation.Value), Color.Green);
|
||||||
|
else if (deliverActor != null)
|
||||||
|
yield return new TargetLineNode(Target.FromActor(deliverActor), Color.Green);
|
||||||
|
}
|
||||||
|
|
||||||
CPos GetSearchFromLocation(Actor self)
|
CPos GetSearchFromLocation(Actor self)
|
||||||
{
|
{
|
||||||
if (harv.LastLinkedProc != null && !harv.LastLinkedProc.IsDead && harv.LastLinkedProc.IsInWorld)
|
if (harv.LastLinkedProc != null && !harv.LastLinkedProc.IsDead && harv.LastLinkedProc.IsInWorld)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -61,7 +62,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
foreach (var n in notifyHarvesterActions)
|
foreach (var n in notifyHarvesterActions)
|
||||||
n.MovingToResources(self, targetCell);
|
n.MovingToResources(self, targetCell);
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, targetCell), Color.Red, false);
|
|
||||||
QueueChild(move.MoveTo(targetCell, 2));
|
QueueChild(move.MoveTo(targetCell, 2));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -106,5 +106,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
base.Cancel(self, keepQueue);
|
base.Cancel(self, keepQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield return new TargetLineNode(Target.FromCell(self.World, targetCell), Color.Green);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -104,6 +105,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
yield return Target.FromActor(Refinery);
|
yield return Target.FromActor(Refinery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield return new TargetLineNode(Target.FromActor(Refinery), Color.Green);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void OnStateDock(Actor self);
|
public abstract void OnStateDock(Actor self);
|
||||||
|
|
||||||
public abstract void OnStateUndock(Actor self);
|
public abstract void OnStateUndock(Actor self);
|
||||||
|
|||||||
@@ -92,5 +92,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
return Target.None;
|
return Target.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
foreach (var n in getInner().TargetLineNodes(self))
|
||||||
|
yield return n;
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -62,5 +63,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
yield return Target.FromPos(end);
|
yield return Target.FromPos(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield return new TargetLineNode(Target.FromPos(end), Color.Green);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -55,7 +56,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||||
lastVisibleTarget = Target.FromTargetPositions(target);
|
lastVisibleTarget = Target.FromTargetPositions(target);
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
|
|
||||||
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
||||||
@@ -65,10 +65,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
wasMovingWithinRange = false;
|
wasMovingWithinRange = false;
|
||||||
|
|
||||||
// Update target lines if required
|
|
||||||
if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue)
|
|
||||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false);
|
|
||||||
|
|
||||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -86,5 +82,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly WDist nearEnough;
|
readonly WDist nearEnough;
|
||||||
readonly Func<List<CPos>> getPath;
|
readonly Func<List<CPos>> getPath;
|
||||||
readonly Actor ignoreActor;
|
readonly Actor ignoreActor;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
List<CPos> path;
|
List<CPos> path;
|
||||||
CPos? destination;
|
CPos? destination;
|
||||||
@@ -43,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Scriptable move order
|
// Scriptable move order
|
||||||
// Ignores lane bias and nearby units
|
// Ignores lane bias and nearby units
|
||||||
public Move(Actor self, CPos destination)
|
public Move(Actor self, CPos destination, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
@@ -57,10 +58,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return path;
|
return path;
|
||||||
};
|
};
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
nearEnough = WDist.Zero;
|
nearEnough = WDist.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(Actor self, CPos destination, WDist nearEnough, Actor ignoreActor = null, bool evaluateNearestMovableCell = false)
|
public Move(Actor self, CPos destination, WDist nearEnough, Actor ignoreActor = null, bool evaluateNearestMovableCell = false,
|
||||||
|
Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
@@ -79,9 +82,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
this.nearEnough = nearEnough;
|
this.nearEnough = nearEnough;
|
||||||
this.ignoreActor = ignoreActor;
|
this.ignoreActor = ignoreActor;
|
||||||
this.evaluateNearestMovableCell = evaluateNearestMovableCell;
|
this.evaluateNearestMovableCell = evaluateNearestMovableCell;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(Actor self, CPos destination, SubCell subCell, WDist nearEnough)
|
public Move(Actor self, CPos destination, SubCell subCell, WDist nearEnough, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
@@ -89,9 +93,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
.FindUnitPathToRange(mobile.FromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self);
|
.FindUnitPathToRange(mobile.FromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self);
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.nearEnough = nearEnough;
|
this.nearEnough = nearEnough;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(Actor self, Target target, WDist range)
|
public Move(Actor self, Target target, WDist range, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
@@ -106,9 +111,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
destination = null;
|
destination = null;
|
||||||
nearEnough = range;
|
nearEnough = range;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(Actor self, Func<List<CPos>> getPath)
|
public Move(Actor self, Func<List<CPos>> getPath, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
@@ -116,6 +122,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
destination = null;
|
destination = null;
|
||||||
nearEnough = WDist.Zero;
|
nearEnough = WDist.Zero;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HashList<T>(List<T> xs)
|
static int HashList<T>(List<T> xs)
|
||||||
@@ -261,6 +268,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return Target.None;
|
return Target.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(Target.FromCell(self.World, destination.Value), targetLineColor.Value);
|
||||||
|
}
|
||||||
|
|
||||||
abstract class MovePart : Activity
|
abstract class MovePart : Activity
|
||||||
{
|
{
|
||||||
protected readonly Move Move;
|
protected readonly Move Move;
|
||||||
|
|||||||
@@ -99,13 +99,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// Target is equivalent to checkTarget variable in other activities
|
// Target is equivalent to checkTarget variable in other activities
|
||||||
// value is either lastVisibleTarget or target based on visibility and validity
|
// value is either lastVisibleTarget or target based on visibility and validity
|
||||||
var targetIsValid = Target.IsValidFor(self);
|
var targetIsValid = Target.IsValidFor(self);
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !targetIsValid;
|
useLastVisibleTarget = targetIsHiddenActor || !targetIsValid;
|
||||||
|
|
||||||
// Update target lines if required
|
|
||||||
if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue)
|
|
||||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false);
|
|
||||||
|
|
||||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
var noTarget = useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self);
|
var noTarget = useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self);
|
||||||
|
|
||||||
@@ -149,5 +144,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
return Target.None;
|
return Target.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor.HasValue)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -20,14 +21,16 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
readonly Mobile mobile;
|
readonly Mobile mobile;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
readonly WDist targetMovementThreshold;
|
readonly WDist targetMovementThreshold;
|
||||||
WPos targetStartPos;
|
WPos targetStartPos;
|
||||||
|
|
||||||
public VisualMoveIntoTarget(Actor self, Target target, WDist targetMovementThreshold)
|
public VisualMoveIntoTarget(Actor self, Target target, WDist targetMovementThreshold, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.targetMovementThreshold = targetMovementThreshold;
|
this.targetMovementThreshold = targetMovementThreshold;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
@@ -76,5 +79,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
yield return target;
|
yield return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -79,7 +80,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PickupState.Intercept:
|
case PickupState.Intercept:
|
||||||
QueueChild(movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4), targetLineColor: Color.Yellow));
|
QueueChild(movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4)));
|
||||||
state = PickupState.LockCarryable;
|
state = PickupState.LockCarryable;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -110,6 +111,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
yield return new TargetLineNode(Target.FromActor(cargo), Color.Yellow);
|
||||||
|
}
|
||||||
|
|
||||||
class AttachUnit : Activity
|
class AttachUnit : Activity
|
||||||
{
|
{
|
||||||
readonly Actor cargo;
|
readonly Actor cargo;
|
||||||
|
|||||||
@@ -149,6 +149,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
base.Cancel(self, keepQueue);
|
base.Cancel(self, keepQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (ChildActivity == null)
|
||||||
|
yield return new TargetLineNode(host, Color.Green);
|
||||||
|
else
|
||||||
|
foreach (var n in ChildActivity.TargetLineNodes(self))
|
||||||
|
yield return n;
|
||||||
|
}
|
||||||
|
|
||||||
void OnResupplyEnding(Actor self)
|
void OnResupplyEnding(Actor self)
|
||||||
{
|
{
|
||||||
if (aircraft != null)
|
if (aircraft != null)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Mods.Common.Traits.Render;
|
using OpenRA.Mods.Common.Traits.Render;
|
||||||
@@ -149,16 +149,24 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
readonly string orderString;
|
readonly string orderString;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
public IssueOrderAfterTransform(string orderString, Target target)
|
public IssueOrderAfterTransform(string orderString, Target target, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
this.orderString = orderString;
|
this.orderString = orderString;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order IssueOrderForTransformedActor(Actor newActor)
|
public Order IssueOrderForTransformedActor(Actor newActor)
|
||||||
{
|
{
|
||||||
return new Order(orderString, newActor, target, true);
|
return new Order(orderString, newActor, target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
actor.CancelActivity();
|
actor.CancelActivity();
|
||||||
pos.SetVisualPosition(actor, spawn);
|
pos.SetVisualPosition(actor, spawn);
|
||||||
actor.QueueActivity(move.MoveIntoWorld(actor, exitSubCell.Value.First, exitSubCell.Value.Second));
|
actor.QueueActivity(move.MoveIntoWorld(actor, exitSubCell.Value.First, exitSubCell.Value.Second));
|
||||||
actor.SetTargetLine(Target.FromCell(w, exitSubCell.Value.First, exitSubCell.Value.Second), Color.Green, false);
|
|
||||||
w.Add(actor);
|
w.Add(actor);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
IEnumerable<IRenderable> RenderInner(WorldRenderer wr)
|
IEnumerable<IRenderable> RenderInner(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (Game.Settings.Game.DrawTargetLine)
|
if (Game.Settings.Game.DrawTargetLine)
|
||||||
yield return new TargetLineRenderable(targetLine, building.Owner.Color);
|
yield return new TargetLineRenderable(targetLine, building.Owner.Color, rp.Info.LineWidth);
|
||||||
|
|
||||||
if (circles != null || flag != null)
|
if (circles != null || flag != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public void DeliverCash(Actor target)
|
public void DeliverCash(Actor target)
|
||||||
{
|
{
|
||||||
var t = Target.FromActor(target);
|
var t = Target.FromActor(target);
|
||||||
Self.SetTargetLine(t, Color.Yellow);
|
|
||||||
Self.QueueActivity(new DonateCash(Self, t, info.Payload, info.PlayerExperience));
|
Self.QueueActivity(new DonateCash(Self, t, info.Payload, info.PlayerExperience));
|
||||||
|
Self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
var level = gainsExperience.Level;
|
var level = gainsExperience.Level;
|
||||||
|
|
||||||
var t = Target.FromActor(target);
|
var t = Target.FromActor(target);
|
||||||
Self.SetTargetLine(t, Color.Yellow);
|
|
||||||
Self.QueueActivity(new DonateExperience(Self, t, level, deliversExperience.PlayerExperience));
|
Self.QueueActivity(new DonateExperience(Self, t, level, deliversExperience.PlayerExperience));
|
||||||
|
Self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -830,14 +830,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
#region Implement IMove
|
#region Implement IMove
|
||||||
|
|
||||||
public Activity MoveTo(CPos cell, int nearEnough)
|
public Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new Fly(self, Target.FromCell(self.World, cell));
|
return new Fly(self, Target.FromCell(self.World, cell), targetLineColor: targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveTo(CPos cell, Actor ignoreActor)
|
public Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new Fly(self, Target.FromCell(self.World, cell));
|
return new Fly(self, Target.FromCell(self.World, cell), targetLineColor: targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist range,
|
public Activity MoveWithinRange(Target target, WDist range,
|
||||||
@@ -993,8 +993,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
UnReserve();
|
UnReserve();
|
||||||
|
|
||||||
var target = Target.FromCell(self.World, cell);
|
var target = Target.FromCell(self.World, cell);
|
||||||
self.SetTargetLine(target, Color.Green);
|
self.QueueActivity(order.Queued, new Fly(self, target, targetLineColor: Color.Green));
|
||||||
self.QueueActivity(order.Queued, new Fly(self, target));
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (orderString == "Land")
|
else if (orderString == "Land")
|
||||||
{
|
{
|
||||||
@@ -1007,8 +1007,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var target = Target.FromCell(self.World, cell);
|
var target = Target.FromCell(self.World, cell);
|
||||||
|
|
||||||
self.SetTargetLine(target, Color.Green);
|
self.QueueActivity(order.Queued, new Land(self, target, targetLineColor: Color.Green));
|
||||||
self.QueueActivity(order.Queued, new Land(self, target));
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (orderString == "Enter" || orderString == "ForceEnter" || orderString == "Repair")
|
else if (orderString == "Enter" || orderString == "ForceEnter" || orderString == "Repair")
|
||||||
{
|
{
|
||||||
@@ -1029,13 +1029,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
UnReserve();
|
UnReserve();
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromActor(targetActor), Color.Green);
|
|
||||||
|
|
||||||
// Aircraft with TakeOffOnResupply would immediately take off again, so there's no point in automatically forcing
|
// Aircraft with TakeOffOnResupply would immediately take off again, so there's no point in automatically forcing
|
||||||
// them to land on a resupplier. For aircraft without it, it makes more sense to land than to idle above a
|
// them to land on a resupplier. For aircraft without it, it makes more sense to land than to idle above a
|
||||||
// free resupplier.
|
// free resupplier.
|
||||||
var forceLand = isForceEnter || !Info.TakeOffOnResupply;
|
var forceLand = isForceEnter || !Info.TakeOffOnResupply;
|
||||||
self.QueueActivity(order.Queued, new ReturnToBase(self, targetActor, forceLand));
|
self.QueueActivity(order.Queued, new ReturnToBase(self, targetActor, forceLand));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (orderString == "Stop")
|
else if (orderString == "Stop")
|
||||||
{
|
{
|
||||||
@@ -1077,9 +1076,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
.Rotate(WRot.FromFacing(self.World.SharedRandom.Next(256)));
|
.Rotate(WRot.FromFacing(self.World.SharedRandom.Next(256)));
|
||||||
var target = Target.FromPos(self.CenterPosition + offset);
|
var target = Target.FromPos(self.CenterPosition + offset);
|
||||||
|
|
||||||
self.CancelActivity();
|
self.QueueActivity(false, new Fly(self, target));
|
||||||
self.SetTargetLine(target, Color.Green, false);
|
self.ShowTargetLines();
|
||||||
self.QueueActivity(new Fly(self, target));
|
|
||||||
UnReserve();
|
UnReserve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -44,9 +45,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new FlyAttack(self, newTarget, forceAttack);
|
return new FlyAttack(self, newTarget, forceAttack, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CanAttack(Actor self, Target target)
|
protected override bool CanAttack(Actor self, Target target)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -85,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
OnRemovedFromWorld(self);
|
OnRemovedFromWorld(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("AttackBomber requires a scripted target");
|
throw new NotImplementedException("AttackBomber requires a scripted target");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public readonly string OutsideRangeCursor = null;
|
public readonly string OutsideRangeCursor = null;
|
||||||
|
|
||||||
|
[Desc("Color to use for the target line.")]
|
||||||
|
public readonly Color TargetLineColor = Color.Red;
|
||||||
|
|
||||||
[Desc("Does the attack type require the attacker to enter the target's cell?")]
|
[Desc("Does the attack type require the attacker to enter the target's cell?")]
|
||||||
public readonly bool AttackRequiresEnteringCell = false;
|
public readonly bool AttackRequiresEnteringCell = false;
|
||||||
|
|
||||||
@@ -196,8 +199,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Target.IsValidFor(self))
|
if (!order.Target.IsValidFor(self))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Red);
|
AttackTarget(order.Target, order.Queued, true, forceAttack, Info.TargetLineColor);
|
||||||
AttackTarget(order.Target, order.Queued, true, forceAttack);
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order.OrderString == "Stop")
|
if (order.OrderString == "Stop")
|
||||||
@@ -221,7 +224,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return order.OrderString == attackOrderName || order.OrderString == forceAttackOrderName ? Info.Voice : null;
|
return order.OrderString == attackOrderName || order.OrderString == forceAttackOrderName ? Info.Voice : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack);
|
public abstract Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
|
||||||
|
|
||||||
public bool HasAnyValidWeapons(Target t, bool checkForCenterTargetingWeapons = false)
|
public bool HasAnyValidWeapons(Target t, bool checkForCenterTargetingWeapons = false)
|
||||||
{
|
{
|
||||||
@@ -388,7 +391,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
&& a.Weapon.IsValidAgainst(t, self.World, self));
|
&& a.Weapon.IsValidAgainst(t, self.World, self));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AttackTarget(Target target, bool queued, bool allowMove, bool forceAttack = false)
|
public void AttackTarget(Target target, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
return;
|
return;
|
||||||
@@ -399,7 +402,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!queued)
|
if (!queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
var activity = GetAttackActivity(self, target, allowMove, forceAttack);
|
var activity = GetAttackActivity(self, target, allowMove, forceAttack, targetLineColor);
|
||||||
self.QueueActivity(activity);
|
self.QueueActivity(activity);
|
||||||
OnQueueAttackActivity(self, activity, target, allowMove, forceAttack);
|
OnQueueAttackActivity(self, activity, target, allowMove, forceAttack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -151,9 +152,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new AttackActivity(self, newTarget, allowMove, forceAttack);
|
return new AttackActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnQueueAttackActivity(Actor self, Activity activity, Target target, bool allowMove, bool forceAttack)
|
public override void OnQueueAttackActivity(Actor self, Activity activity, Target target, bool allowMove, bool forceAttack)
|
||||||
@@ -213,6 +214,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly RevealsShroud[] revealsShroud;
|
readonly RevealsShroud[] revealsShroud;
|
||||||
readonly IMove move;
|
readonly IMove move;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
|
|
||||||
Target target;
|
Target target;
|
||||||
Target lastVisibleTarget;
|
Target lastVisibleTarget;
|
||||||
@@ -224,7 +226,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
bool wasMovingWithinRange;
|
bool wasMovingWithinRange;
|
||||||
bool hasTicked;
|
bool hasTicked;
|
||||||
|
|
||||||
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
|
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
attack = self.Trait<AttackFollow>();
|
attack = self.Trait<AttackFollow>();
|
||||||
move = allowMove ? self.TraitOrDefault<IMove>() : null;
|
move = allowMove ? self.TraitOrDefault<IMove>() : null;
|
||||||
@@ -232,6 +234,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
|
|
||||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||||
@@ -290,7 +293,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
|
||||||
var maxRange = lastVisibleMaximumRange;
|
var maxRange = lastVisibleMaximumRange;
|
||||||
var minRange = lastVisibleMinimumRange;
|
var minRange = lastVisibleMinimumRange;
|
||||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||||
@@ -313,10 +315,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (wasMovingWithinRange && targetIsHiddenActor)
|
if (wasMovingWithinRange && targetIsHiddenActor)
|
||||||
return true;
|
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
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
@@ -339,7 +337,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
wasMovingWithinRange = true;
|
wasMovingWithinRange = true;
|
||||||
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red));
|
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +356,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
|
||||||
attack.ClearRequestedTarget();
|
attack.ClearRequestedTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -41,9 +42,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return TargetInFiringArc(self, target, Info.FacingTolerance);
|
return TargetInFiringArc(self, target, Info.FacingTolerance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new Activities.Attack(self, newTarget, allowMove, forceAttack);
|
return new Activities.Attack(self, newTarget, allowMove, forceAttack, targetLineColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -25,9 +27,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public AttackOmni(Actor self, AttackOmniInfo info)
|
public AttackOmni(Actor self, AttackOmniInfo info)
|
||||||
: base(self, info) { }
|
: base(self, info) { }
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return new SetTarget(this, newTarget, allowMove, forceAttack);
|
return new SetTarget(this, newTarget, allowMove, forceAttack, targetLineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some 3rd-party mods rely on this being public
|
// Some 3rd-party mods rely on this being public
|
||||||
@@ -36,11 +38,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly AttackOmni attack;
|
readonly AttackOmni attack;
|
||||||
readonly bool allowMove;
|
readonly bool allowMove;
|
||||||
readonly bool forceAttack;
|
readonly bool forceAttack;
|
||||||
|
readonly Color? targetLineColor;
|
||||||
Target target;
|
Target target;
|
||||||
|
|
||||||
public SetTarget(AttackOmni attack, Target target, bool allowMove, bool forceAttack)
|
public SetTarget(AttackOmni attack, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
this.targetLineColor = targetLineColor;
|
||||||
this.attack = attack;
|
this.attack = attack;
|
||||||
this.allowMove = allowMove;
|
this.allowMove = allowMove;
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
@@ -77,6 +81,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
target = Target.Invalid;
|
target = Target.Invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
|
{
|
||||||
|
if (targetLineColor != null)
|
||||||
|
yield return new TargetLineNode(target, targetLineColor.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var targetLocation = move.NearestMoveableCell(cell);
|
var targetLocation = move.NearestMoveableCell(cell);
|
||||||
self.SetTargetLine(Target.FromCell(self.World, targetLocation), Color.Red);
|
|
||||||
var assaultMoving = order.OrderString == "AssaultMove";
|
var assaultMoving = order.OrderString == "AssaultMove";
|
||||||
self.QueueActivity(new AttackMoveActivity(self, () => move.MoveTo(targetLocation, 1), assaultMoving));
|
self.QueueActivity(new AttackMoveActivity(self, () => move.MoveTo(targetLocation, 1, targetLineColor: Color.Red), assaultMoving));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,8 +311,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void Attack(Actor self, Target target, bool allowMove)
|
void Attack(Actor self, Target target, bool allowMove)
|
||||||
{
|
{
|
||||||
self.SetTargetLine(target, Color.Red, false);
|
|
||||||
|
|
||||||
foreach (var ab in ActiveAttackBases)
|
foreach (var ab in ActiveAttackBases)
|
||||||
ab.AttackTarget(target, false, allowMove);
|
ab.AttackTarget(target, false, allowMove);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public readonly string Image = "rallypoint";
|
public readonly string Image = "rallypoint";
|
||||||
|
|
||||||
|
[Desc("Width (in pixels) of the rallypoint line.")]
|
||||||
|
public readonly int LineWidth = 2;
|
||||||
|
|
||||||
[SequenceReference("Image")]
|
[SequenceReference("Image")]
|
||||||
public readonly string FlagSequence = "flag";
|
public readonly string FlagSequence = "flag";
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var target = Target.FromCell(self.World, cell);
|
var target = Target.FromCell(self.World, cell);
|
||||||
|
|
||||||
self.SetTargetLine(target, Color.Green);
|
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Enter")
|
else if (order.OrderString == "Enter")
|
||||||
{
|
{
|
||||||
@@ -114,10 +112,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var targetActor = order.Target.Actor;
|
var targetActor = order.Target.Actor;
|
||||||
|
|
||||||
// We only want to set a target line if the order will (most likely) succeed
|
|
||||||
if (Reservable.IsAvailableFor(targetActor, self))
|
|
||||||
self.SetTargetLine(Target.FromActor(targetActor), Color.Green);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentTransform = self.CurrentActivity as Transform;
|
var currentTransform = self.CurrentActivity as Transform;
|
||||||
@@ -130,10 +124,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -93,17 +93,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (transform == null && currentTransform == null)
|
if (transform == null && currentTransform == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
|
|
||||||
// Manually manage the inner activity queue
|
// Manually manage the inner activity queue
|
||||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -107,17 +107,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (transform == null && currentTransform == null)
|
if (transform == null && currentTransform == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, cell), Color.Green);
|
|
||||||
|
|
||||||
// Manually manage the inner activity queue
|
// Manually manage the inner activity queue
|
||||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(new IssueOrderAfterTransform("Move", order.Target));
|
activity.Queue(new IssueOrderAfterTransform("Move", order.Target, Color.Green));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Stop")
|
else if (order.OrderString == "Stop")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,17 +117,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (transform == null && currentTransform == null)
|
if (transform == null && currentTransform == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
|
|
||||||
// Manually manage the inner activity queue
|
// Manually manage the inner activity queue
|
||||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -111,17 +111,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (transform == null && currentTransform == null)
|
if (transform == null && currentTransform == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
|
|
||||||
// Manually manage the inner activity queue
|
// Manually manage the inner activity queue
|
||||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Red);
|
|
||||||
self.QueueActivity(new CaptureActor(self, order.Target));
|
self.QueueActivity(new CaptureActor(self, order.Target));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self) { captureManager.RefreshCaptures(self); }
|
protected override void TraitEnabled(Actor self) { captureManager.RefreshCaptures(self); }
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var targetLocation = move.NearestMoveableCell(cell);
|
var targetLocation = move.NearestMoveableCell(cell);
|
||||||
self.SetTargetLine(Target.FromCell(self.World, targetLocation), Color.Yellow);
|
|
||||||
self.QueueActivity(order.Queued, new DeliverUnit(self, order.Target, Info.DropRange));
|
self.QueueActivity(order.Queued, new DeliverUnit(self, order.Target, Info.DropRange));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Unload")
|
else if (order.OrderString == "Unload")
|
||||||
{
|
{
|
||||||
@@ -316,8 +316,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Yellow);
|
|
||||||
self.QueueActivity(order.Queued, new PickupUnit(self, order.Target.Actor, Info.BeforeLoadDelay));
|
self.QueueActivity(order.Queued, new PickupUnit(self, order.Target.Actor, Info.BeforeLoadDelay));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Yellow);
|
|
||||||
self.QueueActivity(new DonateCash(self, order.Target, info.Payload, info.PlayerExperience));
|
self.QueueActivity(new DonateCash(self, order.Target, info.Payload, info.PlayerExperience));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCashTransfer.OnAcceptingCash(Actor self, Actor donor) { }
|
void INotifyCashTransfer.OnAcceptingCash(Actor self, Actor donor) { }
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Yellow);
|
|
||||||
self.QueueActivity(new DonateExperience(self, order.Target, gainsExperience.Level, info.PlayerExperience));
|
self.QueueActivity(new DonateExperience(self, order.Target, gainsExperience.Level, info.PlayerExperience));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeliversExperienceOrderTargeter : UnitOrderTargeter
|
public class DeliversExperienceOrderTargeter : UnitOrderTargeter
|
||||||
|
|||||||
@@ -86,9 +86,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Red);
|
|
||||||
self.QueueActivity(new Demolish(self, order.Target, info.EnterBehaviour, info.DetonationDelay,
|
self.QueueActivity(new Demolish(self, order.Target, info.EnterBehaviour, info.DetonationDelay,
|
||||||
info.Flashes, info.FlashesDelay, info.FlashInterval));
|
info.Flashes, info.FlashesDelay, info.FlashInterval));
|
||||||
|
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Yellow);
|
|
||||||
self.QueueActivity(new RepairBuilding(self, order.Target, Info));
|
self.QueueActivity(new RepairBuilding(self, order.Target, Info));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
class EngineerRepairOrderTargeter : UnitOrderTargeter
|
class EngineerRepairOrderTargeter : UnitOrderTargeter
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, tunnel.Exit.Value), Color.Green);
|
self.QueueActivity(move.MoveTo(tunnel.Entrance, tunnel.NearEnough, targetLineColor: Color.Green));
|
||||||
self.QueueActivity(move.MoveTo(tunnel.Entrance, tunnel.NearEnough));
|
self.QueueActivity(move.MoveTo(tunnel.Exit.Value, tunnel.NearEnough, targetLineColor: Color.Green));
|
||||||
self.QueueActivity(move.MoveTo(tunnel.Exit.Value, tunnel.NearEnough));
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<VariableObserver> IObservesVariables.GetVariableObservers()
|
IEnumerable<VariableObserver> IObservesVariables.GetVariableObservers()
|
||||||
|
|||||||
@@ -53,10 +53,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (target.Type != TargetType.Actor)
|
if (target.Type != TargetType.Actor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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, targetLineColor: Color.Yellow)));
|
self.QueueActivity(new AttackMoveActivity(self, () => move.MoveFollow(self, target, WDist.Zero, range, targetLineColor: Color.Yellow)));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -149,24 +149,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.AddFrameEndTask(w => self.QueueActivity(new FindAndDeliverResources(self)));
|
self.World.AddFrameEndTask(w => self.QueueActivity(new FindAndDeliverResources(self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetProcLines(Actor proc)
|
|
||||||
{
|
|
||||||
if (proc == null || proc.IsDead)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var linkedHarvs = proc.World.ActorsHavingTrait<Harvester>(h => h.LinkedProc == proc)
|
|
||||||
.Select(a => Target.FromActor(a))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
proc.SetTargetLines(linkedHarvs, Color.Gold);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LinkProc(Actor self, Actor proc)
|
public void LinkProc(Actor self, Actor proc)
|
||||||
{
|
{
|
||||||
var oldProc = LinkedProc;
|
|
||||||
LinkedProc = proc;
|
LinkedProc = proc;
|
||||||
SetProcLines(oldProc);
|
|
||||||
SetProcLines(proc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnlinkProc(Actor self, Actor proc)
|
public void UnlinkProc(Actor self, Actor proc)
|
||||||
@@ -345,10 +330,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
loc = self.Location;
|
loc = self.Location;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, loc), Color.Red);
|
|
||||||
|
|
||||||
// FindResources takes care of calling INotifyHarvesterAction
|
// FindResources takes care of calling INotifyHarvesterAction
|
||||||
self.QueueActivity(order.Queued, new FindAndDeliverResources(self, loc));
|
self.QueueActivity(order.Queued, new FindAndDeliverResources(self, loc));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Deliver")
|
else if (order.OrderString == "Deliver")
|
||||||
{
|
{
|
||||||
@@ -362,8 +346,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (iao == null || !iao.AllowDocking || !IsAcceptableProcType(targetActor))
|
if (iao == null || !iao.AllowDocking || !IsAcceptableProcType(targetActor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
self.QueueActivity(order.Queued, new FindAndDeliverResources(self, targetActor));
|
self.QueueActivity(order.Queued, new FindAndDeliverResources(self, targetActor));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -314,8 +314,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (moveTo.HasValue)
|
if (moveTo.HasValue)
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.SetTargetLine(Target.FromCell(self.World, moveTo.Value), Color.Green, false);
|
|
||||||
self.QueueActivity(new Move(self, moveTo.Value, WDist.Zero));
|
self.QueueActivity(new Move(self, moveTo.Value, WDist.Zero));
|
||||||
|
self.ShowTargetLines();
|
||||||
|
|
||||||
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
|
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
|
||||||
self.ActorID, self.Location, moveTo.Value);
|
self.ActorID, self.Location, moveTo.Value);
|
||||||
@@ -527,14 +527,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return inner;
|
return inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveTo(CPos cell, int nearEnough)
|
public Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), null));
|
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), targetLineColor: targetLineColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveTo(CPos cell, Actor ignoreActor)
|
public Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null)
|
||||||
{
|
{
|
||||||
return WrapMove(new Move(self, cell, WDist.Zero, ignoreActor));
|
return WrapMove(new Move(self, cell, WDist.Zero, ignoreActor, targetLineColor: targetLineColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist range,
|
public Activity MoveWithinRange(Target target, WDist range,
|
||||||
@@ -805,8 +805,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, cell), Color.Green);
|
self.QueueActivity(order.Queued, WrapMove(new Move(self, cell, WDist.FromCells(8), null, true, Color.Green)));
|
||||||
self.QueueActivity(order.Queued, WrapMove(new Move(self, cell, WDist.FromCells(8), null, true)));
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This should only cancel activities queued by this trait
|
// TODO: This should only cancel activities queued by this trait
|
||||||
|
|||||||
@@ -162,8 +162,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
self.QueueActivity(new EnterTransport(self, order.Target));
|
self.QueueActivity(new EnterTransport(self, order.Target));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Reserve(Actor self, Cargo cargo)
|
public bool Reserve(Actor self, Cargo cargo)
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
var exit = CPos.Zero;
|
var exit = CPos.Zero;
|
||||||
var exitLocation = CPos.Zero;
|
var exitLocation = CPos.Zero;
|
||||||
var target = Target.Invalid;
|
|
||||||
|
|
||||||
// Clone the initializer dictionary for the new actor
|
// Clone the initializer dictionary for the new actor
|
||||||
var td = new TypeDictionary();
|
var td = new TypeDictionary();
|
||||||
@@ -70,7 +69,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
||||||
target = Target.FromCell(self.World, exitLocation);
|
|
||||||
|
|
||||||
td.Add(new LocationInit(exit));
|
td.Add(new LocationInit(exit));
|
||||||
td.Add(new CenterPositionInit(spawn));
|
td.Add(new CenterPositionInit(spawn));
|
||||||
@@ -94,8 +92,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false);
|
|
||||||
|
|
||||||
if (!self.IsDead)
|
if (!self.IsDead)
|
||||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||||
t.UnitProduced(self, newUnit, exit);
|
t.UnitProduced(self, newUnit, exit);
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (move != null)
|
if (move != null)
|
||||||
newUnit.QueueActivity(move.MoveTo(destination, 2));
|
newUnit.QueueActivity(move.MoveTo(destination, 2));
|
||||||
|
|
||||||
newUnit.SetTargetLine(Target.FromCell(self.World, destination), Color.Green, false);
|
|
||||||
|
|
||||||
if (!self.IsDead)
|
if (!self.IsDead)
|
||||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||||
t.UnitProduced(self, newUnit, destination);
|
t.UnitProduced(self, newUnit, destination);
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
var exit = CPos.Zero;
|
var exit = CPos.Zero;
|
||||||
var exitLocation = CPos.Zero;
|
var exitLocation = CPos.Zero;
|
||||||
var target = Target.Invalid;
|
|
||||||
|
|
||||||
var info = (ProductionParadropInfo)Info;
|
var info = (ProductionParadropInfo)Info;
|
||||||
var actorType = info.ActorType;
|
var actorType = info.ActorType;
|
||||||
@@ -124,7 +123,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var initialFacing = exitinfo.Facing < 0 ? (to - spawn).Yaw.Facing : exitinfo.Facing;
|
var initialFacing = exitinfo.Facing < 0 ? (to - spawn).Yaw.Facing : exitinfo.Facing;
|
||||||
|
|
||||||
exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
||||||
target = Target.FromCell(self.World, exitLocation);
|
|
||||||
|
|
||||||
td.Add(new LocationInit(exit));
|
td.Add(new LocationInit(exit));
|
||||||
td.Add(new CenterPositionInit(spawn));
|
td.Add(new CenterPositionInit(spawn));
|
||||||
@@ -149,8 +147,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false);
|
|
||||||
|
|
||||||
if (!self.IsDead)
|
if (!self.IsDead)
|
||||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||||
t.UnitProduced(self, newUnit, exit);
|
t.UnitProduced(self, newUnit, exit);
|
||||||
|
|||||||
@@ -10,24 +10,31 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Activities;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
|
[Desc("Renders target lines between order waypoints.")]
|
||||||
public class DrawLineToTargetInfo : ITraitInfo
|
public class DrawLineToTargetInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
[Desc("Delay (in ticks) before the target lines disappear.")]
|
||||||
public readonly int Delay = 60;
|
public readonly int Delay = 60;
|
||||||
|
|
||||||
|
[Desc("Width (in pixels) of the target lines.")]
|
||||||
|
public readonly int LineWidth = 2;
|
||||||
|
|
||||||
|
[Desc("Width (in pixels) of the end node markers.")]
|
||||||
|
public readonly int MarkerWidth = 3;
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(init.Self, this); }
|
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DrawLineToTarget : IRenderAboveShroudWhenSelected, INotifySelected, INotifyBecomingIdle, INotifyOwnerChanged
|
public class DrawLineToTarget : IRenderAboveShroudWhenSelected, INotifySelected
|
||||||
{
|
{
|
||||||
readonly DrawLineToTargetInfo info;
|
readonly DrawLineToTargetInfo info;
|
||||||
List<Target> targets;
|
|
||||||
Color c;
|
|
||||||
int lifetime;
|
int lifetime;
|
||||||
|
|
||||||
public DrawLineToTarget(Actor self, DrawLineToTargetInfo info)
|
public DrawLineToTarget(Actor self, DrawLineToTargetInfo info)
|
||||||
@@ -35,25 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTarget(Actor self, Target target, Color c, bool display)
|
public void ShowTargetLines(Actor a)
|
||||||
{
|
|
||||||
targets = new List<Target> { target };
|
|
||||||
this.c = c;
|
|
||||||
|
|
||||||
if (display)
|
|
||||||
lifetime = info.Delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTargets(Actor self, List<Target> targets, Color c, bool display)
|
|
||||||
{
|
|
||||||
this.targets = targets;
|
|
||||||
this.c = c;
|
|
||||||
|
|
||||||
if (display)
|
|
||||||
lifetime = info.Delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
void INotifySelected.Selected(Actor a)
|
|
||||||
{
|
{
|
||||||
if (a.IsIdle)
|
if (a.IsIdle)
|
||||||
return;
|
return;
|
||||||
@@ -62,65 +51,57 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
lifetime = info.Delay;
|
lifetime = info.Delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifySelected.Selected(Actor a)
|
||||||
|
{
|
||||||
|
ShowTargetLines(a);
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr)
|
IEnumerable<IRenderable> IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
|
if (self.Owner != self.World.LocalPlayer)
|
||||||
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
yield break;
|
||||||
|
|
||||||
|
// Players want to see the lines when in waypoint mode.
|
||||||
|
var force = Game.GetModifierKeys().HasModifier(Modifiers.Shift);
|
||||||
|
|
||||||
|
if (--lifetime <= 0 && !force)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (!(force || Game.Settings.Game.DrawTargetLine))
|
if (!(force || Game.Settings.Game.DrawTargetLine))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (targets == null || targets.Count == 0)
|
var prev = self.CenterPosition;
|
||||||
yield break;
|
var a = self.CurrentActivity;
|
||||||
|
for (; a != null; a = a.NextActivity)
|
||||||
foreach (var target in targets)
|
|
||||||
{
|
{
|
||||||
if (target.Type == TargetType.Invalid)
|
if (a.IsCanceling)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
yield return new TargetLineRenderable(new[] { self.CenterPosition, target.CenterPosition }, c);
|
foreach (var n in a.TargetLineNodes(self))
|
||||||
|
{
|
||||||
|
if (n.Target.Type != TargetType.Invalid)
|
||||||
|
{
|
||||||
|
yield return new TargetLineRenderable(new[] { prev, n.Target.CenterPosition }, n.Color, info.LineWidth, info.MarkerWidth);
|
||||||
|
prev = n.Target.CenterPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRenderAboveShroudWhenSelected.SpatiallyPartitionable { get { return false; } }
|
bool IRenderAboveShroudWhenSelected.SpatiallyPartitionable { get { return false; } }
|
||||||
|
|
||||||
void INotifyBecomingIdle.OnBecomingIdle(Actor self)
|
|
||||||
{
|
|
||||||
targets = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
|
||||||
{
|
|
||||||
targets = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LineTargetExts
|
public static class LineTargetExts
|
||||||
{
|
{
|
||||||
public static void SetTargetLines(this Actor self, List<Target> targets, Color color)
|
public static void ShowTargetLines(this Actor self)
|
||||||
{
|
{
|
||||||
var line = self.TraitOrDefault<DrawLineToTarget>();
|
if (self.Owner != self.World.LocalPlayer)
|
||||||
if (line != null)
|
|
||||||
self.World.AddFrameEndTask(w => line.SetTargets(self, targets, color, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetTargetLine(this Actor self, Target target, Color color)
|
|
||||||
{
|
|
||||||
self.SetTargetLine(target, color, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetTargetLine(this Actor self, Target target, Color color, bool display)
|
|
||||||
{
|
|
||||||
if (!self.Owner.IsAlliedWith(self.World.LocalPlayer))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (self.Disposed)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Draw after frame end so that all the queueing of activities are done before drawing.
|
||||||
var line = self.TraitOrDefault<DrawLineToTarget>();
|
var line = self.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTarget(self, target, color, display);
|
self.World.AddFrameEndTask(w => line.ShowTargetLines(self));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!CanRepairAt(order.Target.Actor) || (!CanRepair() && !CanRearm()))
|
if (!CanRepairAt(order.Target.Actor) || (!CanRepair() && !CanRearm()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
self.QueueActivity(order.Queued, new Resupply(self, order.Target.Actor, new WDist(512)));
|
self.QueueActivity(order.Queued, new Resupply(self, order.Target.Actor, new WDist(512)));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<VariableObserver> IObservesVariables.GetVariableObservers()
|
IEnumerable<VariableObserver> IObservesVariables.GetVariableObservers()
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
|
||||||
self.QueueActivity(new Resupply(self, order.Target.Actor, Info.CloseEnough));
|
self.QueueActivity(new Resupply(self, order.Target.Actor, Info.CloseEnough));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor FindRepairBuilding(Actor self)
|
public Actor FindRepairBuilding(Actor self)
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued)
|
if (!order.Queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Yellow);
|
|
||||||
self.QueueActivity(new RepairBridge(self, order.Target, info.EnterBehaviour, info.RepairNotification));
|
self.QueueActivity(new RepairBridge(self, order.Target, info.EnterBehaviour, info.RepairNotification));
|
||||||
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -425,8 +425,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public interface IMove
|
public interface IMove
|
||||||
{
|
{
|
||||||
Activity MoveTo(CPos cell, int nearEnough);
|
Activity MoveTo(CPos cell, int nearEnough, Color? targetLineColor = null);
|
||||||
Activity MoveTo(CPos cell, Actor ignoreActor);
|
Activity MoveTo(CPos cell, Actor ignoreActor, Color? targetLineColor = null);
|
||||||
Activity MoveWithinRange(Target target, WDist range,
|
Activity MoveWithinRange(Target target, WDist range,
|
||||||
WPos? initialTargetPosition = null, Color? targetLineColor = null);
|
WPos? initialTargetPosition = null, Color? targetLineColor = null);
|
||||||
Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using OpenRA.Activities;
|
|||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Mods.D2k.Activities;
|
using OpenRA.Mods.D2k.Activities;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.D2k.Traits
|
namespace OpenRA.Mods.D2k.Traits
|
||||||
@@ -70,7 +71,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
self.QueueActivity(new SwallowActor(self, target, a, facing));
|
self.QueueActivity(new SwallowActor(self, target, a, facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||||
{
|
{
|
||||||
return new SwallowTarget(self, newTarget, allowMove, forceAttack);
|
return new SwallowTarget(self, newTarget, allowMove, forceAttack);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user