mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-21 21:17:30 +00:00
Update NavyGroup.lua
This commit is contained in:
@@ -214,7 +214,7 @@ function NAVYGROUP:onafterSpawned(From, Event, To)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
self:__UpdateRoute(-1)
|
self:__Cruise(-1)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -224,7 +224,9 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #number n Waypoint number. Default is next waypoint.
|
-- @param #number n Waypoint number. Default is next waypoint.
|
||||||
function NAVYGROUP:onafterUpdateRoute(From, Event, To, n)
|
-- @param #number Speed Speed in knots. Default cruise speed.
|
||||||
|
-- @param #number Depth Depth in meters. Default 0 meters.
|
||||||
|
function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
||||||
|
|
||||||
-- Update route from this waypoint number onwards.
|
-- Update route from this waypoint number onwards.
|
||||||
n=n or self.currentwp+1
|
n=n or self.currentwp+1
|
||||||
@@ -234,22 +236,22 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
|
|
||||||
-- Waypoints.
|
-- Waypoints.
|
||||||
local waypoints={}
|
local waypoints={}
|
||||||
|
|
||||||
|
-- Speed.
|
||||||
|
local speed=Speed and UTILS.KnotsToKmph(Speed) or self.speedCruise
|
||||||
|
|
||||||
-- Current velocity.
|
-- Depth for submarines.
|
||||||
local speed=self.group and self.group:GetVelocityKMH() or 100
|
local depth=Depth or 0
|
||||||
|
|
||||||
|
local current=self:GetCoordinate():WaypointNaval(speed, depth)
|
||||||
local current=self:GetCoordinate():WaypointNaval(speed)
|
|
||||||
table.insert(waypoints, current)
|
table.insert(waypoints, current)
|
||||||
|
|
||||||
-- Add remaining waypoints to route.
|
-- Add remaining waypoints to route.
|
||||||
for i=n, #self.waypoints do
|
for i=n, #self.waypoints do
|
||||||
local wp=self.waypoints[i]
|
local wp=self.waypoints[i]
|
||||||
|
|
||||||
self:E({wp=wp})
|
|
||||||
|
|
||||||
-- Set speed.
|
-- Set speed.
|
||||||
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
wp.speed=UTILS.KmphToMps(speed)
|
||||||
|
|
||||||
-- Add waypoint.
|
-- Add waypoint.
|
||||||
table.insert(waypoints, wp)
|
table.insert(waypoints, wp)
|
||||||
@@ -330,6 +332,30 @@ function NAVYGROUP:onafterCruise(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- On after "Dive" event.
|
||||||
|
-- @param #NAVYGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param #number Depth Dive depth in meters.
|
||||||
|
function NAVYGROUP:onafterDive(From, Event, To, Depth)
|
||||||
|
|
||||||
|
self:UpdateRoute(nil, nil, Depth)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On after "Surface" event.
|
||||||
|
-- @param #NAVYGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param #number Depth Dive depth in meters.
|
||||||
|
function NAVYGROUP:onafterSurface(From, Event, To)
|
||||||
|
|
||||||
|
self:UpdateRoute(nil, nil, 0)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- On after "PassingWaypoint" event.
|
--- On after "PassingWaypoint" event.
|
||||||
-- @param #NAVYGROUP self
|
-- @param #NAVYGROUP self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
|
|||||||
Reference in New Issue
Block a user