Implement Building/UnitDelays
This commit is contained in:
committed by
reaperrr
parent
2a9721a9f8
commit
2aebb05cd0
@@ -119,6 +119,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("What buildings should the AI have a maximum limit to build.")]
|
||||
public readonly Dictionary<string, int> BuildingLimits = null;
|
||||
|
||||
[Desc("When should the AI start building specific buildings.")]
|
||||
public readonly Dictionary<string, int> BuildingDelays = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new BaseBuilderBotModule(init.Self, this); }
|
||||
}
|
||||
|
||||
|
||||
@@ -292,6 +292,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var name = frac.Key;
|
||||
|
||||
// Does this building have initial delay, if so have we passed it?
|
||||
if (baseBuilder.Info.BuildingDelays != null &&
|
||||
baseBuilder.Info.BuildingDelays.ContainsKey(name) &&
|
||||
baseBuilder.Info.BuildingDelays[name] > world.WorldTick)
|
||||
continue;
|
||||
|
||||
// Can we build this structure?
|
||||
if (!buildableThings.Any(b => b.Name == name))
|
||||
continue;
|
||||
|
||||
@@ -33,6 +33,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("What units should the AI have a maximum limit to train.")]
|
||||
public readonly Dictionary<string, int> UnitLimits = null;
|
||||
|
||||
[Desc("When should the AI start train specific units.")]
|
||||
public readonly Dictionary<string, int> UnitDelays = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new UnitBuilderBotModule(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -118,6 +121,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (Info.UnitsToBuild != null && !Info.UnitsToBuild.ContainsKey(name))
|
||||
return;
|
||||
|
||||
if (Info.UnitDelays != null &&
|
||||
Info.UnitDelays.ContainsKey(name) &&
|
||||
Info.UnitDelays[name] > world.WorldTick)
|
||||
return;
|
||||
|
||||
if (Info.UnitLimits != null &&
|
||||
Info.UnitLimits.ContainsKey(name) &&
|
||||
world.Actors.Count(a => a.Owner == player && a.Info.Name == name) >= Info.UnitLimits[name])
|
||||
|
||||
Reference in New Issue
Block a user