From 34592a53bed2f008aa77f89c9f8a14e2021f4c7d Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Sat, 10 Mar 2018 06:58:12 +0100 Subject: [PATCH 1/2] Preliminary --- Moose Development/Moose/Tasking/TaskInfo.lua | 43 +++++++++++++++++++ .../Moose/Tasking/Task_CARGO.lua | 18 ++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Tasking/TaskInfo.lua b/Moose Development/Moose/Tasking/TaskInfo.lua index 3eb941e1c..9605e023d 100644 --- a/Moose Development/Moose/Tasking/TaskInfo.lua +++ b/Moose Development/Moose/Tasking/TaskInfo.lua @@ -226,6 +226,45 @@ function TASKINFO:AddWindAtCoordinate( Coordinate, Order, Detail, Keep ) return self end +--- Add Cargo. +-- @param #TASKINFO self +-- @param Core.Cargo#CARGO Cargo +-- @param #number Order The display order, which is a number from 0 to 100. +-- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. +-- @return #TASKINFO self +function TASKINFO:AddCargo( Cargo, Order, Detail, Keep ) + self:AddInfo( "Cargo", Cargo, Order, Detail, Keep ) + return self +end + + +--- Add Cargo set. +-- @param #TASKINFO self +-- @param Core.Set#SET_CARGO SetCargo +-- @param #number Order The display order, which is a number from 0 to 100. +-- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. +-- @return #TASKINFO self +function TASKINFO:AddCargoSet( SetCargo, Order, Detail, Keep ) + + local CargoReport = REPORT:New() + SetCargo:ForEachCargo( + --- @param Core.Cargo#CARGO Cargo + function( Cargo ) + local CargoType = Cargo:GetType() + local CargoName = Cargo:GetName() + local CargoCoordinate = Cargo:GetCoordinate() + CargoReport:Add( string.format( '- "%s" (%s) at %s', CargoName, CargoType, CargoCoordinate:ToStringMGRS() ) ) + end + ) + + self:AddInfo( "CargoSet", CargoReport:Text(), Order, Detail, Keep ) + + return self +end + + --- Create the taskinfo Report -- @param #TASKINFO self @@ -280,6 +319,10 @@ function TASKINFO:Report( Report, Detail, ReportGroup ) local Coordinate = Data.Data -- Core.Point#COORDINATE Text = Coordinate:ToStringWind( ReportGroup:GetUnit(1), nil, self ) end + if Key == "CargoSet" then + local DataText = Data.Data -- #string + Text = DataText + end if Line < math.floor( Data.Order / 10 ) then if Line == 0 then diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index 812691fcd..c3123da7b 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -162,7 +162,7 @@ do -- TASK_CARGO self.SmokeColor = SMOKECOLOR.Red self.CargoItemCount = {} -- Map of Carriers having a cargo item count to check the cargo loading limits. - self.CargoLimit = 2 + self.CargoLimit = 6 self.DeployZones = {} -- setmetatable( {}, { __mode = "v" } ) -- weak table on value @@ -228,6 +228,7 @@ do -- TASK_CARGO if Cargo:IsAlive() then + self:E( "Cargo is alive" ) -- if Task:is( "RoutingToPickup" ) then -- MENU_GROUP_COMMAND:New( -- TaskUnit:GetGroup(), @@ -239,10 +240,10 @@ do -- TASK_CARGO -- ):SetTime(MenuTime) -- end - + self:E( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } ) if Cargo:IsUnLoaded() then - if CargoItemCount < Task.CargoLimit then + if CargoItemCount <= Task.CargoLimit then if Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then local NotInDeployZones = true for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do @@ -250,12 +251,14 @@ do -- TASK_CARGO NotInDeployZones = false end end + self:E( { NotInDeployZones = NotInDeployZones } ) if NotInDeployZones then if not TaskUnit:InAir() then MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime) end end else + self:E( { "Route" } ) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime) end end @@ -277,7 +280,7 @@ do -- TASK_CARGO end ) - TaskUnit.Menu:Remove( MenuTime ) + --TaskUnit.Menu:Remove( MenuTime ) self:__SelectAction( -15 ) @@ -800,6 +803,13 @@ do -- TASK_CARGO return self.GoalTotal end + function TASK_CARGO:UpdateTaskInfo() + + if self:IsStatePlanned() or self:IsStateAssigned() then + self.TaskInfo:AddTaskName( 0, "MSOD" ) + self.TaskInfo:AddCargoSet( self.SetCargo, 10, "SOD" ) + end + end end From a780f6635ffe4b60a4a1336433434619a7bcddb1 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Sat, 10 Mar 2018 08:11:08 +0100 Subject: [PATCH 2/2] Cargo Transport --- Moose Development/Moose/Core/Cargo.lua | 9 ++++++++- Moose Development/Moose/Tasking/Task_CARGO.lua | 13 ++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 3d7d4ec14..8bdbbd205 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -338,6 +338,13 @@ function CARGO:IsUnLoaded() return self:Is( "UnLoaded" ) end +--- Check if cargo is boarding. +-- @param #CARGO self +-- @return #boolean true if boarding +function CARGO:IsBoarding() + return self:Is( "Boarding" ) +end + --- Check if cargo is alive. -- @param #CARGO self -- @return #boolean true if unloaded @@ -944,7 +951,7 @@ do -- CARGO_UNIT else self:__Boarding( -1, CargoCarrier, NearRadius, ... ) self.RunCount = self.RunCount + 1 - if self.RunCount >= 20 then + if self.RunCount >= 60 then self.RunCount = 0 local Speed = 90 local Angle = 180 diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index c3123da7b..e7cc3f939 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -228,7 +228,6 @@ do -- TASK_CARGO if Cargo:IsAlive() then - self:E( "Cargo is alive" ) -- if Task:is( "RoutingToPickup" ) then -- MENU_GROUP_COMMAND:New( -- TaskUnit:GetGroup(), @@ -240,7 +239,7 @@ do -- TASK_CARGO -- ):SetTime(MenuTime) -- end - self:E( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } ) + self:F( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } ) if Cargo:IsUnLoaded() then if CargoItemCount <= Task.CargoLimit then @@ -251,14 +250,12 @@ do -- TASK_CARGO NotInDeployZones = false end end - self:E( { NotInDeployZones = NotInDeployZones } ) if NotInDeployZones then if not TaskUnit:InAir() then MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime) end end else - self:E( { "Route" } ) MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime) end end @@ -280,7 +277,7 @@ do -- TASK_CARGO end ) - --TaskUnit.Menu:Remove( MenuTime ) + TaskUnit.Menu:Remove( MenuTime ) self:__SelectAction( -15 ) @@ -481,8 +478,10 @@ do -- TASK_CARGO if TaskUnit:InAir() then --- ABORT the boarding. Split group if any and go back to select action. else - self.Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() ) - self.Cargo:Board( TaskUnit, 20, self ) + self.Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() ) + if not self.Cargo:IsBoarding() then + self.Cargo:Board( TaskUnit, 20, self ) + end end else --self:__ArriveAtCargo( -0.1 )