mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Waypoints
This commit is contained in:
@@ -1699,7 +1699,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
local speed=self.group and self.group:GetVelocityKMH() or 100
|
||||
|
||||
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
||||
local current=self.group:GetCoordinate():WaypointAir("BARO", COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
||||
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
||||
table.insert(wp, current)
|
||||
|
||||
-- Add remaining waypoints to route.
|
||||
@@ -1710,7 +1710,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
-- Debug info.
|
||||
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
||||
local db=self.destbase and self.destbase:GetName() or "unknown"
|
||||
self:T(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
||||
self:I(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
||||
|
||||
|
||||
if #wp>1 then
|
||||
@@ -2910,15 +2910,26 @@ end
|
||||
|
||||
--- Initialize Mission Editor waypoints.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #table waypoints Table of waypoints. Default is from group template.
|
||||
-- @return #FLIGHTGROUP self
|
||||
function FLIGHTGROUP:InitWaypoints(waypoints)
|
||||
function FLIGHTGROUP:InitWaypoints()
|
||||
|
||||
-- Template waypoints.
|
||||
self.waypoints0=self.group:GetTemplateRoutePoints()
|
||||
|
||||
self:I(self.waypoints0)
|
||||
|
||||
-- Waypoints of group as defined in the ME.
|
||||
self.waypoints=waypoints or UTILS.DeepCopy(self.waypoints0)
|
||||
-- Waypoints
|
||||
self.waypoints={}
|
||||
|
||||
for index,wp in pairs(self.waypoints0) do
|
||||
|
||||
env.info("FF index "..index)
|
||||
|
||||
local waypoint=self:_CreateWaypoint(wp)
|
||||
|
||||
self:_AddWaypoint(waypoint)
|
||||
|
||||
end
|
||||
|
||||
-- Get home and destination airbases from waypoints.
|
||||
self.homebase=self.homebase or self:GetHomebaseFromWaypoints()
|
||||
|
||||
@@ -539,8 +539,8 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
||||
|
||||
-- Add remaining waypoints to route.
|
||||
for i=n, #self.waypoints do
|
||||
local wp=self.waypoints[i]
|
||||
|
||||
local wp=self.waypoints[i] --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||
|
||||
-- Set speed.
|
||||
if i==n then
|
||||
|
||||
|
||||
@@ -2185,24 +2185,17 @@ end
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #table waypoint DCS waypoint data table.
|
||||
-- @return #OPSGROUP.Waypoint Waypoint data.
|
||||
function OPSGROUP:_CreateWaypoint(waypoint)
|
||||
|
||||
local wp={} --#OPSGROUP.Waypoint
|
||||
function OPSGROUP:_CreateWaypoint(waypoint, detour, onroad, formation)
|
||||
|
||||
wp.wp=waypoint
|
||||
wp.uid=self.wpcounter
|
||||
|
||||
wp.altitude=altitude
|
||||
wp.speed=speed
|
||||
wp.detour=detour
|
||||
wp.formation=formation
|
||||
wp.onroad=onroad
|
||||
|
||||
wp.coordinate=coordinate
|
||||
waypoint.uid=self.wpcounter
|
||||
waypoint.coordinate=COORDINATE:New(waypoint.x, waypoint.alt, waypoint.y)
|
||||
waypoint.detour=detour and detour or false
|
||||
waypoint.formation=formation
|
||||
waypoint.onroad=onroad and onroad or false
|
||||
|
||||
self.wpcounter=self.wpcounter+1
|
||||
|
||||
return wp
|
||||
return waypoint
|
||||
end
|
||||
|
||||
--- Initialize Mission Editor waypoints.
|
||||
@@ -2212,17 +2205,18 @@ end
|
||||
function OPSGROUP:_AddWaypoint(waypoint, wpnumber)
|
||||
|
||||
wpnumber=wpnumber or #self.waypoints+1
|
||||
|
||||
env.info(string.format("adding waypoint at index=%d", wpnumber))
|
||||
|
||||
-- Add waypoint to table.
|
||||
tabel.insert(self.waypoints, wpnumber, waypoint)
|
||||
table.insert(self.waypoints, wpnumber, waypoint)
|
||||
|
||||
end
|
||||
|
||||
--- Initialize Mission Editor waypoints.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #table waypoints Table of waypoints. Default is from group template.
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:InitWaypoints(waypoints)
|
||||
function OPSGROUP:InitWaypoints()
|
||||
|
||||
-- Template waypoints.
|
||||
self.waypoints0=self.group:GetTemplateRoutePoints()
|
||||
@@ -2232,11 +2226,10 @@ function OPSGROUP:InitWaypoints(waypoints)
|
||||
|
||||
for index,wp in pairs(self.waypoints0) do
|
||||
|
||||
local waypoint=self:_CreateWaypoint()
|
||||
local waypoint=self:_CreateWaypoint(wp)
|
||||
|
||||
self:_AddWaypoint(waypoint)
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
@@ -2319,7 +2312,7 @@ function OPSGROUP:_UpdateWaypointTasks(n)
|
||||
table.insert(taskswp, TaskPassingWaypoint)
|
||||
|
||||
-- Waypoint task combo.
|
||||
wp.wp.task=self.group:TaskCombo(taskswp)
|
||||
wp.task=self.group:TaskCombo(taskswp)
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user