Disable unit production when building is locked.
This commit is contained in:
@@ -28,13 +28,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public virtual object Create(ActorInitializer init) { return new Production(init, this); }
|
||||
}
|
||||
|
||||
public class Production
|
||||
public class Production : INotifyCreated
|
||||
{
|
||||
readonly Lazy<RallyPoint> rp;
|
||||
|
||||
public readonly ProductionInfo Info;
|
||||
public string Faction { get; private set; }
|
||||
|
||||
Building building;
|
||||
|
||||
public Production(ActorInitializer init, ProductionInfo info)
|
||||
{
|
||||
Info = info;
|
||||
@@ -42,6 +44,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
building = self.TraitOrDefault<Building>();
|
||||
}
|
||||
|
||||
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string factionVariant)
|
||||
{
|
||||
var exit = CPos.Zero;
|
||||
@@ -122,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public virtual bool Produce(Actor self, ActorInfo producee, string factionVariant)
|
||||
{
|
||||
if (Reservable.IsReserved(self))
|
||||
if (Reservable.IsReserved(self) || (building != null && building.Locked))
|
||||
return false;
|
||||
|
||||
// Pick a spawn/exit point pair
|
||||
|
||||
Reference in New Issue
Block a user