Merge pull request #11619 from pchote/fix-depot-sell

Fix service depot selling.
This commit is contained in:
Matthias Mailänder
2016-07-09 21:17:06 +02:00
committed by GitHub
3 changed files with 21 additions and 7 deletions

View File

@@ -129,7 +129,7 @@ namespace OpenRA.Traits
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); }
public interface INotifyRepair { void Repairing(Actor self, Actor host); }
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
public interface INotifyActorDisposing { void Disposing(Actor self); }
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Activities
self.InflictDamage(self, -hpToRepair, null);
foreach (var depot in host.TraitsImplementing<INotifyRepair>())
depot.Repairing(self, host);
depot.Repairing(host, self);
remainingTicks = repairsUnits.Interval;
}

View File

@@ -24,20 +24,34 @@ namespace OpenRA.Mods.Common.Traits.Render
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 WithSpriteBody spriteBody;
bool buildComplete;
public WithRepairAnimation(Actor self, WithRepairAnimationInfo info)
{
this.info = info;
spriteBody = self.TraitOrDefault<WithSpriteBody>();
}
public void Repairing(Actor self, Actor host)
public void Repairing(Actor self, Actor target)
{
var spriteBody = host.TraitOrDefault<WithSpriteBody>();
if (spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled()))
spriteBody.PlayCustomAnimation(host, info.Sequence, () => spriteBody.CancelCustomAnimation(host));
if (buildComplete && spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled()))
spriteBody.PlayCustomAnimation(self, info.Sequence, () => spriteBody.CancelCustomAnimation(self));
}
public void BuildingComplete(Actor self)
{
buildComplete = true;
}
public void Selling(Actor self)
{
buildComplete = false;
}
public void Sold(Actor self) { }
}
}