Update the Lua API
This commit is contained in:
committed by
Matthias Mailänder
parent
a5bc841355
commit
a10deddf53
@@ -34,19 +34,22 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Build a unit, ignoring the production queue. The activity will wait if the exit is blocked.",
|
||||
"If productionType is nil or unavailable, then an exit will be selected based on Buildable info.")]
|
||||
"If productionType is nil or unavailable, then an exit will be selected based on 'Buildable.BuildAtProductionType'.",
|
||||
"If 'Buildable.BuildAtProductionType' is not set either, a random exit will be selected.")]
|
||||
public void Produce(string actorType, string factionVariant = null, string productionType = null)
|
||||
{
|
||||
ActorInfo actorInfo;
|
||||
if (!Self.World.Map.Rules.Actors.TryGetValue(actorType, out actorInfo))
|
||||
throw new LuaException("Unknown actor type '{0}'".F(actorType));
|
||||
|
||||
var bi = actorInfo.TraitInfo<BuildableInfo>();
|
||||
Self.QueueActivity(new WaitFor(() =>
|
||||
{
|
||||
// Go through all available traits and see which one successfully produces
|
||||
foreach (var p in productionTraits)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(productionType) && !p.Info.Produces.Contains(productionType))
|
||||
var type = productionType ?? bi.BuildAtProductionType;
|
||||
if (!string.IsNullOrEmpty(type) && !p.Info.Produces.Contains(type))
|
||||
continue;
|
||||
|
||||
var inits = new TypeDictionary
|
||||
@@ -55,7 +58,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
new FactionInit(factionVariant ?? BuildableInfo.GetInitialFaction(actorInfo, p.Faction))
|
||||
};
|
||||
|
||||
if (p.Produce(Self, actorInfo, productionType, inits))
|
||||
if (p.Produce(Self, actorInfo, type, inits))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user