mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 02:08:17 +00:00
Astar
This commit is contained in:
@@ -740,19 +740,6 @@ function AIRWING:onafterStart(From, Event, To)
|
||||
-- Info.
|
||||
self:I(self.lid..string.format("Starting AIRWING v%s", AIRWING.version))
|
||||
|
||||
-- Menu.
|
||||
if false then
|
||||
|
||||
-- Add F10 radio menu.
|
||||
self:_SetMenuCoalition()
|
||||
|
||||
for _,_squadron in pairs(self.squadrons) do
|
||||
local squadron=_squadron --Ops.Squadron#SQUADRON
|
||||
self:_AddSquadonMenu(squadron)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Update status.
|
||||
@@ -2162,140 +2149,6 @@ function AIRWING:GetMissionFromRequest(Request)
|
||||
return self:GetMissionFromRequestID(Request.uid)
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Menu Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Patrol carrier.
|
||||
-- @param #AIRWING self
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:_SetMenuCoalition()
|
||||
|
||||
-- Get coalition.
|
||||
local Coalition=self:GetCoalition()
|
||||
|
||||
-- Init menu table.
|
||||
self.menu=self.menu or {}
|
||||
|
||||
-- Init menu coalition table.
|
||||
self.menu[Coalition]=self.menu[Coalition] or {}
|
||||
|
||||
-- Shortcut.
|
||||
local menu=self.menu[Coalition]
|
||||
|
||||
if self.menusingle then
|
||||
-- F10/Skipper/...
|
||||
if not menu.AIRWING then
|
||||
menu.AIRWING=MENU_COALITION:New(Coalition, "AIRWING")
|
||||
end
|
||||
else
|
||||
-- F10/Skipper/<Carrier Alias>/...
|
||||
if not menu.Root then
|
||||
menu.Root=MENU_COALITION:New(Coalition, "AIRWING")
|
||||
end
|
||||
menu.AIRWING=MENU_COALITION:New(Coalition, self.alias, menu.Root)
|
||||
end
|
||||
|
||||
-------------------
|
||||
-- Squadron Menu --
|
||||
-------------------
|
||||
|
||||
menu.Squadron={}
|
||||
menu.Squadron.Main= MENU_COALITION:New(Coalition, "Squadrons", menu.AIRWING)
|
||||
|
||||
menu.Warehouse={}
|
||||
menu.Warehouse.Main = MENU_COALITION:New(Coalition, "Warehouse", menu.AIRWING)
|
||||
menu.Warehouse.Reports = MENU_COALITION_COMMAND:New(Coalition, "Reports On/Off", menu.Warehouse.Main, self.WarehouseReportsToggle, self)
|
||||
menu.Warehouse.Assets = MENU_COALITION_COMMAND:New(Coalition, "Report Assets", menu.Warehouse.Main, self.ReportWarehouseStock, self)
|
||||
|
||||
menu.ReportSquadrons = MENU_COALITION_COMMAND:New(Coalition, "Report Squadrons", menu.AIRWING, self.ReportSquadrons, self)
|
||||
|
||||
end
|
||||
|
||||
--- Report squadron status.
|
||||
-- @param #AIRWING self
|
||||
function AIRWING:ReportSquadrons()
|
||||
|
||||
local text="Squadron Report:"
|
||||
|
||||
for i,_squadron in pairs(self.squadrons) do
|
||||
local squadron=_squadron
|
||||
|
||||
local name=squadron.name
|
||||
|
||||
local nspawned=0
|
||||
local nstock=0
|
||||
for _,_asset in pairs(squadron.assets) do
|
||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
|
||||
local n=asset.nunits
|
||||
|
||||
if asset.spawned then
|
||||
nspawned=nspawned+n
|
||||
else
|
||||
nstock=nstock+n
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
text=string.format("\n%s: AC on duty=%d, in stock=%d", name, nspawned, nstock)
|
||||
|
||||
end
|
||||
|
||||
self:I(self.lid..text)
|
||||
MESSAGE:New(text, 10, "AIRWING", true):ToCoalition(self:GetCoalition())
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Add sub menu for this intruder.
|
||||
-- @param #AIRWING self
|
||||
-- @param Ops.Squadron#SQUADRON squadron The squadron data.
|
||||
function AIRWING:_AddSquadonMenu(squadron)
|
||||
|
||||
local Coalition=self:GetCoalition()
|
||||
|
||||
local root=self.menu[Coalition].Squadron.Main
|
||||
|
||||
local menu=MENU_COALITION:New(Coalition, squadron.name, root)
|
||||
|
||||
MENU_COALITION_COMMAND:New(Coalition, "Report", menu, self._ReportSq, self, squadron)
|
||||
MENU_COALITION_COMMAND:New(Coalition, "Launch CAP", menu, self._LaunchCAP, self, squadron)
|
||||
|
||||
-- Set menu.
|
||||
squadron.menu=menu
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Report squadron status.
|
||||
-- @param #AIRWING self
|
||||
-- @param Ops.Squadron#SQUADRON squadron The squadron object.
|
||||
function AIRWING:_ReportSq(squadron)
|
||||
|
||||
local text=string.format("%s: %s assets:", squadron.name, tostring(squadron.categoryname))
|
||||
for i,_asset in pairs(squadron.assets) do
|
||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
text=text..string.format("%d.) ")
|
||||
end
|
||||
end
|
||||
|
||||
--- Warehouse reports on/off.
|
||||
-- @param #AIRWING self
|
||||
function AIRWING:WarehouseReportsToggle()
|
||||
self.Report=not self.Report
|
||||
MESSAGE:New(string.format("Warehouse reports are now %s", tostring(self.Report)), 10, "AIRWING", true):ToCoalition(self:GetCoalition())
|
||||
end
|
||||
|
||||
|
||||
--- Report warehouse stock.
|
||||
-- @param #AIRWING self
|
||||
function AIRWING:ReportWarehouseStock()
|
||||
local text=self:_GetStockAssetsText(false)
|
||||
MESSAGE:New(text, 10, "AIRWING", true):ToCoalition(self:GetCoalition())
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -345,11 +345,10 @@ function CHIEF:onafterStart(From, Event, To)
|
||||
-- Start parent INTEL.
|
||||
self:GetParent(self).onafterStart(self, From, Event, To)
|
||||
|
||||
-- Start attached airwings.
|
||||
for _,_airwing in pairs(self.airwings) do
|
||||
local airwing=_airwing --Ops.AirWing#AIRWING
|
||||
if airwing:GetState()=="NotReadyYet" then
|
||||
airwing:Start()
|
||||
-- Start wingcommander.
|
||||
if self.wingcommander then
|
||||
if self.wingcommander:GetState()=="NotReadyYet" then
|
||||
self.wingcommander:Start()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ function INTEL:CreateDetectedItems(detectedunitset)
|
||||
item.attribute=group:GetAttribute()
|
||||
item.category=group:GetCategory()
|
||||
item.categoryname=group:GetCategoryName()
|
||||
item.threatlevel=group:GetUnit(1):GetThreatLevel()
|
||||
item.threatlevel=group:GetThreatLevel()
|
||||
item.position=group:GetCoordinate()
|
||||
item.velocity=group:GetVelocityVec3()
|
||||
item.speed=group:GetVelocityMPS()
|
||||
@@ -699,7 +699,7 @@ function INTEL:PaintPicture()
|
||||
|
||||
|
||||
-- Update F10 marker.
|
||||
self:UpdateClusterMarker(cluster, coordinate)
|
||||
self:UpdateClusterMarker(cluster)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -959,7 +959,7 @@ end
|
||||
--- Update cluster F10 marker.
|
||||
-- @param #INTEL self
|
||||
-- @param #INTEL.Cluster cluster The cluster.
|
||||
-- @param Core.Point#COORDINATE newcoordinate Updated cluster positon.
|
||||
-- @return #INTEL self
|
||||
function INTEL:UpdateClusterMarker(cluster, newcoordinate)
|
||||
|
||||
-- Create a marker.
|
||||
@@ -976,10 +976,9 @@ function INTEL:UpdateClusterMarker(cluster, newcoordinate)
|
||||
refresh=true
|
||||
end
|
||||
|
||||
if newcoordinate then
|
||||
cluster.coordinate=newcoordinate
|
||||
if cluster.marker.coordinate~=cluster.coordinate then
|
||||
cluster.marker.coordinate=cluster.coordinate
|
||||
refresh=true
|
||||
refresh=true
|
||||
end
|
||||
|
||||
if refresh then
|
||||
@@ -988,6 +987,7 @@ function INTEL:UpdateClusterMarker(cluster, newcoordinate)
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
-- @field #boolean turning If true, group is currently turning.
|
||||
-- @field #NAVYGROUP.IntoWind intowind Into wind info.
|
||||
-- @field #table Qintowind Queue of "into wind" turns.
|
||||
-- @field #boolean adinfinitum Resume route at first waypoint when final waypoint is reached.
|
||||
-- @field #number depth Ordered depth in meters.
|
||||
-- @extends Ops.OpsGroup#OPSGROUP
|
||||
|
||||
@@ -1230,7 +1229,7 @@ function NAVYGROUP:_CheckGroupDone(delay)
|
||||
|
||||
else
|
||||
|
||||
self:UpdateRoute(nil, nil, self.depth)
|
||||
self:__UpdateRoute(-1, nil, nil, self.depth)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
-- @field #boolean isGround If true, group is some ground unit.
|
||||
-- @field #table waypoints Table of waypoints.
|
||||
-- @field #table waypoints0 Table of initial waypoints.
|
||||
-- @field #number currentwp Current waypoint.
|
||||
-- @field #number currentwp Current waypoint index. This is the index of the last passed waypoint.
|
||||
-- @field #boolean adinfinitum Resume route at first waypoint when final waypoint is reached.
|
||||
-- @field #table taskqueue Queue of tasks.
|
||||
-- @field #number taskcounter Running number of task ids.
|
||||
-- @field #number taskcurrent ID of current task. If 0, there is no current task assigned.
|
||||
@@ -434,19 +435,30 @@ end
|
||||
|
||||
--- Get next waypoint index.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #boolean cyclic If true, return first waypoint if last waypoint was reached.
|
||||
-- @param #boolean cyclic If true, return first waypoint if last waypoint was reached. Default is patrol ad infinitum value set.
|
||||
-- @return #number Next waypoint index.
|
||||
function OPSGROUP:GetWaypointIndexNext(cyclic)
|
||||
|
||||
local n=math.min(self.currentwp+1, #self.waypoints)
|
||||
cyclic=cyclic or self.adinfinitum
|
||||
|
||||
if cyclic and self.currentwp==#self.waypoints then
|
||||
local N=#self.waypoints
|
||||
|
||||
local n=math.min(self.currentwp+1, N)
|
||||
|
||||
if cyclic and self.currentwp==N then
|
||||
n=1
|
||||
end
|
||||
|
||||
return n
|
||||
end
|
||||
|
||||
--- Get current waypoint index. This is the index of the last passed waypoint.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #number Current waypoint index.
|
||||
function OPSGROUP:GetWaypointIndexCurrent()
|
||||
return self.currentwp or 1
|
||||
end
|
||||
|
||||
--- Get waypoint speed.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number indx Waypoint index.
|
||||
@@ -465,14 +477,14 @@ end
|
||||
--- Get waypoint.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number indx Waypoint index.
|
||||
-- @return #table Waypoint table.
|
||||
-- @return #OPSGROUP.Waypoint Waypoint table.
|
||||
function OPSGROUP:GetWaypoint(indx)
|
||||
return self.waypoints[indx]
|
||||
end
|
||||
|
||||
--- Get final waypoint.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #table Waypoint table.
|
||||
-- @return #OPSGROUP.Waypoint Final waypoint table.
|
||||
function OPSGROUP:GetWaypointFinal()
|
||||
return self.waypoints[#self.waypoints]
|
||||
end
|
||||
@@ -480,7 +492,7 @@ end
|
||||
--- Get next waypoint.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #boolean cyclic If true, return first waypoint if last waypoint was reached.
|
||||
-- @return #table Waypoint table.
|
||||
-- @return #OPSGROUP.Waypoint Next waypoint table.
|
||||
function OPSGROUP:GetWaypointNext(cyclic)
|
||||
|
||||
local n=self:GetWaypointIndexNext(cyclic)
|
||||
@@ -490,7 +502,7 @@ end
|
||||
|
||||
--- Get current waypoint.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #table Waypoint table.
|
||||
-- @return #OPSGROUP.Waypoint Current waypoint table.
|
||||
function OPSGROUP:GetWaypointCurrent()
|
||||
return self.waypoints[self.currentwp]
|
||||
end
|
||||
|
||||
@@ -247,7 +247,7 @@ end
|
||||
|
||||
--- Set number of units in groups.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #nunits Number of units. Must be >=1 and <=4. Default 2.
|
||||
-- @param #number nunits Number of units. Must be >=1 and <=4. Default 2.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetGrouping(nunits)
|
||||
self.ngrouping=nunits or 2
|
||||
|
||||
Reference in New Issue
Block a user