Implement Building/UnitDelays

This commit is contained in:
Mustafa Alperen Seki
2019-01-21 14:41:03 +03:00
committed by reaperrr
parent 2a9721a9f8
commit 2aebb05cd0
3 changed files with 17 additions and 0 deletions

View File

@@ -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])