Play time

-- Improved menu system. Much shorter Detection menus now.
-- Improved Detection IDs. Each detection item has now an ID.
-- Added coordinate system.
-- Added menu system to manage coordinates. A system settings menu has
been added.
-- Coordinates can now be switched between LL Degrees, LL Decimal and
MGRS
-- COORDINATE class added.
This commit is contained in:
FlightControl 2017-04-25 10:17:10 +02:00
parent 9d68376abb
commit 8d6b1940bb
7 changed files with 408 additions and 89 deletions

View File

@ -182,8 +182,7 @@
-- * @{#POINT_VEC3.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance.
-- * @{#POINT_VEC3.ToStringLL}(): Generates a Latutude & Longutude text.
--
-- @field #POINT_VEC3 POINT_VEC3
--
-- @field #POINT_VEC3
POINT_VEC3 = {
ClassName = "POINT_VEC3",
Metric = true,
@ -230,13 +229,55 @@ POINT_VEC3 = {
--
-- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2()
--
-- @field #POINT_VEC2 POINT_VEC2
--
-- @field #POINT_VEC2
POINT_VEC2 = {
ClassName = "POINT_VEC2",
}
--- @type COORDINATE
-- @field #number LL_Accuracy
-- @field #boolean LL_DMS
-- @field #number MGRS_Accuracy
-- @field #string System
-- @extends Core.Point#POINT_VEC2
--- # COORDINATE class, extends @{Point#COORDINATE}
--
-- The COORDINATE class defines a 2D coordinate in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified.
-- A COORDINATE can be expressed in LL or in MGRS.
--
-- ## COORDINATE constructor
--
-- A new COORDINATE instance can be created with:
--
-- * @{Point#COORDINATE.New}(): a 2D point, taking an additional height parameter.
-- * @{Point#COORDINATE.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}.
--
-- ## Manupulate the X, Altitude, Y coordinates of the 2D point
--
-- A COORDINATE class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate.
-- Methods exist to manupulate these coordinates.
--
-- The current X, Altitude, Y axis can be retrieved with the methods @{#COORDINATE.GetX}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetY}() respectively.
-- The methods @{#COORDINATE.SetX}(), @{#COORDINATE.SetAlt}(), @{#COORDINATE.SetY}() change the respective axis with a new value.
-- The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods @{#COORDINATE.GetLat}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetLon}() respectively.
-- The current axis values can be changed by using the methods @{#COORDINATE.AddX}(), @{#COORDINATE.AddAlt}(), @{#COORDINATE.AddY}()
-- to add or substract a value from the current respective axis value.
-- Note that the Set and Add methods return the current COORDINATE object, so these manipulation methods can be chained... For example:
--
-- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2()
--
-- @field #COORDINATE
COORDINATE = {
ClassName = "COORDINATE",
LL_Accuracy = 2,
LL_DMS = true,
MGRS_Accuracy = 5,
System = "MGRS",
}
do -- POINT_VEC3
--- RoutePoint AltTypes
@ -542,60 +583,6 @@ function POINT_VEC3:ToStringBR( AngleRadians, Distance )
return s
end
--- Provides a Lat Lon string
-- @param #POINT_VEC3 self
-- @param #number Accuracy The accurancy of significant numbers behind the comma... So Accurancy of 2 is 0.01.
-- @param #boolean DMS true = Degrees, Minutes, Seconds; false = Degrees, Minutes
-- @return #string The LL Text
function POINT_VEC3:ToStringLL( Accuracy, DMS )
Accuracy = Accuracy or 3
local lat, lon = coord.LOtoLL( self:GetVec3() )
return UTILS.tostringLL( lat, lon, Accuracy, DMS )
end
--- Provides a MGRS string
-- @param #POINT_VEC3 self
-- @param #number Accuracy of the 5 digit code.
-- Precision depends on the Accuracy choosen:
-- * 0 = no digits - precision level 100 km
-- * 1 = 1 digits - precision level 10 km
-- * 2 = 2 digits - precision level 1 km
-- * 3 = 3 digits - precision level 100 m
-- * 4 = 4 digits - precision level 10 m.
-- @return #string The MGRS Text
function POINT_VEC3:ToStringMGRS( Accuracy )
Accuracy = Accuracy or 3
local lat, lon = coord.LOtoLL( self:GetVec3() )
local MGRS = coord.LLtoMGRS( lat, lon )
return UTILS.tostringMGRS( MGRS, Accuracy )
end
--- Provides a coordinate string of the point, based on a coordinate format system:
-- * Uses default settings in POINT_VEC3.
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
--
-- @param #POINT_VEC3 self
-- @param Wrapper.Group#GROUP PlayerGroup The specific group with specific settings.
-- @return #string The coordinate Text
function POINT_VEC3:ToString( PlayerGroup ) --R2.3
PlayerGroup = PlayerGroup or GROUP
local CoordFormat = PlayerGroup:GetCoordFormat()
if CoordFormat == "LL" then
return self:ToStringLL( PlayerGroup:GetLLAccuracy(), PlayerGroup:GetLLDMS() )
end
if CoordFormat == "MGRS" then
return self:ToStringMGRS( PlayerGroup:GetMGRSAccuracy() )
end
return nil
end
--- Return the altitude text of the POINT_VEC3.
-- @param #POINT_VEC3 self
@ -1070,4 +1057,159 @@ end
end
do -- COORDINATE
--- COORDINATE constructor.
-- @param #COORDINATE self
-- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North.
-- @param Dcs.DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right.
-- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height.
-- @return Core.Point#COORDINATE
function COORDINATE:New( x, y, LandHeightAdd )
self = BASE:Inherit( self, POINT_VEC2:New( x, y, LandHeightAdd ) ) -- Core.Point#COORDINATE
self:F2( self )
return self
end
--- Create a new COORDINATE object from Vec2 coordinates.
-- @param #COORDINATE self
-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point.
-- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height.
-- @return Core.Point#COORDINATE self
function COORDINATE:NewFromVec2( Vec2, LandHeightAdd )
self = BASE:Inherit( self, POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) ) -- Core.Point#COORDINATE
self:F2( self )
return self
end
--- Create a new COORDINATE object from Vec3 coordinates.
-- @param #COORDINATE self
-- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point.
-- @return Core.Point#COORDINATE self
function COORDINATE:NewFromVec3( Vec3 )
self = BASE:Inherit( self, POINT_VEC2:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE
self:F2( self )
return self
end
--- Provides a Lat Lon string
-- @param #COORDINATE self
-- @param #number LL_Accuracy The accurancy of significant numbers behind the comma... So Accurancy of 2 is 0.01.
-- @param #boolean LL_DMS true = Degrees, Minutes, Seconds; false = Degrees, Minutes
-- @return #string The LL Text
function COORDINATE:ToStringLL( LL_Accuracy, LL_DMS )
LL_Accuracy = LL_Accuracy or self.LL_Accuracy
LL_DMS = LL_DMS or self.LL_DMS
local lat, lon = coord.LOtoLL( self:GetVec3() )
return "LL:" .. UTILS.tostringLL( lat, lon, LL_Accuracy, LL_DMS )
end
--- Provides a MGRS string
-- @param #COORDINATE self
-- @param #number MGRS_Accuracy of the 5 digit code.
-- Precision depends on the Accuracy choosen:
-- * 0 = no digits - precision level 100 km
-- * 1 = 1 digits - precision level 10 km
-- * 2 = 2 digits - precision level 1 km
-- * 3 = 3 digits - precision level 100 m
-- * 4 = 4 digits - precision level 10 m.
-- @return #string The MGRS Text
function COORDINATE:ToStringMGRS( MGRS_Accuracy )
MGRS_Accuracy = MGRS_Accuracy or self.MGRS_Accuracy
local lat, lon = coord.LOtoLL( self:GetVec3() )
local MGRS = coord.LLtoMGRS( lat, lon )
return "MGRS:" .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy )
end
--- Provides a coordinate string of the point, based on a coordinate format system:
-- * Uses default settings in COORDINATE.
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
--
-- @param #COORDINATE self
-- @return #string The coordinate Text in the configured coordinate system.
function COORDINATE:ToString() --R2.3
local Coordinate = COORDINATE -- Core.Point#COORDINATE
local CoordSystem = Coordinate.System
if CoordSystem == "LL" then
return self:ToStringLL( Coordinate.LL_Accuracy, Coordinate.LL_DMS )
end
if CoordSystem == "MGRS" then
return self:ToStringMGRS( Coordinate.MGRS_Accuracy )
end
return nil
end
--- @param #COORDINATE self
-- @return #string The coordinate Text in the configured coordinate system.
function COORDINATE:CoordinateMenu( RootMenu ) --R2.1
if self.SystemMenu then
self.SystemMenu:Remove()
self.SystemMenu = nil
end
self.SystemMenu = MENU_MISSION:New( "System Settings" )
local CoordinateMenu = MENU_MISSION:New( "Coordinates", self.SystemMenu )
local Coordinate = COORDINATE
if Coordinate.System == "LL" then
MENU_MISSION_COMMAND:New( "Activate MGRS", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "MGRS" )
MENU_MISSION_COMMAND:New( "LL Accuracy 1", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 1 )
MENU_MISSION_COMMAND:New( "LL Accuracy 2", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 2 )
MENU_MISSION_COMMAND:New( "LL Accuracy 3", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 3 )
MENU_MISSION_COMMAND:New( "LL Decimal On", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, true )
MENU_MISSION_COMMAND:New( "LL Decimal Off", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, false )
end
if Coordinate.System == "MGRS" then
MENU_MISSION_COMMAND:New( "Activate LL", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "LL" )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 1", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 1 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 2", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 2 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 3", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 3 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 4", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 4 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 5", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 5 )
end
end
--- @param #COORDINATE self
function COORDINATE:MenuSystem( System ) --R2.1
self.System = System
self:CoordinateMenu()
end
--- @param #COORDINATE self
function COORDINATE:MenuLL_Accuracy( LL_Accuracy ) --R2.1
self.LL_Accuracy = LL_Accuracy
self:CoordinateMenu()
end
--- @param #COORDINATE self
function COORDINATE:MenuLL_DMS( LL_DMS ) --R2.1
self.LL_DMS = LL_DMS
self:CoordinateMenu()
end
--- @param #COORDINATE self
function COORDINATE:MenuMGRS_Accuracy( MGRS_Accuracy ) --R2.1
self.MGRS_Accuracy = MGRS_Accuracy
self:CoordinateMenu()
end
end

View File

@ -257,6 +257,22 @@ function ZONE_BASE:GetPointVec3( Height )
return PointVec3
end
--- Returns a @{Point#COORDINATE} of the zone.
-- @param #ZONE_BASE self
-- @param Dcs.DCSTypes#Distance Height The height to add to the land height where the center of the zone is located.
-- @return Core.Point#COORDINATE The Coordinate of the zone.
function ZONE_BASE:GetCoordinate( Height ) --R2.1
self:F2( self.ZoneName )
local Vec3 = self:GetVec3( Height )
local PointVec3 = COORDINATE:NewFromVec3( Vec3 )
self:T2( { PointVec3 } )
return PointVec3
end
--- Define a random @{DCSTypes#Vec2} within the zone.
-- @param #ZONE_BASE self

View File

@ -529,9 +529,11 @@ do -- DESIGNATE
--- Sends the status to the Attack Groups.
-- @param #DESIGNATE self
-- @param Wrapper.Group#GROUP AttackGroup
-- @param #number Duration The time in seconds the report should be visible.
-- @return #DESIGNATE
function DESIGNATE:SendStatus( MenuAttackGroup )
function DESIGNATE:SendStatus( MenuAttackGroup, Duration )
Duration = Duration or 10
self.AttackSet:ForEachGroup(
@ -540,7 +542,7 @@ do -- DESIGNATE
if self.FlashStatusMenu[AttackGroup] or ( MenuAttackGroup and ( AttackGroup:GetName() == MenuAttackGroup:GetName() ) ) then
local DetectedReport = REPORT:New( "Targets ready to be designated:" )
local DetectedReport = REPORT:New( "Targets designated:\n" )
local DetectedItems = self.Detection:GetDetectedItems()
for Index, DetectedItemData in pairs( DetectedItems ) do
@ -551,9 +553,9 @@ do -- DESIGNATE
local CC = self.CC:GetPositionable()
CC:MessageToGroup( DetectedReport:Text( "\n" ), 15, AttackGroup )
CC:MessageToGroup( DetectedReport:Text( "\n" ), Duration, AttackGroup )
local DesignationReport = REPORT:New( "Targets currently marked:" )
local DesignationReport = REPORT:New( "Targets marked:\n" )
self.RecceSet:ForEachGroup(
function( RecceGroup )
@ -567,7 +569,7 @@ do -- DESIGNATE
end
)
CC:MessageToGroup( DesignationReport:Text(), 15, AttackGroup )
CC:MessageToGroup( DesignationReport:Text(), Duration, AttackGroup )
end
end
)
@ -632,18 +634,21 @@ do -- DESIGNATE
end
local StatusMenu = MENU_GROUP:New( AttackGroup, "Status", DesignateMenu )
MENU_GROUP_COMMAND:New( AttackGroup, "Report Status", StatusMenu, self.MenuStatus, self, AttackGroup )
MENU_GROUP_COMMAND:New( AttackGroup, "Report Status 15s", StatusMenu, self.MenuStatus, self, AttackGroup, 15 )
MENU_GROUP_COMMAND:New( AttackGroup, "Report Status 30s", StatusMenu, self.MenuStatus, self, AttackGroup, 30 )
MENU_GROUP_COMMAND:New( AttackGroup, "Report Status 60s", StatusMenu, self.MenuStatus, self, AttackGroup, 60 )
if self.FlashStatusMenu[AttackGroup] then
MENU_GROUP_COMMAND:New( AttackGroup, "Flash Status Off", StatusMenu, self.MenuFlashStatus, self, AttackGroup, false )
MENU_GROUP_COMMAND:New( AttackGroup, "Flash Status Report Off", StatusMenu, self.MenuFlashStatus, self, AttackGroup, false )
else
MENU_GROUP_COMMAND:New( AttackGroup, "Flash Status On", StatusMenu, self.MenuFlashStatus, self, AttackGroup, true )
MENU_GROUP_COMMAND:New( AttackGroup, "Flash Status Report On", StatusMenu, self.MenuFlashStatus, self, AttackGroup, true )
end
local DetectedItems = self.Detection:GetDetectedItems()
for Index, DetectedItemData in pairs( DetectedItems ) do
local Report = self.Detection:DetectedItemReportSummary( Index )
local Report = self.Detection:DetectedItemMenu( Index )
if not self.Designating[Index] then
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, DesignateMenu )
@ -678,11 +683,11 @@ do -- DESIGNATE
---
-- @param #DESIGNATE self
function DESIGNATE:MenuStatus( AttackGroup )
function DESIGNATE:MenuStatus( AttackGroup, Duration )
self:E("Status")
self:SendStatus( AttackGroup )
self:SendStatus( AttackGroup, Duration )
end
---

View File

@ -1154,10 +1154,11 @@ do -- DETECTION_BASE
--- Adds a new DetectedItem to the DetectedItems list.
-- The DetectedItem is a table and contains a SET_UNIT in the field Set.
-- @param #DETECTION_BASE self
-- @param ItemPrefix
-- @param #string DetectedItemIndex The index of the DetectedItem.
-- @param Core.Set#SET_UNIT Set (optional) The Set of Units to be added.
-- @return #DETECTION_BASE.DetectedItem
function DETECTION_BASE:AddDetectedItem( DetectedItemIndex, Set )
function DETECTION_BASE:AddDetectedItem( ItemPrefix, DetectedItemIndex, Set )
local DetectedItem = {}
self.DetectedItemCount = self.DetectedItemCount + 1
@ -1170,7 +1171,7 @@ do -- DETECTION_BASE
end
DetectedItem.Set = Set or SET_UNIT:New():FilterDeads():FilterCrashes()
DetectedItem.ItemID = self.DetectedItemMax
DetectedItem.ItemID = ItemPrefix .. "." .. self.DetectedItemMax
DetectedItem.Removed = false
return DetectedItem
@ -1185,7 +1186,7 @@ do -- DETECTION_BASE
-- @return #DETECTION_BASE.DetectedItem
function DETECTION_BASE:AddDetectedItemZone( DetectedItemIndex, Set, Zone )
local DetectedItem = self:AddDetectedItem( DetectedItemIndex, Set )
local DetectedItem = self:AddDetectedItem( "AREA", DetectedItemIndex, Set )
DetectedItem.Zone = Zone
@ -1234,6 +1235,20 @@ do -- DETECTION_BASE
return nil
end
--- Get a detected ItemID using a given numeric index.
-- @param #DETECTION_BASE self
-- @param #number Index
-- @return #string DetectedItemID
function DETECTION_BASE:GetDetectedItemID( Index )
local DetectedItem = self.DetectedItems[Index]
if DetectedItem then
return DetectedItem.ItemID
end
return ""
end
--- Get the @{Set#SET_UNIT} of a detecttion area using a given numeric index.
-- @param #DETECTION_BASE self
-- @param #number Index
@ -1266,7 +1281,16 @@ do -- DETECTION_BASE
end
end
--- Menu of a detected item using a given numeric index.
-- @param #DETECTION_BASE self
-- @param Index
-- @return #string
function DETECTION_BASE:DetectedItemMenu( Index )
self:F( Index )
return nil
end
--- Report summary of a detected item using a given numeric index.
-- @param #DETECTION_BASE self
@ -1434,7 +1458,7 @@ do -- DETECTION_UNITS
local DetectedItem = self:GetDetectedItem( DetectedUnitName )
if not DetectedItem then
self:T( "Added new DetectedItem" )
DetectedItem = self:AddDetectedItem( DetectedUnitName )
DetectedItem = self:AddDetectedItem( "UNIT", DetectedUnitName )
DetectedItem.Type = DetectedUnit:GetTypeName()
DetectedItem.Name = DetectedObjectData.Name
DetectedItem.Visible = DetectedObjectData.Visible
@ -1457,6 +1481,44 @@ do -- DETECTION_UNITS
end
end
--- Menu of a DetectedItem using a given numeric index.
-- @param #DETECTION_UNITS self
-- @param Index
-- @return #string
function DETECTION_UNITS:DetectedItemMenu( Index )
self:F( Index )
local DetectedItem = self:GetDetectedItem( Index )
local DetectedSet = self:GetDetectedSet( Index )
local DetectedItemID = self:GetDetectedItemID( Index )
self:T( DetectedSet )
if DetectedSet then
local ReportSummary = ""
local UnitDistanceText = ""
local UnitCategoryText = ""
local DetectedItemUnit = DetectedSet:GetFirst() -- Wrapper.Unit#UNIT
if DetectedItemUnit and DetectedItemUnit:IsAlive() then
self:T(DetectedItemUnit)
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString()
ReportSummary = string.format(
"%s - %s",
DetectedItemID,
DetectedItemCoordText
)
end
self:T( ReportSummary )
return ReportSummary
end
end
--- Report summary of a DetectedItem using a given numeric index.
-- @param #DETECTION_UNITS self
@ -1467,6 +1529,7 @@ do -- DETECTION_UNITS
local DetectedItem = self:GetDetectedItem( Index )
local DetectedSet = self:GetDetectedSet( Index )
local DetectedItemID = self:GetDetectedItemID( Index )
self:T( DetectedSet )
if DetectedSet then
@ -1489,19 +1552,20 @@ do -- DETECTION_UNITS
end
if DetectedItem.Visible == false then
UnitDistanceText = string.format( "%.2f", DetectedItem.Distance ) .. " estimated km"
UnitDistanceText = string.format( "%.2f", DetectedItem.Distance ) .. " km, estimated"
else
UnitDistanceText = string.format( "%.2f", DetectedItem.Distance ) .. " km, visual contact"
UnitDistanceText = string.format( "%.2f", DetectedItem.Distance ) .. " km, visual"
end
local DetectedItemPointVec3 = DetectedItemUnit:GetPointVec3()
local DetectedItemPointLL = DetectedItemPointVec3:ToStringLL( 3, true )
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString()
local ThreatLevelA2G = DetectedItemUnit:GetThreatLevel( DetectedItem )
ReportSummary = string.format(
"%s - Threat [%s] (%2d) - %s%s",
DetectedItemPointLL,
"%s - %s - Threat:[%s](%2d) - %s%s",
DetectedItemID,
DetectedItemCoordText,
string.rep( "", ThreatLevelA2G ),
ThreatLevelA2G,
UnitCategoryText,
@ -1514,6 +1578,7 @@ do -- DETECTION_UNITS
return ReportSummary
end
end
--- Report detailed of a detection result.
-- @param #DETECTION_UNITS self
@ -1655,7 +1720,7 @@ do -- DETECTION_TYPES
local DetectedTypeName = DetectedUnit:GetTypeName()
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
if not DetectedItem then
DetectedItem = self:AddDetectedItem( DetectedTypeName )
DetectedItem = self:AddDetectedItem( "TYPE", DetectedTypeName )
DetectedItem.Type = DetectedUnit:GetTypeName()
end
@ -1678,6 +1743,36 @@ do -- DETECTION_TYPES
end
end
--- Menu of a DetectedItem using a given numeric index.
-- @param #DETECTION_TYPES self
-- @param Index
-- @return #string
function DETECTION_TYPES:DetectedItemMenu( DetectedTypeName )
self:F( DetectedTypeName )
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
local DetectedSet = self:GetDetectedSet( DetectedTypeName )
local DetectedItemID = self:GetDetectedItemID( DetectedTypeName )
self:T( DetectedItem )
if DetectedItem then
local DetectedItemUnit = DetectedSet:GetFirst()
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString()
local ReportSummary = string.format(
"%S - %s",
DetectedItemID,
DetectedItemCoordText
)
self:T( ReportSummary )
return ReportSummary
end
end
--- Report summary of a DetectedItem using a given numeric index.
-- @param #DETECTION_TYPES self
@ -1688,6 +1783,7 @@ do -- DETECTION_TYPES
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
local DetectedSet = self:GetDetectedSet( DetectedTypeName )
local DetectedItemID = self:GetDetectedItemID( DetectedTypeName )
self:T( DetectedItem )
if DetectedItem then
@ -1695,9 +1791,16 @@ do -- DETECTION_TYPES
local ThreatLevelA2G = DetectedSet:CalculateThreatLevelA2G()
local DetectedItemsCount = DetectedSet:Count()
local DetectedItemType = DetectedItem.Type
local DetectedItemUnit = DetectedSet:GetFirst()
local DetectedItemCoordinate = DetectedItemUnit:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString()
local ReportSummary = string.format(
"Threat [%s] (%2d) - %2d of %s",
"%S - %s - Threat:[%s](%2d) - %2d of %s",
DetectedItemID,
DetectedItemCoordText,
string.rep( "", ThreatLevelA2G ),
ThreatLevelA2G,
DetectedItemsCount,
@ -1794,6 +1897,36 @@ do -- DETECTION_AREAS
return self
end
--- Menu of a detected item using a given numeric index.
-- @param #DETECTION_AREAS self
-- @param Index
-- @return #string
function DETECTION_AREAS:DetectedItemMenu( Index )
self:F( Index )
local DetectedItem = self:GetDetectedItem( Index )
local DetectedItemID = self:GetDetectedItemID( Index )
if DetectedItem then
local DetectedSet = self:GetDetectedSet( Index )
local ReportSummaryItem
local DetectedZone = self:GetDetectedZone( Index )
local DetectedItemCoordinate = DetectedZone:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString()
local ReportSummary = string.format(
"%s - %s",
DetectedItemID,
DetectedItemCoordText
)
return ReportSummary
end
return nil
end
--- Report summary of a detected item using a given numeric index.
-- @param #DETECTION_AREAS self
@ -1803,21 +1936,24 @@ do -- DETECTION_AREAS
self:F( Index )
local DetectedItem = self:GetDetectedItem( Index )
local DetectedItemID = self:GetDetectedItemID( Index )
if DetectedItem then
local DetectedSet = self:GetDetectedSet( Index )
local ReportSummaryItem
local DetectedZone = self:GetDetectedZone( Index )
local DetectedItemPointVec3 = DetectedZone:GetPointVec3()
local DetectedItemPointLL = DetectedItemPointVec3:ToStringLL( 3, true )
local DetectedItemCoordinate = DetectedZone:GetCoordinate()
local DetectedItemCoordText = DetectedItemCoordinate:ToString()
local ThreatLevelA2G = self:GetTreatLevelA2G( DetectedItem )
local DetectedItemsCount = DetectedSet:Count()
local DetectedItemsTypes = DetectedSet:GetTypeNames()
local ReportSummary = string.format(
"%s - Threat [%s] (%2d) - %2d of %s",
DetectedItemPointLL,
"%s - %s - Threat:[%s](%2d)\n %2d of %s",
DetectedItemID,
DetectedItemCoordText,
string.rep( "", ThreatLevelA2G ),
ThreatLevelA2G,
DetectedItemsCount,

View File

@ -9,5 +9,4 @@ _SCHEDULEDISPATCHER = SCHEDULEDISPATCHER:New() -- Core.Timer#SCHEDULEDISPATCHER
--- Declare the main database object, which is used internally by the MOOSE classes.
_DATABASE = DATABASE:New() -- Database#DATABASE
COORDINATE:CoordinateMenu()

View File

@ -282,7 +282,7 @@ UTILS.tostringMGRS = function(MGRS, acc) --R2.1
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph
else
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Easting/(10^(5-acc)), 0))
.. ' ' .. string.format('%0' .. acc .. 'd', UTILS.round(MGRS.Northing/(10^(5-acc)), 0))
.. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Northing/(10^(5-acc)), 0))
end
end

View File

@ -134,6 +134,27 @@ function POSITIONABLE:GetPointVec3()
return nil
end
--- Returns a COORDINATE object indicating the point in 3D of the POSITIONABLE within the mission.
-- @param Wrapper.Positionable#POSITIONABLE self
-- @return Core.Point#COORDINATE The COORDINATE of the POSITIONABLE.
-- @return #nil The POSITIONABLE is not existing or alive.
function POSITIONABLE:GetCoordinate()
self:F2( self.PositionableName )
local DCSPositionable = self:GetDCSObject()
if DCSPositionable then
local PositionableVec3 = self:GetPositionVec3()
local PositionableCoordinate = COORDINATE:NewFromVec3( PositionableVec3 )
self:T2( PositionableCoordinate )
return PositionableCoordinate
end
return nil
end
--- Returns a random @{DCSTypes#Vec3} vector within a range, indicating the point in 3D of the POSITIONABLE within the mission.
-- @param Wrapper.Positionable#POSITIONABLE self