mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
parent
bdbb1ea018
commit
cf9bbc9ba7
@ -150,29 +150,21 @@ function CARGO:IsNear( PointVec2 )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Loaded State.
|
--- On Loaded callback function.
|
||||||
-- @param #CARGO self
|
function CARGO:OnLoaded( CallBackFunction, ... )
|
||||||
-- @param StateMachine#STATEMACHINE_PROCESS FsmP
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string To
|
|
||||||
-- @param Unit#UNIT CargoCarrier
|
|
||||||
function CARGO:OnLoaded( FsmP, Event, From, To, CargoCarrier )
|
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self:T( "Cargo " .. self.Name .. " loaded in " .. CargoCarrier:GetName() )
|
self.OnLoadedCallBack = CallBackFunction
|
||||||
|
self.OnLoadedParameters = arg
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- UnLoaded State.
|
--- On UnLoaded callback function.
|
||||||
-- @param #CARGO self
|
function CARGO:OnUnLoaded( CallBackFunction, ... )
|
||||||
-- @param StateMachine#STATEMACHINE_PROCESS FsmP
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string To
|
|
||||||
function CARGO:OnUnLoaded( FsmP, Event, From, To )
|
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self:T( "Cargo " .. self.Name .. " unloaded from " .. self.CargoCarrier:GetName() )
|
self.OnUnLoadedCallBack = CallBackFunction
|
||||||
|
self.OnUnLoadedParameters = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #CARGO self
|
--- @param #CARGO self
|
||||||
@ -256,10 +248,10 @@ function CARGO_UNIT:New( Mission, CargoUnit, Type, Name, Weight, ReportRadius, N
|
|||||||
{ name = 'Load', from = 'UnLoaded', to = 'Loaded' },
|
{ name = 'Load', from = 'UnLoaded', to = 'Loaded' },
|
||||||
},
|
},
|
||||||
callbacks = {
|
callbacks = {
|
||||||
onBoard = self.OnBoard,
|
onafterBoard = self.EventBoard,
|
||||||
onLoad = self.OnLoad,
|
onafterLoad = self.EventLoad,
|
||||||
onUnBoard = self.OnUnBoard,
|
onafterUnBoard = self.EventUnBoard,
|
||||||
onUnLoad = self.OnUnLoad,
|
onafterUnLoad = self.EventUnLoad,
|
||||||
onenterBoarding = self.EnterStateBoarding,
|
onenterBoarding = self.EnterStateBoarding,
|
||||||
onleaveBoarding = self.LeaveStateBoarding,
|
onleaveBoarding = self.LeaveStateBoarding,
|
||||||
onenterLoaded = self.EnterStateLoaded,
|
onenterLoaded = self.EnterStateLoaded,
|
||||||
@ -314,6 +306,8 @@ function CARGO_UNIT:EnterStateUnBoarding( FsmP, Event, From, To, ToPointVec2 )
|
|||||||
|
|
||||||
local TaskRoute = self.CargoObject:TaskRoute( Points )
|
local TaskRoute = self.CargoObject:TaskRoute( Points )
|
||||||
self.CargoObject:SetTask( TaskRoute, 1 )
|
self.CargoObject:SetTask( TaskRoute, 1 )
|
||||||
|
|
||||||
|
self:_NextEvent( FsmP.UnBoard, ToPointVec2 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -337,7 +331,7 @@ function CARGO_UNIT:LeaveStateUnBoarding( FsmP, Event, From, To, ToPointVec2 )
|
|||||||
if self:IsNear( ToPointVec2 ) then
|
if self:IsNear( ToPointVec2 ) then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
self:_NextEvent( FsmP.UnLoad, ToPointVec2 )
|
self:_NextEvent( FsmP.UnBoard, ToPointVec2 )
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -368,6 +362,12 @@ function CARGO_UNIT:EnterStateUnLoaded( FsmP, Event, From, To, ToPointVec2 )
|
|||||||
self.CargoObject:ReSpawn( ToPointVec2:GetVec3(), 0 )
|
self.CargoObject:ReSpawn( ToPointVec2:GetVec3(), 0 )
|
||||||
self.CargoCarrier = nil
|
self.CargoCarrier = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.OnUnLoadedCallBack then
|
||||||
|
self.OnUnLoadedCallBack( self, unpack( self.OnUnLoadedParameters ) )
|
||||||
|
self.OnUnLoadedCallBack = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -440,6 +440,12 @@ function CARGO_UNIT:EnterStateLoaded( FsmP, Event, From, To, CargoCarrier )
|
|||||||
if self.CargoObject then
|
if self.CargoObject then
|
||||||
self.CargoObject:Destroy()
|
self.CargoObject:Destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.OnLoadedCallBack then
|
||||||
|
self.OnLoadedCallBack( self, unpack( self.OnLoadedParameters ) )
|
||||||
|
self.OnLoadedCallBack = nil
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -449,7 +455,7 @@ end
|
|||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
function CARGO_UNIT:OnBoard( FsmP, Event, From, To, CargoCarrier )
|
function CARGO_UNIT:EventBoard( FsmP, Event, From, To, CargoCarrier )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self.CargoInAir = self.CargoObject:InAir()
|
self.CargoInAir = self.CargoObject:InAir()
|
||||||
@ -465,30 +471,13 @@ function CARGO_UNIT:OnBoard( FsmP, Event, From, To, CargoCarrier )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Boarded Event.
|
|
||||||
-- @param #CARGO_UNIT self
|
|
||||||
-- @param StateMachine#STATEMACHINE_PROCESS FsmP
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string To
|
|
||||||
-- @param Unit#UNIT CargoCarrier
|
|
||||||
function CARGO_UNIT:OnBoarded( FsmP, Event, From, To, CargoCarrier )
|
|
||||||
self:F()
|
|
||||||
|
|
||||||
if self:IsNear( CargoCarrier ) then
|
|
||||||
self:_NextEvent( FsmP.Load, CargoCarrier )
|
|
||||||
else
|
|
||||||
self:_NextEvent( FsmP.Boarded, CargoCarrier )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- UnBoard Event.
|
--- UnBoard Event.
|
||||||
-- @param #CARGO_UNIT self
|
-- @param #CARGO_UNIT self
|
||||||
-- @param StateMachine#STATEMACHINE_PROCESS FsmP
|
-- @param StateMachine#STATEMACHINE_PROCESS FsmP
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
function CARGO_UNIT:OnUnBoard( FsmP, Event, From, To )
|
function CARGO_UNIT:EventUnBoard( FsmP, Event, From, To )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self.CargoInAir = self.CargoObject:InAir()
|
self.CargoInAir = self.CargoObject:InAir()
|
||||||
@ -512,7 +501,7 @@ end
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Unit#UNIT CargoCarrier
|
-- @param Unit#UNIT CargoCarrier
|
||||||
function CARGO_UNIT:OnLoad( FsmP, Event, From, To, CargoCarrier )
|
function CARGO_UNIT:EventLoad( FsmP, Event, From, To, CargoCarrier )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self:T( self.ClassName )
|
self:T( self.ClassName )
|
||||||
@ -525,7 +514,7 @@ end
|
|||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
function CARGO_UNIT:OnUnLoad( FsmP, Event, From, To )
|
function CARGO_UNIT:EventUnLoad( FsmP, Event, From, To )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
local Mission = MISSION:New( "Transfer Cargo", "High", "Test for Cargo", coalition.side.RED )
|
||||||
|
|
||||||
|
local CargoEngineer = UNIT:FindByName( "Engineer" )
|
||||||
|
local InfantryCargo = CARGO_UNIT:New( Mission, CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
|
||||||
|
|
||||||
|
local CargoCarrierFrom = UNIT:FindByName( "CarrierFrom" )
|
||||||
|
|
||||||
|
local CargoCarrierTo = UNIT:FindByName( "CarrierTo" )
|
||||||
|
|
||||||
|
-- This call will make the Cargo run to the CargoCarrier.
|
||||||
|
-- Upon arrival at the CargoCarrier, the Cargo will be Loaded into the Carrier.
|
||||||
|
-- This process is now fully automated.
|
||||||
|
InfantryCargo:Board( CargoCarrierFrom )
|
||||||
|
|
||||||
|
-- Once the Cargo has been loaded into the Carrier, drive to a point and unload the Cargo.
|
||||||
|
InfantryCargo:OnLoaded(
|
||||||
|
function( Cargo )
|
||||||
|
Cargo:UnLoad()
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Once the Cargo has been unloaded from the Carrier (the Cargo has arrived to the unload gathering point), OnBoard the Cargo in the other Carrier.
|
||||||
|
InfantryCargo:OnUnLoaded(
|
||||||
|
function( Cargo )
|
||||||
|
Cargo:Board( CargoCarrierTo )
|
||||||
|
end
|
||||||
|
)
|
||||||
Loading…
x
Reference in New Issue
Block a user