From 709fccd96c485205c821fa75dd263c87d6bfb573 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 9 Feb 2023 01:06:36 +0100 Subject: [PATCH] OSPTRANSPORT --- Moose Development/Moose/Ops/OpsGroup.lua | 21 ++++++--- Moose Development/Moose/Ops/OpsTransport.lua | 49 +++++++++++++++++--- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 24cb5da82..df746311f 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -7955,7 +7955,7 @@ function OPSGROUP:_CheckCargoTransport() end -- Boarding finished ==> Transport cargo. - if gotcargo and self.cargoTransport:_CheckRequiredCargos(self.cargoTZC) and not boarding then + if gotcargo and self.cargoTransport:_CheckRequiredCargos(self.cargoTZC, self) and not boarding then self:T(self.lid.."Boarding finished ==> Loaded") self:LoadingDone() else @@ -9329,6 +9329,8 @@ function OPSGROUP:onafterUnloading(From, Event, To) -- Set carrier status to UNLOADING. self:_NewCarrierStatus(OPSGROUP.CarrierStatus.UNLOADING) + + self:I(self.lid.."FF Unloading..") -- Deploy zone. local zone=self.cargoTZC.DisembarkZone or self.cargoTZC.DeployZone --Core.Zone#ZONE @@ -9341,7 +9343,6 @@ function OPSGROUP:onafterUnloading(From, Event, To) if cargo.opsgroup:IsLoaded(self.groupname) and not cargo.opsgroup:IsDead() then -- Disembark to carrier. - local needscarrier=false --#boolean local carrier=nil --Ops.OpsGroup#OPSGROUP.Element local carrierGroup=nil --Ops.OpsGroup#OPSGROUP @@ -9354,17 +9355,21 @@ function OPSGROUP:onafterUnloading(From, Event, To) carrier=carrierGroup:GetElementByName(shipname) end - if self.cargoTZC.DisembarkCarriers and #self.cargoTZC.DisembarkCarriers>0 then - - needscarrier=true + if self.cargoTZC.disembarkToCarriers then + + self:I(self.lid.."FF Unloading 100") + self:I(zone:GetName()) + -- Try to find a carrier that can take the cargo. carrier, carrierGroup=self.cargoTransport:FindTransferCarrierForCargo(cargo.opsgroup, zone, self.cargoTZC) --TODO: max unloading time if transfer carrier does not arrive in the zone. end - if needscarrier==false or (needscarrier and carrier and carrierGroup) then + if (self.cargoTZC.disembarkToCarriers and carrier and carrierGroup) or (not self.cargoTZC.disembarkToCarriers) then + + self:I(self.lid.."FF Unloading 200") -- Cargo was delivered (somehow). cargo.delivered=true @@ -9383,7 +9388,7 @@ function OPSGROUP:onafterUnloading(From, Event, To) elseif zone and zone:IsInstanceOf("ZONE_AIRBASE") and zone:GetAirbase():IsShip() then --- - -- Delivered to a ship via helo or VTOL + -- Delivered to a ship via helo that landed on its platform --- -- Issue warning. @@ -9398,6 +9403,8 @@ function OPSGROUP:onafterUnloading(From, Event, To) -- Delivered to deploy zone --- + self:I(self.lid.."FF Unloading 400") + if self.cargoTransport:GetDisembarkInUtero(self.cargoTZC) then -- Unload but keep "in utero" (no coordinate provided). diff --git a/Moose Development/Moose/Ops/OpsTransport.lua b/Moose Development/Moose/Ops/OpsTransport.lua index 3db1707d1..41b7fd4c2 100644 --- a/Moose Development/Moose/Ops/OpsTransport.lua +++ b/Moose Development/Moose/Ops/OpsTransport.lua @@ -172,6 +172,7 @@ OPSTRANSPORT.Status={ -- @field #table TransportPaths Path for Transport. Each elment of the table is of type `#OPSTRANSPORT.Path`. -- @field #table RequiredCargos Required cargos. -- @field #table DisembarkCarriers Carriers where the cargo is directly disembarked to. +-- @field #boolean disembarkToCarriers If `true`, cargo is supposed to embark to another carrier. -- @field #boolean disembarkActivation If true, troops are spawned in late activated state when disembarked from carrier. -- @field #boolean disembarkInUtero If true, troops are disembarked "in utero". -- @field #boolean assets Cargo assets. @@ -722,7 +723,7 @@ function OPSTRANSPORT:GetDisembarkActivation(TransportZoneCombo) return TransportZoneCombo.disembarkActivation end ---- Set transfer carrier(s). These are carrier groups, where the cargo is directly loaded into when disembarked. +--- Set/add transfer carrier(s). These are carrier groups, where the cargo is directly loaded into when disembarked. -- @param #OPSTRANSPORT self -- @param Core.Set#SET_GROUP Carriers Carrier set. Can also be passed as a #GROUP, #OPSGROUP or #SET_OPSGROUP object. -- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo. @@ -734,6 +735,9 @@ function OPSTRANSPORT:SetDisembarkCarriers(Carriers, TransportZoneCombo) -- Use default TZC if no transport zone combo is provided. TransportZoneCombo=TransportZoneCombo or self.tzcDefault + + -- Set that we want to disembark to carriers. + TransportZoneCombo.disembarkToCarriers=true if Carriers:IsInstanceOf("GROUP") or Carriers:IsInstanceOf("OPSGROUP") then @@ -1928,31 +1932,61 @@ end --- Check if all required cargos are loaded. -- @param #OPSTRANSPORT self -- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo. --- @return #boolean If true, all required cargos are loaded or there is no required cargo. -function OPSTRANSPORT:_CheckRequiredCargos(TransportZoneCombo) +-- @param Ops.OpsGroup#OPSGROUP CarrierGroup The carrier group asking. +-- @return #boolean If true, all required cargos are loaded or there is no required cargo or asking carrier is full. +function OPSTRANSPORT:_CheckRequiredCargos(TransportZoneCombo, CarrierGroup) -- Use default TZC if no transport zone combo is provided. TransportZoneCombo=TransportZoneCombo or self.tzcDefault - local requiredCargos=TransportZoneCombo.RequiredCargos + -- Use input or take all cargos. + local requiredCargos=TransportZoneCombo.RequiredCargos or TransportZoneCombo.Cargos if requiredCargos==nil or #requiredCargos==0 then return true end + -- All carrier names. local carrierNames=self:_GetCarrierNames() - local gotit=true + -- Cargo groups not loaded yet. + local weightmin=nil + for _,_cargo in pairs(requiredCargos) do local cargo=_cargo --Ops.OpsGroup#OPSGROUP + -- Is this cargo loaded into any carrier? + local isLoaded=cargo:IsLoaded(carrierNames) - if not cargo:IsLoaded(carrierNames) then - return false + if not isLoaded then + local weight=cargo:GetWeightTotal() + + if weightmin==nil or weight