Properly clean up traits that used to hook only death.

This commit is contained in:
Paul Chote
2015-05-23 22:09:50 +01:00
parent 4ff309811f
commit 8ae3afa3c5
9 changed files with 47 additions and 12 deletions

View File

@@ -54,7 +54,8 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new Cargo(init, this); }
}
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled, INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, IDisableMove
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled,
INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, IDisableMove, INotifyActorDisposing
{
public readonly CargoInfo Info;
readonly Actor self;
@@ -305,6 +306,14 @@ namespace OpenRA.Mods.Common.Traits
cargo.Clear();
}
public void Disposing(Actor self)
{
foreach (var c in cargo)
c.Dispose();
cargo.Clear();
}
public void Selling(Actor self) { }
public void Sold(Actor self)
{