Optimized landing, messaging, flow

This commit is contained in:
FlightControl 2017-04-14 08:26:53 +02:00
parent ff64255ea7
commit 9a2b56fb9f
3 changed files with 171 additions and 155 deletions

View File

@ -355,99 +355,115 @@ do -- CARGO_REPRESENTABLE
ClassName = "CARGO_REPRESENTABLE" ClassName = "CARGO_REPRESENTABLE"
} }
--- CARGO_REPRESENTABLE Constructor. --- CARGO_REPRESENTABLE Constructor.
-- @param #CARGO_REPRESENTABLE self -- @param #CARGO_REPRESENTABLE self
-- @param Wrapper.Controllable#Controllable CargoObject -- @param Wrapper.Controllable#Controllable CargoObject
-- @param #string Type -- @param #string Type
-- @param #string Name -- @param #string Name
-- @param #number Weight -- @param #number Weight
-- @param #number ReportRadius (optional) -- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional) -- @param #number NearRadius (optional)
-- @return #CARGO_REPRESENTABLE -- @return #CARGO_REPRESENTABLE
function CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, ReportRadius, NearRadius ) function CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO
self:F( { Type, Name, Weight, ReportRadius, NearRadius } ) self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
return self return self
end end
--- Route a cargo unit to a PointVec2. --- Route a cargo unit to a PointVec2.
-- @param #CARGO_REPRESENTABLE self -- @param #CARGO_REPRESENTABLE self
-- @param Core.Point#POINT_VEC2 ToPointVec2 -- @param Core.Point#POINT_VEC2 ToPointVec2
-- @param #number Speed -- @param #number Speed
-- @return #CARGO_REPRESENTABLE -- @return #CARGO_REPRESENTABLE
function CARGO_REPRESENTABLE:RouteTo( ToPointVec2, Speed ) function CARGO_REPRESENTABLE:RouteTo( ToPointVec2, Speed )
self:F2( ToPointVec2 ) self:F2( ToPointVec2 )
local Points = {} local Points = {}
local PointStartVec2 = self.CargoObject:GetPointVec2() local PointStartVec2 = self.CargoObject:GetPointVec2()
Points[#Points+1] = PointStartVec2:RoutePointGround( Speed ) Points[#Points+1] = PointStartVec2:RoutePointGround( Speed )
Points[#Points+1] = ToPointVec2:RoutePointGround( Speed ) Points[#Points+1] = ToPointVec2:RoutePointGround( Speed )
local TaskRoute = self.CargoObject:TaskRoute( Points )
self.CargoObject:SetTask( TaskRoute, 2 )
return self
end
local TaskRoute = self.CargoObject:TaskRoute( Points )
self.CargoObject:SetTask( TaskRoute, 2 )
return self
end
end -- CARGO_REPRESENTABLE end -- CARGO_REPRESENTABLE
do -- CARGO_REPORTABLE do -- CARGO_REPORTABLE
--- @type CARGO_REPORTABLE --- @type CARGO_REPORTABLE
-- @extends #CARGO -- @extends #CARGO
CARGO_REPORTABLE = { CARGO_REPORTABLE = {
ClassName = "CARGO_REPORTABLE" ClassName = "CARGO_REPORTABLE"
} }
--- CARGO_REPORTABLE Constructor. --- CARGO_REPORTABLE Constructor.
-- @param #CARGO_REPORTABLE self -- @param #CARGO_REPORTABLE self
-- @param Wrapper.Controllable#Controllable CargoObject -- @param Wrapper.Controllable#Controllable CargoObject
-- @param #string Type -- @param #string Type
-- @param #string Name -- @param #string Name
-- @param #number Weight -- @param #number Weight
-- @param #number ReportRadius (optional) -- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional) -- @param #number NearRadius (optional)
-- @return #CARGO_REPORTABLE -- @return #CARGO_REPORTABLE
function CARGO_REPORTABLE:New( CargoObject, Type, Name, Weight, ReportRadius ) function CARGO_REPORTABLE:New( CargoObject, Type, Name, Weight, ReportRadius )
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE
self:F( { Type, Name, Weight, ReportRadius } ) self:F( { Type, Name, Weight, ReportRadius } )
self.ReportRadius = ReportRadius or 1000 self.ReportRadius = ReportRadius or 1000
self.CargoObject = CargoObject self.CargoObject = CargoObject
return self return self
end
--- Check if CargoCarrier is in the ReportRadius for the Cargo to be Loaded.
-- @param #CARGO_REPORTABLE self
-- @param Core.Point#POINT_VEC2 PointVec2
-- @return #boolean
function CARGO_REPORTABLE:IsInRadius( PointVec2 )
self:F( { PointVec2 } )
local Distance = 0
if self:IsLoaded() then
Distance = PointVec2:DistanceFromPointVec2( self.CargoCarrier:GetPointVec2() )
else
Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
end end
self:T( Distance )
if Distance <= self.ReportRadius then --- Check if CargoCarrier is in the ReportRadius for the Cargo to be Loaded.
return true -- @param #CARGO_REPORTABLE self
else -- @param Core.Point#POINT_VEC2 PointVec2
return false -- @return #boolean
function CARGO_REPORTABLE:IsInRadius( PointVec2 )
self:F( { PointVec2 } )
local Distance = 0
if self:IsLoaded() then
Distance = PointVec2:DistanceFromPointVec2( self.CargoCarrier:GetPointVec2() )
else
Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
end
self:T( Distance )
if Distance <= self.ReportRadius then
return true
else
return false
end
end end
end
--- Get the range till cargo will board. --- Send a CC message to a GROUP.
-- @param #CARGO self -- @param #COMMANDCENTER self
-- @return #number The range till cargo will board. -- @param #string Message
function CARGO:GetBoardingRange() -- @param Wrapper.Group#GROUP TaskGroup
return self.ReportRadius -- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
end function CARGO_REPORTABLE:MessageToGroup( Message, TaskGroup, Name )
local Prefix = Name and "@ " .. Name .. ": " or "@ " .. TaskGroup:GetCallsign() .. ": "
Message = Prefix .. Message
MESSAGE:New( Message, 20, "Cargo: " .. self:GetName() ):ToGroup( TaskGroup )
end
--- Get the range till cargo will board.
-- @param #CARGO self
-- @return #number The range till cargo will board.
function CARGO_REPORTABLE:GetBoardingRange()
return self.ReportRadius
end
end end
@ -649,7 +665,7 @@ end
function CARGO_UNIT:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... ) function CARGO_UNIT:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } ) self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
local Speed = 10 local Speed = 90
local Angle = 180 local Angle = 180
local Distance = 5 local Distance = 5
@ -1103,8 +1119,8 @@ end
-- @param #string Event -- @param #string Event
-- @param #string From -- @param #string From
-- @param #string To -- @param #string To
function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius ) function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
self:F() self:F({From, Event, To, ToPointVec2, NearRadius})
NearRadius = NearRadius or 25 NearRadius = NearRadius or 25
@ -1120,7 +1136,7 @@ function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius
end end
) )
self:__UnBoarding( 1, ToPointVec2, NearRadius ) self:__UnBoarding( 1, ToPointVec2, NearRadius, ... )
end end
end end
@ -1131,8 +1147,8 @@ end
-- @param #string Event -- @param #string Event
-- @param #string From -- @param #string From
-- @param #string To -- @param #string To
function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius ) function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
self:F( { ToPointVec2, From, Event, To } ) self:F( { From, Event, To, ToPointVec2, NearRadius } )
NearRadius = NearRadius or 25 NearRadius = NearRadius or 25
@ -1154,7 +1170,7 @@ function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius
if UnBoarded then if UnBoarded then
return true return true
else else
self:__UnBoarding( 1, ToPointVec2, NearRadius ) self:__UnBoarding( 1, ToPointVec2, NearRadius, ... )
end end
return false return false
@ -1168,12 +1184,12 @@ end
-- @param #string Event -- @param #string Event
-- @param #string From -- @param #string From
-- @param #string To -- @param #string To
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius ) function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
self:F( { ToPointVec2, From, Event, To } ) self:F( { From, Event, To, ToPointVec2, NearRadius } )
NearRadius = NearRadius or 25 NearRadius = NearRadius or 25
self:__UnLoad( 1, ToPointVec2 ) self:__UnLoad( 1, ToPointVec2, ... )
end end
@ -1184,8 +1200,8 @@ end
-- @param #string Event -- @param #string Event
-- @param #string From -- @param #string From
-- @param #string To -- @param #string To
function CARGO_GROUP:onenterUnLoaded( From, Event, To, ToPointVec2 ) function CARGO_GROUP:onenterUnLoaded( From, Event, To, ToPointVec2, ... )
self:F( { ToPointVec2, From, Event, To } ) self:F( { From, Event, To, ToPointVec2 } )
if From == "Loaded" then if From == "Loaded" then

