From 8b8fcaaacddac424ccc43d5f104ce4f5e40269d6 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Sun, 8 Apr 2018 18:59:42 +0200 Subject: [PATCH] # Conflicts: # Moose Development/Moose/Tasking/Task_CARGO.lua --- Moose Development/Moose/Cargo/Cargo.lua | 2 +- Moose Development/Moose/Cargo/CargoCrate.lua | 22 +++++++++++++++- .../Moose/Cargo/CargoSlingload.lua | 20 ++++++++++++++ .../Moose/Tasking/Task_CARGO.lua | 26 ++++++++----------- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Moose Development/Moose/Cargo/Cargo.lua b/Moose Development/Moose/Cargo/Cargo.lua index 09fac4fc3..52ad16b29 100644 --- a/Moose Development/Moose/Cargo/Cargo.lua +++ b/Moose Development/Moose/Cargo/Cargo.lua @@ -561,7 +561,7 @@ do -- CARGO -- @param Core.Point#Coordinate Coordinate -- @return #boolean true if the CargoGroup is within the loading radius. function CARGO:IsInLoadRadius( Coordinate ) - self:F( { Coordinate } ) + self:F( { Coordinate, LoadRadius = self.LoadRadius } ) local Distance = 0 if self:IsUnLoaded() then diff --git a/Moose Development/Moose/Cargo/CargoCrate.lua b/Moose Development/Moose/Cargo/CargoCrate.lua index b4a61a58b..1edd1c167 100644 --- a/Moose Development/Moose/Cargo/CargoCrate.lua +++ b/Moose Development/Moose/Cargo/CargoCrate.lua @@ -134,12 +134,32 @@ do -- CARGO_CRATE return false end + --- Check if Cargo Crate is in the radius for the Cargo to be reported. + -- @param #CARGO self + -- @param Core.Point#Coordinate Coordinate + -- @return #boolean true if the Cargo Crate is within the report radius. + function CARGO_CRATE:IsInReportRadius( Coordinate ) + self:F( { Coordinate, LoadRadius = self.LoadRadius } ) + + local Distance = 0 + if self:IsUnLoaded() then + Distance = Coordinate:DistanceFromPointVec2( self.CargoObject:GetPointVec2() ) + self:T( Distance ) + if Distance <= self.LoadRadius then + return true + end + end + + return false + end + + --- Check if Cargo Crate is in the radius for the Cargo to be Boarded or Loaded. -- @param #CARGO self -- @param Core.Point#Coordinate Coordinate -- @return #boolean true if the Cargo Crate is within the loading radius. function CARGO_CRATE:IsInLoadRadius( Coordinate ) - self:F( { Coordinate } ) + self:F( { Coordinate, LoadRadius = self.NearRadius } ) local Distance = 0 if self:IsUnLoaded() then diff --git a/Moose Development/Moose/Cargo/CargoSlingload.lua b/Moose Development/Moose/Cargo/CargoSlingload.lua index 5e979d93c..f8be5c183 100644 --- a/Moose Development/Moose/Cargo/CargoSlingload.lua +++ b/Moose Development/Moose/Cargo/CargoSlingload.lua @@ -97,6 +97,26 @@ do -- CARGO_SLINGLOAD end + --- Check if Cargo Crate is in the radius for the Cargo to be reported. + -- @param #CARGO_SLINGLOAD self + -- @param Core.Point#Coordinate Coordinate + -- @return #boolean true if the Cargo Crate is within the report radius. + function CARGO_SLINGLOAD:IsInReportRadius( Coordinate ) + self:F( { Coordinate, LoadRadius = self.LoadRadius } ) + + local Distance = 0 + if self:IsUnLoaded() then + Distance = Coordinate:DistanceFromPointVec2( self.CargoObject:GetPointVec2() ) + self:T( Distance ) + if Distance <= self.LoadRadius then + return true + end + end + + return false + end + + --- Check if Cargo Slingload is in the radius for the Cargo to be Boarded or Loaded. -- @param #CARGO_SLINGLOAD self -- @param Core.Point#Coordinate Coordinate diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index ece266d49..055604c9c 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -457,7 +457,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if Cargo:IsAlive() then - self.Cargo = Cargo -- Core.Cargo#CARGO + self.Cargo = Cargo -- Cargo.Cargo#CARGO Task:SetCargoPickup( self.Cargo, TaskUnit ) self:__RouteToPickupPoint( -0.1 ) end @@ -539,7 +539,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if self.Cargo:IsAlive() then - if self.Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then + if self.Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then if TaskUnit:InAir() then self:__Land( -10, Action ) else @@ -548,9 +548,9 @@ do -- TASK_CARGO end else if Action == "Pickup" then - self:__RouteToPickupZone( -0.1 ) + self:__RouteToPickup( -0.1, self.Cargo ) else - self:__RouteToDeployZone( -0.1 ) + self:__RouteToDeploy( -0.1, self.Cargo ) end end end @@ -563,7 +563,7 @@ do -- TASK_CARGO self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) if self.Cargo:IsAlive() then - if self.Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then + if self.Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then if TaskUnit:InAir() then self:__Land( -0.1, Action ) else @@ -571,9 +571,9 @@ do -- TASK_CARGO end else if Action == "Pickup" then - self:__RouteToPickupZone( -0.1 ) + self:__RouteToPickup( -0.1, self.Cargo ) else - self:__RouteToDeployZone( -0.1 ) + self:__RouteToDeploy( -0.1, self.Cargo ) end end end @@ -624,6 +624,8 @@ do -- TASK_CARGO -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterBoarded( TaskUnit, Task, From, Event, To, Cargo ) + self:F( { Cargo = Cargo } ) + local TaskUnitName = TaskUnit:GetName() self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } ) @@ -639,6 +641,8 @@ do -- TASK_CARGO -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onenterLoaded( TaskUnit, Task, From, Event, To, Cargo ) + self:F( { Cargo = Cargo } ) + local TaskUnitName = TaskUnit:GetName() self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } ) @@ -651,14 +655,6 @@ do -- TASK_CARGO self:__SelectAction( 1 ) - -- TODO:I need to find a more decent solution for this. - Task:E( { CargoPickedUp = Task.CargoPickedUp } ) - if Cargo:IsAlive() then - if Task.CargoPickedUp then - Task:CargoPickedUp( TaskUnit, Cargo ) - end - end - end