mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Fix for clients which weren't initialized with a cargo bay weight limit value. Each time a cargo bay weight limit is enquired through the method GetCargoBayFeeWeight(), if there isn't a cargo bay weight limit set, the default cargo bay weight limit will be calculated, so that the logic will always be executed.
This commit is contained in:
parent
d9a5618773
commit
185c27013d
@ -810,12 +810,18 @@ function SET_GROUP:GetAliveSet()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Add a GROUP to SET_GROUP.
|
--- Add a GROUP to SET_GROUP.
|
||||||
|
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
||||||
-- @param Core.Set#SET_GROUP self
|
-- @param Core.Set#SET_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
||||||
-- @return self
|
-- @return self
|
||||||
function SET_GROUP:AddGroup( group )
|
function SET_GROUP:AddGroup( group )
|
||||||
|
|
||||||
self:Add( group:GetName(), group )
|
self:Add( group:GetName(), group )
|
||||||
|
|
||||||
|
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
||||||
|
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
||||||
|
UnitData:SetCargoBayWeightLimit()
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1425,6 +1431,24 @@ function SET_GROUP:IsIncludeObject( MooseGroup )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Iterate the SET_GROUP and set for each unit the default cargo bay weight limit.
|
||||||
|
-- Because within a group, the type of carriers can differ, each cargo bay weight limit is set on @{Wrapper.Unit} level.
|
||||||
|
-- @param #SET_GROUP self
|
||||||
|
-- @usage
|
||||||
|
-- -- Set the default cargo bay weight limits of the carrier units.
|
||||||
|
-- local MySetGroup = SET_GROUP:New()
|
||||||
|
-- MySetGroup:SetCargoBayWeightLimit()
|
||||||
|
function SET_GROUP:SetCargoBayWeightLimit()
|
||||||
|
local Set = self:GetSet()
|
||||||
|
for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP
|
||||||
|
for UnitName, UnitData in pairs( GroupData:GetUnits() ) do
|
||||||
|
--local UnitData = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
UnitData:SetCargoBayWeightLimit()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
do -- SET_UNIT
|
do -- SET_UNIT
|
||||||
|
|
||||||
--- @type SET_UNIT
|
--- @type SET_UNIT
|
||||||
@ -1593,12 +1617,15 @@ do -- SET_UNIT
|
|||||||
|
|
||||||
--- Add UNIT(s) to SET_UNIT.
|
--- Add UNIT(s) to SET_UNIT.
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
-- @param #string AddUnit A single UNIT.
|
-- @param Wrapper.Unit#UNIT Unit A single UNIT.
|
||||||
-- @return #SET_UNIT self
|
-- @return #SET_UNIT self
|
||||||
function SET_UNIT:AddUnit( AddUnit )
|
function SET_UNIT:AddUnit( Unit )
|
||||||
self:F2( AddUnit:GetName() )
|
self:F2( Unit:GetName() )
|
||||||
|
|
||||||
self:Add( AddUnit:GetName(), AddUnit )
|
self:Add( Unit:GetName(), Unit )
|
||||||
|
|
||||||
|
-- Set the default cargo bay limit each time a new unit is added to the set.
|
||||||
|
Unit:SetCargoBayWeightLimit()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -2420,6 +2447,22 @@ do -- SET_UNIT
|
|||||||
|
|
||||||
return TypeReport:Text( Delimiter )
|
return TypeReport:Text( Delimiter )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Iterate the SET_UNIT and set for each unit the default cargo bay weight limit.
|
||||||
|
-- @param #SET_UNIT self
|
||||||
|
-- @usage
|
||||||
|
-- -- Set the default cargo bay weight limits of the carrier units.
|
||||||
|
-- local MySetUnit = SET_UNIT:New()
|
||||||
|
-- MySetUnit:SetCargoBayWeightLimit()
|
||||||
|
function SET_UNIT:SetCargoBayWeightLimit()
|
||||||
|
local Set = self:GetSet()
|
||||||
|
for UnitID, UnitData in pairs( Set ) do -- For each UNIT in SET_UNIT
|
||||||
|
--local UnitData = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
UnitData:SetCargoBayWeightLimit()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -589,13 +589,6 @@ do -- TASK_CARGO
|
|||||||
Fsm:AddTransition( "Rejected", "Reject", "Aborted" )
|
Fsm:AddTransition( "Rejected", "Reject", "Aborted" )
|
||||||
Fsm:AddTransition( "Failed", "Fail", "Failed" )
|
Fsm:AddTransition( "Failed", "Fail", "Failed" )
|
||||||
|
|
||||||
for _, Group in pairs( SetGroup:GetSet() ) do
|
|
||||||
for __, Unit in pairs( Group:GetUnits() ) do
|
|
||||||
local Unit = Unit -- Wrapper.Unit#UNIT
|
|
||||||
Unit:SetCargoBayWeightLimit()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---- @param #FSM_PROCESS self
|
---- @param #FSM_PROCESS self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @param #TASK_CARGO Task
|
-- @param #TASK_CARGO Task
|
||||||
|
|||||||
@ -946,6 +946,12 @@ do -- Cargo
|
|||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
-- @return #number CargoBayFreeWeight
|
-- @return #number CargoBayFreeWeight
|
||||||
function POSITIONABLE:GetCargoBayFreeWeight()
|
function POSITIONABLE:GetCargoBayFreeWeight()
|
||||||
|
|
||||||
|
-- When there is no cargo bay weight limit set, then calculate this for this positionable!
|
||||||
|
if not self.__.CargoBayWeightLimit then
|
||||||
|
self:SetCargoBayWeightLimit()
|
||||||
|
end
|
||||||
|
|
||||||
local CargoWeight = 0
|
local CargoWeight = 0
|
||||||
for CargoName, Cargo in pairs( self.__.Cargo ) do
|
for CargoName, Cargo in pairs( self.__.Cargo ) do
|
||||||
CargoWeight = CargoWeight + Cargo:GetWeight()
|
CargoWeight = CargoWeight + Cargo:GetWeight()
|
||||||
@ -1007,6 +1013,7 @@ do -- Cargo
|
|||||||
self.__.CargoBayWeightLimit = CargoBayWeightLimit
|
self.__.CargoBayWeightLimit = CargoBayWeightLimit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:F({CargoBayWeightLimit = self.__.CargoBayWeightLimit})
|
||||||
end
|
end
|
||||||
end --- Cargo
|
end --- Cargo
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user