Work in progress. Limit functions for POSITIONABLE.

This commit is contained in:
FlightControl 2018-08-08 22:41:02 +02:00
parent b438df27a4
commit a14c2ef589
3 changed files with 93 additions and 51 deletions

View File

@ -188,7 +188,6 @@ function AI_CARGO_AIRPLANE:SetCarrier( Airplane )
function Airplane:OnEventEngineShutdown( EventData ) function Airplane:OnEventEngineShutdown( EventData )
self:F("Calling")
AICargo:Landed( self.Airplane ) AICargo:Landed( self.Airplane )
end end
@ -233,8 +232,6 @@ end
function AI_CARGO_AIRPLANE:onafterLanded( Airplane, From, Event, To ) function AI_CARGO_AIRPLANE:onafterLanded( Airplane, From, Event, To )
self:F({Airplane, From, Event, To}) self:F({Airplane, From, Event, To})
self:F({IsAlive=Airplane:IsAlive()})
self:F({RoutePickup=self.RoutePickup})
if Airplane and Airplane:IsAlive()~=nil then if Airplane and Airplane:IsAlive()~=nil then
@ -406,6 +403,7 @@ function AI_CARGO_AIRPLANE:onafterLoaded( Airplane, From, Event, To )
env.info("FF troops loaded into cargo plane") env.info("FF troops loaded into cargo plane")
if Airplane and Airplane:IsAlive() then if Airplane and Airplane:IsAlive() then
-- Check if another cargo can be loaded into the airplane.
end end
end end

View File

@ -403,6 +403,7 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
-- The Pickup sequence ... -- The Pickup sequence ...
-- Check if this Carrier need to go and Pickup something... -- Check if this Carrier need to go and Pickup something...
-- So, if the cargo bay is not full yet with cargo to be loaded ...
self:I( { IsTransporting = AI_Cargo:IsTransporting() } ) self:I( { IsTransporting = AI_Cargo:IsTransporting() } )
if AI_Cargo:IsTransporting() == false then if AI_Cargo:IsTransporting() == false then
-- ok, so there is a free Carrier -- ok, so there is a free Carrier

View File

@ -798,56 +798,99 @@ function POSITIONABLE:GetLaserCode() --R2.1
return self.LaserCode return self.LaserCode
end end
--- Add cargo. do -- Cargo
-- @param #POSITIONABLE self
-- @param Core.Cargo#CARGO Cargo --- Add cargo.
-- @return #POSITIONABLE -- @param #POSITIONABLE self
function POSITIONABLE:AddCargo( Cargo ) -- @param Core.Cargo#CARGO Cargo
-- @return #POSITIONABLE
function POSITIONABLE:AddCargo( Cargo )
self.__.Cargo[Cargo] = Cargo self.__.Cargo[Cargo] = Cargo
return self return self
end end
--- Get all contained cargo. --- Get all contained cargo.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self
-- @return #POSITIONABLE -- @return #POSITIONABLE
function POSITIONABLE:GetCargo() function POSITIONABLE:GetCargo()
return self.__.Cargo return self.__.Cargo
end end
--- Remove cargo. --- Remove cargo.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self
-- @param Core.Cargo#CARGO Cargo -- @param Core.Cargo#CARGO Cargo
-- @return #POSITIONABLE -- @return #POSITIONABLE
function POSITIONABLE:RemoveCargo( Cargo ) function POSITIONABLE:RemoveCargo( Cargo )
self.__.Cargo[Cargo] = nil self.__.Cargo[Cargo] = nil
return self return self
end end
--- Returns if carrier has given cargo. --- Returns if carrier has given cargo.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self
-- @return Core.Cargo#CARGO Cargo -- @return Core.Cargo#CARGO Cargo
function POSITIONABLE:HasCargo( Cargo ) function POSITIONABLE:HasCargo( Cargo )
return self.__.Cargo[Cargo] return self.__.Cargo[Cargo]
end end
--- Clear all cargo. --- Clear all cargo.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self
function POSITIONABLE:ClearCargo() function POSITIONABLE:ClearCargo()
self.__.Cargo = {} self.__.Cargo = {}
end end
--- Get cargo item count. --- Get cargo item count.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self
-- @return Core.Cargo#CARGO Cargo -- @return Core.Cargo#CARGO Cargo
function POSITIONABLE:CargoItemCount() function POSITIONABLE:CargoItemCount()
local ItemCount = 0 local ItemCount = 0
for CargoName, Cargo in pairs( self.__.Cargo ) do for CargoName, Cargo in pairs( self.__.Cargo ) do
ItemCount = ItemCount + Cargo:GetCount() ItemCount = ItemCount + Cargo:GetCount()
end end
return ItemCount return ItemCount
end end
--- Get Cargo Bay Free Volume in m3.
-- @param #POSITIONABLE self
-- @return #number CargoBayFreeVolume
function POSITIONABLE:GetCargoBayFreeVolume()
local CargoVolume = 0
for CargoName, Cargo in pairs( self.__.Cargo ) do
CargoVolume = CargoVolume + Cargo:GetVolume()
end
return self.__.CargoBayVolumeLimit - CargoVolume
end
--- Get Cargo Bay Free Weight in kg.
-- @param #POSITIONABLE self
-- @return #number CargoBayFreeWeight
function POSITIONABLE:GetCargoBayFreeWeight()
local CargoWeight = 0
for CargoName, Cargo in pairs( self.__.Cargo ) do
CargoWeight = CargoWeight + Cargo:GetWeight()
end
return self.__.CargoBayWeightLimit - CargoWeight
end
--- Get Cargo Bay Volume Limit in m3.
-- @param #POSITIONABLE self
-- @param #number VolumeLimit
function POSITIONABLE:SetCargoBayVolumeLimit( VolumeLimit )
self.__.CargoBayVolumeLimit = VolumeLimit
end
--- Get Cargo Bay Weight Limit in kg.
-- @param #POSITIONABLE self
-- @param #number WeightLimit
function POSITIONABLE:GetCargoBayFreeWeightLimit( WeightLimit )
self.__.CargoBayWeightLimit = WeightLimit
end
end --- Cargo
--- Signal a flare at the position of the POSITIONABLE. --- Signal a flare at the position of the POSITIONABLE.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self