Add Lua cargo insertion code and Utils.Skip. Needed for Allies 03 Classic.
This commit is contained in:
@@ -38,6 +38,27 @@ Reinforcements.PerformHelicopterExtraction = function(owner, helicopterName, pas
|
||||
return heli
|
||||
end
|
||||
|
||||
Reinforcements.PerformInsertion = function(owner, vehicleName, passengerNames, enterPath, exitPath)
|
||||
local facing = { 0, "Int32" }
|
||||
if #enterPath > 1 then
|
||||
facing = { Map.GetFacing(CPos.op_Subtraction(enterPath[2], enterPath[1]), 0), "Int32" }
|
||||
end
|
||||
local vehicle = Actor.Create(vehicleName, { Owner = owner, Location = enterPath[1], Facing = facing })
|
||||
local cargo = Actor.Trait(vehicle, "Cargo")
|
||||
local passengers = { }
|
||||
for i, passengerName in ipairs(passengerNames) do
|
||||
local passenger = Actor.Create(passengerName, { AddToWorld = false, Owner = owner })
|
||||
passengers[i] = passenger
|
||||
cargo:Load(vehicle, passenger)
|
||||
end
|
||||
Utils.Do(Utils.Skip(enterPath, 1), function(l) Actor.ScriptedMove(vehicle, l) end)
|
||||
Actor.UnloadCargo(vehicle, true)
|
||||
Actor.Wait(vehicle, 25)
|
||||
Utils.Do(exitPath, function(l) Actor.ScriptedMove(vehicle, l) end)
|
||||
Actor.RemoveSelf(vehicle)
|
||||
return vehicle, passengers
|
||||
end
|
||||
|
||||
Reinforcements.Reinforce = function(owner, reinforcementNames, enterLocation, rallyPointLocation, interval, onCreateFunc)
|
||||
local facing = { Map.GetFacing(CPos.op_Subtraction(rallyPointLocation, enterLocation), 0), "Int32" }
|
||||
local reinforcements = { }
|
||||
|
||||
@@ -57,5 +57,5 @@ Team.Contains = function(team, actor)
|
||||
end
|
||||
|
||||
Team.Do = function(team, func)
|
||||
Utils.ForEach(team.Actors, func)
|
||||
Utils.Do(team.Actors, func)
|
||||
end
|
||||
@@ -56,12 +56,22 @@ Utils.Any = function(array, func)
|
||||
return false
|
||||
end
|
||||
|
||||
Utils.ForEach = function(array, func)
|
||||
Utils.Do = function(array, func)
|
||||
for i, item in ipairs(array) do
|
||||
func(item)
|
||||
end
|
||||
end
|
||||
|
||||
Utils.Skip = function(array, n)
|
||||
local ret = { }
|
||||
for i, item in ipairs(array) do
|
||||
if i > n then
|
||||
table.insert(ret, item)
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
Utils.TableToArray = function(luaTable)
|
||||
return Internal.TableToArray(luaTable)
|
||||
end
|
||||
Reference in New Issue
Block a user