mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS Cargo
This commit is contained in:
parent
2c92bb9d61
commit
c0401447dd
@ -108,7 +108,7 @@
|
|||||||
-- @field #OPSGROUP carrierGroup Carrier group transporting this group as cargo.
|
-- @field #OPSGROUP carrierGroup Carrier group transporting this group as cargo.
|
||||||
-- @field #table cargoqueue Table containing cargo groups to be transported.
|
-- @field #table cargoqueue Table containing cargo groups to be transported.
|
||||||
-- @field #table cargoBay Table containing OPSGROUP loaded into this group.
|
-- @field #table cargoBay Table containing OPSGROUP loaded into this group.
|
||||||
-- @field #OPSGROUP.CargoTransport cargoTransport Current cargo transport assignment.
|
-- @field Ops.OpsTransport#OPSTRANSPORT cargoTransport Current cargo transport assignment.
|
||||||
-- @field #string cargoStatus Cargo status of this group acting as cargo.
|
-- @field #string cargoStatus Cargo status of this group acting as cargo.
|
||||||
-- @field #string carrierStatus Carrier status of this group acting as cargo carrier.
|
-- @field #string carrierStatus Carrier status of this group acting as cargo carrier.
|
||||||
-- @field #number cargocounter Running number of cargo UIDs.
|
-- @field #number cargocounter Running number of cargo UIDs.
|
||||||
@ -2999,7 +2999,7 @@ function OPSGROUP:CountRemainingTransports()
|
|||||||
|
|
||||||
-- Loop over mission queue.
|
-- Loop over mission queue.
|
||||||
for _,_transport in pairs(self.cargoqueue) do
|
for _,_transport in pairs(self.cargoqueue) do
|
||||||
local transport=_transport --#OPSGROUP.CargoTransport
|
local transport=_transport --Ops.OpsTransport#OPSTRANSPORT
|
||||||
|
|
||||||
-- Count not delivered (executing or scheduled) assignments.
|
-- Count not delivered (executing or scheduled) assignments.
|
||||||
if transport and transport.status~=OPSGROUP.TransportStatus.DELIVERED then
|
if transport and transport.status~=OPSGROUP.TransportStatus.DELIVERED then
|
||||||
@ -4752,7 +4752,7 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
|
|
||||||
-- Loop over cargo queue and check if everything was delivered.
|
-- Loop over cargo queue and check if everything was delivered.
|
||||||
for i=#self.cargoqueue,1,-1 do
|
for i=#self.cargoqueue,1,-1 do
|
||||||
local transport=self.cargoqueue[i] --#OPSGROUP.CargoTransport
|
local transport=self.cargoqueue[i] --Ops.OpsTransport#OPSTRANSPORT
|
||||||
local delivered=self:_CheckDelivered(transport)
|
local delivered=self:_CheckDelivered(transport)
|
||||||
if delivered then
|
if delivered then
|
||||||
self:Delivered(transport)
|
self:Delivered(transport)
|
||||||
@ -4807,7 +4807,7 @@ end
|
|||||||
|
|
||||||
--- Get cargo transport from cargo queue.
|
--- Get cargo transport from cargo queue.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @return #OPSGROUP.CargoTransport The next due cargo transport or `nil`.
|
-- @return Ops.OpsTransport#OPSTRANSPORT The next due cargo transport or `nil`.
|
||||||
function OPSGROUP:_GetNextCargoTransport()
|
function OPSGROUP:_GetNextCargoTransport()
|
||||||
|
|
||||||
-- Abs. mission time in seconds.
|
-- Abs. mission time in seconds.
|
||||||
@ -4818,8 +4818,8 @@ function OPSGROUP:_GetNextCargoTransport()
|
|||||||
|
|
||||||
-- Sort results table wrt prio and distance to pickup zone.
|
-- Sort results table wrt prio and distance to pickup zone.
|
||||||
local function _sort(a, b)
|
local function _sort(a, b)
|
||||||
local transportA=a --#OPSGROUP.CargoTransport
|
local transportA=a --Ops.OpsTransport#OPSTRANSPORT
|
||||||
local transportB=b --#OPSGROUP.CargoTransport
|
local transportB=b --Ops.OpsTransport#OPSTRANSPORT
|
||||||
local distA=transportA.pickupzone:GetCoordinate():Get2DDistance(coord)
|
local distA=transportA.pickupzone:GetCoordinate():Get2DDistance(coord)
|
||||||
local distB=transportB.pickupzone:GetCoordinate():Get2DDistance(coord)
|
local distB=transportB.pickupzone:GetCoordinate():Get2DDistance(coord)
|
||||||
return (transportA.prio<transportB.prio) or (transportA.prio==transportB.prio and distA<distB)
|
return (transportA.prio<transportB.prio) or (transportA.prio==transportB.prio and distA<distB)
|
||||||
@ -4829,7 +4829,7 @@ function OPSGROUP:_GetNextCargoTransport()
|
|||||||
-- Look for first mission that is SCHEDULED.
|
-- Look for first mission that is SCHEDULED.
|
||||||
local vip=math.huge
|
local vip=math.huge
|
||||||
for _,_cargotransport in pairs(self.cargoqueue) do
|
for _,_cargotransport in pairs(self.cargoqueue) do
|
||||||
local cargotransport=_cargotransport --#OPSGROUP.CargoTransport
|
local cargotransport=_cargotransport --Ops.OpsTransport#OPSTRANSPORT
|
||||||
if cargotransport.importance and cargotransport.importance<vip then
|
if cargotransport.importance and cargotransport.importance<vip then
|
||||||
vip=cargotransport.importance
|
vip=cargotransport.importance
|
||||||
end
|
end
|
||||||
@ -4926,12 +4926,12 @@ end
|
|||||||
|
|
||||||
--- Delete a cargo transport assignment from the cargo queue
|
--- Delete a cargo transport assignment from the cargo queue
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #OPSGROUP.CargoTransport CargoTransport Cargo transport do be deleted.
|
-- @param Ops.OpsTransport#OPSTRANSPORT CargoTransport Cargo transport do be deleted.
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:DelCargoTransport(CargoTransport)
|
function OPSGROUP:DelCargoTransport(CargoTransport)
|
||||||
|
|
||||||
for i,_transport in pairs(self.cargoqueue) do
|
for i,_transport in pairs(self.cargoqueue) do
|
||||||
local transport=_transport --#OPSGROUP.CargoTransport
|
local transport=_transport --Ops.OpsTransport#OPSTRANSPORT
|
||||||
if transport.uid==CargoTransport.uid then
|
if transport.uid==CargoTransport.uid then
|
||||||
table.remove(self.cargoqueue, i)
|
table.remove(self.cargoqueue, i)
|
||||||
return self
|
return self
|
||||||
@ -4952,7 +4952,7 @@ end
|
|||||||
-- @param Core.Zone#ZONE Embarkzone (Optional) Zone where the cargo is going to be embarked into the transport. By default is goes to the assigned carrier unit.
|
-- @param Core.Zone#ZONE Embarkzone (Optional) Zone where the cargo is going to be embarked into the transport. By default is goes to the assigned carrier unit.
|
||||||
-- @param Core.Zone#ZONE Disembarkzone (Optional) Zone where the cargo disembarks to (is spawned after unloaded). Default is anywhere in the deploy zone.
|
-- @param Core.Zone#ZONE Disembarkzone (Optional) Zone where the cargo disembarks to (is spawned after unloaded). Default is anywhere in the deploy zone.
|
||||||
-- @param #OPSGROUP DisembarkCarrierGroup (Optional) The OPSGROUP where the cargo is directly loaded into.
|
-- @param #OPSGROUP DisembarkCarrierGroup (Optional) The OPSGROUP where the cargo is directly loaded into.
|
||||||
-- @return #OPSGROUP.CargoTransport Cargo transport.
|
-- @return Ops.OpsTransport#OPSTRANSPORT Cargo transport.
|
||||||
function OPSGROUP:CreateCargoTransport(GroupSet, Pickupzone, Deployzone, Prio, Importance, ClockStart, Embarkzone, Disembarkzone, DisembarkCarrierGroup)
|
function OPSGROUP:CreateCargoTransport(GroupSet, Pickupzone, Deployzone, Prio, Importance, ClockStart, Embarkzone, Disembarkzone, DisembarkCarrierGroup)
|
||||||
|
|
||||||
-- Current mission time.
|
-- Current mission time.
|
||||||
@ -4967,7 +4967,7 @@ function OPSGROUP:CreateCargoTransport(GroupSet, Pickupzone, Deployzone, Prio, I
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Data structure.
|
-- Data structure.
|
||||||
local transport={} --#OPSGROUP.CargoTransport
|
local transport={} --Ops.OpsTransport#OPSTRANSPORT
|
||||||
transport.uid=self.cargocounter
|
transport.uid=self.cargocounter
|
||||||
transport.status=OPSGROUP.TransportStatus.PLANNING
|
transport.status=OPSGROUP.TransportStatus.PLANNING
|
||||||
transport.pickupzone=Pickupzone
|
transport.pickupzone=Pickupzone
|
||||||
@ -5678,7 +5678,14 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
|||||||
-- Delivered to deploy zone
|
-- Delivered to deploy zone
|
||||||
---
|
---
|
||||||
|
|
||||||
if not self.cargoTransport.inactiveUnload then
|
if self.cargoTransport.disembarkInUtero then
|
||||||
|
|
||||||
|
-- Unload but keep "in utero" (no coordinate provided).
|
||||||
|
self:Unload(cargo.opsgroup)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- TODO: honor disembark zone!
|
||||||
|
|
||||||
local zoneCarrier=ZONE_RADIUS:New("Carrier", self:GetVec2(), 100)
|
local zoneCarrier=ZONE_RADIUS:New("Carrier", self:GetVec2(), 100)
|
||||||
|
|
||||||
@ -5687,11 +5694,8 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
|||||||
local Heading=math.random(0,359)
|
local Heading=math.random(0,359)
|
||||||
|
|
||||||
-- Unload.
|
-- Unload.
|
||||||
env.info("FF unload cargo "..cargo.opsgroup:GetName())
|
self:Unload(cargo.opsgroup, Coordinate, self.cargoTransport.disembarkActivation, Heading)
|
||||||
self:Unload(cargo.opsgroup, Coordinate, nil, Heading)
|
|
||||||
else
|
|
||||||
env.info("FF unload cargo Inactive "..cargo.opsgroup:GetName())
|
|
||||||
self:Unload(cargo.opsgroup)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -5711,8 +5715,11 @@ end
|
|||||||
-- @param Core.Point#COORDINATE Coordinate Coordinate were the group is unloaded to.
|
-- @param Core.Point#COORDINATE Coordinate Coordinate were the group is unloaded to.
|
||||||
-- @param #number Heading Heading of group.
|
-- @param #number Heading Heading of group.
|
||||||
function OPSGROUP:onbeforeUnload(From, Event, To, OpsGroup, Coordinate, Heading)
|
function OPSGROUP:onbeforeUnload(From, Event, To, OpsGroup, Coordinate, Heading)
|
||||||
--TODO: Add check if CargoGroup is cargo of this carrier.
|
|
||||||
return true
|
-- Remove group from carrier bay. If group is not in cargo bay, function will return false and transition is denied.
|
||||||
|
local removed=self:_DelCargobay(OpsGroup)
|
||||||
|
|
||||||
|
return removed
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "Unload" event. Carrier unloads a cargo group from its cargo bay.
|
--- On after "Unload" event. Carrier unloads a cargo group from its cargo bay.
|
||||||
@ -5725,10 +5732,7 @@ end
|
|||||||
-- @param #boolean Activated If `true`, group is active. If `false`, group is spawned in late activated state.
|
-- @param #boolean Activated If `true`, group is active. If `false`, group is spawned in late activated state.
|
||||||
-- @param #number Heading (Optional) Heading of group in degrees. Default is random heading for each unit.
|
-- @param #number Heading (Optional) Heading of group in degrees. Default is random heading for each unit.
|
||||||
function OPSGROUP:onafterUnload(From, Event, To, OpsGroup, Coordinate, Activated, Heading)
|
function OPSGROUP:onafterUnload(From, Event, To, OpsGroup, Coordinate, Activated, Heading)
|
||||||
|
|
||||||
-- Remove group from carrier bay.
|
|
||||||
self:_DelCargobay(OpsGroup)
|
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
OpsGroup:I(OpsGroup.lid..string.format("New cargo status %s --> %s", OpsGroup.cargoStatus, OPSGROUP.CargoStatus.NOTCARGO))
|
OpsGroup:I(OpsGroup.lid..string.format("New cargo status %s --> %s", OpsGroup.cargoStatus, OPSGROUP.CargoStatus.NOTCARGO))
|
||||||
|
|
||||||
@ -5841,7 +5845,7 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #OPSGROUP.CargoTransport CargoTransport
|
-- @param Ops.OpsTransport#OPSTRANSPORT CargoTransport
|
||||||
function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
|
function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
|
||||||
|
|
||||||
-- Set cargo status.
|
-- Set cargo status.
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
--
|
--
|
||||||
-- ## Main Features:
|
-- ## Main Features:
|
||||||
--
|
--
|
||||||
-- * Patrol waypoints *ad infinitum*
|
-- * Transport troops from A to B.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Example Missions:
|
-- ## Example Missions:
|
||||||
--
|
--
|
||||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Armygroup).
|
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Transport).
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -32,22 +32,25 @@
|
|||||||
-- @field #number prio Priority of this transport. Should be a number between 0 (high prio) and 100 (low prio).
|
-- @field #number prio Priority of this transport. Should be a number between 0 (high prio) and 100 (low prio).
|
||||||
-- @field #number importance Importance of this transport. Smaller=higher.
|
-- @field #number importance Importance of this transport. Smaller=higher.
|
||||||
-- @field #number Tstart Start time in *abs.* seconds.
|
-- @field #number Tstart Start time in *abs.* seconds.
|
||||||
|
-- @field #number Tstop Stop time in *abs.* seconds. Default `#nil` (never stops).
|
||||||
-- @field Core.Zone#ZONE pickupzone Zone where the cargo is picked up.
|
-- @field Core.Zone#ZONE pickupzone Zone where the cargo is picked up.
|
||||||
-- @field Core.Zone#ZONE deployzone Zone where the cargo is dropped off.
|
-- @field Core.Zone#ZONE deployzone Zone where the cargo is dropped off.
|
||||||
-- @field Core.Zone#ZONE embarkzone (Optional) Zone where the cargo is supposed to embark. Default is the pickup zone.
|
-- @field Core.Zone#ZONE embarkzone (Optional) Zone where the cargo is supposed to embark. Default is the pickup zone.
|
||||||
-- @field Core.Zone#ZONE disembarkzone (Optional) Zone where the cargo is disembarked. Default is the deploy zone.
|
-- @field Core.Zone#ZONE disembarkzone (Optional) Zone where the cargo is disembarked. Default is the deploy zone.
|
||||||
-- @field Ops.OpsGroup#OPSGROUP carrierGroup The new carrier group.
|
-- @field Ops.OpsGroup#OPSGROUP carrierGroup The new carrier group.
|
||||||
|
-- @field disembarkActivation Activation setting when group is disembared from carrier.
|
||||||
|
-- @field disembarkInUtero Do not spawn the group in any any state but leave it "*in utero*". For example, to directly load it into another carrier.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *Your soul may belong to Jesus, but your ass belongs to the marines.* -- Eugene B. Sledge
|
--- *Victory is the beautiful, bright-colored flower. Transport is the stem without which it could never have blossomed.* -- Winston Churchill
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- # The OPSTRANSPORT Concept
|
-- # The OPSTRANSPORT Concept
|
||||||
--
|
--
|
||||||
-- This class enhances naval groups.
|
-- Transport OPSGROUPS using carriers such as APCs, helicopters or airplanes.
|
||||||
--
|
--
|
||||||
-- @field #OPSTRANSPORT
|
-- @field #OPSTRANSPORT
|
||||||
OPSTRANSPORT = {
|
OPSTRANSPORT = {
|
||||||
@ -99,11 +102,13 @@ function OPSTRANSPORT:New(GroupSet, Pickupzone, Deployzone)
|
|||||||
-- Inherit everything from FSM class.
|
-- Inherit everything from FSM class.
|
||||||
local self=BASE:Inherit(self, FSM:New()) -- #OPSTRANSPORT
|
local self=BASE:Inherit(self, FSM:New()) -- #OPSTRANSPORT
|
||||||
|
|
||||||
|
-- Increase ID counter.
|
||||||
_OPSTRANSPORTID=_OPSTRANSPORTID+1
|
_OPSTRANSPORTID=_OPSTRANSPORTID+1
|
||||||
|
|
||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
self.lid=string.format("OPSTRANSPORT [UID=%d] %s --> %s | ", _OPSTRANSPORTID, Pickupzone:GetName(), Deployzone:GetName())
|
self.lid=string.format("OPSTRANSPORT [UID=%d] %s --> %s | ", _OPSTRANSPORTID, Pickupzone:GetName(), Deployzone:GetName())
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
self.uid=_OPSTRANSPORTID
|
self.uid=_OPSTRANSPORTID
|
||||||
self.status=OPSTRANSPORT.Status.PLANNING
|
self.status=OPSTRANSPORT.Status.PLANNING
|
||||||
self.pickupzone=Pickupzone
|
self.pickupzone=Pickupzone
|
||||||
@ -112,53 +117,15 @@ function OPSTRANSPORT:New(GroupSet, Pickupzone, Deployzone)
|
|||||||
self.disembarkzone=Deployzone
|
self.disembarkzone=Deployzone
|
||||||
self.prio=50
|
self.prio=50
|
||||||
self.importance=nil
|
self.importance=nil
|
||||||
self.Tstart=timer.getAbsTime()
|
self.Tstart=timer.getAbsTime()+5
|
||||||
self.carrierGroup=nil
|
self.carrierGroup=nil
|
||||||
self.cargos={}
|
self.cargos={}
|
||||||
self.carriers={}
|
self.carriers={}
|
||||||
|
|
||||||
|
if GroupSet then
|
||||||
|
self:AddCargoGroups(GroupSet, Pickupzone, Deployzone)
|
||||||
-- Check type of GroupSet provided.
|
|
||||||
if GroupSet:IsInstanceOf("GROUP") or GroupSet:IsInstanceOf("OPSGROUP") then
|
|
||||||
|
|
||||||
-- We got a single GROUP or OPSGROUP object.
|
|
||||||
local cargo=self:_CreateCargoGroupData(GroupSet, Pickupzone, Deployzone)
|
|
||||||
|
|
||||||
if cargo then --and self:CanCargo(cargo.opsgroup)
|
|
||||||
table.insert(self.cargos, cargo)
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
-- We got a SET_GROUP object.
|
|
||||||
|
|
||||||
for _,group in pairs(GroupSet.Set) do
|
|
||||||
|
|
||||||
local cargo=self:_CreateCargoGroupData(group, Pickupzone, Deployzone)
|
|
||||||
|
|
||||||
if cargo then --and self:CanCargo(cargo.opsgroup) then
|
|
||||||
table.insert(self.cargos, cargo)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug info.
|
|
||||||
if self.verbose>=0 then
|
|
||||||
local text=string.format("Created Cargo Transport (UID=%d) from %s(%s) --> %s(%s)",
|
|
||||||
self.uid, self.pickupzone:GetName(), self.embarkzone:GetName(), self.deployzone:GetName(), self.disembarkzone:GetName())
|
|
||||||
local Weight=0
|
|
||||||
for _,_cargo in pairs(self.cargos) do
|
|
||||||
local cargo=_cargo --#OPSGROUP.CargoGroup
|
|
||||||
local weight=cargo.opsgroup:GetWeightTotal()
|
|
||||||
Weight=Weight+weight
|
|
||||||
text=text..string.format("\n- %s [%s] weight=%.1f kg", cargo.opsgroup:GetName(), cargo.opsgroup:GetState(), weight)
|
|
||||||
end
|
|
||||||
text=text..string.format("\nTOTAL: Ncargo=%d, Weight=%.1f kg", #self.cargos, Weight)
|
|
||||||
self:I(self.lid..text)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- FMS start state is PLANNED.
|
-- FMS start state is PLANNED.
|
||||||
self:SetStartState(OPSTRANSPORT.Status.PLANNED)
|
self:SetStartState(OPSTRANSPORT.Status.PLANNED)
|
||||||
@ -182,6 +149,56 @@ end
|
|||||||
-- User Functions
|
-- User Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Add cargo groups to be transported.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param Core.Set#SET_GROUP GroupSet Set of groups to be transported. Can also be passed as a single GROUP or OPSGROUP object.
|
||||||
|
-- @return #OPSTRANSPORT self
|
||||||
|
function OPSTRANSPORT:AddCargoGroups(GroupSet, Pickupzone, Deployzone)
|
||||||
|
|
||||||
|
-- Check type of GroupSet provided.
|
||||||
|
if GroupSet:IsInstanceOf("GROUP") or GroupSet:IsInstanceOf("OPSGROUP") then
|
||||||
|
|
||||||
|
-- We got a single GROUP or OPSGROUP object.
|
||||||
|
local cargo=self:_CreateCargoGroupData(GroupSet, Pickupzone, Deployzone)
|
||||||
|
|
||||||
|
if cargo then --and self:CanCargo(cargo.opsgroup)
|
||||||
|
table.insert(self.cargos, cargo)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- We got a SET_GROUP object.
|
||||||
|
|
||||||
|
for _,group in pairs(GroupSet.Set) do
|
||||||
|
|
||||||
|
local cargo=self:_CreateCargoGroupData(group, Pickupzone, Deployzone)
|
||||||
|
|
||||||
|
if cargo then
|
||||||
|
table.insert(self.cargos, cargo)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
if self.verbose>=0 then
|
||||||
|
local text=string.format("Created Cargo Transport (UID=%d) from %s(%s) --> %s(%s)",
|
||||||
|
self.uid, self.pickupzone:GetName(), self.embarkzone:GetName(), self.deployzone:GetName(), self.disembarkzone:GetName())
|
||||||
|
local Weight=0
|
||||||
|
for _,_cargo in pairs(self.cargos) do
|
||||||
|
local cargo=_cargo --#OPSGROUP.CargoGroup
|
||||||
|
local weight=cargo.opsgroup:GetWeightTotal()
|
||||||
|
Weight=Weight+weight
|
||||||
|
text=text..string.format("\n- %s [%s] weight=%.1f kg", cargo.opsgroup:GetName(), cargo.opsgroup:GetState(), weight)
|
||||||
|
end
|
||||||
|
text=text..string.format("\nTOTAL: Ncargo=%d, Weight=%.1f kg", #self.cargos, Weight)
|
||||||
|
self:I(self.lid..text)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set embark zone.
|
--- Set embark zone.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Core.Zone#ZONE EmbarkZone Zone where the troops are embarked.
|
-- @param Core.Zone#ZONE EmbarkZone Zone where the troops are embarked.
|
||||||
@ -191,6 +208,43 @@ function OPSTRANSPORT:SetEmbarkZone(EmbarkZone)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set disembark zone.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param Core.Zone#ZONE DisembarkZone Zone where the troops are disembarked.
|
||||||
|
-- @return #OPSTRANSPORT self
|
||||||
|
function OPSTRANSPORT:SetDisembarkZone(DisembarkZone)
|
||||||
|
self.disembarkzone=DisembarkZone or self.deployzone
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set activation status of group when disembarked from transport carrier.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param #boolean Active If `true` or `nil`, group is activated when disembarked. If `false`, group is late activated and needs to be activated manually.
|
||||||
|
-- @return #OPSTRANSPORT self
|
||||||
|
function OPSTRANSPORT:SetDisembarkActivation(Active)
|
||||||
|
if Active==true or Active==nil then
|
||||||
|
self.disembarkActivation=true
|
||||||
|
else
|
||||||
|
self.disembarkActivation=false
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set if group remains *in utero* after disembarkment from carrier. Can be used to directly load the group into another carrier. Similar to disembark in late activated state.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param #boolean InUtero If `true` or `nil`, group remains *in utero* after disembarkment.
|
||||||
|
-- @return #OPSTRANSPORT self
|
||||||
|
function OPSTRANSPORT:SetDisembarkInUtero(InUtero)
|
||||||
|
if InUtero==true or InUtero==nil then
|
||||||
|
self.disembarkInUtero=true
|
||||||
|
else
|
||||||
|
self.disembarkInUtero=false
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add a carrier assigned for this transport.
|
--- Add a carrier assigned for this transport.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Ops.OpsGroup#OPSGROUP CarrierGroup Carrier OPSGROUP.
|
-- @param Ops.OpsGroup#OPSGROUP CarrierGroup Carrier OPSGROUP.
|
||||||
@ -240,7 +294,7 @@ function OPSTRANSPORT:_CreateCargoGroupData(group, Pickupzone, Deployzone)
|
|||||||
|
|
||||||
if group:IsInstanceOf("OPSGROUP") then
|
if group:IsInstanceOf("OPSGROUP") then
|
||||||
opsgroup=group
|
opsgroup=group
|
||||||
else
|
elseif group:IsInstanceOf("GROUP") then
|
||||||
|
|
||||||
opsgroup=_DATABASE:GetOpsGroup(group)
|
opsgroup=_DATABASE:GetOpsGroup(group)
|
||||||
|
|
||||||
@ -252,10 +306,11 @@ function OPSTRANSPORT:_CreateCargoGroupData(group, Pickupzone, Deployzone)
|
|||||||
else
|
else
|
||||||
opsgroup=ARMYGROUP:New(group)
|
opsgroup=ARMYGROUP:New(group)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
--env.info("FF found opsgroup in createcargo")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:E(self.lid.."ERROR: Cargo must be a GROUP or OPSGROUP object!")
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local cargo={} --#OPSGROUP.CargoGroup
|
local cargo={} --#OPSGROUP.CargoGroup
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user