Remove legacy Building plumbing.
This commit is contained in:
@@ -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<CPos, SubCell>[] occupiedCells;
|
||||
Pair<CPos, SubCell>[] 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<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
public Pair<CPos, SubCell>[] OccupiedCells() { return occupiedCells; }
|
||||
|
||||
Pair<CPos, SubCell>[] ITargetableCells.TargetableCells() { return targetableCells; }
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
if (SkipMakeAnimation || !self.Info.HasTraitInfo<WithMakeAnimationInfo>())
|
||||
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<INotifyBuildComplete>())
|
||||
notify.BuildingComplete(self);
|
||||
}
|
||||
|
||||
void INotifySold.Selling(Actor self)
|
||||
{
|
||||
if (Info.RemoveSmudgesOnSell)
|
||||
RemoveSmudges();
|
||||
|
||||
BuildComplete = false;
|
||||
}
|
||||
|
||||
void INotifySold.Sold(Actor self) { }
|
||||
|
||||
@@ -106,9 +106,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>();
|
||||
foreach (var notify in notifyOthers)
|
||||
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, productionType);
|
||||
|
||||
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
||||
t.BuildingComplete(newUnit);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -102,9 +102,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>();
|
||||
foreach (var notify in notifyOthers)
|
||||
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, productionType);
|
||||
|
||||
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
||||
t.BuildingComplete(newUnit);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
@@ -158,9 +158,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>();
|
||||
foreach (var notify in notifyOthers)
|
||||
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit, productionType);
|
||||
|
||||
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
||||
t.BuildingComplete(newUnit);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<WithSpriteBody>().Where(w => info.BodyNames.Contains(w.Info.Name)).ToArray();
|
||||
skipMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||
var building = self.TraitOrDefault<Building>();
|
||||
if (building != null && !building.SkipMakeAnimation)
|
||||
Forward(self, () => building.NotifyBuildingComplete(self));
|
||||
if (!skipMakeAnimation)
|
||||
Forward(self, () => { });
|
||||
}
|
||||
|
||||
public void Forward(Actor self, Action onComplete)
|
||||
|
||||
@@ -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); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user