mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Progress on the new cargo group movements
This commit is contained in:
parent
25659647a6
commit
ca32c57c52
@ -1,5 +1,7 @@
|
|||||||
--- **Core** -- Management of CARGO logistics, that can be transported from and to transportation carriers.
|
--- **Core** -- Management of CARGO logistics, that can be transported from and to transportation carriers.
|
||||||
--
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
@ -602,23 +604,19 @@ end -- CARGO_REPRESENTABLE
|
|||||||
|
|
||||||
--- CARGO_REPORTABLE Constructor.
|
--- CARGO_REPORTABLE Constructor.
|
||||||
-- @param #CARGO_REPORTABLE self
|
-- @param #CARGO_REPORTABLE self
|
||||||
-- @param Wrapper.Controllable#Controllable CargoObject
|
|
||||||
-- @param #string Type
|
-- @param #string Type
|
||||||
-- @param #string Name
|
-- @param #string Name
|
||||||
-- @param #number Weight
|
-- @param #number Weight
|
||||||
-- @param #number ReportRadius (optional)
|
-- @param #number ReportRadius (optional)
|
||||||
-- @param #number NearRadius (optional)
|
-- @param #number NearRadius (optional)
|
||||||
-- @return #CARGO_REPORTABLE
|
-- @return #CARGO_REPORTABLE
|
||||||
function CARGO_REPORTABLE:New( CargoObject, Type, Name, Weight, ReportRadius )
|
function CARGO_REPORTABLE:New( Type, Name, Weight, ReportRadius )
|
||||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE
|
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE
|
||||||
self:F( { Type, Name, Weight, ReportRadius } )
|
self:F( { Type, Name, Weight, ReportRadius } )
|
||||||
|
|
||||||
self.CargoSet = SET_CARGO:New() -- Core.Set#SET_CARGO
|
self.CargoSet = SET_CARGO:New() -- Core.Set#SET_CARGO
|
||||||
|
|
||||||
self.ReportRadius = ReportRadius or 1000
|
self.ReportRadius = ReportRadius or 1000
|
||||||
self.CargoObject = CargoObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -776,8 +774,9 @@ do -- CARGO_UNIT
|
|||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
if self.CargoObject then
|
if self.CargoObject then
|
||||||
|
self:F( { CargoObject = self.CargoObject } )
|
||||||
self.CargoObject:ReSpawn( CargoDeployPointVec2:GetVec3(), CargoDeployHeading )
|
self.CargoObject:ReSpawn( CargoDeployPointVec2:GetVec3(), CargoDeployHeading )
|
||||||
self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
--self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
||||||
self.CargoCarrier = nil
|
self.CargoCarrier = nil
|
||||||
|
|
||||||
local Points = {}
|
local Points = {}
|
||||||
@ -1150,6 +1149,8 @@ do -- CARGO_GROUP
|
|||||||
}
|
}
|
||||||
|
|
||||||
--- CARGO_GROUP constructor.
|
--- CARGO_GROUP constructor.
|
||||||
|
-- This make a new CARGO_GROUP from a @{Group} object.
|
||||||
|
-- It will "ungroup" the group object within the sim, and will create a @{Set} of individual Unit objects.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP CargoGroup
|
-- @param Wrapper.Group#GROUP CargoGroup
|
||||||
-- @param #string Type
|
-- @param #string Type
|
||||||
@ -1158,23 +1159,47 @@ do -- CARGO_GROUP
|
|||||||
-- @param #number NearRadius (optional)
|
-- @param #number NearRadius (optional)
|
||||||
-- @return #CARGO_GROUP
|
-- @return #CARGO_GROUP
|
||||||
function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius )
|
function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( CargoGroup, Type, Name, 0, ReportRadius ) ) -- #CARGO_GROUP
|
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, ReportRadius ) ) -- #CARGO_GROUP
|
||||||
self:F( { Type, Name, ReportRadius } )
|
self:F( { Type, Name, ReportRadius } )
|
||||||
|
|
||||||
self.CargoObject = CargoGroup
|
|
||||||
self:SetDeployed( false )
|
self:SetDeployed( false )
|
||||||
self.CargoGroup = CargoGroup
|
|
||||||
|
|
||||||
local WeightGroup = 0
|
local WeightGroup = 0
|
||||||
|
local GroupName = CargoGroup:GetName()
|
||||||
|
|
||||||
for UnitID, UnitData in pairs( CargoGroup:GetUnits() ) do
|
CargoGroup:Destroy()
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
|
||||||
local WeightUnit = Unit:GetDesc().massEmpty
|
-- We iterate through the group template and for each unit in the template, we create a new group with one unit.
|
||||||
WeightGroup = WeightGroup + WeightUnit
|
for UnitID, UnitTemplate in pairs( _DATABASE:GetGroupTemplate(GroupName).units ) do
|
||||||
local CargoUnit = CARGO_UNIT:New( Unit, Type, Unit:GetName(), WeightUnit )
|
|
||||||
self.CargoSet:Add( CargoUnit:GetName(), CargoUnit )
|
local GroupTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplate(GroupName) )
|
||||||
|
local GroupName = env.getValueDictByKey( GroupTemplate.name )
|
||||||
|
self:E( GroupName )
|
||||||
|
|
||||||
|
-- We create a new group object with one unit...
|
||||||
|
-- First we prepare the template...
|
||||||
|
GroupTemplate.name = GroupName .. "#CARGO#" .. UnitID
|
||||||
|
GroupTemplate.units = {}
|
||||||
|
GroupTemplate.units[1] = UnitTemplate
|
||||||
|
local UnitName = UnitTemplate.name .. "#CARGO"
|
||||||
|
GroupTemplate.units[1].name = UnitTemplate.name .. "#CARGO"
|
||||||
|
|
||||||
|
|
||||||
|
-- Then we register the new group in the database
|
||||||
|
local CargoGroup = GROUP:NewTemplate( GroupTemplate, GroupTemplate.CoalitionID, GroupTemplate.CategoryID, GroupTemplate.CountryID)
|
||||||
|
|
||||||
|
-- Now we spawn the new group based on the template created.
|
||||||
|
_DATABASE:Spawn( GroupTemplate )
|
||||||
|
|
||||||
|
-- And we register the spawned unit as part of the CargoSet.
|
||||||
|
local Unit = UNIT:FindByName( UnitName )
|
||||||
|
--local WeightUnit = Unit:GetDesc().massEmpty
|
||||||
|
--WeightGroup = WeightGroup + WeightUnit
|
||||||
|
local CargoUnit = CARGO_UNIT:New( Unit, Type, UnitName, 10 )
|
||||||
|
self.CargoSet:Add( UnitName, CargoUnit )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self:SetWeight( WeightGroup )
|
self:SetWeight( WeightGroup )
|
||||||
|
|
||||||
self:T( { "Weight Cargo", WeightGroup } )
|
self:T( { "Weight Cargo", WeightGroup } )
|
||||||
@ -1355,7 +1380,7 @@ function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius
|
|||||||
function( Cargo, NearRadius )
|
function( Cargo, NearRadius )
|
||||||
|
|
||||||
Cargo:__UnBoard( Timer, ToPointVec2, NearRadius )
|
Cargo:__UnBoard( Timer, ToPointVec2, NearRadius )
|
||||||
Timer = Timer + 10
|
Timer = Timer + 1
|
||||||
end, { NearRadius }
|
end, { NearRadius }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -336,7 +336,7 @@ end
|
|||||||
-- @param #number UnitNumber The number of the UNIT wrapper class to be returned.
|
-- @param #number UnitNumber The number of the UNIT wrapper class to be returned.
|
||||||
-- @return Wrapper.Unit#UNIT The UNIT wrapper class.
|
-- @return Wrapper.Unit#UNIT The UNIT wrapper class.
|
||||||
function GROUP:GetUnit( UnitNumber )
|
function GROUP:GetUnit( UnitNumber )
|
||||||
self:F2( { self.GroupName, UnitNumber } )
|
self:E( { self.GroupName, UnitNumber } )
|
||||||
|
|
||||||
local DCSGroup = self:GetDCSObject()
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
|
|||||||
@ -193,10 +193,12 @@ end
|
|||||||
-- @param #number Heading The heading of the unit respawn.
|
-- @param #number Heading The heading of the unit respawn.
|
||||||
function UNIT:ReSpawn( SpawnVec3, Heading )
|
function UNIT:ReSpawn( SpawnVec3, Heading )
|
||||||
|
|
||||||
|
self:T( self:Name() )
|
||||||
local SpawnGroupTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplateFromUnitName( self:Name() ) )
|
local SpawnGroupTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplateFromUnitName( self:Name() ) )
|
||||||
self:T( SpawnGroupTemplate )
|
self:T( SpawnGroupTemplate )
|
||||||
|
|
||||||
local SpawnGroup = self:GetGroup()
|
local SpawnGroup = self:GetGroup()
|
||||||
|
self:T( { SpawnGroup = SpawnGroup } )
|
||||||
|
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
|
|
||||||
@ -221,7 +223,7 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
|
|||||||
end
|
end
|
||||||
|
|
||||||
for UnitTemplateID, UnitTemplateData in pairs( SpawnGroupTemplate.units ) do
|
for UnitTemplateID, UnitTemplateData in pairs( SpawnGroupTemplate.units ) do
|
||||||
self:T( UnitTemplateData.name )
|
self:T( { UnitTemplateData.name, self:Name() } )
|
||||||
if UnitTemplateData.name == self:Name() then
|
if UnitTemplateData.name == self:Name() then
|
||||||
self:T("Adjusting")
|
self:T("Adjusting")
|
||||||
SpawnGroupTemplate.units[UnitTemplateID].alt = SpawnVec3.y
|
SpawnGroupTemplate.units[UnitTemplateID].alt = SpawnVec3.y
|
||||||
@ -261,6 +263,8 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:T( SpawnGroupTemplate )
|
||||||
|
|
||||||
_DATABASE:Spawn( SpawnGroupTemplate )
|
_DATABASE:Spawn( SpawnGroupTemplate )
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user