mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress reworking object model.
This commit is contained in:
parent
e99458520a
commit
5e6043aeb3
@ -2,8 +2,8 @@
|
|||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- 1) @{Airbase#AIRBASE} class, extends @{Base#BASE}
|
-- 1) @{Airbase#AIRBASE} class, extends @{Positionable#POSITIONABLE}
|
||||||
-- =================================================
|
-- =================================================================
|
||||||
-- The @{AIRBASE} class is a wrapper class to handle the DCS Airbase objects:
|
-- The @{AIRBASE} class is a wrapper class to handle the DCS Airbase objects:
|
||||||
--
|
--
|
||||||
-- * Support all DCS Airbase APIs.
|
-- * Support all DCS Airbase APIs.
|
||||||
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
--- The AIRBASE class
|
--- The AIRBASE class
|
||||||
-- @type AIRBASE
|
-- @type AIRBASE
|
||||||
-- @extends Base#BASE
|
-- @extends Positionable#POSITIONABLE
|
||||||
AIRBASE = {
|
AIRBASE = {
|
||||||
ClassName="AIRBASE",
|
ClassName="AIRBASE",
|
||||||
CategoryName = {
|
CategoryName = {
|
||||||
@ -63,13 +63,11 @@ AIRBASE = {
|
|||||||
|
|
||||||
--- Create a new AIRBASE from DCSAirbase.
|
--- Create a new AIRBASE from DCSAirbase.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param DCSAirbase#Airbase DCSAirbase
|
-- @param #string AirbaseName The name of the airbase.
|
||||||
-- @param Database#DATABASE Database
|
|
||||||
-- @return Airbase#AIRBASE
|
-- @return Airbase#AIRBASE
|
||||||
function AIRBASE:Register( AirbaseName )
|
function AIRBASE:Register( AirbaseName )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) )
|
||||||
self:F2( AirbaseName )
|
|
||||||
self.AirbaseName = AirbaseName
|
self.AirbaseName = AirbaseName
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
--- This module contains the CONTROLLABLE class.
|
--- This module contains the CONTROLLABLE class.
|
||||||
--
|
--
|
||||||
-- 1) @{Controllable#CONTROLLABLE} class, extends @{Base#BASE}
|
-- 1) @{Controllable#CONTROLLABLE} class, extends @{Positionable#POSITIONABLE}
|
||||||
-- ===========================================================
|
-- ===========================================================
|
||||||
-- The @{Controllable#CONTROLLABLE} class is a wrapper class to handle the DCS Controllable objects:
|
-- The @{Controllable#CONTROLLABLE} class is a wrapper class to handle the DCS Controllable objects:
|
||||||
--
|
--
|
||||||
@ -127,28 +127,21 @@
|
|||||||
|
|
||||||
--- The CONTROLLABLE class
|
--- The CONTROLLABLE class
|
||||||
-- @type CONTROLLABLE
|
-- @type CONTROLLABLE
|
||||||
-- @extends Base#BASE
|
-- @extends Positionable#POSITIONABLE
|
||||||
-- @field DCSControllable#Controllable DCSControllable The DCS controllable class.
|
-- @field DCSControllable#Controllable DCSControllable The DCS controllable class.
|
||||||
-- @field #string ControllableName The name of the controllable.
|
-- @field #string ControllableName The name of the controllable.
|
||||||
CONTROLLABLE = {
|
CONTROLLABLE = {
|
||||||
ClassName = "CONTROLLABLE",
|
ClassName = "CONTROLLABLE",
|
||||||
ControllableName = "",
|
ControllableName = "",
|
||||||
ControllableID = 0,
|
|
||||||
Controller = nil,
|
|
||||||
DCSControllable = nil,
|
|
||||||
WayPointFunctions = {},
|
WayPointFunctions = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- A DCSControllable
|
|
||||||
-- @type DCSControllable
|
|
||||||
-- @field id_ The ID of the controllable in DCS
|
|
||||||
|
|
||||||
--- Create a new CONTROLLABLE from a DCSControllable
|
--- Create a new CONTROLLABLE from a DCSControllable
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param DCSControllable#Controllable ControllableName The DCS Controllable name
|
-- @param DCSControllable#Controllable ControllableName The DCS Controllable name
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:New( ControllableName )
|
function CONTROLLABLE:New( ControllableName )
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
||||||
self:F2( ControllableName )
|
self:F2( ControllableName )
|
||||||
self.ControllableName = ControllableName
|
self.ControllableName = ControllableName
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -7,17 +7,17 @@
|
|||||||
-- The @{Detection#DETECTION_BASE} class defines the core functions to administer detected objects.
|
-- The @{Detection#DETECTION_BASE} class defines the core functions to administer detected objects.
|
||||||
-- Detected objects are grouped in SETS of UNITS.
|
-- Detected objects are grouped in SETS of UNITS.
|
||||||
--
|
--
|
||||||
-- 1.1) DETECTION constructor:
|
-- 1.1) DETECTION_BASE constructor:
|
||||||
-- ----------------------------
|
-- --------------------------------
|
||||||
-- * @{Detection#DETECTION.New}(): Create a new DETECTION object.
|
-- * @{Detection#DETECTION.New}(): Create a new DETECTION object.
|
||||||
--
|
--
|
||||||
-- 1.2) DETECTION initialization:
|
-- 1.2) DETECTION_BASE initialization:
|
||||||
-- ------------------------------
|
-- -----------------------------------
|
||||||
-- By default, detection will return detected units with all the methods available.
|
-- By default, detection will return detected objects with all the methods available.
|
||||||
-- However, you can specify which units it found with specific detection methods.
|
-- However, you can ask how the objects were found with specific detection methods.
|
||||||
-- If you use one of the below functions, the detection will work with the detection method specified.
|
-- If you use one of the below methods, the detection will work with the detection method specified.
|
||||||
-- You can specify to apply multiple detection methods.
|
-- You can specify to apply multiple detection methods.
|
||||||
-- Use the following functions to report the units it detected using the methods Visual, Optical, Radar, IRST, RWR, DLINK:
|
-- Use the following functions to report the objects it detected using the methods Visual, Optical, Radar, IRST, RWR, DLINK:
|
||||||
--
|
--
|
||||||
-- * @{Detection#DETECTION.InitDetectVisual}(): Detected using Visual.
|
-- * @{Detection#DETECTION.InitDetectVisual}(): Detected using Visual.
|
||||||
-- * @{Detection#DETECTION.InitDetectOptical}(): Detected using Optical.
|
-- * @{Detection#DETECTION.InitDetectOptical}(): Detected using Optical.
|
||||||
@ -26,6 +26,17 @@
|
|||||||
-- * @{Detection#DETECTION.InitDetectRWR}(): Detected using RWR.
|
-- * @{Detection#DETECTION.InitDetectRWR}(): Detected using RWR.
|
||||||
-- * @{Detection#DETECTION.InitDetectDLINK}(): Detected using DLINK.
|
-- * @{Detection#DETECTION.InitDetectDLINK}(): Detected using DLINK.
|
||||||
--
|
--
|
||||||
|
-- 1.3) Obtain objects detected by DETECTION_BASE:
|
||||||
|
-- -----------------------------------------------
|
||||||
|
-- DETECTION_BASE builds @{Set}s of objects detected. These @{Set#SET_BASE}s can be retrieved using the method @{Detection#DETECTION_BASE.GetDetectedSets}().
|
||||||
|
-- The method will return a list (table) of @{Set#SET_BASE} objects.
|
||||||
|
--
|
||||||
|
-- 2) @{Detection#DETECTION_UNITGROUPS} class, extends @{Detection#DETECTION_BASE}
|
||||||
|
-- ===============================================================================
|
||||||
|
-- The @{Detection#DETECTION_UNITGROUPS} class will detect units within the battle zone for a FAC group,
|
||||||
|
-- and will build a list (table) of @{Set#SET_UNIT}s containing the @{Unit#UNIT}s detected.
|
||||||
|
--
|
||||||
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module Detection
|
-- @module Detection
|
||||||
@ -39,29 +50,31 @@
|
|||||||
-- @field Group#GROUP FACGroup The GROUP in the Forward Air Controller role.
|
-- @field Group#GROUP FACGroup The GROUP in the Forward Air Controller role.
|
||||||
-- @field DCSTypes#Distance DetectionRange The range till which targets are accepted to be detected.
|
-- @field DCSTypes#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||||
-- @field DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
-- @field DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||||
-- @field #DETECTION_BASE.DetectedUnitSets DetectedUnitSets A list of @{Set#SET_UNIT}s containing the units in each set that were detected within a DetectedZoneRange.
|
-- @field #DETECTION_BASE.DetectedSets DetectedSets A list of @{Set#SET_BASE}s containing the objects in each set that were detected within a DetectedZoneRange.
|
||||||
-- @field #DETECTION_BASE.DetectedUnitZones DetectedUnitZones A list of @{Zone#ZONE_UNIT}s containing the zones of the reference detected units.
|
-- @field #DETECTION_BASE.DetectedZones DetectedZones A list of @{Zone#ZONE_BASE}s containing the zones of the reference detected objects.
|
||||||
-- @extends Set#SET_BASE
|
-- @extends Set#SET_BASE
|
||||||
DETECTION_BASE = {
|
DETECTION_BASE = {
|
||||||
ClassName = "DETECTION_BASE",
|
ClassName = "DETECTION_BASE",
|
||||||
DetectedUnitSets = {},
|
DetectedSets = {},
|
||||||
DetectedUnitZones = {},
|
DetectedObjects = {},
|
||||||
DetectedUnits = {},
|
|
||||||
FACGroup = nil,
|
FACGroup = nil,
|
||||||
DetectionRange = nil,
|
DetectionRange = nil,
|
||||||
DetectionZoneRange = nil,
|
DetectionZoneRange = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @type DETECTION_BASE.DetectedUnitSets
|
--- @type DETECTION_BASE.DetectedSets
|
||||||
-- @list <Set#SET_UNIT>
|
-- @list <Set#SET_BASE>
|
||||||
|
|
||||||
|
|
||||||
--- @type DETECTION_BASE.DetectedUnitZones
|
--- @type DETECTION_BASE.DetectedZones
|
||||||
-- @list <Zone#ZONE_UNIT>
|
-- @list <Zone#ZONE_BASE>
|
||||||
|
|
||||||
|
|
||||||
--- DETECTION constructor.
|
--- DETECTION constructor.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @param Group#GROUP FACGroup The GROUP in the Forward Air Controller role.
|
||||||
|
-- @param DCSTypes#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||||
|
-- @param DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||||
-- @return #DETECTION_BASE self
|
-- @return #DETECTION_BASE self
|
||||||
function DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange )
|
function DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange )
|
||||||
|
|
||||||
@ -152,45 +165,56 @@ function DETECTION_BASE:GetFACGroup()
|
|||||||
return self.FACGroup
|
return self.FACGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the detected @{Set#SET_UNIT}s.
|
--- Get the detected @{Set#SET_BASE}s.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @return #DETECTION_BASE.DetectedUnitSets DetectedUnitSets
|
-- @return #DETECTION_BASE.DetectedSets DetectedSets
|
||||||
function DETECTION_BASE:GetDetectionUnitSets()
|
function DETECTION_BASE:GetDetectionSets()
|
||||||
|
|
||||||
local DetectionUnitSets = self.DetectedUnitSets
|
local DetectionSets = self.DetectedSets
|
||||||
return DetectionUnitSets
|
return DetectionSets
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the amount of SETs with detected units.
|
--- Get the amount of SETs with detected objects.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @return #number Count
|
-- @return #number Count
|
||||||
function DETECTION_BASE:GetDetectionUnitSetCount()
|
function DETECTION_BASE:GetDetectionSetCount()
|
||||||
|
|
||||||
local DetectionUnitSetCount = #self.DetectedUnitSets
|
local DetectionSetCount = #self.DetectedSets
|
||||||
return DetectionUnitSetCount
|
return DetectionSetCount
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a SET of detected units using a given numeric index.
|
--- Get a SET of detected objects using a given numeric index.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
-- @param #number Index
|
-- @param #number Index
|
||||||
-- @return Set#SET_UNIT
|
-- @return Set#SET_BASE
|
||||||
function DETECTION_BASE:GetDetectionUnitSet( Index )
|
function DETECTION_BASE:GetDetectionSet( Index )
|
||||||
|
|
||||||
local DetectionUnitSet = self.DetectedUnitSets[Index]
|
local DetectionSet = self.DetectedSets[Index]
|
||||||
if DetectionUnitSet then
|
if DetectionSet then
|
||||||
return DetectionUnitSet
|
return DetectionSet
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Form @{Set}s of detected @{Unit#UNIT}s in an array of @{Set#SET_UNIT}s.
|
--- Make a DetectionSet table. This function will be overridden in the derived clsses.
|
||||||
|
-- @param #DETECTION_BASE self
|
||||||
|
-- @return #DETECTION_BASE self
|
||||||
|
function DETECTION_BASE:CreateDetectionSets()
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
self:E( "Error, in DETECTION_BASE class..." )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Form @{Set}s of detected @{Unit#UNIT}s in an array of @{Set#SET_BASE}s.
|
||||||
-- @param #DETECTION_BASE self
|
-- @param #DETECTION_BASE self
|
||||||
function DETECTION_BASE:_DetectionScheduler( SchedulerName )
|
function DETECTION_BASE:_DetectionScheduler( SchedulerName )
|
||||||
self:F2( { SchedulerName } )
|
self:F2( { SchedulerName } )
|
||||||
|
|
||||||
self.DetectedUnitSets = {}
|
self.DetectedObjects = {}
|
||||||
self.DetectedUnitZones = {}
|
self.DetectedSets = {}
|
||||||
|
self.DetectedZones = {}
|
||||||
|
|
||||||
if self.FACGroup:IsAlive() then
|
if self.FACGroup:IsAlive() then
|
||||||
local FACGroupName = self.FACGroup:GetName()
|
local FACGroupName = self.FACGroup:GetName()
|
||||||
@ -205,98 +229,149 @@ function DETECTION_BASE:_DetectionScheduler( SchedulerName )
|
|||||||
)
|
)
|
||||||
|
|
||||||
for FACDetectedTargetID, FACDetectedTarget in pairs( FACDetectedTargets ) do
|
for FACDetectedTargetID, FACDetectedTarget in pairs( FACDetectedTargets ) do
|
||||||
local FACObject = FACDetectedTarget.object
|
local FACObject = FACDetectedTarget.object -- DCSObject#Object
|
||||||
self:T2( FACObject )
|
self:T2( FACObject )
|
||||||
|
|
||||||
if FACObject and FACObject:isExist() and FACObject.id_ < 50000000 then
|
if FACObject and FACObject:isExist() and FACObject.id_ < 50000000 then
|
||||||
|
|
||||||
local FACDetectedUnit = UNIT:Find( FACObject )
|
local FACDetectedObjectName = FACObject:getName()
|
||||||
local FACDetectedUnitName = FACDetectedUnit:GetName()
|
|
||||||
|
|
||||||
local FACDetectedUnitPositionVec3 = FACDetectedUnit:GetPointVec3()
|
local FACDetectedObjectPositionVec3 = FACObject:getPoint()
|
||||||
local FACGroupPositionVec3 = self.FACGroup:GetPointVec3()
|
local FACGroupPositionVec3 = self.FACGroup:GetPointVec3()
|
||||||
local Distance = ( ( FACDetectedUnitPositionVec3.x - FACGroupPositionVec3.x )^2 +
|
|
||||||
( FACDetectedUnitPositionVec3.y - FACGroupPositionVec3.y )^2 +
|
local Distance = ( ( FACDetectedObjectPositionVec3.x - FACGroupPositionVec3.x )^2 +
|
||||||
( FACDetectedUnitPositionVec3.z - FACGroupPositionVec3.z )^2
|
( FACDetectedObjectPositionVec3.y - FACGroupPositionVec3.y )^2 +
|
||||||
|
( FACDetectedObjectPositionVec3.z - FACGroupPositionVec3.z )^2
|
||||||
) ^ 0.5 / 1000
|
) ^ 0.5 / 1000
|
||||||
|
|
||||||
self:T( { FACGroupName, FACDetectedUnitName, Distance } )
|
self:T( { FACGroupName, FACDetectedObjectName, Distance } )
|
||||||
|
|
||||||
if Distance <= self.DetectionRange then
|
if Distance <= self.DetectionRange then
|
||||||
|
|
||||||
if not self.DetectedUnits[FACDetectedUnitName] then
|
if not self.DetectedObjects[FACDetectedObjectName] then
|
||||||
self.DetectedUnits[FACDetectedUnitName] = {}
|
self.DetectedObjects[FACDetectedObjectName] = {}
|
||||||
end
|
end
|
||||||
self.DetectedUnits[FACDetectedUnitName].DetectedUnit = UNIT:FindByName( FACDetectedUnitName )
|
self.DetectedObjects[FACDetectedObjectName].Name = FACDetectedObjectName
|
||||||
self.DetectedUnits[FACDetectedUnitName].Visible = FACDetectedTarget.visible
|
self.DetectedObjects[FACDetectedObjectName].Visible = FACDetectedTarget.visible
|
||||||
self.DetectedUnits[FACDetectedUnitName].Type = FACDetectedTarget.type
|
self.DetectedObjects[FACDetectedObjectName].Type = FACDetectedTarget.type
|
||||||
self.DetectedUnits[FACDetectedUnitName].Distance = FACDetectedTarget.distance
|
self.DetectedObjects[FACDetectedObjectName].Distance = FACDetectedTarget.distance
|
||||||
else
|
else
|
||||||
-- if beyond the DetectionRange then nullify...
|
-- if beyond the DetectionRange then nullify...
|
||||||
if self.DetectedUnits[FACDetectedUnitName] then
|
if self.DetectedObjects[FACDetectedObjectName] then
|
||||||
self.DetectedUnits[FACDetectedUnitName] = nil
|
self.DetectedObjects[FACDetectedObjectName] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:T2( self.DetectedObjects )
|
||||||
|
|
||||||
-- okay, now we have a list of detected unit names ...
|
-- okay, now we have a list of detected object names ...
|
||||||
-- Sort the table based on distance ...
|
-- Sort the table based on distance ...
|
||||||
self:T( { "Sorting DetectedUnits table:", self.DetectedUnits } )
|
self:T( { "Sorting DetectedObjects table:", self.DetectedObjects } )
|
||||||
table.sort( self.DetectedUnits, function( a, b ) return a.Distance < b.Distance end )
|
table.sort( self.DetectedObjects, function( a, b ) return a.Distance < b.Distance end )
|
||||||
self:T( { "Sorted Targets Table:", self.DetectedUnits } )
|
self:T( { "Sorted Targets Table:", self.DetectedObjects } )
|
||||||
|
|
||||||
-- Now group the DetectedUnits table into SET_UNITs, evaluating the DetectionZoneRange.
|
-- Now group the DetectedObjects table into SET_BASEs, evaluating the DetectionZoneRange.
|
||||||
|
|
||||||
if self.DetectedUnits then
|
if self.DetectedObjects then
|
||||||
for DetectedUnitName, DetectedUnitData in pairs( self.DetectedUnits ) do
|
self:CreateDetectionSets()
|
||||||
local DetectedUnit = DetectedUnitData.DetectedUnit -- Unit#UNIT
|
|
||||||
if DetectedUnit and DetectedUnit:IsAlive() then
|
|
||||||
self:T( DetectedUnit:GetName() )
|
|
||||||
if #self.DetectedUnitSets == 0 then
|
|
||||||
self:T( { "Adding Unit Set #", 1 } )
|
|
||||||
self.DetectedUnitZones[1] = ZONE_UNIT:New( DetectedUnitName, DetectedUnit, self.DetectionZoneRange )
|
|
||||||
self.DetectedUnitSets[1] = SET_UNIT:New()
|
|
||||||
self.DetectedUnitSets[1]:AddUnit( DetectedUnit )
|
|
||||||
else
|
|
||||||
local AddedToSet = false
|
|
||||||
for DetectedZoneIndex = 1, #self.DetectedUnitZones do
|
|
||||||
self:T( "Detected Unit Set #" .. DetectedZoneIndex )
|
|
||||||
local DetectedUnitSet = self.DetectedUnitSets[DetectedZoneIndex] -- Set#SET_UNIT
|
|
||||||
DetectedUnitSet:Flush()
|
|
||||||
local DetectedZone = self.DetectedUnitZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
|
|
||||||
if DetectedUnit:IsInZone( DetectedZone ) then
|
|
||||||
self:T( "Adding to Unit Set #" .. DetectedZoneIndex )
|
|
||||||
DetectedUnitSet:AddUnit( DetectedUnit )
|
|
||||||
AddedToSet = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if AddedToSet == false then
|
|
||||||
local DetectedZoneIndex = #self.DetectedUnitZones + 1
|
|
||||||
self:T( "Adding new zone #" .. DetectedZoneIndex )
|
|
||||||
self.DetectedUnitZones[DetectedZoneIndex] = ZONE_UNIT:New( DetectedUnitName, DetectedUnit, self.DetectionZoneRange )
|
|
||||||
self.DetectedUnitSets[DetectedZoneIndex] = SET_UNIT:New()
|
|
||||||
self.DetectedUnitSets[DetectedZoneIndex]:AddUnit( DetectedUnit )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Now all the tests should have been build, now make some smoke and flares...
|
|
||||||
|
end
|
||||||
for DetectedZoneIndex = 1, #self.DetectedUnitZones do
|
end
|
||||||
local DetectedUnitSet = self.DetectedUnitSets[DetectedZoneIndex] -- Set#SET_UNIT
|
|
||||||
local DetectedZone = self.DetectedUnitZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
|
|
||||||
self:T( "Detected Set #" .. DetectedZoneIndex )
|
|
||||||
DetectedUnitSet:ForEachUnit(
|
--- DETECTION_UNITGROUPS class
|
||||||
--- @param Unit#UNIT DetectedUnit
|
-- @type DETECTION_UNITGROUPS
|
||||||
function( DetectedUnit )
|
-- @field #DETECTION_UNITGROUPS.DetectedSets DetectedSets A list of @{Set#SET_UNIT}s containing the units in each set that were detected within a DetectedZoneRange.
|
||||||
self:T( DetectedUnit:GetName() )
|
-- @field #DETECTION_UNITGROUPS.DetectedZones DetectedZones A list of @{Zone#ZONE_UNIT}s containing the zones of the reference detected units.
|
||||||
DetectedUnit:FlareRed()
|
-- @extends Set#SET_BASE
|
||||||
|
DETECTION_UNITGROUPS = {
|
||||||
|
ClassName = "DETECTION_UNITGROUPS",
|
||||||
|
DetectedZones = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- @type DETECTION_UNITGROUPS.DetectedSets
|
||||||
|
-- @list <Set#SET_UNIT>
|
||||||
|
|
||||||
|
|
||||||
|
--- @type DETECTION_UNITGROUPS.DetectedZones
|
||||||
|
-- @list <Zone#ZONE_UNIT>
|
||||||
|
|
||||||
|
|
||||||
|
--- DETECTION_UNITGROUPS constructor.
|
||||||
|
-- @param #DETECTION_UNITGROUPS self
|
||||||
|
-- @field Group#GROUP FACGroup The GROUP in the Forward Air Controller role.
|
||||||
|
-- @field DCSTypes#Distance DetectionRange The range till which targets are accepted to be detected.
|
||||||
|
-- @field DCSTypes#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target.
|
||||||
|
-- @return #DETECTION_UNITGROUPS self
|
||||||
|
function DETECTION_UNITGROUPS:New( FACGroup, DetectionRange, DetectionZoneRange )
|
||||||
|
|
||||||
|
-- Inherits from DETECTION_BASE
|
||||||
|
local self = BASE:Inherit( self, DETECTION_BASE:New( FACGroup, DetectionRange, DetectionZoneRange ) )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Make a DetectionSet table. This function will be overridden in the derived clsses.
|
||||||
|
-- @param #DETECTION_UNITGROUPS self
|
||||||
|
-- @return #DETECTION_UNITGROUPS self
|
||||||
|
function DETECTION_UNITGROUPS:CreateDetectionSets()
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
for DetectedUnitName, DetectedUnitData in pairs( self.DetectedObjects ) do
|
||||||
|
local DetectedUnit = UNIT:FindByName( DetectedUnitData.Name ) -- Unit#UNIT
|
||||||
|
if DetectedUnit and DetectedUnit:IsAlive() then
|
||||||
|
self:T( DetectedUnit:GetName() )
|
||||||
|
if #self.DetectedSets == 0 then
|
||||||
|
self:T( { "Adding Unit Set #", 1 } )
|
||||||
|
self.DetectedZones[1] = ZONE_UNIT:New( DetectedUnitName, DetectedUnit, self.DetectionZoneRange )
|
||||||
|
self.DetectedSets[1] = SET_BASE:New()
|
||||||
|
self.DetectedSets[1]:AddUnit( DetectedUnit )
|
||||||
|
else
|
||||||
|
local AddedToSet = false
|
||||||
|
for DetectedZoneIndex = 1, #self.DetectedZones do
|
||||||
|
self:T( "Detected Unit Set #" .. DetectedZoneIndex )
|
||||||
|
local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE
|
||||||
|
DetectedUnitSet:Flush()
|
||||||
|
local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
|
||||||
|
if DetectedUnit:IsInZone( DetectedZone ) then
|
||||||
|
self:T( "Adding to Unit Set #" .. DetectedZoneIndex )
|
||||||
|
DetectedUnitSet:AddUnit( DetectedUnit )
|
||||||
|
AddedToSet = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
)
|
if AddedToSet == false then
|
||||||
DetectedZone:FlareZone( POINT_VEC3.SmokeColor.White, 30, math.random( 0,90 ) )
|
local DetectedZoneIndex = #self.DetectedZones + 1
|
||||||
|
self:T( "Adding new zone #" .. DetectedZoneIndex )
|
||||||
|
self.DetectedZones[DetectedZoneIndex] = ZONE_UNIT:New( DetectedUnitName, DetectedUnit, self.DetectionZoneRange )
|
||||||
|
self.DetectedSets[DetectedZoneIndex] = SET_BASE:New()
|
||||||
|
self.DetectedSets[DetectedZoneIndex]:AddUnit( DetectedUnit )
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
-- Now all the tests should have been build, now make some smoke and flares...
|
||||||
|
|
||||||
|
for DetectedZoneIndex = 1, #self.DetectedZones do
|
||||||
|
local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE
|
||||||
|
local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
|
||||||
|
self:T( "Detected Set #" .. DetectedZoneIndex )
|
||||||
|
DetectedUnitSet:ForEachUnit(
|
||||||
|
--- @param Unit#UNIT DetectedUnit
|
||||||
|
function( DetectedUnit )
|
||||||
|
self:T( DetectedUnit:GetName() )
|
||||||
|
DetectedUnit:FlareRed()
|
||||||
|
end
|
||||||
|
)
|
||||||
|
DetectedZone:FlareZone( POINT_VEC3.SmokeColor.White, 30, math.random( 0,90 ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,17 +11,31 @@
|
|||||||
--
|
--
|
||||||
-- Detected objects are grouped in SETS of UNITS.
|
-- Detected objects are grouped in SETS of UNITS.
|
||||||
--
|
--
|
||||||
-- 1.1) FAC constructor:
|
-- 1.1) FAC_BASE constructor:
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- * @{Fac#FAC.New}(): Create a new FAC object.
|
-- * @{Fac#FAC_BASE.New}(): Create a new FAC_BASE instance.
|
||||||
--
|
--
|
||||||
-- 1.2) FAC initialization:
|
-- 1.2) FAC_BASE reporting:
|
||||||
-- ------------------------------
|
-- ------------------------
|
||||||
|
-- Derived FAC_BASE classes will reports detected units using the method @{Fac#FAC_BASE.ReportDetected}(). This method implements polymorphic behaviour.
|
||||||
|
-- The time interval in seconds of the reporting can be changed using the methods @{Fac#FAC_BASE.SetReportInterval}().
|
||||||
|
-- Reporting can be started and stopped using the methods @{Fac#FAC_BASE.StartReporting}() and @{Fac#FAC_BASE.StopReporting}() respectively.
|
||||||
|
-- If an ad-hoc report is requested, use the method @{Fac#FAC_BASE#ReportNow}().
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
-- 2) @{Fac#FAC_REPORTING} class, extends @{Fac#FAC_BASE}
|
||||||
|
-- ======================================================
|
||||||
|
-- The @{Fac#FAC_REPORTING} class implements detected units reporting. Reporting can be controlled using the reporting methods available in the @{Fac#FAC_BASE} class.
|
||||||
|
--
|
||||||
|
-- 2.1) FAC_REPORTING constructor:
|
||||||
|
-- -------------------------------
|
||||||
|
-- * @{Fac#FAC_REPORTING.New}(): Create a new FAC_REPORTING instance.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
-- @module Fac
|
-- @module Fac
|
||||||
-- @author Mechanic : Concept & Testing
|
-- @author Mechanic, Prof_Hilactic, FlightControl : Concept & Testing
|
||||||
-- @author FlightControl : Design & Programming
|
-- @author FlightControl : Design & Programming
|
||||||
|
|
||||||
|
|
||||||
@ -55,6 +69,17 @@ function FAC_BASE:New( ClientSet, Detection )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Reports the detected items to the @{Set#SET_CLIENT}.
|
||||||
|
-- @param #FAC_BASE self
|
||||||
|
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
|
||||||
|
-- @return #FAC_BASE self
|
||||||
|
function FAC_BASE:ReportDetected( DetectedSets )
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Report the detected @{Unit#UNIT}s detected within the @{DetectION#DETECTION_BASE} object to the @{Set#SET_CLIENT}s.
|
--- Report the detected @{Unit#UNIT}s detected within the @{DetectION#DETECTION_BASE} object to the @{Set#SET_CLIENT}s.
|
||||||
-- @param #FAC_BASE self
|
-- @param #FAC_BASE self
|
||||||
@ -65,33 +90,71 @@ function FAC_BASE:_FacScheduler( SchedulerName )
|
|||||||
--- @param Client#CLIENT Client
|
--- @param Client#CLIENT Client
|
||||||
function( Client )
|
function( Client )
|
||||||
if Client:IsAlive() then
|
if Client:IsAlive() then
|
||||||
local DetectedUnitSets = self.Detection:GetDetectionUnitSets()
|
local DetectedSets = self.Detection:GetDetectionSets()
|
||||||
local DetectedMsg = { }
|
return self:ReportDetected( Client, DetectedSets )
|
||||||
for DetectedUnitSetID, DetectedUnitSet in pairs( DetectedUnitSets ) do
|
|
||||||
local UnitSet = DetectedUnitSet -- Set#SET_UNIT
|
|
||||||
local MT = {} -- Message Text
|
|
||||||
local UnitTypes = {}
|
|
||||||
for DetectedUnitID, DetectedUnitData in pairs( UnitSet:GetSet() ) do
|
|
||||||
local DetectedUnit = DetectedUnitData -- Unit#UNIT
|
|
||||||
local UnitType = DetectedUnit:GetTypeName()
|
|
||||||
if not UnitTypes[UnitType] then
|
|
||||||
UnitTypes[UnitType] = 1
|
|
||||||
else
|
|
||||||
UnitTypes[UnitType] = UnitTypes[UnitType] + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for UnitTypeID, UnitType in pairs( UnitTypes ) do
|
|
||||||
MT[#MT+1] = UnitType .. " of " .. UnitTypeID
|
|
||||||
end
|
|
||||||
local MessageText = table.concat( MT, ", " )
|
|
||||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. MessageText
|
|
||||||
end
|
|
||||||
local FACGroup = self.Detection:GetFACGroup()
|
|
||||||
FACGroup:MessageToClient( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), 12, Client )
|
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- FAC_REPORTING
|
||||||
|
|
||||||
|
--- FAC_REPORTING class.
|
||||||
|
-- @type FAC_REPORTING
|
||||||
|
-- @field Set#SET_CLIENT ClientSet The clients to which the FAC will report to.
|
||||||
|
-- @field Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects.
|
||||||
|
-- @extends Set#SET_BASE
|
||||||
|
FAC_REPORTING = {
|
||||||
|
ClassName = "FAC_REPORTING",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- FAC_REPORTING constructor.
|
||||||
|
-- @param #FAC_REPORTING self
|
||||||
|
-- @param Set#SET_CLIENT ClientSet
|
||||||
|
-- @param Detection#DETECTION_BASE Detection
|
||||||
|
-- @return #FAC_REPORTING self
|
||||||
|
function FAC_REPORTING:New( ClientSet, Detection )
|
||||||
|
|
||||||
|
-- Inherits from FAC_BASE
|
||||||
|
local self = BASE:Inherit( self, FAC_BASE:New( ClientSet, Detection ) )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Reports the detected items to the @{Set#SET_CLIENT}.
|
||||||
|
-- @param #FAC_REPORTING self
|
||||||
|
-- @param Client#CLIENT Client The @{Client} object to where the report needs to go.
|
||||||
|
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
|
||||||
|
-- @return #boolean Return true if you want the reporting to continue... false will cancel the reporting loop.
|
||||||
|
function FAC_REPORTING:ReportDetected( Client, DetectedSets )
|
||||||
|
self:F2( Client )
|
||||||
|
DetectedSets:Flush()
|
||||||
|
|
||||||
|
local DetectedMsg = {}
|
||||||
|
for DetectedUnitSetID, DetectedUnitSet in pairs( DetectedSets ) do
|
||||||
|
local UnitSet = DetectedUnitSet -- Set#SET_UNIT
|
||||||
|
local MT = {} -- Message Text
|
||||||
|
local UnitTypes = {}
|
||||||
|
for DetectedUnitID, DetectedUnitData in pairs( UnitSet:GetSet() ) do
|
||||||
|
local DetectedUnit = DetectedUnitData -- Unit#UNIT
|
||||||
|
local UnitType = DetectedUnit:GetTypeName()
|
||||||
|
if not UnitTypes[UnitType] then
|
||||||
|
UnitTypes[UnitType] = 1
|
||||||
|
else
|
||||||
|
UnitTypes[UnitType] = UnitTypes[UnitType] + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for UnitTypeID, UnitType in pairs( UnitTypes ) do
|
||||||
|
MT[#MT+1] = UnitType .. " of " .. UnitTypeID
|
||||||
|
end
|
||||||
|
local MessageText = table.concat( MT, ", " )
|
||||||
|
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. MessageText
|
||||||
|
end
|
||||||
|
local FACGroup = self.Detection:GetFACGroup()
|
||||||
|
FACGroup:MessageToClient( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), 12, Client )
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
@ -150,21 +150,11 @@
|
|||||||
--- The GROUP class
|
--- The GROUP class
|
||||||
-- @type GROUP
|
-- @type GROUP
|
||||||
-- @extends Controllable#CONTROLLABLE
|
-- @extends Controllable#CONTROLLABLE
|
||||||
-- @field DCSGroup#Group DCSGroup The DCS group class.
|
|
||||||
-- @field #string GroupName The name of the group.
|
-- @field #string GroupName The name of the group.
|
||||||
GROUP = {
|
GROUP = {
|
||||||
ClassName = "GROUP",
|
ClassName = "GROUP",
|
||||||
GroupName = "",
|
|
||||||
GroupID = 0,
|
|
||||||
Controller = nil,
|
|
||||||
DCSGroup = nil,
|
|
||||||
WayPointFunctions = {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--- A DCSGroup
|
|
||||||
-- @type DCSGroup
|
|
||||||
-- @field id_ The ID of the group in DCS
|
|
||||||
|
|
||||||
--- Create a new GROUP from a DCSGroup
|
--- Create a new GROUP from a DCSGroup
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param DCSGroup#Group GroupName The DCS Group name
|
-- @param DCSGroup#Group GroupName The DCS Group name
|
||||||
@ -327,40 +317,6 @@ function GROUP:GetCountry()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the name of the DCS Group.
|
|
||||||
-- @param #GROUP self
|
|
||||||
-- @return #string The DCS Group name.
|
|
||||||
function GROUP:GetName()
|
|
||||||
self:F2( self.GroupName )
|
|
||||||
|
|
||||||
local DCSGroup = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSGroup then
|
|
||||||
local GroupName = DCSGroup:getName()
|
|
||||||
self:T3( GroupName )
|
|
||||||
return GroupName
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the DCS Group identifier.
|
|
||||||
-- @param #GROUP self
|
|
||||||
-- @return #number The identifier of the DCS Group.
|
|
||||||
function GROUP:GetID()
|
|
||||||
self:F2( self.GroupName )
|
|
||||||
|
|
||||||
local DCSGroup = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSGroup then
|
|
||||||
local GroupID = DCSGroup:getID()
|
|
||||||
self:T3( GroupID )
|
|
||||||
return GroupID
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the UNIT wrapper class with number UnitNumber.
|
--- Returns the UNIT wrapper class with number UnitNumber.
|
||||||
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
@ -517,11 +473,14 @@ function GROUP:GetCallsign()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group.
|
--- Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group.
|
||||||
|
-- @param #GROUP self
|
||||||
-- @return DCSTypes#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group.
|
-- @return DCSTypes#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group.
|
||||||
function GROUP:GetPointVec2()
|
function GROUP:GetPointVec2()
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
local GroupPointVec2 = self:GetUnit(1):GetPointVec2()
|
local UnitPoint = self:GetUnit(1)
|
||||||
|
UnitPoint:GetPointVec2()
|
||||||
|
local GroupPointVec2 = UnitPoint:GetPointVec2()
|
||||||
self:T3( GroupPointVec2 )
|
self:T3( GroupPointVec2 )
|
||||||
return GroupPointVec2
|
return GroupPointVec2
|
||||||
end
|
end
|
||||||
|
|||||||
205
Moose Development/Moose/Identifiable.lua
Normal file
205
Moose Development/Moose/Identifiable.lua
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
--- This module contains the IDENTIFIABLE class.
|
||||||
|
--
|
||||||
|
-- 1) @{Identifiable#IDENTIFIABLE} class, extends @{Object#OBJECT}
|
||||||
|
-- ===============================================================
|
||||||
|
-- The @{Identifiable#IDENTIFIABLE} class is a wrapper class to handle the DCS Identifiable objects:
|
||||||
|
--
|
||||||
|
-- * Support all DCS Identifiable APIs.
|
||||||
|
-- * Enhance with Identifiable specific APIs not in the DCS Identifiable API set.
|
||||||
|
-- * Manage the "state" of the DCS Identifiable.
|
||||||
|
--
|
||||||
|
-- 1.1) IDENTIFIABLE constructor:
|
||||||
|
-- ------------------------------
|
||||||
|
-- The IDENTIFIABLE class provides the following functions to construct a IDENTIFIABLE instance:
|
||||||
|
--
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.New}(): Create a IDENTIFIABLE instance.
|
||||||
|
--
|
||||||
|
-- 1.2) IDENTIFIABLE methods:
|
||||||
|
-- --------------------------
|
||||||
|
-- The following methods can be used to identify an identifiable object:
|
||||||
|
--
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.GetName}(): Returns the name of the Identifiable.
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.IsAlive}(): Returns if the Identifiable is alive.
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.GetTypeName}(): Returns the type name of the Identifiable.
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.GetCoalition}(): Returns the coalition of the Identifiable.
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.GetCountry}(): Returns the country of the Identifiable.
|
||||||
|
-- * @{Identifiable#IDENTIFIABLE.GetDesc}(): Returns the descriptor structure of the Identifiable.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- @module Identifiable
|
||||||
|
-- @author FlightControl
|
||||||
|
|
||||||
|
--- The IDENTIFIABLE class
|
||||||
|
-- @type IDENTIFIABLE
|
||||||
|
-- @extends Object#OBJECT
|
||||||
|
-- @field #string IdentifiableName The name of the identifiable.
|
||||||
|
IDENTIFIABLE = {
|
||||||
|
ClassName = "IDENTIFIABLE",
|
||||||
|
IdentifiableName = "",
|
||||||
|
}
|
||||||
|
|
||||||
|
local _CategoryName = {
|
||||||
|
[Unit.Category.AIRPLANE] = "Airplane",
|
||||||
|
[Unit.Category.HELICOPTER] = "Helicoper",
|
||||||
|
[Unit.Category.GROUND_UNIT] = "Ground Identifiable",
|
||||||
|
[Unit.Category.SHIP] = "Ship",
|
||||||
|
[Unit.Category.STRUCTURE] = "Structure",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Create a new IDENTIFIABLE from a DCSIdentifiable
|
||||||
|
-- @param #IDENTIFIABLE self
|
||||||
|
-- @param DCSIdentifiable#Identifiable IdentifiableName The DCS Identifiable name
|
||||||
|
-- @return #IDENTIFIABLE self
|
||||||
|
function IDENTIFIABLE:New( IdentifiableName )
|
||||||
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
self:F2( IdentifiableName )
|
||||||
|
self.IdentifiableName = IdentifiableName
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns if the Identifiable is alive.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return #boolean true if Identifiable is alive.
|
||||||
|
-- @return #nil The DCS Identifiable is not existing or alive.
|
||||||
|
function IDENTIFIABLE:IsAlive()
|
||||||
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableIsAlive = DCSIdentifiable:isExist()
|
||||||
|
return IdentifiableIsAlive
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns DCS Identifiable object name.
|
||||||
|
-- The function provides access to non-activated objects too.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return #string The name of the DCS Identifiable.
|
||||||
|
-- @return #nil The DCS Identifiable is not existing or alive.
|
||||||
|
function IDENTIFIABLE:GetName()
|
||||||
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableName = self.IdentifiableName
|
||||||
|
return IdentifiableName
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.IdentifiableName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns the type name of the DCS Identifiable.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return #string The type name of the DCS Identifiable.
|
||||||
|
-- @return #nil The DCS Identifiable is not existing or alive.
|
||||||
|
function IDENTIFIABLE:GetTypeName()
|
||||||
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableTypeName = DCSIdentifiable:getTypeName()
|
||||||
|
self:T3( IdentifiableTypeName )
|
||||||
|
return IdentifiableTypeName
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.IdentifiableName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns the DCS Identifiable category name as defined within the DCS Identifiable Descriptor.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return #string The DCS Identifiable Category Name
|
||||||
|
function IDENTIFIABLE:GetCategoryName()
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableCategoryName = _CategoryName[ self:GetDesc().category ]
|
||||||
|
return IdentifiableCategoryName
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.IdentifiableName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns coalition of the Identifiable.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return DCSCoalitionObject#coalition.side The side of the coalition.
|
||||||
|
-- @return #nil The DCS Identifiable is not existing or alive.
|
||||||
|
function IDENTIFIABLE:GetCoalition()
|
||||||
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableCoalition = DCSIdentifiable:getCoalition()
|
||||||
|
self:T3( IdentifiableCoalition )
|
||||||
|
return IdentifiableCoalition
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.IdentifiableName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns country of the Identifiable.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return DCScountry#country.id The country identifier.
|
||||||
|
-- @return #nil The DCS Identifiable is not existing or alive.
|
||||||
|
function IDENTIFIABLE:GetCountry()
|
||||||
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableCountry = DCSIdentifiable:getCountry()
|
||||||
|
self:T3( IdentifiableCountry )
|
||||||
|
return IdentifiableCountry
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.IdentifiableName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns Identifiable descriptor. Descriptor type depends on Identifiable category.
|
||||||
|
-- @param Identifiable#IDENTIFIABLE self
|
||||||
|
-- @return DCSIdentifiable#Identifiable.Desc The Identifiable descriptor.
|
||||||
|
-- @return #nil The DCS Identifiable is not existing or alive.
|
||||||
|
function IDENTIFIABLE:GetDesc()
|
||||||
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
|
local DCSIdentifiable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSIdentifiable then
|
||||||
|
local IdentifiableDesc = DCSIdentifiable:getDesc()
|
||||||
|
self:T2( IdentifiableDesc )
|
||||||
|
return IdentifiableDesc
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.IdentifiableName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
Include.File( "Routines" )
|
Include.File( "Routines" )
|
||||||
Include.File( "Base" )
|
Include.File( "Base" )
|
||||||
|
Include.File( "Object" )
|
||||||
|
Include.File( "Identifiable" )
|
||||||
|
Include.File( "Positionable" )
|
||||||
|
Include.File( "Controllable" )
|
||||||
Include.File( "Scheduler" )
|
Include.File( "Scheduler" )
|
||||||
Include.File( "Event" )
|
Include.File( "Event" )
|
||||||
Include.File( "Menu" )
|
Include.File( "Menu" )
|
||||||
|
|||||||
213
Moose Development/Moose/Object.lua
Normal file
213
Moose Development/Moose/Object.lua
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
--- This module contains the OBJECT class.
|
||||||
|
--
|
||||||
|
-- 1) @{Object#OBJECT} class, extends @{Base#BASE}
|
||||||
|
-- ===========================================================
|
||||||
|
-- The @{Object#OBJECT} class is a wrapper class to handle the DCS Object objects:
|
||||||
|
--
|
||||||
|
-- * Support all DCS Object APIs.
|
||||||
|
-- * Enhance with Object specific APIs not in the DCS Object API set.
|
||||||
|
-- * Manage the "state" of the DCS Object.
|
||||||
|
--
|
||||||
|
-- 1.1) OBJECT constructor:
|
||||||
|
-- ------------------------------
|
||||||
|
-- The OBJECT class provides the following functions to construct a OBJECT instance:
|
||||||
|
--
|
||||||
|
-- * @{Object#OBJECT.New}(): Create a OBJECT instance.
|
||||||
|
--
|
||||||
|
-- 1.2) OBJECT methods:
|
||||||
|
-- --------------------------
|
||||||
|
-- The following methods can be used to identify an Object object:
|
||||||
|
--
|
||||||
|
-- * @{Object#OBJECT.GetID}(): Returns the ID of the Object object.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- @module Object
|
||||||
|
-- @author FlightControl
|
||||||
|
|
||||||
|
--- The OBJECT class
|
||||||
|
-- @type OBJECT
|
||||||
|
-- @extends Base#BASE
|
||||||
|
-- @field #string ObjectName The name of the Object.
|
||||||
|
OBJECT = {
|
||||||
|
ClassName = "OBJECT",
|
||||||
|
ObjectName = "",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--- A DCSObject
|
||||||
|
-- @type DCSObject
|
||||||
|
-- @field id_ The ID of the controllable in DCS
|
||||||
|
|
||||||
|
--- Create a new OBJECT from a DCSObject
|
||||||
|
-- @param #OBJECT self
|
||||||
|
-- @param DCSObject#Object ObjectName The Object name
|
||||||
|
-- @return #OBJECT self
|
||||||
|
function OBJECT:New( ObjectName )
|
||||||
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
self:F2( ObjectName )
|
||||||
|
self.ObjectName = ObjectName
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns if the Object is alive.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return #boolean true if Object is alive.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:IsAlive()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectIsAlive = DCSObject:isExist()
|
||||||
|
return ObjectIsAlive
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns DCS Object object name.
|
||||||
|
-- The function provides access to non-activated objects too.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return #string The name of the DCS Object.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:GetName()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectName = self.ObjectName
|
||||||
|
return ObjectName
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns the type name of the DCS Object.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return #string The type name of the DCS Object.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:GetTypeName()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectTypeName = DCSObject:getTypeName()
|
||||||
|
self:T3( ObjectTypeName )
|
||||||
|
return ObjectTypeName
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the Object's callsign - the localized string.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return #string The Callsign of the Object.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:GetCallSign()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectCallSign = DCSObject:getCallsign()
|
||||||
|
return ObjectCallSign
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns the DCS Object category name as defined within the DCS Object Descriptor.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return #string The DCS Object Category Name
|
||||||
|
function OBJECT:GetCategoryName()
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectCategoryName = _CategoryName[ self:GetDesc().category ]
|
||||||
|
return ObjectCategoryName
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns coalition of the Object.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return DCSCoalitionObject#coalition.side The side of the coalition.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:GetCoalition()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectCoalition = DCSObject:getCoalition()
|
||||||
|
self:T3( ObjectCoalition )
|
||||||
|
return ObjectCoalition
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns country of the Object.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return DCScountry#country.id The country identifier.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:GetCountry()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectCountry = DCSObject:getCountry()
|
||||||
|
self:T3( ObjectCountry )
|
||||||
|
return ObjectCountry
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns Object descriptor. Descriptor type depends on Object category.
|
||||||
|
-- @param Object#OBJECT self
|
||||||
|
-- @return DCSObject#Object.Desc The Object descriptor.
|
||||||
|
-- @return #nil The DCS Object is not existing or alive.
|
||||||
|
function OBJECT:GetDesc()
|
||||||
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSObject then
|
||||||
|
local ObjectDesc = DCSObject:getDesc()
|
||||||
|
self:T2( ObjectDesc )
|
||||||
|
return ObjectDesc
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.ObjectName .. " not found!" )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
213
Moose Development/Moose/Positionable.lua
Normal file
213
Moose Development/Moose/Positionable.lua
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
--- This module contains the POSITIONABLE class.
|
||||||
|
--
|
||||||
|
-- 1) @{Positionable#POSITIONABLE} class, extends @{Identifiable#IDENTIFIABLE}
|
||||||
|
-- ===========================================================
|
||||||
|
-- The @{Positionable#POSITIONABLE} class is a wrapper class to handle the DCS Positionable objects:
|
||||||
|
--
|
||||||
|
-- * Support all DCS Positionable APIs.
|
||||||
|
-- * Enhance with Positionable specific APIs not in the DCS Positionable API set.
|
||||||
|
-- * Manage the "state" of the DCS Positionable.
|
||||||
|
--
|
||||||
|
-- 1.1) POSITIONABLE constructor:
|
||||||
|
-- ------------------------------
|
||||||
|
-- The POSITIONABLE class provides the following functions to construct a POSITIONABLE instance:
|
||||||
|
--
|
||||||
|
-- * @{Positionable#POSITIONABLE.New}(): Create a POSITIONABLE instance.
|
||||||
|
--
|
||||||
|
-- 1.2) POSITIONABLE methods:
|
||||||
|
-- --------------------------
|
||||||
|
-- The following methods can be used to identify an measurable object:
|
||||||
|
--
|
||||||
|
-- * @{Positionable#POSITIONABLE.GetID}(): Returns the ID of the measurable object.
|
||||||
|
-- * @{Positionable#POSITIONABLE.GetName}(): Returns the name of the measurable object.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- @module Positionable
|
||||||
|
-- @author FlightControl
|
||||||
|
|
||||||
|
--- The POSITIONABLE class
|
||||||
|
-- @type POSITIONABLE
|
||||||
|
-- @extends Identifiable#IDENTIFIABLE
|
||||||
|
-- @field #string PositionableName The name of the measurable.
|
||||||
|
POSITIONABLE = {
|
||||||
|
ClassName = "POSITIONABLE",
|
||||||
|
PositionableName = "",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- A DCSPositionable
|
||||||
|
-- @type DCSPositionable
|
||||||
|
-- @field id_ The ID of the controllable in DCS
|
||||||
|
|
||||||
|
--- Create a new POSITIONABLE from a DCSPositionable
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param DCSPositionable#Positionable PositionableName The DCS Positionable name
|
||||||
|
-- @return #POSITIONABLE self
|
||||||
|
function POSITIONABLE:New( PositionableName )
|
||||||
|
local self = BASE:Inherit( self, IDENTIFIABLE:New( PositionableName ) )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the @{DCSTypes#Position3} position vectors indicating the point and direction vectors in 3D of the DCS Positionable within the mission.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return DCSTypes#Position The 3D position vectors of the DCS Positionable.
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:GetPositionVec3()
|
||||||
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
local PositionablePosition = DCSPositionable:getPosition()
|
||||||
|
self:T3( PositionablePosition )
|
||||||
|
return PositionablePosition
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the @{DCSTypes#Vec2} vector indicating the point in 2D of the DCS Positionable within the mission.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return DCSTypes#Vec2 The 2D point vector of the DCS Positionable.
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:GetPointVec2()
|
||||||
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
local PositionablePointVec3 = DCSPositionable:getPosition().p
|
||||||
|
|
||||||
|
local PositionablePointVec2 = {}
|
||||||
|
PositionablePointVec2.x = PositionablePointVec3.x
|
||||||
|
PositionablePointVec2.y = PositionablePointVec3.z
|
||||||
|
|
||||||
|
self:T2( PositionablePointVec2 )
|
||||||
|
return PositionablePointVec2
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns the @{DCSTypes#Vec3} vector indicating the point in 3D of the DCS Positionable within the mission.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return DCSTypes#Vec3 The 3D point vector of the DCS Positionable.
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:GetPointVec3()
|
||||||
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
local PositionablePointVec3 = DCSPositionable:getPosition().p
|
||||||
|
self:T3( PositionablePointVec3 )
|
||||||
|
return PositionablePointVec3
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the altitude of the DCS Positionable.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return DCSTypes#Distance The altitude of the DCS Positionable.
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:GetAltitude()
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
local PositionablePointVec3 = DCSPositionable:getPoint() --DCSTypes#Vec3
|
||||||
|
return PositionablePointVec3.y
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns if the Positionable is located above a runway.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return #boolean true if Positionable is above a runway.
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:IsAboveRunway()
|
||||||
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
|
||||||
|
local PointVec2 = self:GetPointVec2()
|
||||||
|
local SurfaceType = land.getSurfaceType( PointVec2 )
|
||||||
|
local IsAboveRunway = SurfaceType == land.SurfaceType.RUNWAY
|
||||||
|
|
||||||
|
self:T2( IsAboveRunway )
|
||||||
|
return IsAboveRunway
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns the DCS Positionable heading.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return #number The DCS Positionable heading
|
||||||
|
function POSITIONABLE:GetHeading()
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
|
||||||
|
local PositionablePosition = DCSPositionable:getPosition()
|
||||||
|
if PositionablePosition then
|
||||||
|
local PositionableHeading = math.atan2( PositionablePosition.x.z, PositionablePosition.x.x )
|
||||||
|
if PositionableHeading < 0 then
|
||||||
|
PositionableHeading = PositionableHeading + 2 * math.pi
|
||||||
|
end
|
||||||
|
self:T2( PositionableHeading )
|
||||||
|
return PositionableHeading
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns true if the DCS Positionable is in the air.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return #boolean true if in the air.
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:InAir()
|
||||||
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
local PositionableInAir = DCSPositionable:inAir()
|
||||||
|
self:T3( PositionableInAir )
|
||||||
|
return PositionableInAir
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the DCS Positionable velocity vector.
|
||||||
|
-- @param Positionable#POSITIONABLE self
|
||||||
|
-- @return DCSTypes#Vec3 The velocity vector
|
||||||
|
-- @return #nil The DCS Positionable is not existing or alive.
|
||||||
|
function POSITIONABLE:GetVelocity()
|
||||||
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSPositionable then
|
||||||
|
local PositionableVelocityVec3 = DCSPositionable:getVelocity()
|
||||||
|
self:T3( PositionableVelocityVec3 )
|
||||||
|
return PositionableVelocityVec3
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
--- This module contains the STATIC class.
|
--- This module contains the STATIC class.
|
||||||
--
|
--
|
||||||
-- 1) @{Static#STATIC} class, extends @{Unit#UNIT}
|
-- 1) @{Static#STATIC} class, extends @{Positionable#POSITIONABLE}
|
||||||
-- ===============================================
|
-- ===============================================================
|
||||||
-- Statics are **Static Units** defined within the Mission Editor.
|
-- Statics are **Static Units** defined within the Mission Editor.
|
||||||
-- Note that Statics are almost the same as Units, but they don't have a controller.
|
-- Note that Statics are almost the same as Units, but they don't have a controller.
|
||||||
-- The @{Static#STATIC} class is a wrapper class to handle the DCS Static objects:
|
-- The @{Static#STATIC} class is a wrapper class to handle the DCS Static objects:
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
--- The STATIC class
|
--- The STATIC class
|
||||||
-- @type STATIC
|
-- @type STATIC
|
||||||
-- @extends Unit#UNIT
|
-- @extends Positionable#POSITIONABLE
|
||||||
STATIC = {
|
STATIC = {
|
||||||
ClassName = "STATIC",
|
ClassName = "STATIC",
|
||||||
}
|
}
|
||||||
@ -62,10 +62,7 @@ function STATIC:FindByName( StaticName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function STATIC:Register( StaticName )
|
function STATIC:Register( StaticName )
|
||||||
local self = BASE:Inherit( self, UNIT:Register( StaticName ) )
|
local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) )
|
||||||
|
|
||||||
self:F( StaticName )
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -79,13 +79,6 @@
|
|||||||
-- @field #UNIT.SmokeColor SmokeColor
|
-- @field #UNIT.SmokeColor SmokeColor
|
||||||
UNIT = {
|
UNIT = {
|
||||||
ClassName="UNIT",
|
ClassName="UNIT",
|
||||||
CategoryName = {
|
|
||||||
[Unit.Category.AIRPLANE] = "Airplane",
|
|
||||||
[Unit.Category.HELICOPTER] = "Helicoper",
|
|
||||||
[Unit.Category.GROUND_UNIT] = "Ground Unit",
|
|
||||||
[Unit.Category.SHIP] = "Ship",
|
|
||||||
[Unit.Category.STRUCTURE] = "Structure",
|
|
||||||
},
|
|
||||||
FlareColor = {
|
FlareColor = {
|
||||||
Green = trigger.flareColor.Green,
|
Green = trigger.flareColor.Green,
|
||||||
Red = trigger.flareColor.Red,
|
Red = trigger.flareColor.Red,
|
||||||
@ -120,13 +113,10 @@ UNIT = {
|
|||||||
|
|
||||||
--- Create a new UNIT from DCSUnit.
|
--- Create a new UNIT from DCSUnit.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param DCSUnit#Unit DCSUnit
|
-- @param #string UnitName The name of the DCS unit.
|
||||||
-- @param Database#DATABASE Database
|
|
||||||
-- @return Unit#UNIT
|
-- @return Unit#UNIT
|
||||||
function UNIT:Register( UnitName )
|
function UNIT:Register( UnitName )
|
||||||
|
local self = BASE:Inherit( self, CONTROLLABLE:New( UnitName ) )
|
||||||
local self = BASE:Inherit( self, CONTROLLABLE:New() )
|
|
||||||
self:F2( UnitName )
|
|
||||||
self.UnitName = UnitName
|
self.UnitName = UnitName
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -168,78 +158,8 @@ function UNIT:GetDCSObject()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns coalition of the Unit.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSCoalitionObject#coalition.side The side of the coalition.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetCoalition()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitCoalition = DCSUnit:getCoalition()
|
|
||||||
self:T3( UnitCoalition )
|
|
||||||
return UnitCoalition
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns country of the Unit.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCScountry#country.id The country identifier.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetCountry()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitCountry = DCSUnit:getCountry()
|
|
||||||
self:T3( UnitCountry )
|
|
||||||
return UnitCountry
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns DCS Unit object name.
|
|
||||||
-- The function provides access to non-activated units too.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #string The name of the DCS Unit.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetName()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitName = self.UnitName
|
|
||||||
return UnitName
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the unit is alive.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #boolean true if Unit is alive.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:IsAlive()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitIsAlive = DCSUnit:isExist()
|
|
||||||
return UnitIsAlive
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns if the unit is activated.
|
--- Returns if the unit is activated.
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
@ -259,30 +179,25 @@ function UNIT:IsActive()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns if the unit is located above a runway.
|
--- Returns the Unit's callsign - the localized string.
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
-- @return #boolean true if Unit is above a runway.
|
-- @return #string The Callsign of the Unit.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:IsAboveRunway()
|
function UNIT:GetCallSign()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
|
local UnitCallSign = DCSUnit:getCallsign()
|
||||||
local PointVec2 = self:GetPointVec2()
|
return UnitCallSign
|
||||||
local SurfaceType = land.getSurfaceType( PointVec2 )
|
|
||||||
local IsAboveRunway = SurfaceType == land.SurfaceType.RUNWAY
|
|
||||||
|
|
||||||
self:T2( IsAboveRunway )
|
|
||||||
return IsAboveRunway
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:E( self.ClassName .. " " .. self.UnitName .. " not found!" )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns name of the player that control the unit or nil if the unit is controlled by A.I.
|
--- Returns name of the player that control the unit or nil if the unit is controlled by A.I.
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
-- @return #string Player Name
|
-- @return #string Player Name
|
||||||
@ -304,23 +219,6 @@ function UNIT:GetPlayerName()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the unit's unique identifier.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSUnit#Unit.ID Unit ID
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetID()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitID = DCSUnit:getID()
|
|
||||||
return UnitID
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the unit's number in the group.
|
--- Returns the unit's number in the group.
|
||||||
-- The number is the same number the unit has in ME.
|
-- The number is the same number the unit has in ME.
|
||||||
-- It may not be changed during the mission.
|
-- It may not be changed during the mission.
|
||||||
@ -359,69 +257,23 @@ function UNIT:GetGroup()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the unit's callsign - the localized string.
|
-- Need to add here functions to check if radar is on and which object etc.
|
||||||
|
|
||||||
|
--- Returns the prefix name of the DCS Unit. A prefix name is a part of the name before a '#'-sign.
|
||||||
|
-- DCS Units spawned with the @{SPAWN} class contain a '#'-sign to indicate the end of the (base) DCS Unit name.
|
||||||
|
-- The spawn sequence number and unit number are contained within the name after the '#' sign.
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
-- @return #string The Callsign of the Unit.
|
-- @return #string The name of the DCS Unit.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:GetCallSign()
|
function UNIT:GetPrefix()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitCallSign = DCSUnit:getCallsign()
|
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
|
||||||
return UnitCallSign
|
self:T3( UnitPrefix )
|
||||||
end
|
return UnitPrefix
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the unit's health. Dead units has health <= 1.0.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #number The Unit's health value.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetLife()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitLife = DCSUnit:getLife()
|
|
||||||
return UnitLife
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the Unit's initial health.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #number The Unit's initial health value.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetLife0()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitLife0 = DCSUnit:getLife0()
|
|
||||||
return UnitLife0
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #number The relative amount of fuel (from 0.0 to 1.0).
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetFuel()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitFuel = DCSUnit:getFuel()
|
|
||||||
return UnitFuel
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -485,63 +337,52 @@ function UNIT:GetRadar()
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Need to add here functions to check if radar is on and which object etc.
|
--- Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0.
|
||||||
|
|
||||||
--- Returns unit descriptor. Descriptor type depends on unit category.
|
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
-- @return DCSUnit#Unit.Desc The Unit descriptor.
|
-- @return #number The relative amount of fuel (from 0.0 to 1.0).
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:GetDesc()
|
function UNIT:GetFuel()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitDesc = DCSUnit:getDesc()
|
local UnitFuel = DCSUnit:getFuel()
|
||||||
self:T2( UnitDesc )
|
return UnitFuel
|
||||||
return UnitDesc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:E( "Unit " .. self.UnitName .. "not found!" )
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the unit's health. Dead units has health <= 1.0.
|
||||||
--- Returns the type name of the DCS Unit.
|
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
-- @return #string The type name of the DCS Unit.
|
-- @return #number The Unit's health value.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:GetTypeName()
|
function UNIT:GetLife()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitTypeName = DCSUnit:getTypeName()
|
local UnitLife = DCSUnit:getLife()
|
||||||
self:T3( UnitTypeName )
|
return UnitLife
|
||||||
return UnitTypeName
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the Unit's initial health.
|
||||||
|
|
||||||
--- Returns the prefix name of the DCS Unit. A prefix name is a part of the name before a '#'-sign.
|
|
||||||
-- DCS Units spawned with the @{SPAWN} class contain a '#'-sign to indicate the end of the (base) DCS Unit name.
|
|
||||||
-- The spawn sequence number and unit number are contained within the name after the '#' sign.
|
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
-- @return #string The name of the DCS Unit.
|
-- @return #number The Unit's initial health value.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
-- @return #nil The DCS Unit is not existing or alive.
|
||||||
function UNIT:GetPrefix()
|
function UNIT:GetLife0()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
|
local UnitLife0 = DCSUnit:getLife0()
|
||||||
self:T3( UnitPrefix )
|
return UnitLife0
|
||||||
return UnitPrefix
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -549,83 +390,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the @{DCSTypes#Vec2} vector indicating the point in 2D of the DCS Unit within the mission.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSTypes#Vec2 The 2D point vector of the DCS Unit.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetPointVec2()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitPointVec3 = DCSUnit:getPosition().p
|
|
||||||
|
|
||||||
local UnitPointVec2 = {}
|
|
||||||
UnitPointVec2.x = UnitPointVec3.x
|
|
||||||
UnitPointVec2.y = UnitPointVec3.z
|
|
||||||
|
|
||||||
self:T2( UnitPointVec2 )
|
|
||||||
return UnitPointVec2
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the @{DCSTypes#Vec3} vector indicating the point in 3D of the DCS Unit within the mission.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSTypes#Vec3 The 3D point vector of the DCS Unit.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetPointVec3()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitPointVec3 = DCSUnit:getPosition().p
|
|
||||||
self:T3( UnitPointVec3 )
|
|
||||||
return UnitPointVec3
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the @{DCSTypes#Position3} position vectors indicating the point and direction vectors in 3D of the DCS Unit within the mission.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSTypes#Position The 3D position vectors of the DCS Unit.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetPositionVec3()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitPosition = DCSUnit:getPosition()
|
|
||||||
self:T3( UnitPosition )
|
|
||||||
return UnitPosition
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the DCS Unit velocity vector.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSTypes#Vec3 The velocity vector
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetVelocity()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitVelocityVec3 = DCSUnit:getVelocity()
|
|
||||||
self:T3( UnitVelocityVec3 )
|
|
||||||
return UnitVelocityVec3
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Is functions
|
-- Is functions
|
||||||
|
|
||||||
@ -663,40 +427,6 @@ function UNIT:IsNotInZone( Zone )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns true if the DCS Unit is in the air.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #boolean true if in the air.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:InAir()
|
|
||||||
self:F2( self.UnitName )
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitInAir = DCSUnit:inAir()
|
|
||||||
self:T3( UnitInAir )
|
|
||||||
return UnitInAir
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the altitude of the DCS Unit.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return DCSTypes#Distance The altitude of the DCS Unit.
|
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetAltitude()
|
|
||||||
self:F2()
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitPointVec3 = DCSUnit:getPoint() --DCSTypes#Vec3
|
|
||||||
return UnitPointVec3.y
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns true if there is an **other** DCS Unit within a radius of the current 2D point of the DCS Unit.
|
--- Returns true if there is an **other** DCS Unit within a radius of the current 2D point of the DCS Unit.
|
||||||
-- @param Unit#UNIT self
|
-- @param Unit#UNIT self
|
||||||
@ -725,41 +455,6 @@ function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the DCS Unit category name as defined within the DCS Unit Descriptor.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #string The DCS Unit Category Name
|
|
||||||
function UNIT:GetCategoryName()
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
local UnitCategoryName = self.CategoryName[ self:GetDesc().category ]
|
|
||||||
return UnitCategoryName
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the DCS Unit heading.
|
|
||||||
-- @param Unit#UNIT self
|
|
||||||
-- @return #number The DCS Unit heading
|
|
||||||
function UNIT:GetHeading()
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
|
|
||||||
local UnitPosition = DCSUnit:getPosition()
|
|
||||||
if UnitPosition then
|
|
||||||
local UnitHeading = math.atan2( UnitPosition.x.z, UnitPosition.x.x )
|
|
||||||
if UnitHeading < 0 then
|
|
||||||
UnitHeading = UnitHeading + 2 * math.pi
|
|
||||||
end
|
|
||||||
self:T2( UnitHeading )
|
|
||||||
return UnitHeading
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Signal a flare at the position of the UNIT.
|
--- Signal a flare at the position of the UNIT.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
local FACGroup = GROUP:FindByName( "FAC Group" )
|
local FACGroup = GROUP:FindByName( "FAC Group" )
|
||||||
|
|
||||||
local FACDetection = DETECTION_BASE:New( FACGroup, 1000, 250 )
|
local FACDetection = DETECTION_UNITGROUPS:New( FACGroup, 1000, 250 )
|
||||||
local FACClientSet = SET_CLIENT:New():FilterCoalitions( "blue" ):FilterStart()
|
local FACClientSet = SET_CLIENT:New():FilterCoalitions( "blue" ):FilterStart()
|
||||||
|
|
||||||
local FACReporting = FAC_BASE:New( FACClientSet, FACDetection )
|
local FACReporting = FAC_REPORTING:New( FACClientSet, FACDetection )
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user