mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS
This commit is contained in:
parent
591dd128ce
commit
7792381c36
@ -390,17 +390,6 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
|
||||
-- Do we want to drive on road to the next wp?
|
||||
local onroad=wp.action==ENUMS.Formation.Vehicle.OnRoad
|
||||
|
||||
-- Current point.
|
||||
local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speedWp), ENUMS.Formation.Vehicle.OffRoad)
|
||||
table.insert(waypoints, current)
|
||||
|
||||
-- Insert a point on road.
|
||||
if onroad then
|
||||
local current=self:GetClosestRoad():WaypointGround(UTILS.MpsToKmph(self.speedWp), ENUMS.Formation.Vehicle.OnRoad)
|
||||
table.insert(waypoints, current)
|
||||
end
|
||||
|
||||
|
||||
-- Speed.
|
||||
if Speed then
|
||||
wp.speed=UTILS.KnotsToMps(Speed)
|
||||
@ -437,6 +426,17 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
|
||||
-- Add waypoint.
|
||||
table.insert(waypoints, wp)
|
||||
|
||||
|
||||
-- Current point.
|
||||
local current=self:GetCoordinate():WaypointGround(UTILS.MpsToKmph(self.speedWp), ENUMS.Formation.Vehicle.OffRoad)
|
||||
table.insert(waypoints, 1, current)
|
||||
|
||||
-- Insert a point on road.
|
||||
if onroad then
|
||||
local current=self:GetClosestRoad():WaypointGround(UTILS.MpsToKmph(self.speedWp), ENUMS.Formation.Vehicle.OnRoad)
|
||||
table.insert(waypoints, 2, current)
|
||||
end
|
||||
|
||||
-- Debug output.
|
||||
if false then
|
||||
for i,_wp in pairs(waypoints) do
|
||||
|
||||
@ -1677,6 +1677,26 @@ function OPSGROUP:GetTasksWaypoint(id)
|
||||
return tasks
|
||||
end
|
||||
|
||||
--- Count remaining waypoint tasks.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number uid Unique waypoint ID.
|
||||
-- @return #number Number of waypoint tasks.
|
||||
function OPSGROUP:CountTasksWaypoint(id)
|
||||
|
||||
-- Tasks table.
|
||||
local n=0
|
||||
|
||||
-- Look for first task that SCHEDULED.
|
||||
for _,_task in pairs(self.taskqueue) do
|
||||
local task=_task --#OPSGROUP.Task
|
||||
if task.type==OPSGROUP.TaskType.WAYPOINT and task.status==OPSGROUP.TaskStatus.SCHEDULED and task.waypoint==id then
|
||||
n=n+1
|
||||
end
|
||||
end
|
||||
|
||||
return n
|
||||
end
|
||||
|
||||
--- Sort task queue.
|
||||
-- @param #OPSGROUP self
|
||||
function OPSGROUP:_SortTaskQueue()
|
||||
@ -3061,10 +3081,20 @@ function OPSGROUP:_CheckGroupDone(delay)
|
||||
self:ScheduleOnce(delay, self._CheckGroupDone, self)
|
||||
else
|
||||
|
||||
-- Get current waypoint.
|
||||
local waypoint=self:GetWaypoint(self.currentwp)
|
||||
|
||||
local n=self:GetTasksWaypoint(id)
|
||||
if waypoint then
|
||||
|
||||
-- Number of tasks remaining for this waypoint.
|
||||
local ntasks=self:CountTasksWaypoint(waypoint.uid)
|
||||
|
||||
-- We only want to update the route if there are no more tasks to be done.
|
||||
if ntasks>0 then
|
||||
self:T(self.lid..string.format("Still got %d tasks for the current waypoint UID=%d", ntasks, waypoint.uid))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if self.adinfinitum then
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user