Require explicit INotifyAddedToWorld and INotifyRemovedFromWorld
This commit is contained in:
@@ -134,7 +134,9 @@ namespace OpenRA.Traits
|
|||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyCreated { void Created(Actor self); }
|
public interface INotifyCreated { void Created(Actor self); }
|
||||||
|
|
||||||
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyAddedToWorld { void AddedToWorld(Actor self); }
|
public interface INotifyAddedToWorld { void AddedToWorld(Actor self); }
|
||||||
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); }
|
public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); }
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
return !active;
|
return !active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddedToWorld(Actor self)
|
protected override void AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
base.AddedToWorld(self);
|
base.AddedToWorld(self);
|
||||||
blockedPositions = info.Tiles(self.Location);
|
blockedPositions = info.Tiles(self.Location);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
bi = self.Info.TraitInfo<BuildingInfo>();
|
bi = self.Info.TraitInfo<BuildingInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
var rows = info.HasMinibib ? 1 : 2;
|
var rows = info.HasMinibib ? 1 : 2;
|
||||||
var width = bi.Dimensions.X;
|
var width = bi.Dimensions.X;
|
||||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
foreach (var a in anims)
|
foreach (var a in anims)
|
||||||
rs.Remove(a);
|
rs.Remove(a);
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
if (world.Disposing)
|
if (world.Disposing)
|
||||||
return;
|
return;
|
||||||
@@ -341,7 +341,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
if (world.Disposing)
|
if (world.Disposing)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -295,7 +295,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
NotifyBuildingComplete(self);
|
NotifyBuildingComplete(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
|
{
|
||||||
|
AddedToWorld(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
if (Info.RemoveSmudgesOnBuild)
|
if (Info.RemoveSmudgesOnBuild)
|
||||||
RemoveSmudges();
|
RemoveSmudges();
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return !self.IsDisabled() && BuildComplete && blocking.AppearsFriendlyTo(self);
|
return !self.IsDisabled() && BuildComplete && blocking.AppearsFriendlyTo(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddedToWorld(Actor self)
|
protected override void AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
base.AddedToWorld(self);
|
base.AddedToWorld(self);
|
||||||
blockedPositions = Info.Tiles(self.Location);
|
blockedPositions = Info.Tiles(self.Location);
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
cachedVRange = WDist.Zero;
|
cachedVRange = WDist.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
cachedPosition = self.CenterPosition;
|
cachedPosition = self.CenterPosition;
|
||||||
proximityTrigger = self.World.ActorMap.AddProximityTrigger(cachedPosition, cachedRange, cachedVRange, ActorEntered, ActorExited);
|
proximityTrigger = self.World.ActorMap.AddProximityTrigger(cachedPosition, cachedRange, cachedVRange, ActorEntered, ActorExited);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.ActorMap.RemoveProximityTrigger(proximityTrigger);
|
self.World.ActorMap.RemoveProximityTrigger(proximityTrigger);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return self.IsAtGroundLevel() && crushClasses.Contains(info.CrushClass);
|
return self.IsAtGroundLevel() && crushClasses.Contains(info.CrushClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.AddToMaps(self, this);
|
self.World.AddToMaps(self, this);
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
cs.IncrementCrates();
|
cs.IncrementCrates();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.RemoveFromMaps(self, this);
|
self.World.RemoveFromMaps(self, this);
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
health = self.Trait<Health>();
|
health = self.Trait<Health>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
if (!Info.StartOnThreshold)
|
if (!Info.StartOnThreshold)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -118,12 +118,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.UpdateMaps(self, this);
|
self.World.UpdateMaps(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.AddToMaps(self, this);
|
self.World.AddToMaps(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.RemoveFromMaps(self, this);
|
self.World.RemoveFromMaps(self, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public WPos CenterPosition { get { return position; } }
|
public WPos CenterPosition { get { return position; } }
|
||||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
|
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.ActorMap.AddInfluence(self, this);
|
self.World.ActorMap.AddInfluence(self, this);
|
||||||
self.World.ActorMap.AddPosition(self, this);
|
self.World.ActorMap.AddPosition(self, this);
|
||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.ScreenMap.Add(self);
|
self.World.ScreenMap.Add(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.ActorMap.RemoveInfluence(self, this);
|
self.World.ActorMap.RemoveInfluence(self, this);
|
||||||
self.World.ActorMap.RemovePosition(self, this);
|
self.World.ActorMap.RemovePosition(self, this);
|
||||||
|
|||||||
@@ -569,12 +569,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.AddToMaps(self, this);
|
self.World.AddToMaps(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
self.World.RemoveFromMaps(self, this);
|
self.World.RemoveFromMaps(self, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return actorToDrop.Trait<IPositionable>().CanEnterCell(p);
|
return actorToDrop.Trait<IPositionable>().CanEnterCell(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
OnRemovedFromWorld(self);
|
OnRemovedFromWorld(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self) { Unreserve(self); }
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self) { Unreserve(self); }
|
||||||
|
|
||||||
public void Unreserve(Actor self)
|
public void Unreserve(Actor self)
|
||||||
{
|
{
|
||||||
if (ReservedCargo == null)
|
if (ReservedCargo == null)
|
||||||
|
|||||||
@@ -43,9 +43,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void TraitEnabled(Actor self) { PlayerPower.UpdateActor(self); }
|
protected override void TraitEnabled(Actor self) { PlayerPower.UpdateActor(self); }
|
||||||
protected override void TraitDisabled(Actor self) { PlayerPower.UpdateActor(self); }
|
protected override void TraitDisabled(Actor self) { PlayerPower.UpdateActor(self); }
|
||||||
public void AddedToWorld(Actor self) { PlayerPower.UpdateActor(self); }
|
|
||||||
public void RemovedFromWorld(Actor self) { PlayerPower.RemoveActor(self); }
|
void INotifyAddedToWorld.AddedToWorld(Actor self) { PlayerPower.UpdateActor(self); }
|
||||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self) { PlayerPower.RemoveActor(self); }
|
||||||
|
|
||||||
|
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
PlayerPower.RemoveActor(self);
|
PlayerPower.RemoveActor(self);
|
||||||
PlayerPower = newOwner.PlayerActor.Trait<PowerManager>();
|
PlayerPower = newOwner.PlayerActor.Trait<PowerManager>();
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
aat.SetDirty();
|
aat.SetDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromWorld(Actor self)
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
{
|
{
|
||||||
UpdateNeighbours(self);
|
UpdateNeighbours(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
buildingInfo = self.Info.TraitInfo<BuildingInfo>();
|
buildingInfo = self.Info.TraitInfo<BuildingInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
{
|
{
|
||||||
var map = self.World.Map;
|
var map = self.World.Map;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user