Require explicit INotifyActorDisposing

This commit is contained in:
reaperrr
2017-09-27 22:38:42 +02:00
committed by abcdefg30
parent 5026dfe5d3
commit 9aaf800bca
9 changed files with 17 additions and 13 deletions

View File

@@ -135,6 +135,8 @@ namespace OpenRA.Traits
public interface INotifyAddedToWorld { void AddedToWorld(Actor self); }
public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); }
[RequireExplicitImplementation]
public interface INotifyActorDisposing { void Disposing(Actor self); }
public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); }
public interface INotifyEffectiveOwnerChanged { void OnEffectiveOwnerChanged(Actor self, Player oldEffectiveOwner, Player newEffectiveOwner); }

View File

@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Traits
ActOnFrozenActorsForAllPlayers(Refresh);
}
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
ActOnFrozenActorsForAllPlayers(Remove);
}

View File

@@ -523,7 +523,7 @@ namespace OpenRA.Mods.Common.Scripting
Clear(t);
}
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
ClearAll();
}

View File

@@ -824,7 +824,7 @@ namespace OpenRA.Mods.Common.Traits
#endregion
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
UnReserve();
}

View File

@@ -38,6 +38,8 @@ namespace OpenRA.Mods.Common.Traits
public int NetWorth { get; protected set; }
bool disposed;
public EditorResourceLayer(Actor self)
{
if (self.World.Type != WorldType.Editor)
@@ -198,8 +200,7 @@ namespace OpenRA.Mods.Common.Traits
l.Draw(wr.Viewport);
}
bool disposed;
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
if (disposed)
return;

View File

@@ -36,6 +36,8 @@ namespace OpenRA.Mods.Common.Traits
protected readonly CellLayer<CellContents> Content;
protected readonly CellLayer<CellContents> RenderContent;
bool disposed;
public ResourceLayer(Actor self)
{
world = self.World;
@@ -286,8 +288,7 @@ namespace OpenRA.Mods.Common.Traits
return Content[cell].Type.Info.MaxDensity;
}
bool disposed;
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
if (disposed)
return;

View File

@@ -95,6 +95,7 @@ namespace OpenRA.Mods.Common.Traits
Shroud currentShroud;
Func<PPos, bool> visibleUnderShroud, visibleUnderFog;
TerrainSpriteLayer shroudLayer, fogLayer;
bool disposed;
public ShroudRenderer(World world, ShroudRendererInfo info)
{
@@ -301,8 +302,7 @@ namespace OpenRA.Mods.Common.Traits
return sprites[variant * variantStride + edgesToSpriteIndexOffset[(byte)edges]];
}
bool disposed;
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
if (disposed)
return;

View File

@@ -88,6 +88,7 @@ namespace OpenRA.Mods.Common.Traits
readonly World world;
TerrainSpriteLayer render;
bool disposed;
public SmudgeLayer(Actor self, SmudgeLayerInfo info)
{
@@ -207,8 +208,7 @@ namespace OpenRA.Mods.Common.Traits
render.Draw(wr.Viewport);
}
bool disposed;
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
if (disposed)
return;

View File

@@ -32,6 +32,7 @@ namespace OpenRA.Mods.D2k.Traits
TerrainSpriteLayer render;
Theater theater;
bool disposed;
public BuildableTerrainLayer(Actor self, BuildableTerrainLayerInfo info)
{
@@ -75,8 +76,7 @@ namespace OpenRA.Mods.D2k.Traits
render.Draw(wr.Viewport);
}
bool disposed;
public void Disposing(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
if (disposed)
return;