Fix carryalls telling carryables to unreserve when they are reserved for a different carryall;

Reserve carryable in FreeActorWithDelivery
This commit is contained in:
penev92
2015-04-14 01:53:11 +03:00
parent 70c9bca847
commit 665c82305e
4 changed files with 17 additions and 8 deletions

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.D2k.Activities
readonly IFacing cargoFacing;
readonly IFacing selfFacing;
enum State { Transport, Land, Release, Done }
enum State { Transport, Land, Release }
State state;
@@ -108,11 +108,6 @@ namespace OpenRA.Mods.D2k.Activities
}
Release();
state = State.Done;
return Util.SequenceActivities(new Wait(10), this);
case State.Done:
self.Trait<Carryall>().UnreserveCarryable();
return NextActivity;
}
@@ -125,7 +120,11 @@ namespace OpenRA.Mods.D2k.Activities
cargoFacing.Facing = selfFacing.Facing;
// Put back into world
self.World.AddFrameEndTask(w => cargo.World.Add(cargo));
self.World.AddFrameEndTask(w =>
{
cargo.World.Add(cargo);
carryall.UnreserveCarryable();
});
// Unlock carryable
carryall.CarryableReleased();

View File

@@ -64,7 +64,9 @@ namespace OpenRA.Mods.D2k.Traits
if (clientInitialActivity != null)
cargo.QueueActivity(Game.CreateObject<Activity>(clientInitialActivity));
cargo.Trait<Carryable>().Destination = location;
var carryable = cargo.Trait<Carryable>();
carryable.Destination = location;
carryable.Reserve(carrier);
carrier.Trait<Carryall>().AttachCarryable(cargo);

View File

@@ -116,6 +116,9 @@ namespace OpenRA.Mods.D2k.Traits
public bool Reserve(Actor carrier)
{
if (Reserved)
return false;
if ((self.Location - Destination).Length < info.MinDistance)
{
MovementCancelled(self);

View File

@@ -122,6 +122,9 @@ namespace OpenRA.Mods.D2k.Traits
// Reserve the carryable so its ours exclusively
public bool ReserveCarryable(Actor carryable)
{
if (Carrying != null)
return false;
if (carryable.Trait<Carryable>().Reserve(self))
{
Carrying = carryable;
@@ -144,6 +147,7 @@ namespace OpenRA.Mods.D2k.Traits
}
IsBusy = false;
Carrying = null;
}
// INotifyKilled
@@ -177,6 +181,7 @@ namespace OpenRA.Mods.D2k.Traits
// Called when released
public void CarryableReleased()
{
IsBusy = false;
IsCarrying = false;
anim = null;
}