Fix harvesters losing their last harvesting position when carried by carryall.
This commit is contained in:
@@ -26,7 +26,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class AutoCarryable : Carryable, ICallForTransport
|
||||
{
|
||||
readonly AutoCarryableInfo info;
|
||||
Activity afterLandActivity;
|
||||
|
||||
public AutoCarryable(Actor self, AutoCarryableInfo info)
|
||||
: base(self, info)
|
||||
@@ -38,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// No longer want to be carried
|
||||
void ICallForTransport.MovementCancelled(Actor self) { MovementCancelled(self); }
|
||||
void ICallForTransport.RequestTransport(Actor self, CPos destination, Activity afterLandActivity) { RequestTransport(self, destination, afterLandActivity); }
|
||||
void ICallForTransport.RequestTransport(Actor self, CPos destination) { RequestTransport(self, destination); }
|
||||
|
||||
void MovementCancelled(Actor self)
|
||||
{
|
||||
@@ -46,12 +45,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
Destination = null;
|
||||
afterLandActivity = null;
|
||||
|
||||
// TODO: We could implement something like a carrier.Trait<Carryall>().CancelTransportNotify(self) and call it here
|
||||
}
|
||||
|
||||
void RequestTransport(Actor self, CPos destination, Activity afterLandActivity)
|
||||
void RequestTransport(Actor self, CPos destination)
|
||||
{
|
||||
var delta = self.World.Map.CenterOfCell(destination) - self.CenterPosition;
|
||||
if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared)
|
||||
@@ -61,7 +59,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
Destination = destination;
|
||||
this.afterLandActivity = afterLandActivity;
|
||||
|
||||
if (state != State.Free)
|
||||
return;
|
||||
@@ -85,9 +82,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Destination = null;
|
||||
|
||||
if (afterLandActivity != null)
|
||||
self.QueueActivity(false, afterLandActivity);
|
||||
|
||||
base.Detached(self);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("The condition to grant to self while being carried.")]
|
||||
public readonly string CarriedCondition = null;
|
||||
|
||||
[GrantedConditionReference]
|
||||
[Desc("The condition to grant to self while being locked for carry.")]
|
||||
public readonly string LockedCondition = null;
|
||||
|
||||
[Desc("Carryall attachment point relative to body.")]
|
||||
public readonly WVec LocalOffset = WVec.Zero;
|
||||
|
||||
@@ -36,6 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
ConditionManager conditionManager;
|
||||
int reservedToken = ConditionManager.InvalidConditionToken;
|
||||
int carriedToken = ConditionManager.InvalidConditionToken;
|
||||
int lockedToken = ConditionManager.InvalidConditionToken;
|
||||
|
||||
public Actor Carrier { get; private set; }
|
||||
public bool Reserved { get { return state != State.Free; } }
|
||||
@@ -100,6 +105,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (reservedToken != ConditionManager.InvalidConditionToken)
|
||||
reservedToken = conditionManager.RevokeCondition(self, reservedToken);
|
||||
|
||||
if (lockedToken != ConditionManager.InvalidConditionToken)
|
||||
lockedToken = conditionManager.RevokeCondition(self, lockedToken);
|
||||
}
|
||||
|
||||
// Prepare for transport pickup
|
||||
@@ -110,7 +118,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
state = State.Locked;
|
||||
Carrier = carrier;
|
||||
self.QueueActivity(false, new WaitFor(() => state != State.Locked, false));
|
||||
|
||||
if (lockedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.LockedCondition))
|
||||
lockedToken = conditionManager.GrantCondition(self, Info.LockedCondition);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,18 +29,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
transports = self.TraitsImplementing<ICallForTransport>().ToArray();
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell, Activity next)
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell)
|
||||
{
|
||||
foreach (var t in transports)
|
||||
t.RequestTransport(self, targetCell, next);
|
||||
t.RequestTransport(self, targetCell);
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor, Activity next)
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor)
|
||||
{
|
||||
var iao = refineryActor.Trait<IAcceptResources>();
|
||||
var location = refineryActor.Location + iao.DeliveryOffset;
|
||||
foreach (var t in transports)
|
||||
t.RequestTransport(self, location, next);
|
||||
t.RequestTransport(self, location);
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self)
|
||||
|
||||
@@ -210,9 +210,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return color;
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell, Activity next) { }
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor, Activity next) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
||||
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
void INotifyHarvesterAction.Docked() { }
|
||||
void INotifyHarvesterAction.Undocked() { }
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell, Activity next) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor, Activity next) { }
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
anim.PlayThen(info.Sequence, () => visible = false);
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell, Activity next) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor targetRefinery, Activity next) { }
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor targetRefinery) { }
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||
void INotifyHarvesterAction.Docked() { }
|
||||
void INotifyHarvesterAction.Undocked() { }
|
||||
|
||||
Reference in New Issue
Block a user