Move the TraitInfo stuff into rules.lua
This commit is contained in:
@@ -174,3 +174,4 @@ LuaScripts:
|
||||
mods/common/lua/mission.lua
|
||||
mods/common/lua/reinforcements.lua
|
||||
mods/common/lua/supportpowers.lua
|
||||
mods/common/lua/rules.lua
|
||||
|
||||
@@ -173,24 +173,4 @@ end
|
||||
|
||||
Actor.Trait = function(actor, className)
|
||||
return Internal.Trait(actor, className)
|
||||
end
|
||||
|
||||
Actor.HasTraitInfo = function(actorType, className)
|
||||
return Internal.HasTraitInfo(actorType, className)
|
||||
end
|
||||
|
||||
Actor.TraitInfoOrDefault = function(actorType, className)
|
||||
return Internal.TraitInfoOrDefault(actorType, className)
|
||||
end
|
||||
|
||||
Actor.TraitInfo = function(actorType, className)
|
||||
return Internal.TraitInfo(actorType, className)
|
||||
end
|
||||
|
||||
Actor.InitialAltitude = function(actorName)
|
||||
if Actor.HasTraitInfo("AircraftInfo") then
|
||||
return Actor.TraitInfo(actorName, "AircraftInfo").CruiseAltitude
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
@@ -2,8 +2,8 @@ Reinforcements = { }
|
||||
|
||||
Reinforcements.Insert = function(owner, transportName, passengerNames, enterPath, exitPath)
|
||||
local facing = { Map.GetFacing(CPos.op_Subtraction(enterPath[2], enterPath[1]), 0), "Int32" }
|
||||
local altitude = Actor.InitialAltitude(transportName)
|
||||
local transport = Actor.Create(transportName, { Owner = owner, Location = enterPath[1], Facing = facing, Altitude = { altitude, "Int32" } })
|
||||
local altitude = { Rules.InitialAltitude(transportName), "Int32" }
|
||||
local transport = Actor.Create(transportName, { Owner = owner, Location = enterPath[1], Facing = facing, Altitude = altitude })
|
||||
local cargo = Actor.Trait(transport, "Cargo")
|
||||
local passengers = { }
|
||||
|
||||
@@ -24,8 +24,8 @@ end
|
||||
|
||||
Reinforcements.Extract = function(owner, transportName, passengerNames, enterPath, exitPath)
|
||||
local facing = { Map.GetFacing(CPos.op_Subtraction(enterPath[2], enterPath[1]), 0), "Int32" }
|
||||
local altitude = Actor.InitialAltitude(transportName)
|
||||
local transport = Actor.Create(transportName, { Owner = owner, Location = enterPath[1], Facing = facing, Altitude = { altitude, "Int32" } })
|
||||
local altitude = { Rules.InitialAltitude(transportName), "Int32" }
|
||||
local transport = Actor.Create(transportName, { Owner = owner, Location = enterPath[1], Facing = facing, Altitude = altitude })
|
||||
local cargo = Actor.Trait(transport, "Cargo")
|
||||
|
||||
Utils.Do(Utils.Skip(enterPath, 1), function(l) Actor.ScriptedMove(transport, l) end)
|
||||
|
||||
21
mods/common/lua/rules.lua
Normal file
21
mods/common/lua/rules.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
Rules = { }
|
||||
|
||||
Rules.HasTraitInfo = function(actorType, className)
|
||||
return Internal.HasTraitInfo(actorType, className)
|
||||
end
|
||||
|
||||
Rules.TraitInfoOrDefault = function(actorType, className)
|
||||
return Internal.TraitInfoOrDefault(actorType, className)
|
||||
end
|
||||
|
||||
Rules.TraitInfo = function(actorType, className)
|
||||
return Internal.TraitInfo(actorType, className)
|
||||
end
|
||||
|
||||
Rules.InitialAltitude = function(actorType)
|
||||
local ai = Rules.TraitInfoOrDefault(actorType, "AircraftInfo")
|
||||
if ai ~= nil then
|
||||
return ai.CruiseAltitude
|
||||
end
|
||||
return 0
|
||||
end
|
||||
@@ -2,7 +2,7 @@ SupportPowers = { }
|
||||
|
||||
SupportPowers.Airstrike = function(owner, planeName, enterLocation, bombLocation)
|
||||
local facing = { Map.GetFacing(CPos.op_Subtraction(bombLocation, enterLocation), 0), "Int32" }
|
||||
local altitude = { Actor.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
|
||||
local altitude = { Rules.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
|
||||
local plane = Actor.Create(planeName, { Location = enterLocation, Owner = owner, Facing = facing, Altitude = altitude })
|
||||
Actor.Trait(plane, "AttackBomber"):SetTarget(bombLocation.CenterPosition)
|
||||
Actor.Fly(plane, bombLocation.CenterPosition)
|
||||
@@ -13,7 +13,7 @@ end
|
||||
|
||||
SupportPowers.Paradrop = function(owner, planeName, passengerNames, enterLocation, dropLocation)
|
||||
local facing = { Map.GetFacing(CPos.op_Subtraction(dropLocation, enterLocation), 0), "Int32" }
|
||||
local altitude = { Actor.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
|
||||
local altitude = { Rules.TraitInfo(planeName, "AircraftInfo").CruiseAltitude, "Int32" }
|
||||
local plane = Actor.Create(planeName, { Location = enterLocation, Owner = owner, Facing = facing, Altitude = altitude })
|
||||
Actor.FlyAttackCell(plane, dropLocation)
|
||||
Actor.Trait(plane, "ParaDrop"):SetLZ(dropLocation)
|
||||
|
||||
@@ -154,3 +154,4 @@ LuaScripts:
|
||||
mods/common/lua/mission.lua
|
||||
mods/common/lua/reinforcements.lua
|
||||
mods/common/lua/supportpowers.lua
|
||||
mods/common/lua/rules.lua
|
||||
|
||||
@@ -174,3 +174,4 @@ LuaScripts:
|
||||
mods/common/lua/mission.lua
|
||||
mods/common/lua/reinforcements.lua
|
||||
mods/common/lua/supportpowers.lua
|
||||
mods/common/lua/rules.lua
|
||||
|
||||
@@ -195,3 +195,4 @@ LuaScripts:
|
||||
mods/common/lua/mission.lua
|
||||
mods/common/lua/reinforcements.lua
|
||||
mods/common/lua/supportpowers.lua
|
||||
mods/common/lua/rules.lua
|
||||
|
||||
Reference in New Issue
Block a user