Fix service depot animation breaking sell.

This commit is contained in:
Paul Chote
2016-07-09 11:11:31 +01:00
parent 196dd04b5d
commit 7325f0e733

View File

@@ -24,20 +24,34 @@ namespace OpenRA.Mods.Common.Traits.Render
public object Create(ActorInitializer init) { return new WithRepairAnimation(init.Self, this); } public object Create(ActorInitializer init) { return new WithRepairAnimation(init.Self, this); }
} }
public class WithRepairAnimation : INotifyRepair public class WithRepairAnimation : INotifyRepair, INotifyBuildComplete, INotifySold
{ {
readonly WithRepairAnimationInfo info; readonly WithRepairAnimationInfo info;
readonly WithSpriteBody spriteBody;
bool buildComplete;
public WithRepairAnimation(Actor self, WithRepairAnimationInfo info) public WithRepairAnimation(Actor self, WithRepairAnimationInfo info)
{ {
this.info = info; this.info = info;
spriteBody = self.TraitOrDefault<WithSpriteBody>();
} }
public void Repairing(Actor self, Actor host) public void Repairing(Actor self, Actor host)
{ {
var spriteBody = host.TraitOrDefault<WithSpriteBody>(); if (buildComplete && spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled()))
if (spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled()))
spriteBody.PlayCustomAnimation(host, info.Sequence, () => spriteBody.CancelCustomAnimation(host)); spriteBody.PlayCustomAnimation(host, info.Sequence, () => spriteBody.CancelCustomAnimation(host));
} }
public void BuildingComplete(Actor self)
{
buildComplete = true;
}
public void Selling(Actor self)
{
buildComplete = false;
}
public void Sold(Actor self) { }
} }
} }