Restricted terrain targeting to force-move enter transports

This commit is contained in:
atlimit8
2014-10-05 11:38:06 -05:00
parent b736e059e9
commit acc0b618c8
3 changed files with 8 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Activities
readonly IMove move; readonly IMove move;
readonly int maxTries = 0; readonly int maxTries = 0;
readonly bool targetCenter;
public Target Target { get { return target; } } public Target Target { get { return target; } }
Target target; Target target;
State nextState = State.ApproachingOrEntering; // Hint/starting point for next state State nextState = State.ApproachingOrEntering; // Hint/starting point for next state
@@ -31,11 +32,12 @@ namespace OpenRA.Mods.RA.Activities
Activity inner; Activity inner;
bool firstApproach = true; bool firstApproach = true;
protected Enter(Actor self, Actor target, int maxTries = 1) protected Enter(Actor self, Actor target, int maxTries = 1, bool targetCenter = false)
{ {
this.move = self.Trait<IMove>(); this.move = self.Trait<IMove>();
this.target = Target.FromActor(target); this.target = Target.FromActor(target);
this.maxTries = maxTries; this.maxTries = maxTries;
this.targetCenter = targetCenter;
} }
// CanEnter(target) should to be true; othwise, Enter may abort. // CanEnter(target) should to be true; othwise, Enter may abort.
@@ -160,7 +162,7 @@ namespace OpenRA.Mods.RA.Activities
case ReserveStatus.None: case ReserveStatus.None:
return State.Done; // No available target -> abort to next activity return State.Done; // No available target -> abort to next activity
case ReserveStatus.TooFar: case ReserveStatus.TooFar:
inner = move.MoveToTarget(self, Target.FromPos(target.CenterPosition)); // Approach inner = move.MoveToTarget(self, targetCenter ? Target.FromPos(target.CenterPosition) : target); // Approach
return State.ApproachingOrEntering; return State.ApproachingOrEntering;
case ReserveStatus.Pending: case ReserveStatus.Pending:
return State.ApproachingOrEntering; // Retry next tick return State.ApproachingOrEntering; // Retry next tick

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.RA.Activities
readonly int maxTries; readonly int maxTries;
Cargo cargo; Cargo cargo;
public EnterTransport(Actor self, Actor transport, int maxTries = 0) public EnterTransport(Actor self, Actor transport, int maxTries = 0, bool targetCenter = false)
: base(self, transport, maxTries) : base(self, transport, maxTries, targetCenter)
{ {
this.transport = transport; this.transport = transport;
this.maxTries = maxTries; this.maxTries = maxTries;

View File

@@ -165,7 +165,8 @@ namespace OpenRA.Mods.RA
self.SetTargetLine(target, Color.Green); self.SetTargetLine(target, Color.Green);
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new EnterTransport(self, order.TargetActor, order.OrderString == "EnterTransport" ? 0 : Info.MaxAlternateTransportAttempts)); var transports = order.OrderString == "EnterTransports";
self.QueueActivity(new EnterTransport(self, order.TargetActor, transports ? Info.MaxAlternateTransportAttempts : 0, transports));
} }
} }