Added callback in Passenger during unload from cargo just before the actor is added back to the world
This commit is contained in:
@@ -119,11 +119,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
var move = actor.Trait<IMove>();
|
var move = actor.Trait<IMove>();
|
||||||
var pos = actor.Trait<IPositionable>();
|
var pos = actor.Trait<IPositionable>();
|
||||||
|
var passenger = actor.Trait<Passenger>();
|
||||||
|
|
||||||
pos.SetPosition(actor, exitSubCell.Value.Cell, exitSubCell.Value.SubCell);
|
pos.SetPosition(actor, exitSubCell.Value.Cell, exitSubCell.Value.SubCell);
|
||||||
pos.SetCenterPosition(actor, spawn);
|
pos.SetCenterPosition(actor, spawn);
|
||||||
|
|
||||||
actor.CancelActivity();
|
passenger.OnBeforeAddedToWorld(actor);
|
||||||
w.Add(actor);
|
w.Add(actor);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,8 +428,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
foreach (var nbm in nbms)
|
foreach (var nbm in nbms)
|
||||||
nbm.OnNotifyBlockingMove(passenger, passenger);
|
nbm.OnNotifyBlockingMove(passenger, passenger);
|
||||||
|
|
||||||
// For show.
|
passenger.Trait<Passenger>().OnEjectedFromKilledCargo(passenger);
|
||||||
passenger.QueueActivity(new Nudge(passenger));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
passenger.Kill(e.Attacker);
|
passenger.Kill(e.Attacker);
|
||||||
|
|||||||
@@ -207,6 +207,19 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
ReservedCargo = null;
|
ReservedCargo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnBeforeAddedToWorld(Actor actor)
|
||||||
|
{
|
||||||
|
actor.CancelActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnEjectedFromKilledCargo(Actor self)
|
||||||
|
{
|
||||||
|
// Cancel all other activities to keep consistent behavior with the one in UnloadCargo.
|
||||||
|
self.CurrentActivity?.Cancel(self);
|
||||||
|
|
||||||
|
self.QueueActivity(new Nudge(self));
|
||||||
|
}
|
||||||
|
|
||||||
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (Transport == null)
|
if (Transport == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user