View File

@ -274,8 +274,7 @@ end
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown. -- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
function COMMANDCENTER:MessageToGroup( Message, TaskGroup, Name ) function COMMANDCENTER:MessageToGroup( Message, TaskGroup, Name )
local Prefix = "@ Group" local Prefix = Name and "@ " .. Name .. ": " or "@ " .. TaskGroup:GetCallsign() .. ": "
Prefix = Prefix .. ( Name and " (" .. Name .. "): " or '' )
Message = Prefix .. Message Message = Prefix .. Message
self:GetPositionable():MessageToGroup( Message , 20, TaskGroup, self:GetName() ) self:GetPositionable():MessageToGroup( Message , 20, TaskGroup, self:GetName() )

View File

@ -36,7 +36,7 @@
-- --
-- * **FlightControl**: Concept, Design & Programming. -- * **FlightControl**: Concept, Design & Programming.
-- --
-- @module Task_CARGO -- @module Task_Cargo
do -- TASK_CARGO do -- TASK_CARGO
@ -102,7 +102,7 @@ do -- TASK_CARGO
Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployZone", ACT_ROUTE_ZONE:New(), { Arrived = "ArriveAtDeploy" } ) Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployZone", ACT_ROUTE_ZONE:New(), { Arrived = "ArriveAtDeploy" } )
Fsm:AddTransition( "Arrived", "ArriveAtDeploy", "ArrivedAtDeploy" ) Fsm:AddTransition( "Arrived", "ArriveAtDeploy", "ArrivedAtDeploy" )
Fsm:AddTransition( { "ArrivedAtPickup", "ArrivedAtDeploy" }, "Land", "Landing" ) Fsm:AddTransition( { "ArrivedAtPickup", "ArrivedAtDeploy", "Landing" }, "Land", "Landing" )
Fsm:AddTransition( "Landing", "Landed", "Landed" ) Fsm:AddTransition( "Landing", "Landed", "Landed" )
Fsm:AddTransition( "WaitingForCommand", "PrepareBoarding", "AwaitBoarding" ) Fsm:AddTransition( "WaitingForCommand", "PrepareBoarding", "AwaitBoarding" )
@ -122,7 +122,7 @@ do -- TASK_CARGO
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnEnterWaitingForCommand( TaskUnit, Task ) function Fsm:OnEnterWaitingForCommand( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
@ -165,7 +165,8 @@ do -- TASK_CARGO
TaskUnit.Menu, TaskUnit.Menu,
self.MenuUnBoardCargo, self.MenuUnBoardCargo,
self, self,
Cargo Cargo,
DeployZone
) )
else else
MENU_GROUP_COMMAND:New( MENU_GROUP_COMMAND:New(
@ -187,7 +188,7 @@ do -- TASK_CARGO
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnLeaveWaitingForCommand( TaskUnit, Task ) function Fsm:OnLeaveWaitingForCommand( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
@ -198,8 +199,8 @@ do -- TASK_CARGO
self:__PrepareBoarding( 1.0, Cargo ) self:__PrepareBoarding( 1.0, Cargo )
end end
function Fsm:MenuUnBoardCargo( Cargo ) function Fsm:MenuUnBoardCargo( Cargo, DeployZone )
self:__PrepareUnBoarding( 1.0, Cargo ) self:__PrepareUnBoarding( 1.0, Cargo, DeployZone )
end end
function Fsm:MenuRouteToPickup( Cargo ) function Fsm:MenuRouteToPickup( Cargo )
@ -213,26 +214,26 @@ do -- TASK_CARGO
--- Route to Cargo --- Route to Cargo
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:onafterRouteToPickup( TaskUnit, Task, From, Event, To, Cargo ) function Fsm:onafterRouteToPickup( TaskUnit, Task, From, Event, To, Cargo )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
self.Cargo = Cargo self.Cargo = Cargo
Task:SetCargoPickup( self.Cargo, TaskUnit ) Task:SetCargoPickup( self.Cargo, TaskUnit )
self:__RouteToPickupPoint( 0.1 ) self:__RouteToPickupPoint( -0.1 )
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:onafterArriveAtPickup( TaskUnit, Task ) function Fsm:onafterArriveAtPickup( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
if TaskUnit:IsAir() then if TaskUnit:IsAir() then
self:__Land( -0.1 ) self:__Land( -0.1, "Pickup" )
else else
self:__SelectAction( -0.1 ) self:__SelectAction( -0.1 )
end end
@ -248,19 +249,19 @@ do -- TASK_CARGO
self.DeployZone = DeployZone self.DeployZone = DeployZone
Task:SetDeployZone( self.DeployZone, TaskUnit ) Task:SetDeployZone( self.DeployZone, TaskUnit )
self:__RouteToDeployZone( 0.1 ) self:__RouteToDeployZone( -0.1 )
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:onafterArriveAtDeploy( TaskUnit, Task ) function Fsm:onafterArriveAtDeploy( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
if TaskUnit:IsAir() then if TaskUnit:IsAir() then
self:__Land( -0.1 ) self:__Land( -0.1, "Deploy" )
else else
self:__SelectAction( -0.1 ) self:__SelectAction( -0.1 )
end end
@ -271,65 +272,64 @@ do -- TASK_CARGO
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterLand( TaskUnit, Task, From, Event, To ) function Fsm:OnAfterLand( TaskUnit, Task, From, Event, To, Action )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then
if TaskUnit:InAir() then if TaskUnit:InAir() then
Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup(), "Land" ) Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() )
self:__Land( -10 ) self:__Land( -10, Action )
else else
Task:GetMission():GetCommandCenter():MessageToGroup( "Landed ...", TaskUnit:GetGroup(), "Land" ) Task:GetMission():GetCommandCenter():MessageToGroup( "Landed ...", TaskUnit:GetGroup() )
self:__Landed( -0.1 ) self:__Landed( -0.1, Action )
end end
else else
self:__ArriveAtCargo( -0.1 ) if Action == "Pickup" then
self:__RouteToPickupZone( -0.1 )
else
self:__RouteToDeployZone( -0.1 )
end
end end
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterLanded( TaskUnit, Task ) function Fsm:OnAfterLanded( TaskUnit, Task, From, Event, To, Action )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then
if TaskUnit:InAir() then if TaskUnit:InAir() then
self:__Land( -0.1 ) self:__Land( -0.1, Action )
else else
Task:GetMission():GetCommandCenter():MessageToGroup( "Preparing to board in 10 seconds ...", TaskUnit:GetGroup(), "Boarding" ) self:__SelectAction( -0.1 )
self:__PrepareBoarding( -10 )
end end
else else
self:__ArriveAtCargo( -0.1 ) if Action == "Pickup" then
self:__RouteToPickupZone( -0.1 )
else
self:__RouteToDeployZone( -0.1 )
end
end end
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterPrepareBoarding( TaskUnit, Task, From, Event, To, Cargo ) function Fsm:OnAfterPrepareBoarding( TaskUnit, Task, From, Event, To, Cargo )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
self.Cargo = Cargo self.Cargo = Cargo -- Core.Cargo#CARGO_GROUP
if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then self:__Board( -0.1 )
if TaskUnit:InAir() then
self:__Land( -0.1 )
else
self:__Board( -0.1 )
end
else
self:__ArriveAtCargo( -0.1 )
end
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterBoard( TaskUnit, Task ) function Fsm:OnAfterBoard( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
@ -344,13 +344,13 @@ do -- TASK_CARGO
if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then
if TaskUnit:InAir() then if TaskUnit:InAir() then
self:__Land( -0.1 ) --- ABORT the boarding. Split group if any and go back to select action.
else else
Task:GetMission():GetCommandCenter():MessageToGroup( "Boarding ...", TaskUnit:GetGroup(), "Boarding" ) self.Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() )
self.Cargo:Board( TaskUnit, 20, self ) self.Cargo:Board( TaskUnit, 20, self )
end end
else else
self:__ArriveAtCargo( -0.1 ) --self:__ArriveAtCargo( -0.1 )
end end
end end
@ -358,11 +358,11 @@ do -- TASK_CARGO
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterBoarded( TaskUnit, Task ) function Fsm:OnAfterBoarded( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
Task:GetMission():GetCommandCenter():MessageToGroup( "Boarded ...", TaskUnit:GetGroup(), "Boarding" ) self.Cargo:MessageToGroup( "Boarded ...", TaskUnit:GetGroup() )
self:__SelectAction( 1 ) self:__SelectAction( 1 )
end end
@ -370,42 +370,43 @@ do -- TASK_CARGO
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterPrepareUnBoarding( TaskUnit, Task, From, Event, To, Cargo, DeployZone ) function Fsm:OnAfterPrepareUnBoarding( TaskUnit, Task, From, Event, To, Cargo, DeployZone )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
self.Cargo = Cargo
self.DeployZone = DeployZone self.DeployZone = DeployZone
self.Cargo:__UnBoard( -0.1, DeployZone, 20 ) self:__UnBoard( -0.1 )
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterUnBoard( TaskUnit, Task ) function Fsm:OnAfterUnBoard( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
function self.Cargo:OnEnterUnLoaded( From, Event, To, TaskUnit, TaskProcess ) function self.Cargo:OnEnterUnLoaded( From, Event, To, DeployZone, TaskProcess )
self:E({From, Event, To, TaskUnit, TaskProcess }) self:E({From, Event, To, TaskUnit, TaskProcess })
TaskProcess:__UnBoarded( 0.1 ) TaskProcess:__UnBoarded( -0.1 )
end end
Task:GetMission():GetCommandCenter():MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup(), "UnBoarding" ) self.Cargo:MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup() )
self.Cargo:__UnBoard( -0.1, self.DeployZone, 20 ) self.Cargo:UnBoard( self.DeployZone:GetPointVec2(), 20, self )
end end
--- ---
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_CARGO#TASK_CARGO Task -- @param Tasking.Task_Cargo#TASK_CARGO Task
function Fsm:OnAfterUnBoarded( TaskUnit, Task ) function Fsm:OnAfterUnBoarded( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
Task:GetMission():GetCommandCenter():MessageToGroup( "UnBoarded ...", TaskUnit:GetGroup(), "UnBoarding" ) self.Cargo:MessageToGroup( "UnBoarded ...", TaskUnit:GetGroup() )
self:__SelectAction( 1 ) self:__SelectAction( 1 )
end end