mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-11 03:43:38 +00:00
Update NavyGroup.lua
This commit is contained in:
@@ -214,7 +214,7 @@ function NAVYGROUP:onafterSpawned(From, Event, To)
|
||||
end
|
||||
|
||||
-- Update route.
|
||||
self:__UpdateRoute(-1)
|
||||
self:__Cruise(-1)
|
||||
|
||||
end
|
||||
|
||||
@@ -224,7 +224,9 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @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.
|
||||
n=n or self.currentwp+1
|
||||
@@ -234,22 +236,22 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
|
||||
-- Waypoints.
|
||||
local waypoints={}
|
||||
|
||||
-- Speed.
|
||||
local speed=Speed and UTILS.KnotsToKmph(Speed) or self.speedCruise
|
||||
|
||||
-- Current velocity.
|
||||
local speed=self.group and self.group:GetVelocityKMH() or 100
|
||||
-- Depth for submarines.
|
||||
local depth=Depth or 0
|
||||
|
||||
|
||||
local current=self:GetCoordinate():WaypointNaval(speed)
|
||||
local current=self:GetCoordinate():WaypointNaval(speed, depth)
|
||||
table.insert(waypoints, current)
|
||||
|
||||
-- Add remaining waypoints to route.
|
||||
for i=n, #self.waypoints do
|
||||
local wp=self.waypoints[i]
|
||||
|
||||
self:E({wp=wp})
|
||||
|
||||
-- Set speed.
|
||||
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
||||
wp.speed=UTILS.KmphToMps(speed)
|
||||
|
||||
-- Add waypoint.
|
||||
table.insert(waypoints, wp)
|
||||
@@ -330,6 +332,30 @@ function NAVYGROUP:onafterCruise(From, Event, To)
|
||||
|
||||
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.
|
||||
-- @param #NAVYGROUP self
|
||||
-- @param #string From From state.
|
||||
|
||||
Reference in New Issue
Block a user