Dispose actors when tearing down the world.

This commit is contained in:
Paul Chote
2015-05-23 21:41:21 +01:00
parent 585a43fd8f
commit 4ff309811f
3 changed files with 24 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ namespace OpenRA
{
public enum WorldType { Regular, Shellmap, Editor }
public class World
public sealed class World : IDisposable
{
class ActorIDComparer : IComparer<Actor>
{
@@ -369,6 +369,19 @@ namespace OpenRA
pi.OutcomeTimestampUtc = DateTime.UtcNow;
}
}
public void Dispose()
{
frameEndActions.Clear();
// Dispose newer actors first, and the world actor last
foreach (var a in actors.Reverse())
a.Dispose();
// Actor disposals are done in a FrameEndTask
while (frameEndActions.Count != 0)
frameEndActions.Dequeue()(this);
}
}
public struct TraitPair<T>