diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 3863518280..2da513cd38 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -243,12 +243,10 @@ namespace OpenRA.Mods.Common.Traits } } - public class Building : IOccupySpace, ITargetableCells, INotifySold, INotifyTransform, ISync, INotifyCreated, + public class Building : IOccupySpace, ITargetableCells, INotifySold, INotifyTransform, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld { - public readonly bool SkipMakeAnimation; public readonly BuildingInfo Info; - public bool BuildComplete { get; private set; } [Sync] readonly CPos topLeft; readonly Actor self; @@ -257,20 +255,6 @@ namespace OpenRA.Mods.Common.Traits Pair[] occupiedCells; Pair[] targetableCells; - // Shared activity lock: undeploy, sell, capture, etc. - [Sync] public bool Locked = true; - - public bool Lock() - { - if (Locked) - return false; - - Locked = true; - return true; - } - - public void Unlock() { Locked = false; } - public CPos TopLeft { get { return topLeft; } } public WPos CenterPosition { get; private set; } @@ -288,19 +272,12 @@ namespace OpenRA.Mods.Common.Traits .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World); - SkipMakeAnimation = init.Contains(); } public Pair[] OccupiedCells() { return occupiedCells; } Pair[] ITargetableCells.TargetableCells() { return targetableCells; } - void INotifyCreated.Created(Actor self) - { - if (SkipMakeAnimation || !self.Info.HasTraitInfo()) - NotifyBuildingComplete(self); - } - void INotifyAddedToWorld.AddedToWorld(Actor self) { AddedToWorld(self); @@ -321,24 +298,10 @@ namespace OpenRA.Mods.Common.Traits influence.RemoveInfluence(self, Info.Tiles(self.Location)); } - public void NotifyBuildingComplete(Actor self) - { - if (BuildComplete) - return; - - BuildComplete = true; - Unlock(); - - foreach (var notify in self.TraitsImplementing()) - notify.BuildingComplete(self); - } - void INotifySold.Selling(Actor self) { if (Info.RemoveSmudgesOnSell) RemoveSmudges(); - - BuildComplete = false; } void INotifySold.Sold(Actor self) { } diff --git a/OpenRA.Mods.Common/Traits/Production.cs b/OpenRA.Mods.Common/Traits/Production.cs index aaac112a20..3571ff4bb9 100644 --- a/OpenRA.Mods.Common/Traits/Production.cs +++ b/OpenRA.Mods.Common/Traits/Production.cs @@ -106,9 +106,6 @@ namespace OpenRA.Mods.Common.Traits var notifyOthers = self.World.ActorsWithTrait(); foreach (var notify in notifyOthers) notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, productionType); - - foreach (var t in newUnit.TraitsImplementing()) - t.BuildingComplete(newUnit); }); } diff --git a/OpenRA.Mods.Common/Traits/ProductionFromMapEdge.cs b/OpenRA.Mods.Common/Traits/ProductionFromMapEdge.cs index 9c58a25a03..0bd654801c 100644 --- a/OpenRA.Mods.Common/Traits/ProductionFromMapEdge.cs +++ b/OpenRA.Mods.Common/Traits/ProductionFromMapEdge.cs @@ -102,9 +102,6 @@ namespace OpenRA.Mods.Common.Traits var notifyOthers = self.World.ActorsWithTrait(); foreach (var notify in notifyOthers) notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, productionType); - - foreach (var t in newUnit.TraitsImplementing()) - t.BuildingComplete(newUnit); }); return true; diff --git a/OpenRA.Mods.Common/Traits/ProductionParadrop.cs b/OpenRA.Mods.Common/Traits/ProductionParadrop.cs index 86ce3abed5..ed475c7bcb 100644 --- a/OpenRA.Mods.Common/Traits/ProductionParadrop.cs +++ b/OpenRA.Mods.Common/Traits/ProductionParadrop.cs @@ -158,9 +158,6 @@ namespace OpenRA.Mods.Common.Traits var notifyOthers = self.World.ActorsWithTrait(); foreach (var notify in notifyOthers) notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, productionType); - - foreach (var t in newUnit.TraitsImplementing()) - t.BuildingComplete(newUnit); }); } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs index 26bf54ad04..5a6fd48319 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs @@ -36,6 +36,7 @@ namespace OpenRA.Mods.Common.Traits.Render { readonly WithMakeAnimationInfo info; readonly WithSpriteBody[] wsbs; + readonly bool skipMakeAnimation; ConditionManager conditionManager; int token = ConditionManager.InvalidConditionToken; @@ -45,14 +46,14 @@ namespace OpenRA.Mods.Common.Traits.Render this.info = info; var self = init.Self; wsbs = self.TraitsImplementing().Where(w => info.BodyNames.Contains(w.Info.Name)).ToArray(); + skipMakeAnimation = init.Contains(); } void INotifyCreated.Created(Actor self) { conditionManager = self.TraitOrDefault(); - var building = self.TraitOrDefault(); - if (building != null && !building.SkipMakeAnimation) - Forward(self, () => building.NotifyBuildingComplete(self)); + if (!skipMakeAnimation) + Forward(self, () => { }); } public void Forward(Actor self, Action onComplete) diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index eb74e7583e..58c7d6a3ae 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -105,9 +105,6 @@ namespace OpenRA.Mods.Common.Traits void PreparingAttack(Actor self, Target target, Armament a, Barrel barrel); } - [RequireExplicitImplementation] - public interface INotifyBuildComplete { void BuildingComplete(Actor self); } - [RequireExplicitImplementation] public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); }