Unboarding and Unboarding timing updates.

This commit is contained in:
FlightControl
2018-09-21 16:29:53 +02:00
parent 8516cb349c
commit c8f2786611
3 changed files with 15 additions and 9 deletions
+5 -5
View File
@@ -213,7 +213,7 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
local Boarding = false local Boarding = false
local LoadInterval = 2 local LoadInterval = 5
local LoadDelay = 0 local LoadDelay = 0
local Carrier_List = {} local Carrier_List = {}
local Carrier_Weight = {} local Carrier_Weight = {}
@@ -261,8 +261,8 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
if Carrier_Weight[CarrierUnit] > CargoWeight then --and CargoBayFreeVolume > CargoVolume then if Carrier_Weight[CarrierUnit] > CargoWeight then --and CargoBayFreeVolume > CargoVolume then
Carrier:RouteStop() Carrier:RouteStop()
--Cargo:Ungroup() --Cargo:Ungroup()
Cargo:__Board( LoadDelay, CarrierUnit, 25 ) Cargo:__Board( -LoadDelay, CarrierUnit, 25 )
LoadDelay = LoadDelay + LoadInterval LoadDelay = LoadDelay + Cargo:GetCount() * LoadInterval
self:__Board( LoadDelay, Cargo, CarrierUnit, PickupZone ) self:__Board( LoadDelay, Cargo, CarrierUnit, PickupZone )
-- So now this CarrierUnit has Cargo that is being loaded. -- So now this CarrierUnit has Cargo that is being loaded.
@@ -308,7 +308,7 @@ function AI_CARGO:onafterBoard( Carrier, From, Event, To, Cargo, CarrierUnit, Pi
if Carrier and Carrier:IsAlive() then if Carrier and Carrier:IsAlive() then
self:F({ IsLoaded = Cargo:IsLoaded(), Cargo:GetName(), Carrier:GetName() } ) self:F({ IsLoaded = Cargo:IsLoaded(), Cargo:GetName(), Carrier:GetName() } )
if not Cargo:IsLoaded() then if not Cargo:IsLoaded() then
self:__Board( 10, Cargo, CarrierUnit, PickupZone ) self:__Board( -10, Cargo, CarrierUnit, PickupZone )
return return
end end
end end
@@ -397,7 +397,7 @@ function AI_CARGO:onafterUnload( Carrier, From, Event, To, DeployZone )
self:F( { Cargo = Cargo:GetName(), Isloaded = Cargo:IsLoaded() } ) self:F( { Cargo = Cargo:GetName(), Isloaded = Cargo:IsLoaded() } )
if Cargo:IsLoaded() then if Cargo:IsLoaded() then
Cargo:__UnBoard( UnboardDelay ) Cargo:__UnBoard( UnboardDelay )
UnboardDelay = UnboardDelay + UnboardInterval UnboardDelay = UnboardDelay + Cargo:GetCount() * UnboardInterval
Cargo:SetDeployed( true ) Cargo:SetDeployed( true )
self:__Unboard( UnboardDelay, Cargo, CarrierUnit, DeployZone ) self:__Unboard( UnboardDelay, Cargo, CarrierUnit, DeployZone )
end end
@@ -1097,13 +1097,14 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
local PickupCargo = nil local PickupCargo = nil
local PickupZone = nil local PickupZone = nil
--self.SetCargo:Flush()
for CargoName, Cargo in UTILS.spairs( self.SetCargo:GetSet(), function( t, a, b ) return t[a]:GetWeight() < t[b]:GetWeight() end ) do for CargoName, Cargo in UTILS.spairs( self.SetCargo: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
self:F( { Cargo = Cargo:GetName(), UnLoaded = Cargo:IsUnLoaded(), Deployed = Cargo:IsDeployed(), PickupCargo = self.PickupCargo[Carrier] ~= nil } ) self:F( { Cargo = Cargo:GetName(), UnLoaded = Cargo:IsUnLoaded(), Deployed = Cargo:IsDeployed(), PickupCargo = self.PickupCargo[Carrier] ~= nil } )
if Cargo:IsUnLoaded() == true and Cargo:IsDeployed() == false then if Cargo:IsUnLoaded() == true and Cargo:IsDeployed() == false then
local CargoCoordinate = Cargo:GetCoordinate() local CargoCoordinate = Cargo:GetCoordinate()
local CoordinateFree = true local CoordinateFree = true
self.PickupZoneSet:Flush() --self.PickupZoneSet:Flush()
PickupZone = self.PickupZoneSet and self.PickupZoneSet:IsCoordinateInZone( CargoCoordinate ) PickupZone = self.PickupZoneSet and self.PickupZoneSet:IsCoordinateInZone( CargoCoordinate )
if not self.PickupZoneSet or PickupZone then if not self.PickupZoneSet or PickupZone then
for CarrierPickup, Coordinate in pairs( self.PickupCargo ) do for CarrierPickup, Coordinate in pairs( self.PickupCargo ) do
+8 -3
View File
@@ -271,7 +271,7 @@ do -- CARGO_UNIT
local TaskRoute = self.CargoObject:TaskRoute( Points ) local TaskRoute = self.CargoObject:TaskRoute( Points )
self.CargoObject:SetTask( TaskRoute, 2 ) self.CargoObject:SetTask( TaskRoute, 2 )
self:__Boarding( -1, CargoCarrier, NearRadius ) self:__Boarding( -5, CargoCarrier, NearRadius )
self.RunCount = 0 self.RunCount = 0
end end
end end
@@ -297,8 +297,13 @@ do -- CARGO_UNIT
if self:IsNear( CargoCarrier:GetPointVec2(), NearRadius ) then if self:IsNear( CargoCarrier:GetPointVec2(), NearRadius ) then
self:__Load( 1, CargoCarrier, ... ) self:__Load( 1, CargoCarrier, ... )
else else
self:__Boarding( -1, CargoCarrier, NearRadius, ... ) if self:IsNear( CargoCarrier:GetPointVec2(), 20 ) then
self.RunCount = self.RunCount + 1 self:__Boarding( -2, CargoCarrier, NearRadius, ... )
self.RunCount = self.RunCount + 2
else
self:__Boarding( -10, CargoCarrier, NearRadius, ... )
self.RunCount = self.RunCount + 10
end
if self.RunCount >= 40 then if self.RunCount >= 40 then
self.RunCount = 0 self.RunCount = 0
local Speed = 90 local Speed = 90