mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
# Conflicts:
# Moose Development/Moose/Tasking/Task_CARGO.lua
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user