mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'develop' into FF/Develop
This commit is contained in:
commit
1097c02b06
@ -419,11 +419,11 @@ function AI_CARGO_APC:onbeforeLoad( APC, From, Event, To )
|
|||||||
|
|
||||||
if APC and APC:IsAlive() then
|
if APC and APC:IsAlive() then
|
||||||
self.APC_Cargo = {}
|
self.APC_Cargo = {}
|
||||||
self.APC_Cargo_Weight = {}
|
|
||||||
for _, APCUnit in pairs( APC:GetUnits() ) do
|
for _, APCUnit in pairs( APC:GetUnits() ) do
|
||||||
local APCUnit = APCUnit -- Wrapper.Unit#UNIT
|
local APCUnit = APCUnit -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
self.APC_Cargo_Weight[APCUnit] = APCUnit:GetCargoBayFreeWeight()
|
local CargoBayFreeWeight = APCUnit:GetCargoBayFreeWeight()
|
||||||
|
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
||||||
|
|
||||||
--for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
--for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
for _, Cargo in UTILS.spairs( self.CargoSet:GetSet(), function( t, a, b ) return t[a]:GetWeight() > t[b]:GetWeight() end ) do
|
for _, Cargo in UTILS.spairs( self.CargoSet:GetSet(), function( t, a, b ) return t[a]:GetWeight() > t[b]:GetWeight() end ) do
|
||||||
@ -433,11 +433,8 @@ function AI_CARGO_APC:onbeforeLoad( APC, From, Event, To )
|
|||||||
if Cargo:IsInLoadRadius( APCUnit:GetCoordinate() ) then
|
if Cargo:IsInLoadRadius( APCUnit:GetCoordinate() ) then
|
||||||
self:F( { "In radius", APCUnit:GetName() } )
|
self:F( { "In radius", APCUnit:GetName() } )
|
||||||
|
|
||||||
local CargoBayFreeWeight = self.APC_Cargo_Weight[APCUnit]
|
|
||||||
local CargoWeight = Cargo:GetWeight()
|
local CargoWeight = Cargo:GetWeight()
|
||||||
|
|
||||||
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
|
||||||
|
|
||||||
-- Only when there is space within the bay to load the next cargo item!
|
-- Only when there is space within the bay to load the next cargo item!
|
||||||
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
||||||
APC:RouteStop()
|
APC:RouteStop()
|
||||||
@ -448,7 +445,6 @@ function AI_CARGO_APC:onbeforeLoad( APC, From, Event, To )
|
|||||||
-- So now this APCUnit has Cargo that is being loaded.
|
-- So now this APCUnit has Cargo that is being loaded.
|
||||||
-- This will be used further in the logic to follow and to check cargo status.
|
-- This will be used further in the logic to follow and to check cargo status.
|
||||||
self.APC_Cargo[APCUnit] = Cargo
|
self.APC_Cargo[APCUnit] = Cargo
|
||||||
self.APC_Cargo_Weight[APCUnit] = self.APC_Cargo_Weight[APCUnit] - CargoWeight
|
|
||||||
Boarding = true
|
Boarding = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -478,15 +474,14 @@ function AI_CARGO_APC:onafterBoard( APC, From, Event, To, Cargo, APCUnit )
|
|||||||
if not Cargo:IsLoaded() then
|
if not Cargo:IsLoaded() then
|
||||||
self:__Board( 10, Cargo, APCUnit )
|
self:__Board( 10, Cargo, APCUnit )
|
||||||
else
|
else
|
||||||
|
local CargoBayFreeWeight = APCUnit:GetCargoBayFreeWeight()
|
||||||
|
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
||||||
for _, Cargo in UTILS.spairs( self.CargoSet:GetSet(), function( t, a, b ) return t[a]:GetWeight() > t[b]:GetWeight() end ) do
|
for _, Cargo in UTILS.spairs( self.CargoSet:GetSet(), function( t, a, b ) return t[a]:GetWeight() > t[b]:GetWeight() end ) do
|
||||||
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
||||||
if Cargo:IsUnLoaded() then
|
if Cargo:IsUnLoaded() then
|
||||||
if Cargo:IsInLoadRadius( APCUnit:GetCoordinate() ) then
|
if Cargo:IsInLoadRadius( APCUnit:GetCoordinate() ) then
|
||||||
local CargoBayFreeWeight = self.APC_Cargo_Weight[APCUnit]
|
|
||||||
local CargoWeight = Cargo:GetWeight()
|
local CargoWeight = Cargo:GetWeight()
|
||||||
|
|
||||||
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
|
||||||
|
|
||||||
-- Only when there is space within the bay to load the next cargo item!
|
-- Only when there is space within the bay to load the next cargo item!
|
||||||
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
||||||
Cargo:Board( APCUnit, 25 )
|
Cargo:Board( APCUnit, 25 )
|
||||||
@ -494,7 +489,6 @@ function AI_CARGO_APC:onafterBoard( APC, From, Event, To, Cargo, APCUnit )
|
|||||||
-- So now this APCUnit has Cargo that is being loaded.
|
-- So now this APCUnit has Cargo that is being loaded.
|
||||||
-- This will be used further in the logic to follow and to check cargo status.
|
-- This will be used further in the logic to follow and to check cargo status.
|
||||||
self.APC_Cargo[APCUnit] = Cargo
|
self.APC_Cargo[APCUnit] = Cargo
|
||||||
self.APC_Cargo_Weight[APCUnit] = self.APC_Cargo_Weight[APCUnit] - CargoWeight
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -355,17 +355,22 @@ function AI_CARGO_AIRPLANE:onafterDeploy( Airplane, From, Event, To, Airbase, Sp
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- On after Load event. Checks if cargo is inside the load radius and if so starts the boarding process.
|
--- On before Load event. Checks if cargo is inside the load radius and if so starts the boarding process.
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane Transport plane.
|
-- @param Wrapper.Group#GROUP Airplane Transport plane.
|
||||||
-- @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 Wrapper.Point#COORDINATE Coordinate Place where the cargo is guided to if it is inside the load radius.
|
-- @param Wrapper.Point#COORDINATE Coordinate Place where the cargo is guided to if it is inside the load radius.
|
||||||
function AI_CARGO_AIRPLANE:onafterLoad( Airplane, From, Event, To, Coordinate )
|
function AI_CARGO_AIRPLANE:onbeforeLoad( Airplane, From, Event, To, Coordinate )
|
||||||
|
|
||||||
|
|
||||||
|
local Boarding = false
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() ~= nil then
|
if Airplane and Airplane:IsAlive() ~= nil then
|
||||||
|
|
||||||
|
for _, AirplaneUnit in pairs( Airplane:GetUnits() ) do
|
||||||
|
local AirplaneUnit = AirplaneUnit -- Wrapper.Unit#UNIT
|
||||||
for _,_Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _,_Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
self:F({_Cargo:GetName()})
|
self:F({_Cargo:GetName()})
|
||||||
local Cargo=_Cargo --Cargo.Cargo#CARGO
|
local Cargo=_Cargo --Cargo.Cargo#CARGO
|
||||||
@ -375,14 +380,18 @@ function AI_CARGO_AIRPLANE:onafterLoad( Airplane, From, Event, To, Coordinate )
|
|||||||
-- Is there a cargo still unloaded?
|
-- Is there a cargo still unloaded?
|
||||||
if Cargo:IsUnLoaded() == true then
|
if Cargo:IsUnLoaded() == true then
|
||||||
|
|
||||||
self:__Board( 5, Cargo )
|
Cargo:Board( AirplaneUnit, 25 )
|
||||||
Cargo:Board( Airplane, 25 )
|
self:__Board( 5, Cargo, AirplaneUnit )
|
||||||
|
Boarding = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return Boarding
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -392,17 +401,22 @@ 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.
|
||||||
function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To, Cargo )
|
-- @param Cargo.Cargo#CARGO Cargo Cargo object.
|
||||||
|
-- @param Wrapper.Unit#UNIT AirplaneUnit
|
||||||
|
function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To, Cargo, AirplaneUnit )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
|
|
||||||
self:F({ IsLoaded = Cargo:IsLoaded() } )
|
self:F({ IsLoaded = Cargo:IsLoaded() } )
|
||||||
|
|
||||||
if not Cargo:IsLoaded() then
|
if not Cargo:IsLoaded() then
|
||||||
self:__Board( 10, Cargo )
|
self:__Board( 10, Cargo, AirplaneUnit )
|
||||||
else
|
else
|
||||||
|
local CargoBayFreeWeight = AirplaneUnit:GetCargoBayFreeWeight()
|
||||||
|
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
||||||
|
|
||||||
-- Check if another cargo can be loaded into the airplane.
|
-- Check if another cargo can be loaded into the airplane.
|
||||||
for _,_Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _,_Cargo in UTILS.spairs( self.CargoSet:GetSet(), function( t, a, b ) return t[a]:GetWeight() > t[b]:GetWeight() end ) do
|
||||||
|
|
||||||
self:F({_Cargo:GetName()})
|
self:F({_Cargo:GetName()})
|
||||||
local Cargo =_Cargo --Cargo.Cargo#CARGO
|
local Cargo =_Cargo --Cargo.Cargo#CARGO
|
||||||
@ -414,7 +428,7 @@ function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To, Cargo )
|
|||||||
local InRadius = Cargo:IsInLoadRadius( Airplane:GetCoordinate() )
|
local InRadius = Cargo:IsInLoadRadius( Airplane:GetCoordinate() )
|
||||||
if InRadius then
|
if InRadius then
|
||||||
|
|
||||||
local CargoBayFreeWeight = Airplane:GetCargoBayFreeWeight()
|
local CargoBayFreeWeight = AirplaneUnit:GetCargoBayFreeWeight()
|
||||||
--local CargoBayFreeVolume = Airplane:GetCargoBayFreeVolume()
|
--local CargoBayFreeVolume = Airplane:GetCargoBayFreeVolume()
|
||||||
|
|
||||||
local CargoWeight = Cargo:GetWeight()
|
local CargoWeight = Cargo:GetWeight()
|
||||||
@ -465,7 +479,8 @@ end
|
|||||||
function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
local Cargos = Airplane:GetCargo()
|
for _, AirplaneUnit in pairs( Airplane:GetUnits() ) do
|
||||||
|
local Cargos = AirplaneUnit:GetCargo()
|
||||||
for CargoID, Cargo in pairs( Cargos ) do
|
for CargoID, Cargo in pairs( Cargos ) do
|
||||||
|
|
||||||
local Angle = 180
|
local Angle = 180
|
||||||
@ -479,6 +494,7 @@ function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
|||||||
self:__Unboard( 10, Cargo )
|
self:__Unboard( 10, Cargo )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -496,7 +512,8 @@ function AI_CARGO_AIRPLANE:onafterUnboard( Airplane, From, Event, To, Cargo )
|
|||||||
if not Cargo:IsUnLoaded() then
|
if not Cargo:IsUnLoaded() then
|
||||||
self:__Unboard( 10, Cargo )
|
self:__Unboard( 10, Cargo )
|
||||||
else
|
else
|
||||||
local Cargos = Airplane:GetCargo()
|
for _, AirplaneUnit in pairs( Airplane:GetUnits() ) do
|
||||||
|
local Cargos = AirplaneUnit:GetCargo()
|
||||||
for CargoID, Cargo in pairs( Cargos ) do
|
for CargoID, Cargo in pairs( Cargos ) do
|
||||||
if Cargo:IsLoaded() then
|
if Cargo:IsLoaded() then
|
||||||
local Angle = 180
|
local Angle = 180
|
||||||
@ -515,6 +532,7 @@ function AI_CARGO_AIRPLANE:onafterUnboard( Airplane, From, Event, To, Cargo )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- On after Unloaded event. Cargo has been unloaded, i.e. the unboarding process is finished.
|
--- On after Unloaded event. Cargo has been unloaded, i.e. the unboarding process is finished.
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
|||||||
@ -395,6 +395,9 @@ function AI_CARGO_HELICOPTER:onbeforeLoad( Helicopter, From, Event, To)
|
|||||||
if Helicopter and Helicopter:IsAlive() then
|
if Helicopter and Helicopter:IsAlive() then
|
||||||
for _, HelicopterUnit in pairs( Helicopter:GetUnits() ) do
|
for _, HelicopterUnit in pairs( Helicopter:GetUnits() ) do
|
||||||
local HelicopterUnit = HelicopterUnit -- Wrapper.Unit#UNIT
|
local HelicopterUnit = HelicopterUnit -- Wrapper.Unit#UNIT
|
||||||
|
local CargoBayFreeWeight = HelicopterUnit:GetCargoBayFreeWeight()
|
||||||
|
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
||||||
|
|
||||||
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
||||||
self:F( { IsUnLoaded = Cargo:IsUnLoaded() } )
|
self:F( { IsUnLoaded = Cargo:IsUnLoaded() } )
|
||||||
@ -402,17 +405,14 @@ function AI_CARGO_HELICOPTER:onbeforeLoad( Helicopter, From, Event, To)
|
|||||||
if Cargo:IsInLoadRadius( HelicopterUnit:GetCoordinate() ) then
|
if Cargo:IsInLoadRadius( HelicopterUnit:GetCoordinate() ) then
|
||||||
self:F( { "In radius", HelicopterUnit:GetName() } )
|
self:F( { "In radius", HelicopterUnit:GetName() } )
|
||||||
|
|
||||||
local CargoBayFreeWeight = HelicopterUnit:GetCargoBayFreeWeight()
|
|
||||||
local CargoWeight = Cargo:GetWeight()
|
local CargoWeight = Cargo:GetWeight()
|
||||||
|
|
||||||
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
|
||||||
|
|
||||||
-- Only when there is space within the bay to load the next cargo item!
|
-- Only when there is space within the bay to load the next cargo item!
|
||||||
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
||||||
|
|
||||||
--Cargo:Ungroup()
|
--Cargo:Ungroup()
|
||||||
Cargo:Board( HelicopterUnit, 25 )
|
Cargo:Board( HelicopterUnit, 25 )
|
||||||
self:__Board( 1, Cargo )
|
self:__Board( 1, Cargo, HelicopterUnit )
|
||||||
self.Helicopter_Cargo[HelicopterUnit] = Cargo
|
self.Helicopter_Cargo[HelicopterUnit] = Cargo
|
||||||
Boarding = true
|
Boarding = true
|
||||||
break
|
break
|
||||||
@ -435,36 +435,33 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Cargo.Cargo#CARGO Cargo Cargo object.
|
-- @param Cargo.Cargo#CARGO Cargo Cargo object.
|
||||||
function AI_CARGO_HELICOPTER:onafterBoard( Helicopter, From, Event, To, Cargo )
|
-- @param Wrapper.Unit#UNIT HelicopterUnit
|
||||||
self:F( { Helicopter, From, Event, To, Cargo } )
|
function AI_CARGO_HELICOPTER:onafterBoard( Helicopter, From, Event, To, Cargo, HelicopterUnit )
|
||||||
|
self:F( { Helicopter, From, Event, To, Cargo, HelicopterUnit } )
|
||||||
|
|
||||||
if Helicopter and Helicopter:IsAlive() then
|
if Helicopter and Helicopter:IsAlive() then
|
||||||
self:F({ IsLoaded = Cargo:IsLoaded() } )
|
self:F({ IsLoaded = Cargo:IsLoaded() } )
|
||||||
if not Cargo:IsLoaded() then
|
if not Cargo:IsLoaded() then
|
||||||
self:__Board( 10, Cargo )
|
self:__Board( 10, Cargo, HelicopterUnit )
|
||||||
else
|
else
|
||||||
for _, HelicopterUnit in pairs( Helicopter:GetUnits() ) do
|
local CargoBayFreeWeight = HelicopterUnit:GetCargoBayFreeWeight()
|
||||||
local HelicopterUnit = HelicopterUnit -- Wrapper.Unit#UNIT
|
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
||||||
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
||||||
if Cargo:IsUnLoaded() then
|
if Cargo:IsUnLoaded() then
|
||||||
if Cargo:IsInLoadRadius( HelicopterUnit:GetCoordinate() ) then
|
if Cargo:IsInLoadRadius( HelicopterUnit:GetCoordinate() ) then
|
||||||
local CargoBayFreeWeight = HelicopterUnit:GetCargoBayFreeWeight()
|
|
||||||
local CargoWeight = Cargo:GetWeight()
|
local CargoWeight = Cargo:GetWeight()
|
||||||
|
|
||||||
self:F({CargoBayFreeWeight=CargoBayFreeWeight})
|
|
||||||
|
|
||||||
-- Only when there is space within the bay to load the next cargo item!
|
-- Only when there is space within the bay to load the next cargo item!
|
||||||
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
if CargoBayFreeWeight > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
|
||||||
Cargo:Board( HelicopterUnit, 25 )
|
Cargo:Board( HelicopterUnit, 25 )
|
||||||
self:__Board( 10, Cargo )
|
self:__Board( 10, Cargo, HelicopterUnit )
|
||||||
self.Helicopter_Cargo[HelicopterUnit] = Cargo
|
self.Helicopter_Cargo[HelicopterUnit] = Cargo
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
self:__Loaded( 1, Cargo ) -- Will only be executed when no more cargo is boarded.
|
self:__Loaded( 1, Cargo ) -- Will only be executed when no more cargo is boarded.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1032,8 +1032,12 @@ do -- CARGO_REPRESENTABLE
|
|||||||
self:I( { Desc = Desc } )
|
self:I( { Desc = Desc } )
|
||||||
local Weight = math.random( 80, 120 )
|
local Weight = math.random( 80, 120 )
|
||||||
if Desc then
|
if Desc then
|
||||||
|
if Desc.typeName == "2B11 mortar" then
|
||||||
|
Weight = 210
|
||||||
|
else
|
||||||
Weight = Desc.massEmpty
|
Weight = Desc.massEmpty
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self:SetWeight( Weight )
|
self:SetWeight( Weight )
|
||||||
|
|
||||||
|
|||||||
@ -1008,6 +1008,17 @@ do -- Cargo
|
|||||||
["MLRS FDDM"] = 4,
|
["MLRS FDDM"] = 4,
|
||||||
["MTLB"] = 25,
|
["MTLB"] = 25,
|
||||||
["TPZ"] = 10,
|
["TPZ"] = 10,
|
||||||
|
["Ural-4320 APA-5D"] = 10,
|
||||||
|
["GAZ-66"] = 8,
|
||||||
|
["GAZ-3307"] = 12,
|
||||||
|
["GAZ-3308"] = 14,
|
||||||
|
["Tigr_233036"] = 6,
|
||||||
|
["KAMAZ Truck"] = 12,
|
||||||
|
["KrAZ6322"] = 12,
|
||||||
|
["M 818"] = 12,
|
||||||
|
["Ural-375"] = 12,
|
||||||
|
["Ural-4320-31"] = 14,
|
||||||
|
["Ural-4320T"] = 14,
|
||||||
}
|
}
|
||||||
|
|
||||||
local CargoBayWeightLimit = ( Weights[Desc.typeName] or 0 ) * 95
|
local CargoBayWeightLimit = ( Weights[Desc.typeName] or 0 ) * 95
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user