mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed the remaining issues with APCs, Helicopter and Airplane cargo dispatchers.
This commit is contained in:
parent
f655e7e652
commit
337e7eab53
@ -230,13 +230,13 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
|
||||
local Carrier_Count = #Carrier_List
|
||||
local Carrier_Index = 1
|
||||
|
||||
local Loaded = false
|
||||
|
||||
for _, Cargo in UTILS.spairs( self.CargoSet:GetSet(), function( t, a, b ) return t[a]:GetWeight() > t[b]:GetWeight() end ) do
|
||||
local Cargo = Cargo -- Cargo.Cargo#CARGO
|
||||
|
||||
self:F( { IsUnLoaded = Cargo:IsUnLoaded(), IsDeployed = Cargo:IsDeployed(), Cargo:GetName(), Carrier:GetName() } )
|
||||
|
||||
local Loaded = false
|
||||
|
||||
-- Try all Carriers, but start from the one according the Carrier_Index
|
||||
for Carrier_Loop = 1, #Carrier_List do
|
||||
|
||||
@ -248,7 +248,7 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
|
||||
Carrier_Index = 1
|
||||
end
|
||||
|
||||
if Cargo:IsUnLoaded() then -- and not Cargo:IsDeployed() then
|
||||
if Cargo:IsUnLoaded() and not Cargo:IsDeployed() then
|
||||
if Cargo:IsInLoadRadius( CarrierUnit:GetCoordinate() ) then
|
||||
self:F( { "In radius", CarrierUnit:GetName() } )
|
||||
|
||||
@ -277,12 +277,13 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
|
||||
|
||||
end
|
||||
|
||||
if not Loaded then
|
||||
-- No loading happened, so we need to pickup something else.
|
||||
self.Relocating = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if not Loaded == true then
|
||||
-- No loading happened, so we need to pickup something else.
|
||||
self.Relocating = false
|
||||
end
|
||||
end
|
||||
|
||||
return Boarding
|
||||
@ -309,7 +310,7 @@ function AI_CARGO:onafterBoard( Carrier, From, Event, To, Cargo, CarrierUnit, Pi
|
||||
end
|
||||
end
|
||||
|
||||
self:__Loaded( 10, Cargo, CarrierUnit, PickupZone )
|
||||
self:__Loaded( 0.1, Cargo, CarrierUnit, PickupZone )
|
||||
|
||||
end
|
||||
|
||||
@ -337,7 +338,7 @@ function AI_CARGO:onafterLoaded( Carrier, From, Event, To, Cargo, PickupZone )
|
||||
end
|
||||
|
||||
if Loaded then
|
||||
self:PickedUp( PickupZone )
|
||||
self:__PickedUp( 0.1, PickupZone )
|
||||
end
|
||||
|
||||
end
|
||||
@ -363,9 +364,9 @@ function AI_CARGO:onafterPickedUp( Carrier, From, Event, To, PickupZone )
|
||||
end
|
||||
|
||||
self.Relocating = false
|
||||
if HasCargo then
|
||||
self.Transporting = true
|
||||
end
|
||||
if HasCargo then
|
||||
self.Transporting = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function AI_CARGO_APC:onafterMonitor( APC, From, Event, To )
|
||||
self:F( { APC, From, Event, To } )
|
||||
self:F( { APC, From, Event, To, IsTransporting = self:IsTransporting() } )
|
||||
|
||||
if self.CombatRadius > 0 then
|
||||
if APC and APC:IsAlive() then
|
||||
|
||||
@ -438,7 +438,8 @@ function AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo )
|
||||
|
||||
self:AddTransition( "Monitoring", "Home", "Monitoring" )
|
||||
|
||||
self.MonitorTimeInterval = 30
|
||||
self:SetMonitorTimeInterval( 30 )
|
||||
|
||||
self.DeployRadiusInner = 200
|
||||
self.DeployRadiusOuter = 500
|
||||
|
||||
@ -481,29 +482,13 @@ function AI_CARGO_DISPATCHER:NewWithZones( SetCarrier, SetCargo, PickupZoneSet,
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Creates a new AI_CARGO_DISPATCHER object.
|
||||
--- Set the monitor time interval.
|
||||
-- @param #AI_CARGO_DISPATCHER self
|
||||
-- @param Core.Set#SET_GROUP SetCarrier
|
||||
-- @param Core.Set#SET_CARGO SetCargo
|
||||
-- @param Core.Set#SET_AIRBASE PickupAirbasesSet
|
||||
-- @param Core.Set#SET_AIRBASE DeployAirbasesSet
|
||||
-- @param #number MonitorTimeInterval
|
||||
-- @return #AI_CARGO_DISPATCHER
|
||||
-- @usage
|
||||
--
|
||||
-- -- Create a new cargo dispatcher
|
||||
-- SetCarriers = SET_GROUP:New():FilterPrefixes( "APC" ):FilterStart()
|
||||
-- SetCargos = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
||||
-- PickupAirbasesSet = SET_AIRBASES:New()
|
||||
-- DeployAirbasesSet = SET_AIRBASES:New()
|
||||
-- AICargoDispatcher = AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo, PickupAirbasesSet, DeployAirbasesSet )
|
||||
--
|
||||
function AI_CARGO_DISPATCHER:NewWithAirbases( SetCarriers, SetCargos, PickupAirbasesSet, DeployAirbasesSet )
|
||||
function AI_CARGO_DISPATCHER:SetMonitorTimeInterval( MonitorTimeInterval )
|
||||
|
||||
local self = AI_CARGO_DISPATCHER:New( SetCarriers, SetCargos ) -- #AI_CARGO_DISPATCHER
|
||||
|
||||
self.DeployAirbasesSet = DeployAirbasesSet
|
||||
self.PickupAirbasesSet = PickupAirbasesSet
|
||||
self.MonitorTimeInterval = MonitorTimeInterval
|
||||
|
||||
return self
|
||||
end
|
||||
@ -532,30 +517,8 @@ function AI_CARGO_DISPATCHER:SetHomeZone( HomeZone )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set the home airbase. This is for air units, i.e. helicopters and airplanes.
|
||||
-- When there is nothing anymore to pickup, the carriers will go back to their home base. They will await here new orders.
|
||||
-- @param #AI_CARGO_DISPATCHER self
|
||||
-- @param Wrapper.Airbase#AIRBASE HomeBase Airbase where the carriers will go after all pickup assignments are done.
|
||||
-- @return #AI_CARGO_DISPATCHER self
|
||||
function AI_CARGO_DISPATCHER:SetHomeBase( HomeBase )
|
||||
|
||||
self.HomeBase = HomeBase
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set the home base.
|
||||
-- When there is nothing anymore to pickup, the carriers will return to their home airbase. There they will await new orders.
|
||||
-- @param #AI_CARGO_DISPATCHER self
|
||||
-- @param Wrapper.Airbase#AIRBASE HomeBase The airbase where the carrier will go to, once they completed all pending assignments.
|
||||
-- @return #AI_CARGO_DISPATCHER self
|
||||
function AI_CARGO_DISPATCHER:SetHomeBase( HomeBase )
|
||||
|
||||
self.HomeBase = HomeBase
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Sets or randomizes the pickup location for the carrier around the cargo coordinate in a radius defined an outer and optional inner radius.
|
||||
@ -1022,7 +985,7 @@ function AI_CARGO_DISPATCHER:onafterTransport( From, Event, To, Carrier, Cargo )
|
||||
local DeployZone = self.DeployZoneSet:GetRandomZone()
|
||||
|
||||
local DeployCoordinate = DeployZone:GetCoordinate():GetRandomCoordinateInRadius( self.DeployOuterRadius, self.DeployInnerRadius )
|
||||
self.AI_Cargo[Carrier]:Deploy( DeployCoordinate, math.random( self.DeployMinSpeed, self.DeployMaxSpeed ), DeployZone )
|
||||
self.AI_Cargo[Carrier]:__Deploy( 0.1, DeployCoordinate, math.random( self.DeployMinSpeed, self.DeployMaxSpeed ), DeployZone )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -67,6 +67,8 @@ function AI_CARGO_DISPATCHER_AIRPLANE:New( AirplaneSet, CargoSet, PickupZoneSet,
|
||||
self:SetPickupSpeed( 1200, 600 )
|
||||
self:SetPickupRadius( 0, 0 )
|
||||
self:SetDeployRadius( 0, 0 )
|
||||
|
||||
self:SetMonitorTimeInterval( 600 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -1974,7 +1974,7 @@ do -- Route methods
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #CONTROLLABLE
|
||||
function CONTROLLABLE:RouteStop()
|
||||
self:F(self:GetName() .. "RouteStop")
|
||||
self:F(self:GetName() .. " RouteStop")
|
||||
|
||||
local CommandStop = self:CommandStopRoute( true )
|
||||
self:SetCommand( CommandStop )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user