Fix undock anim playing even if docking was cancelled
...before dock anim could run. The undock animation would play even if the dock anim hadn't run (meaning the sequence cancelled before the docking completed, for example due to refinery death).
This commit is contained in:
@@ -45,10 +45,12 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
|
|
||||||
public override void OnStateUndock(Actor self)
|
public override void OnStateUndock(Actor self)
|
||||||
{
|
{
|
||||||
dockingState = DockingState.Wait;
|
// If body.Docked wasn't set, we didn't actually dock and have to skip the undock overlay
|
||||||
|
if (!body.Docked)
|
||||||
if (spriteOverlay != null && !spriteOverlay.Visible)
|
dockingState = DockingState.Complete;
|
||||||
|
else if (spriteOverlay != null && !spriteOverlay.Visible)
|
||||||
{
|
{
|
||||||
|
dockingState = DockingState.Wait;
|
||||||
spriteOverlay.Visible = true;
|
spriteOverlay.Visible = true;
|
||||||
spriteOverlay.WithOffset.Animation.PlayBackwardsThen(spriteOverlay.Info.Sequence, () =>
|
spriteOverlay.WithOffset.Animation.PlayBackwardsThen(spriteOverlay.Info.Sequence, () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
readonly WithSpriteBody wsb;
|
readonly WithSpriteBody wsb;
|
||||||
readonly WithDockingAnimationInfo wda;
|
readonly WithDockingAnimationInfo wda;
|
||||||
|
protected bool dockAnimPlayed;
|
||||||
|
|
||||||
public SpriteHarvesterDockSequence(Actor self, Actor refinery, WAngle dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
|
public SpriteHarvesterDockSequence(Actor self, Actor refinery, WAngle dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
|
||||||
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
|
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
|
||||||
@@ -32,11 +33,20 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
trait.Docked();
|
trait.Docked();
|
||||||
|
|
||||||
wsb.PlayCustomAnimation(self, wda.DockSequence, () => wsb.PlayCustomAnimationRepeating(self, wda.DockLoopSequence));
|
wsb.PlayCustomAnimation(self, wda.DockSequence, () => wsb.PlayCustomAnimationRepeating(self, wda.DockLoopSequence));
|
||||||
|
dockAnimPlayed = true;
|
||||||
dockingState = DockingState.Loop;
|
dockingState = DockingState.Loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnStateUndock(Actor self)
|
public override void OnStateUndock(Actor self)
|
||||||
{
|
{
|
||||||
|
// If dock animation hasn't played, we didn't actually dock and have to skip the undock anim and notification
|
||||||
|
if (!dockAnimPlayed)
|
||||||
|
{
|
||||||
|
dockingState = DockingState.Complete;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dockingState = DockingState.Wait;
|
||||||
wsb.PlayCustomAnimationBackwards(self, wda.DockSequence,
|
wsb.PlayCustomAnimationBackwards(self, wda.DockSequence,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
@@ -44,7 +54,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||||
trait.Undocked();
|
trait.Undocked();
|
||||||
});
|
});
|
||||||
dockingState = DockingState.Wait;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user