mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Warehosue v0.3.3
This commit is contained in:
@@ -132,7 +132,7 @@ function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
||||
AirplaneUnit:SetCargoBayWeightLimit()
|
||||
end
|
||||
|
||||
self.Relocating = true
|
||||
self.Relocating = false --FF should be false or set according to state of airplane!
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -127,8 +127,8 @@ function AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo )
|
||||
self:AddTransition( "*", "BackHome", "*" ) --FF
|
||||
|
||||
self.MonitorTimeInterval = 30
|
||||
self.DeployRadiusInner = 200
|
||||
self.DeployRadiusOuter = 500
|
||||
self.DeployInnerRadius = 200
|
||||
self.DeployOuterRadius = 500
|
||||
|
||||
self.PickupCargo = {}
|
||||
self.CarrierHome = {}
|
||||
@@ -231,19 +231,6 @@ function AI_CARGO_DISPATCHER:SetHomeBase( HomeBase )
|
||||
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.
|
||||
-- This radius is influencing the location where the carrier will land to pickup the cargo.
|
||||
-- There are two aspects that are very important to remember and take into account:
|
||||
@@ -368,12 +355,13 @@ end
|
||||
-- @param #AI_CARGO_DISPATCHER self
|
||||
function AI_CARGO_DISPATCHER:onafterMonitor()
|
||||
|
||||
env.info("FF number of cargo set = "..self.SetCargo:Count())
|
||||
|
||||
for CarrierGroupName, Carrier in pairs( self.SetCarrier:GetSet() ) do
|
||||
env.info("FF cargo dispatcher carrier group "..CarrierGroupName)
|
||||
|
||||
local Carrier = Carrier -- Wrapper.Group#GROUP
|
||||
local AI_Cargo = self.AI_Cargo[Carrier]
|
||||
if not AI_Cargo then
|
||||
env.info("FF not AI CARGO")
|
||||
|
||||
-- ok, so this Carrier does not have yet an AI_CARGO handling object...
|
||||
-- let's create one and also declare the Loaded and UnLoaded handlers.
|
||||
@@ -404,10 +392,15 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
|
||||
self:Unloaded( Carrier, Cargo )
|
||||
end
|
||||
|
||||
-- FF added back home event.
|
||||
-- FF added BackHome event.
|
||||
function AI_Cargo.OnAfterBackHome( AI_Cargo, Carrier, From, Event, To)
|
||||
self:BackHome( Carrier )
|
||||
end
|
||||
|
||||
-- FF added RTB event.
|
||||
function AI_Cargo.OnAfterRTB( AI_Cargo, Carrier, From, Event, To, Airbase)
|
||||
self:RTB( Carrier, Airbase )
|
||||
end
|
||||
end
|
||||
|
||||
-- The Pickup sequence ...
|
||||
@@ -459,6 +452,7 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
|
||||
end
|
||||
|
||||
if PickupCargo then
|
||||
|
||||
self.CarrierHome[Carrier] = nil
|
||||
local PickupCoordinate = PickupCargo:GetCoordinate():GetRandomCoordinateInRadius( self.PickupOuterRadius, self.PickupInnerRadius )
|
||||
|
||||
@@ -472,18 +466,34 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
|
||||
AI_Cargo:Pickup( PickupCoordinate, math.random( self.PickupMinSpeed, self.PickupMaxSpeed ) )
|
||||
end
|
||||
break
|
||||
|
||||
else
|
||||
|
||||
env.info("FF HomeZone or HomeBase?")
|
||||
if self.HomeZone then
|
||||
|
||||
env.info("FF HomeZone! Really?")
|
||||
if not self.CarrierHome[Carrier] then
|
||||
env.info("FF Yes!")
|
||||
self.CarrierHome[Carrier] = true
|
||||
AI_Cargo:__Home( 60, self.HomeZone:GetRandomPointVec2() )
|
||||
else
|
||||
env.info("FF Nope!")
|
||||
end
|
||||
elseif self.HomeBase then
|
||||
|
||||
elseif self.HomeBase2 then
|
||||
|
||||
env.info("FF HomeBase! Really?")
|
||||
if not self.CarrierHome[Carrier] then
|
||||
env.info("FF Yes!")
|
||||
self.CarrierHome[Carrier] = true
|
||||
AI_Cargo:__RTB( 60, self.HomeBase )
|
||||
end
|
||||
AI_Cargo:__RTB( 1, self.HomeBase )
|
||||
else
|
||||
env.info("FF Nope!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -827,16 +827,6 @@ function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinat
|
||||
Tasks[#Tasks+1] = Helicopter:TaskLandAtVec2( CoordinateTo:GetVec2() )
|
||||
Route[#Route].task = Helicopter:TaskCombo( Tasks )
|
||||
|
||||
-- FF
|
||||
--[[
|
||||
local Tasks2 = {}
|
||||
Tasks2[#Tasks2+1] = Helicopter:TaskFunction("AI_CARGO_HELICOPTER._BackHome", self)
|
||||
|
||||
Route[#Route+1] = WaypointTo
|
||||
Route[#Route].task = Helicopter:TaskCombo( Tasks2 )
|
||||
-- FF
|
||||
]]
|
||||
|
||||
Route[#Route+1] = WaypointTo
|
||||
|
||||
-- Now route the helicopter
|
||||
@@ -930,9 +920,10 @@ end
|
||||
--- Function called when transport is back home and nothing more to do. Triggering the event BackHome.
|
||||
-- @param Wrapper.Group#GROUP Helicopter Cargo helicopter.
|
||||
-- @param #AI_CARGO_HELICOPTER self
|
||||
function AI_CARGO_HELICOPTER._BackHome(Group, self)
|
||||
--Trigger BackHome event.
|
||||
function AI_CARGO_HELICOPTER._BackHome(Group, self)
|
||||
env.info("FF ai cargo helicopter back home task function")
|
||||
Group:SmokeRed()
|
||||
--Trigger BackHome event.
|
||||
self:__BackHome(1)
|
||||
end
|
||||
|
||||
@@ -944,5 +935,6 @@ end
|
||||
-- @param Event
|
||||
-- @param To
|
||||
function AI_CARGO_HELICOPTER:onafterBackHome( Helicopter, From, Event, To )
|
||||
env.info("FF ai cargo helicopter back home event")
|
||||
Helicopter:SmokeRed()
|
||||
end
|
||||
Reference in New Issue
Block a user