Fixed for transport cargo

This commit is contained in:
FlightControl_Master
2018-03-12 14:21:20 +01:00
parent 5120088b66
commit 01c18278fc
2 changed files with 31 additions and 14 deletions

View File

@@ -255,7 +255,7 @@ function TASKINFO:AddCargoSet( SetCargo, Order, Detail, Keep )
local CargoType = Cargo:GetType() local CargoType = Cargo:GetType()
local CargoName = Cargo:GetName() local CargoName = Cargo:GetName()
local CargoCoordinate = Cargo:GetCoordinate() local CargoCoordinate = Cargo:GetCoordinate()
CargoReport:Add( string.format( '- "%s" (%s) at %s', CargoName, CargoType, CargoCoordinate:ToStringMGRS() ) ) CargoReport:Add( string.format( '"%s" (%s) at %s', CargoName, CargoType, CargoCoordinate:ToStringMGRS() ) )
end end
) )

View File

@@ -173,7 +173,7 @@ 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", "Boarding" }, "SelectAction", "*" ) Fsm:AddTransition( { "Planned", "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Landed", "Boarding" }, "SelectAction", "*" )
Fsm:AddTransition( "*", "RouteToPickup", "RoutingToPickup" ) Fsm:AddTransition( "*", "RouteToPickup", "RoutingToPickup" )
Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup", Cancelled = "CancelRouteToPickup" } ) Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup", Cancelled = "CancelRouteToPickup" } )
@@ -196,6 +196,8 @@ do -- TASK_CARGO
Fsm:AddTransition( "AwaitUnBoarding", "UnBoard", "UnBoarding" ) Fsm:AddTransition( "AwaitUnBoarding", "UnBoard", "UnBoarding" )
Fsm:AddTransition( "UnBoarding", "UnBoarded", "UnBoarded" ) Fsm:AddTransition( "UnBoarding", "UnBoarded", "UnBoarded" )
Fsm:AddTransition( "*", "Planned", "Planned" )
Fsm:AddTransition( "Deployed", "Success", "Success" ) Fsm:AddTransition( "Deployed", "Success", "Success" )
Fsm:AddTransition( "Rejected", "Reject", "Aborted" ) Fsm:AddTransition( "Rejected", "Reject", "Aborted" )
@@ -214,7 +216,7 @@ do -- TASK_CARGO
local MenuTime = timer.getTime() local MenuTime = timer.getTime()
TaskUnit.Menu = MENU_GROUP:New( TaskUnit:GetGroup(), Task:GetName() .. " @ " .. TaskUnit:GetName() ):SetTime( MenuTime ) TaskUnit.Menu = MENU_GROUP:New( TaskUnit:GetGroup(), Task:GetName() .. " @ " .. TaskUnit:GetName() )
local CargoItemCount = TaskUnit:CargoItemCount() local CargoItemCount = TaskUnit:CargoItemCount()
@@ -253,10 +255,12 @@ do -- TASK_CARGO
if NotInDeployZones then if NotInDeployZones then
if not TaskUnit:InAir() then if not TaskUnit:InAir() then
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime)
TaskUnit.Menu:SetTime( MenuTime )
end end
end end
else else
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime)
TaskUnit.Menu:SetTime( MenuTime )
end end
end end
end end
@@ -264,11 +268,13 @@ do -- TASK_CARGO
if Cargo:IsLoaded() then if Cargo:IsLoaded() then
if not TaskUnit:InAir() then if not TaskUnit:InAir() then
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Unboard cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuUnBoardCargo, self, Cargo ):SetTime(MenuTime) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Unboard cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuUnBoardCargo, self, Cargo ):SetTime(MenuTime)
TaskUnit.Menu:SetTime( MenuTime )
end end
-- Deployzones are optional zones that can be selected to request routing information. -- 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 not Cargo:IsInZone( DeployZone ) then if not Cargo:IsInZone( DeployZone ) then
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Deploy cargo at " .. DeployZoneName, TaskUnit.Menu, self.MenuRouteToDeploy, self, DeployZone ):SetTime(MenuTime) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Deploy cargo at " .. DeployZoneName, TaskUnit.Menu, self.MenuRouteToDeploy, self, DeployZone ):SetTime(MenuTime)
TaskUnit.Menu:SetTime( MenuTime )
end end
end end
end end
@@ -603,6 +609,7 @@ do -- TASK_CARGO
end end
end end
self:Planned()
self:__SelectAction( 1 ) self:__SelectAction( 1 )
end end
@@ -802,13 +809,19 @@ do -- TASK_CARGO
return self.GoalTotal return self.GoalTotal
end end
--- @param #TASK_CARGO self
function TASK_CARGO:UpdateTaskInfo() function TASK_CARGO:UpdateTaskInfo()
if self:IsStatePlanned() or self:IsStateAssigned() then if self:IsStatePlanned() or self:IsStateAssigned() then
self.TaskInfo:AddTaskName( 0, "MSOD" ) self.TaskInfo:AddTaskName( 0, "MSOD" )
self.TaskInfo:AddCargoSet( self.SetCargo, 10, "SOD" ) self.TaskInfo:AddCargoSet( self.SetCargo, 10, "SOD", true )
end end
end end
function TASK_CARGO:ReportOrder( ReportGroup )
return 0
end
end end
@@ -937,7 +950,7 @@ do -- TASK_CARGO_TRANSPORT
function TASK_CARGO_TRANSPORT:ReportOrder( ReportGroup ) function TASK_CARGO_TRANSPORT:ReportOrder( ReportGroup )
return true return 0
end end
@@ -956,23 +969,27 @@ do -- TASK_CARGO_TRANSPORT
-- Loop the CargoSet (so evaluate each Cargo in the SET_CARGO ). -- Loop the CargoSet (so evaluate each Cargo in the SET_CARGO ).
for CargoID, CargoData in pairs( Set ) do for CargoID, CargoData in pairs( Set ) do
local Cargo = CargoData -- Core.Cargo#CARGO local Cargo = CargoData -- Core.Cargo#CARGO
self:F( { Cargo = Cargo:GetName(), CargoDeployed = Cargo:IsDeployed() } )
if Cargo:IsDeployed() then if Cargo:IsDeployed() then
-- Loop the DeployZones set for the TASK_CARGO_TRANSPORT. -- -- Loop the DeployZones set for the TASK_CARGO_TRANSPORT.
for DeployZoneID, DeployZone in pairs( DeployZones ) do -- for DeployZoneID, DeployZone in pairs( DeployZones ) do
--
-- If there is a Cargo not in one of DeployZones, then not all Cargo is deployed. -- -- If all cargo is in one of the deploy zones, then all is good.
self:T( { Cargo.CargoObject } ) -- self:T( { Cargo.CargoObject } )
if Cargo:IsInZone( DeployZone ) == false then -- if Cargo:IsInZone( DeployZone ) == false then
CargoDeployed = false -- CargoDeployed = false
end -- end
end -- end
else else
CargoDeployed = false CargoDeployed = false
end end
end end
self:F( { CargoDeployed = CargoDeployed } )
return CargoDeployed return CargoDeployed
end end