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

@@ -8,6 +8,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
@@ -42,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual object Create(ActorInitializer init) { return new Refinery(init.Self, this); }
}
public class Refinery : ITick, IAcceptResources, INotifyKilled, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync
public class Refinery : ITick, IAcceptResources, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync, INotifyActorDisposing
{
readonly Actor self;
readonly RefineryInfo info;
@@ -118,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
public void Killed(Actor self, AttackInfo e)
public void Disposing(Actor self)
{
CancelDock(self);
foreach (var harv in GetLinkedHarvesters())

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Reserve landing places for aircraft.")]
class ReservableInfo : TraitInfo<Reservable> { }
public class Reservable : ITick, INotifyKilled, INotifyOwnerChanged, INotifySold
public class Reservable : ITick, INotifyOwnerChanged, INotifySold, INotifyActorDisposing
{
Actor reservedFor;
Aircraft reservedForAircraft;
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
return res != null && res.reservedFor != null;
}
public void Killed(Actor self, AttackInfo e)
public void Disposing(Actor self)
{
if (reservedForAircraft != null)
reservedForAircraft.UnReserve();