mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed menu and deployment of cargo
-- You can now deploy cargo anywhere in the battlefield. -- The menu generation is improved. ---- No more first remove menu and then build, but "refresh"...
This commit is contained in:
@@ -182,24 +182,24 @@ do -- TASK_CARGO
|
|||||||
|
|
||||||
Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } )
|
Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } )
|
||||||
|
|
||||||
Fsm:AddTransition( { "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Landed" }, "SelectAction", "WaitingForCommand" )
|
Fsm:AddTransition( { "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Landed", "Boarding" }, "SelectAction", "*" )
|
||||||
|
|
||||||
Fsm:AddTransition( "WaitingForCommand", "RouteToPickup", "RoutingToPickup" )
|
Fsm:AddTransition( "*", "RouteToPickup", "RoutingToPickup" )
|
||||||
Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup" } )
|
Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup" } )
|
||||||
Fsm:AddTransition( "Arrived", "ArriveAtPickup", "ArrivedAtPickup" )
|
Fsm:AddTransition( "Arrived", "ArriveAtPickup", "ArrivedAtPickup" )
|
||||||
|
|
||||||
Fsm:AddTransition( "WaitingForCommand", "RouteToDeploy", "RoutingToDeploy" )
|
Fsm:AddTransition( "*", "RouteToDeploy", "RoutingToDeploy" )
|
||||||
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", "Landing" }, "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( "*", "PrepareBoarding", "AwaitBoarding" )
|
||||||
Fsm:AddTransition( "AwaitBoarding", "Board", "Boarding" )
|
Fsm:AddTransition( "AwaitBoarding", "Board", "Boarding" )
|
||||||
Fsm:AddTransition( "Boarding", "Boarded", "Boarded" )
|
Fsm:AddTransition( "Boarding", "Boarded", "Boarded" )
|
||||||
|
|
||||||
Fsm:AddTransition( "WaitingForCommand", "PrepareUnBoarding", "AwaitUnBoarding" )
|
Fsm:AddTransition( "*", "PrepareUnBoarding", "AwaitUnBoarding" )
|
||||||
Fsm:AddTransition( "AwaitUnBoarding", "UnBoard", "UnBoarding" )
|
Fsm:AddTransition( "AwaitUnBoarding", "UnBoard", "UnBoarding" )
|
||||||
Fsm:AddTransition( "UnBoarding", "UnBoarded", "UnBoarded" )
|
Fsm:AddTransition( "UnBoarding", "UnBoarded", "UnBoarded" )
|
||||||
|
|
||||||
@@ -213,14 +213,12 @@ 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:onafterSelectAction( TaskUnit, Task )
|
||||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
if TaskUnit.Menu then
|
local MenuTime = timer.getTime()
|
||||||
TaskUnit.Menu:Remove()
|
|
||||||
end
|
|
||||||
|
|
||||||
TaskUnit.Menu = MENU_GROUP:New( TaskUnit:GetGroup(), Task:GetName() .. " @ " .. TaskUnit:GetName() )
|
TaskUnit.Menu = MENU_GROUP:New( TaskUnit:GetGroup(), Task:GetName() .. " @ " .. TaskUnit:GetName() ):SetTime( MenuTime )
|
||||||
|
|
||||||
Task.SetCargo:ForEachCargo(
|
Task.SetCargo:ForEachCargo(
|
||||||
|
|
||||||
@@ -235,7 +233,7 @@ do -- TASK_CARGO
|
|||||||
self.MenuBoardCargo,
|
self.MenuBoardCargo,
|
||||||
self,
|
self,
|
||||||
Cargo
|
Cargo
|
||||||
)
|
):SetTime(MenuTime)
|
||||||
else
|
else
|
||||||
MENU_GROUP_COMMAND:New(
|
MENU_GROUP_COMMAND:New(
|
||||||
TaskUnit:GetGroup(),
|
TaskUnit:GetGroup(),
|
||||||
@@ -244,23 +242,24 @@ do -- TASK_CARGO
|
|||||||
self.MenuRouteToPickup,
|
self.MenuRouteToPickup,
|
||||||
self,
|
self,
|
||||||
Cargo
|
Cargo
|
||||||
)
|
):SetTime(MenuTime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Cargo:IsLoaded() then
|
if Cargo:IsLoaded() then
|
||||||
|
|
||||||
|
MENU_GROUP_COMMAND:New(
|
||||||
|
TaskUnit:GetGroup(),
|
||||||
|
"Unboard cargo " .. Cargo.Name,
|
||||||
|
TaskUnit.Menu,
|
||||||
|
self.MenuUnBoardCargo,
|
||||||
|
self,
|
||||||
|
Cargo
|
||||||
|
):SetTime(MenuTime)
|
||||||
|
|
||||||
|
-- Deployzones are optional zones that can be selected to request routing information.
|
||||||
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
||||||
if Cargo:IsInZone( DeployZone ) then
|
if not Cargo:IsInZone( DeployZone ) then
|
||||||
MENU_GROUP_COMMAND:New(
|
|
||||||
TaskUnit:GetGroup(),
|
|
||||||
"Unboard cargo " .. Cargo.Name,
|
|
||||||
TaskUnit.Menu,
|
|
||||||
self.MenuUnBoardCargo,
|
|
||||||
self,
|
|
||||||
Cargo,
|
|
||||||
DeployZone
|
|
||||||
)
|
|
||||||
else
|
|
||||||
MENU_GROUP_COMMAND:New(
|
MENU_GROUP_COMMAND:New(
|
||||||
TaskUnit:GetGroup(),
|
TaskUnit:GetGroup(),
|
||||||
"Route to Deploy cargo at " .. DeployZoneName,
|
"Route to Deploy cargo at " .. DeployZoneName,
|
||||||
@@ -268,13 +267,16 @@ do -- TASK_CARGO
|
|||||||
self.MenuRouteToDeploy,
|
self.MenuRouteToDeploy,
|
||||||
self,
|
self,
|
||||||
DeployZone
|
DeployZone
|
||||||
)
|
):SetTime(MenuTime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TaskUnit.Menu:Remove( MenuTime )
|
||||||
|
|
||||||
|
|
||||||
self:__SelectAction( -15 )
|
self:__SelectAction( -15 )
|
||||||
|
|
||||||
@@ -476,12 +478,20 @@ do -- TASK_CARGO
|
|||||||
-- @param To
|
-- @param To
|
||||||
-- @param Cargo
|
-- @param Cargo
|
||||||
-- @param Core.Zone#ZONE_BASE DeployZone
|
-- @param Core.Zone#ZONE_BASE DeployZone
|
||||||
function Fsm:onafterPrepareUnBoarding( TaskUnit, Task, From, Event, To, Cargo, DeployZone )
|
function Fsm:onafterPrepareUnBoarding( TaskUnit, Task, From, Event, To, Cargo )
|
||||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID(), From, Event, To, Cargo, DeployZone } )
|
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID(), From, Event, To, Cargo } )
|
||||||
|
|
||||||
self.Cargo = Cargo
|
self.Cargo = Cargo
|
||||||
self.DeployZone = DeployZone -- Core.Zone#ZONE_BASE
|
self.DeployZone = nil
|
||||||
self:__UnBoard( -0.1, Cargo, DeployZone )
|
|
||||||
|
-- Check if the Cargo is at a deployzone... If it is, provide it as a parameter!
|
||||||
|
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
||||||
|
if Cargo:IsInZone( DeployZone ) then
|
||||||
|
self.DeployZone = DeployZone -- Core.Zone#ZONE_BASE
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:__UnBoard( -0.1, Cargo, self.DeployZone )
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user