- Have added cargo bay limits based on volume and weight.

- AI Cargo Dispatcher works with cargo bay limits for carrier. (i still need to add options to set the parameters for this).
- Carriers load now multiple cargo.
- Added weight and volume attached to cargo objects for units. I reworked the respawning of cargo units, so that these volumes and weights are collected from the unit Descriptor properties!
- There are still bugs, which I need to resolve, but it is going in the right direction.
This commit is contained in:
FlightControl
2018-08-11 11:33:43 +02:00
parent a14c2ef589
commit 7f9f9b33fd
6 changed files with 129 additions and 31 deletions

View File

@@ -73,6 +73,7 @@ do -- CARGO_GROUP
self:SetDeployed( false )
local WeightGroup = 0
local VolumeGroup = 0
self.CargoGroup:Destroy()
@@ -96,10 +97,7 @@ do -- CARGO_GROUP
-- And we register the spawned unit as part of the CargoSet.
local Unit = UNIT:Register( CargoUnitName )
--local WeightUnit = Unit:GetDesc().massEmpty
--WeightGroup = WeightGroup + WeightUnit
local CargoUnit = CARGO_UNIT:New( Unit, Type, CargoUnitName, 10, LoadRadius, NearRadius )
self.CargoSet:Add( CargoUnitName, CargoUnit )
end
-- Then we register the new group in the database
@@ -107,6 +105,31 @@ do -- CARGO_GROUP
-- Now we spawn the new group based on the template created.
self.CargoObject = _DATABASE:Spawn( GroupTemplate )
for CargoUnitID, CargoUnit in pairs( self.CargoObject:GetUnits() ) do
local Desc = CargoUnit:GetDesc()
self:I( { Desc = Desc } )
local WeightUnit = math.random( 80, 120 )
if Desc then
WeightUnit = Desc.massEmpty
end
local Box = CargoUnit:GetBoundingBox()
local VolumeUnit = ( Box.max.x - Box.min.x ) * ( Box.max.y - Box.min.y ) * ( Box.max.z - Box.min.z )
self:I( { VolumeUnit = VolumeUnit, WeightUnit = WeightUnit } )
local CargoUnitName = CargoUnit:GetName()
local Cargo = CARGO_UNIT:New( CargoUnit, Type, CargoUnitName, 0, LoadRadius, NearRadius )
Cargo:SetWeight( WeightUnit )
Cargo:SetVolume( VolumeUnit )
self.CargoSet:Add( CargoUnitName, Cargo )
WeightGroup = WeightGroup + WeightUnit
VolumeGroup = VolumeGroup + VolumeUnit
end
self:SetWeight( WeightGroup )
self.CargoLimit = 10