mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Publishing a working version :-)
This commit is contained in:
@@ -380,12 +380,12 @@ end
|
||||
--- Trace a function call. Must be at the beginning of the function logic.
|
||||
-- @param #BASE self
|
||||
-- @param Arguments A #table or any field.
|
||||
function BASE:F( Arguments )
|
||||
function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
|
||||
|
||||
if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
|
||||
|
||||
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = debug.getinfo( 3, "l" )
|
||||
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
|
||||
|
||||
local Function = "function"
|
||||
if DebugInfoCurrent.name then
|
||||
@@ -408,8 +408,11 @@ end
|
||||
-- @param Arguments A #table or any field.
|
||||
function BASE:F2( Arguments )
|
||||
|
||||
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = debug.getinfo( 3, "l" )
|
||||
|
||||
if _TraceLevel >= 2 then
|
||||
self:F( Arguments )
|
||||
self:F( Arguments, DebugInfoCurrent, DebugInfoFrom )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -419,8 +422,11 @@ end
|
||||
-- @param Arguments A #table or any field.
|
||||
function BASE:F3( Arguments )
|
||||
|
||||
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = debug.getinfo( 3, "l" )
|
||||
|
||||
if _TraceLevel >= 3 then
|
||||
self:F( Arguments )
|
||||
self:F( Arguments, DebugInfoCurrent, DebugInfoFrom )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -428,12 +434,12 @@ end
|
||||
--- Trace a function logic. Can be anywhere within the function logic.
|
||||
-- @param #BASE self
|
||||
-- @param Arguments A #table or any field.
|
||||
function BASE:T( Arguments )
|
||||
function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
|
||||
|
||||
if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
|
||||
|
||||
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = debug.getinfo( 3, "l" )
|
||||
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
|
||||
|
||||
local Function = "function"
|
||||
if DebugInfoCurrent.name then
|
||||
@@ -456,8 +462,11 @@ end
|
||||
-- @param Arguments A #table or any field.
|
||||
function BASE:T2( Arguments )
|
||||
|
||||
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = debug.getinfo( 3, "l" )
|
||||
|
||||
if _TraceLevel >= 2 then
|
||||
self:T( Arguments )
|
||||
self:T( Arguments, DebugInfoCurrent, DebugInfoFrom )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -467,8 +476,11 @@ end
|
||||
-- @param Arguments A #table or any field.
|
||||
function BASE:T3( Arguments )
|
||||
|
||||
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
|
||||
local DebugInfoFrom = debug.getinfo( 3, "l" )
|
||||
|
||||
if _TraceLevel >= 3 then
|
||||
self:T( Arguments )
|
||||
self:T( Arguments, DebugInfoCurrent, DebugInfoFrom )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -36,9 +36,11 @@ Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
Include.File( "Menu" )
|
||||
Include.File( "Group" )
|
||||
Include.File( "Static" )
|
||||
Include.File( "Unit" )
|
||||
Include.File( "Event" )
|
||||
Include.File( "Client" )
|
||||
Include.File( "Scheduler" )
|
||||
|
||||
|
||||
--- DATABASE class
|
||||
@@ -54,7 +56,9 @@ DATABASE = {
|
||||
},
|
||||
DCSUnits = {},
|
||||
DCSGroups = {},
|
||||
DCSStatics = {},
|
||||
UNITS = {},
|
||||
STATICS = {},
|
||||
GROUPS = {},
|
||||
PLAYERS = {},
|
||||
PLAYERSALIVE = {},
|
||||
@@ -100,7 +104,8 @@ function DATABASE:New()
|
||||
_EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
|
||||
|
||||
self:_RegisterTemplates()
|
||||
self:_RegisterDatabase()
|
||||
self:_RegisterGroupsAndUnits()
|
||||
self:_RegisterStatics()
|
||||
self:_RegisterPlayers()
|
||||
|
||||
return self
|
||||
@@ -133,6 +138,32 @@ function DATABASE:DeleteUnit( DCSUnitName )
|
||||
self.DCSUnits[DCSUnitName] = nil
|
||||
end
|
||||
|
||||
--- Adds a Static based on the Static Name in the DATABASE.
|
||||
-- @param #DATABASE self
|
||||
function DATABASE:AddStatic( DCSStatic, DCSStaticName )
|
||||
|
||||
self.DCSStatics[DCSStaticName] = DCSStatic
|
||||
self.STATICS[DCSStaticName] = STATIC:Register( DCSStaticName )
|
||||
end
|
||||
|
||||
|
||||
--- Deletes a Static from the DATABASE based on the Static Name.
|
||||
-- @param #DATABASE self
|
||||
function DATABASE:DeleteStatic( DCSStaticName )
|
||||
|
||||
self.DCSStatics[DCSStaticName] = nil
|
||||
end
|
||||
|
||||
--- Finds a STATIC based on the StaticName.
|
||||
-- @param #DATABASE self
|
||||
-- @param #string StaticName
|
||||
-- @return Static#STATIC The found STATIC.
|
||||
function DATABASE:FindStatic( StaticName )
|
||||
|
||||
local StaticFound = self.STATICS[StaticName]
|
||||
return StaticFound
|
||||
end
|
||||
|
||||
|
||||
--- Finds a CLIENT based on the ClientName.
|
||||
-- @param #DATABASE self
|
||||
@@ -220,6 +251,8 @@ function DATABASE:Spawn( SpawnTemplate )
|
||||
SpawnTemplate.SpawnCategoryID = nil
|
||||
|
||||
self:_RegisterTemplate( SpawnTemplate )
|
||||
|
||||
self:T3( SpawnTemplate )
|
||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||
|
||||
-- Restore
|
||||
@@ -227,7 +260,6 @@ function DATABASE:Spawn( SpawnTemplate )
|
||||
SpawnTemplate.SpawnCountryID = SpawnCountryID
|
||||
SpawnTemplate.SpawnCategoryID = SpawnCategoryID
|
||||
|
||||
|
||||
local SpawnGroup = GROUP:Register( SpawnTemplate.name )
|
||||
return SpawnGroup
|
||||
end
|
||||
@@ -320,10 +352,10 @@ function DATABASE:_RegisterPlayers()
|
||||
end
|
||||
|
||||
|
||||
--- Private method that registers all datapoints within in the mission.
|
||||
--- Private method that registers all Groups and Units within in the mission.
|
||||
-- @param #DATABASE self
|
||||
-- @return #DATABASE self
|
||||
function DATABASE:_RegisterDatabase()
|
||||
function DATABASE:_RegisterGroupsAndUnits()
|
||||
|
||||
local CoalitionsData = { GroupsRed = coalition.getGroups( coalition.side.RED ), GroupsBlue = coalition.getGroups( coalition.side.BLUE ) }
|
||||
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
||||
@@ -356,6 +388,27 @@ function DATABASE:_RegisterDatabase()
|
||||
return self
|
||||
end
|
||||
|
||||
function DATABASE:_RegisterStatics()
|
||||
|
||||
local CoalitionsData = { GroupsRed = coalition.getStaticObjects( coalition.side.RED ), GroupsBlue = coalition.getStaticObjects( coalition.side.BLUE ) }
|
||||
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
||||
for DCSStaticId, DCSStatic in pairs( CoalitionData ) do
|
||||
|
||||
if DCSStatic:isExist() then
|
||||
local DCSStaticName = DCSStatic:getName()
|
||||
|
||||
self:E( { "Register Static:", DCSStatic, DCSStaticName } )
|
||||
self:AddStatic( DCSStatic, DCSStaticName )
|
||||
else
|
||||
self:E( { "Static does not exist: ", DCSStatic } )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Events
|
||||
|
||||
--- Handles the OnBirth event for the alive units set.
|
||||
|
||||
195
Moose Development/Moose/Point.lua
Normal file
195
Moose Development/Moose/Point.lua
Normal file
@@ -0,0 +1,195 @@
|
||||
--- This module contains the POINT classes.
|
||||
--
|
||||
-- 1) @{Point#POINT_VEC3} class, extends @{Base#BASE}
|
||||
-- ===============================================
|
||||
-- The @{Point#POINT_VEC3} class defines a 3D point in the simulator.
|
||||
--
|
||||
-- 1.1) POINT_VEC3 constructor
|
||||
-- ---------------------------
|
||||
--
|
||||
-- A new POINT instance can be created with:
|
||||
--
|
||||
-- * @{#POINT_VEC3.New}(): a 3D point.
|
||||
--
|
||||
-- 2) @{Point#POINT_VEC2} class, extends @{Point#POINT_VEC3}
|
||||
-- =========================================================
|
||||
-- The @{Point#POINT_VEC2} class defines a 2D point in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified.
|
||||
--
|
||||
-- 2.1) POINT_VEC2 constructor
|
||||
-- ---------------------------
|
||||
--
|
||||
-- A new POINT instance can be created with:
|
||||
--
|
||||
-- * @{#POINT_VEC2.New}(): a 2D point.
|
||||
--
|
||||
-- @module Point
|
||||
-- @author FlightControl
|
||||
|
||||
Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
Include.File( "Point" )
|
||||
|
||||
--- The POINT_VEC3 class
|
||||
-- @type POINT_VEC3
|
||||
-- @extends Base#BASE
|
||||
-- @field #POINT_VEC3.SmokeColor SmokeColor
|
||||
-- @field #POINT_VEC3.FlareColor FlareColor
|
||||
POINT_VEC3 = {
|
||||
ClassName = "POINT_VEC3",
|
||||
SmokeColor = {
|
||||
Green = trigger.smokeColor.Green,
|
||||
Red = trigger.smokeColor.Red,
|
||||
White = trigger.smokeColor.White,
|
||||
Orange = trigger.smokeColor.Orange,
|
||||
Blue = trigger.smokeColor.Blue
|
||||
},
|
||||
FlareColor = {
|
||||
Green = trigger.flareColor.Green,
|
||||
Red = trigger.flareColor.Red,
|
||||
White = trigger.flareColor.White,
|
||||
Yellow = trigger.flareColor.Yellow
|
||||
},
|
||||
}
|
||||
|
||||
--- SmokeColor
|
||||
-- @type POINT_VEC3.SmokeColor
|
||||
-- @field Green
|
||||
-- @field Red
|
||||
-- @field White
|
||||
-- @field Orange
|
||||
-- @field Blue
|
||||
|
||||
--- FlareColor
|
||||
-- @type POINT_VEC3.FlareColor
|
||||
-- @field Green
|
||||
-- @field Red
|
||||
-- @field White
|
||||
-- @field Yellow
|
||||
|
||||
-- Constructor.
|
||||
|
||||
--- Create a new POINT_VEC3 object.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North.
|
||||
-- @param DCSTypes#Distance y The y coordinate of the Vec3 point, pointing Upwards.
|
||||
-- @param DCSTypes#Distance z The z coordinate of the Vec3 point, pointing to the Right.
|
||||
-- @return Point#POINT_VEC3
|
||||
function POINT_VEC3:New( x, y, z )
|
||||
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F2( { x, y, z } )
|
||||
self.PointVec3 = { x = x, y = y, z = z }
|
||||
return self
|
||||
end
|
||||
|
||||
--- Smokes the point in a color.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param Point#POINT_VEC3.SmokeColor SmokeColor
|
||||
function POINT_VEC3:Smoke( SmokeColor )
|
||||
self:F2( { SmokeColor, self.PointVec3 } )
|
||||
trigger.action.smoke( self.PointVec3, SmokeColor )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Green.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeGreen()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Green )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Red.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeRed()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Red )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 White.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeWhite()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.White )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Orange.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeOrange()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Orange )
|
||||
end
|
||||
|
||||
--- Smoke the POINT_VEC3 Blue.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:SmokeBlue()
|
||||
self:F2()
|
||||
self:Smoke( POINT_VEC3.SmokeColor.Blue )
|
||||
end
|
||||
|
||||
--- Flares the point in a color.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param Point#POINT_VEC3.FlareColor
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:Flare( FlareColor, Azimuth )
|
||||
self:F2( { FlareColor, self.PointVec3 } )
|
||||
trigger.action.signalFlare( self.PointVec3, FlareColor, Azimuth and Azimuth or 0 )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 White.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:FlareWhite( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.White, Azimuth )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 Yellow.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:FlareYellow( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.Yellow, Azimuth )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 Green.
|
||||
-- @param #POINT_VEC3 self
|
||||
-- @param DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0.
|
||||
function POINT_VEC3:FlareGreen( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.Green, Azimuth )
|
||||
end
|
||||
|
||||
--- Flare the POINT_VEC3 Red.
|
||||
-- @param #POINT_VEC3 self
|
||||
function POINT_VEC3:FlareRed( Azimuth )
|
||||
self:F2( Azimuth )
|
||||
self:Flare( POINT_VEC3.FlareColor.Red, Azimuth )
|
||||
end
|
||||
|
||||
|
||||
--- The POINT_VEC2 class
|
||||
-- @type POINT_VEC2
|
||||
-- @extends Point#POINT_VEC3
|
||||
POINT_VEC2 = {
|
||||
ClassName = "POINT_VEC2",
|
||||
}
|
||||
|
||||
--- Create a new POINT_VEC2 object.
|
||||
-- @param #POINT_VEC2 self
|
||||
-- @param DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North.
|
||||
-- @param DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right.
|
||||
-- @param 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 Point#POINT_VEC2
|
||||
function POINT_VEC2:New( x, y, LandHeightAdd )
|
||||
|
||||
local LandHeight = land.getHeight( { ["x"] = x, ["y"] = y } )
|
||||
if LandHeightAdd then
|
||||
LandHeight = LandHeight + LandHeightAdd
|
||||
end
|
||||
|
||||
local self = BASE:Inherit( self, POINT_VEC3:New( x, LandHeight, y ) )
|
||||
self:F2( { x, y, LandHeightAdd } )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -473,6 +473,12 @@ function SPAWN:SpawnWithIndex( SpawnIndex )
|
||||
end
|
||||
|
||||
self.SpawnGroups[self.SpawnIndex].Spawned = true
|
||||
|
||||
local SpawnGroup = self.SpawnGroups[self.SpawnIndex].Group -- Group#GROUP
|
||||
local Route = SpawnGroup:GetTaskRoute()
|
||||
SpawnGroup:Route(Route)
|
||||
|
||||
|
||||
return self.SpawnGroups[self.SpawnIndex].Group
|
||||
else
|
||||
--self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
|
||||
@@ -980,11 +986,12 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex )
|
||||
SpawnTemplate.name = self:SpawnGroupName( SpawnIndex )
|
||||
|
||||
SpawnTemplate.groupId = nil
|
||||
SpawnTemplate.lateActivation = false
|
||||
--SpawnTemplate.lateActivation = false
|
||||
SpawnTemplate.lateActivation = false -- TODO BUGFIX
|
||||
|
||||
if SpawnTemplate.SpawnCategoryID == Group.Category.GROUND then
|
||||
self:T( "For ground units, visible needs to be false..." )
|
||||
SpawnTemplate.visible = false
|
||||
SpawnTemplate.visible = false -- TODO BUGFIX
|
||||
end
|
||||
|
||||
if SpawnTemplate.SpawnCategoryID == Group.Category.HELICOPTER or SpawnTemplate.SpawnCategoryID == Group.Category.AIRPLANE then
|
||||
@@ -1032,7 +1039,7 @@ end
|
||||
-- @param #number SpawnIndex
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:_RandomizeTemplate( SpawnIndex )
|
||||
self:F( { self.SpawnTemplatePrefix, SpawnIndex } )
|
||||
self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnRandomizeTemplate } )
|
||||
|
||||
if self.SpawnRandomizeTemplate then
|
||||
self.SpawnGroups[SpawnIndex].SpawnTemplatePrefix = self.SpawnTemplatePrefixTable[ math.random( 1, #self.SpawnTemplatePrefixTable ) ]
|
||||
|
||||
81
Moose Development/Moose/Static.lua
Normal file
81
Moose Development/Moose/Static.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
--- This module contains the STATIC class.
|
||||
--
|
||||
-- 1) @{Static#STATIC} class, extends @{Unit#UNIT}
|
||||
-- ===============================================
|
||||
-- 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.
|
||||
-- The @{Static#STATIC} class is a wrapper class to handle the DCS Static objects:
|
||||
--
|
||||
-- * Wraps the DCS Static objects.
|
||||
-- * Support all DCS Static APIs.
|
||||
-- * Enhance with Static specific APIs not in the DCS API set.
|
||||
--
|
||||
-- 1.1) STATIC reference methods
|
||||
-- -----------------------------
|
||||
-- For each DCS Static will have a STATIC wrapper object (instance) within the _@{DATABASE} object.
|
||||
-- This is done at the beginning of the mission (when the mission starts).
|
||||
--
|
||||
-- The STATIC class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference
|
||||
-- using the Static Name.
|
||||
--
|
||||
-- Another thing to know is that STATIC objects do not "contain" the DCS Static object.
|
||||
-- The STATIc methods will reference the DCS Static object by name when it is needed during API execution.
|
||||
-- If the DCS Static object does not exist or is nil, the STATIC methods will return nil and log an exception in the DCS.log file.
|
||||
--
|
||||
-- The STATIc class provides the following functions to retrieve quickly the relevant STATIC instance:
|
||||
--
|
||||
-- * @{#STATIC.FindByName}(): Find a STATIC instance from the _DATABASE object using a DCS Static name.
|
||||
--
|
||||
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
||||
--
|
||||
-- @module Static
|
||||
-- @author FlightControl
|
||||
|
||||
Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
Include.File( "Message" )
|
||||
|
||||
|
||||
--- The STATIC class
|
||||
-- @type STATIC
|
||||
-- @extends Unit#UNIT
|
||||
STATIC = {
|
||||
ClassName = "STATIC",
|
||||
}
|
||||
|
||||
|
||||
--- Finds a STATIC from the _DATABASE using the relevant Static Name.
|
||||
-- As an optional parameter, a briefing text can be given also.
|
||||
-- @param #STATIC self
|
||||
-- @param #string StaticName Name of the DCS **Static** as defined within the Mission Editor.
|
||||
-- @return #STATIC
|
||||
function STATIC:FindByName( StaticName )
|
||||
local StaticFound = _DATABASE:FindStatic( StaticName )
|
||||
|
||||
if StaticFound then
|
||||
StaticFound:F( { StaticName } )
|
||||
|
||||
return StaticFound
|
||||
end
|
||||
|
||||
error( "STATIC not found for: " .. StaticName )
|
||||
end
|
||||
|
||||
function STATIC:Register( StaticName )
|
||||
local self = BASE:Inherit( self, UNIT:Register( StaticName ) )
|
||||
|
||||
self:F( StaticName )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function STATIC:GetDCSUnit()
|
||||
local DCSStatic = StaticObject.getByName( self.UnitName )
|
||||
|
||||
if DCSStatic then
|
||||
return DCSStatic
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
@@ -535,7 +535,7 @@ function UNIT:GetPointVec2()
|
||||
UnitPointVec2.x = UnitPointVec3.x
|
||||
UnitPointVec2.y = UnitPointVec3.z
|
||||
|
||||
self:T3( UnitPointVec2 )
|
||||
self:T2( UnitPointVec2 )
|
||||
return UnitPointVec2
|
||||
end
|
||||
|
||||
|
||||
@@ -65,16 +65,21 @@
|
||||
Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
Include.File( "Message" )
|
||||
Include.File( "Point" )
|
||||
|
||||
|
||||
|
||||
--- The ZONE_BASE class
|
||||
-- @type ZONE_BASE
|
||||
-- @Extends Base#BASE
|
||||
-- @extends Base#BASE
|
||||
ZONE_BASE = {
|
||||
ClassName = "ZONE_BASE",
|
||||
}
|
||||
|
||||
|
||||
--- ZONE_BASE constructor
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param #string ZoneName Name of the zone.
|
||||
-- @return #ZONE_BASE self
|
||||
function ZONE_BASE:New( ZoneName )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F( ZoneName )
|
||||
@@ -106,21 +111,30 @@ function ZONE_BASE:IsPointVec3InZone( PointVec3 )
|
||||
return InZone
|
||||
end
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param SmokeColor The smoke color.
|
||||
function ZONE_BASE:SmokeZone( SmokeColor )
|
||||
self:F2( SmokeColor )
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
||||
-- @type ZONE_RADIUS
|
||||
-- @field DCSTypes#Vec2 PointVec2 The current location of the zone.
|
||||
-- @field DCSTypes#Distance Radius The radius of the zone.
|
||||
-- @Extends Zone#ZONE_BASE
|
||||
-- @extends Zone#ZONE_BASE
|
||||
ZONE_RADIUS = {
|
||||
ClassName="ZONE_RADIUS",
|
||||
}
|
||||
|
||||
--- Constructor of ZONE_RADIUS, taking the zone name, the zone location and a radius.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param #string ZoneName Name of the zone.
|
||||
-- @param DCSTypes#Vec2 PointVec2 The location of the zone.
|
||||
-- @param DCSTypes#Distance Radius The radius of the zone.
|
||||
-- @return #ZONE_RADIUS
|
||||
-- @return #ZONE_RADIUS self
|
||||
function ZONE_RADIUS:New( ZoneName, PointVec2, Radius )
|
||||
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) )
|
||||
self:F( { ZoneName, PointVec2, Radius } )
|
||||
@@ -131,6 +145,59 @@ function ZONE_RADIUS:New( ZoneName, PointVec2, Radius )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param #POINT_VEC3.SmokeColor SmokeColor The smoke color.
|
||||
-- @param #number Points (optional) The amount of points in the circle.
|
||||
-- @return #ZONE_RADIUS self
|
||||
function ZONE_RADIUS:SmokeZone( SmokeColor, Points )
|
||||
self:F2( SmokeColor )
|
||||
|
||||
local Point = {}
|
||||
local PointVec2 = self:GetPointVec2()
|
||||
|
||||
Points = Points and Points or 360
|
||||
|
||||
local Angle
|
||||
local RadialBase = math.pi*2
|
||||
|
||||
for Angle = 0, 360, 360 / Points do
|
||||
local Radial = Angle * RadialBase / 360
|
||||
Point.x = PointVec2.x + math.cos( Radial ) * self:GetRadius()
|
||||
Point.y = PointVec2.y + math.sin( Radial ) * self:GetRadius()
|
||||
POINT_VEC2:New( Point.x, Point.y ):Smoke( SmokeColor )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Flares the zone boundaries in a color.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param #POINT_VEC3.FlareColor FlareColor The flare color.
|
||||
-- @param #number Points (optional) The amount of points in the circle.
|
||||
-- @param DCSTypes#Azimuth Azimuth (optional) Azimuth The azimuth of the flare.
|
||||
-- @return #ZONE_RADIUS self
|
||||
function ZONE_RADIUS:FlareZone( FlareColor, Points, Azimuth )
|
||||
self:F2( { FlareColor, Azimuth } )
|
||||
|
||||
local Point = {}
|
||||
local PointVec2 = self:GetPointVec2()
|
||||
|
||||
Points = Points and Points or 360
|
||||
|
||||
local Angle
|
||||
local RadialBase = math.pi*2
|
||||
|
||||
for Angle = 0, 360, 360 / Points do
|
||||
local Radial = Angle * RadialBase / 360
|
||||
Point.x = PointVec2.x + math.cos( Radial ) * self:GetRadius()
|
||||
Point.y = PointVec2.y + math.sin( Radial ) * self:GetRadius()
|
||||
POINT_VEC2:New( Point.x, Point.y ):Flare( FlareColor, Azimuth )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Returns the radius of the zone.
|
||||
-- @param #ZONE_RADIUS self
|
||||
@@ -197,14 +264,17 @@ function ZONE_RADIUS:GetPointVec3( Height )
|
||||
return PointVec3
|
||||
end
|
||||
|
||||
|
||||
--- Returns if a location is within the zone.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param DCSTypes#Vec2 PointVec2 The location to test.
|
||||
-- @return #boolean true if the location is within the zone.
|
||||
function ZONE_RADIUS:IsPointVec2InZone( PointVec2 )
|
||||
self:F2( PointVec2 )
|
||||
|
||||
local ZonePointVec2 = self:GetPointVec2()
|
||||
|
||||
if (( PointVec2.x - self.PointVec2.x )^2 + ( PointVec2.y - self.PointVec2.y ) ^2 ) ^ 0.5 <= self.Radius then
|
||||
if (( PointVec2.x - ZonePointVec2.x )^2 + ( PointVec2.y - ZonePointVec2.y ) ^2 ) ^ 0.5 <= self:GetRadius() then
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -218,7 +288,7 @@ end
|
||||
function ZONE_RADIUS:IsPointVec3InZone( PointVec3 )
|
||||
self:F2( PointVec3 )
|
||||
|
||||
local InZone = self:IsPointVec3InZone( { x = PointVec3.x, y = PointVec3.z } )
|
||||
local InZone = self:IsPointVec2InZone( { x = PointVec3.x, y = PointVec3.z } )
|
||||
|
||||
return InZone
|
||||
end
|
||||
@@ -230,10 +300,11 @@ function ZONE_RADIUS:GetRandomPointVec2()
|
||||
self:F( self.ZoneName )
|
||||
|
||||
local Point = {}
|
||||
local PointVec2 = self:GetPointVec2()
|
||||
|
||||
local angle = math.random() * math.pi*2;
|
||||
Point.x = self.PointVec2.x + math.cos( angle ) * math.random() * self.Radius;
|
||||
Point.y = self.PointVec2.y + math.sin( angle ) * math.random() * self.Radius;
|
||||
Point.x = PointVec2.x + math.cos( angle ) * math.random() * self:GetRadius();
|
||||
Point.y = PointVec2.y + math.sin( angle ) * math.random() * self:GetRadius();
|
||||
|
||||
self:T( { Point } )
|
||||
|
||||
@@ -244,7 +315,7 @@ end
|
||||
|
||||
--- The ZONE class, defined by the zone name as defined within the Mission Editor. The location and the radius are automatically collected from the mission settings.
|
||||
-- @type ZONE
|
||||
-- @Extends Zone#ZONE_RADIUS
|
||||
-- @extends Zone#ZONE_RADIUS
|
||||
ZONE = {
|
||||
ClassName="ZONE",
|
||||
}
|
||||
@@ -263,7 +334,7 @@ function ZONE:New( ZoneName )
|
||||
return nil
|
||||
end
|
||||
|
||||
local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, { x = Zone.x, y = Zone.y }, Zone.radius ) )
|
||||
local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, { x = Zone.point.x, y = Zone.point.z }, Zone.radius ) )
|
||||
self:F( ZoneName )
|
||||
|
||||
self.Zone = Zone
|
||||
@@ -272,11 +343,10 @@ function ZONE:New( ZoneName )
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
|
||||
-- @type ZONE_UNIT
|
||||
-- @field Unit#UNIT ZoneUNIT
|
||||
-- @Extends Zone#ZONE_RADIUS
|
||||
-- @extends Zone#ZONE_RADIUS
|
||||
ZONE_UNIT = {
|
||||
ClassName="ZONE_UNIT",
|
||||
}
|
||||
@@ -313,7 +383,7 @@ end
|
||||
|
||||
--- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||
-- @type ZONE_POLYGON
|
||||
-- @Extends Zone#ZONE_BASE
|
||||
-- @extends Zone#ZONE_BASE
|
||||
ZONE_POLYGON = {
|
||||
ClassName="ZONE_POLYGON",
|
||||
}
|
||||
@@ -342,6 +412,40 @@ function ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param #POINT_VEC3.SmokeColor SmokeColor The smoke color.
|
||||
-- @return #ZONE_POLYGON self
|
||||
function ZONE_POLYGON:SmokeZone( SmokeColor )
|
||||
self:F2( SmokeColor )
|
||||
|
||||
local i
|
||||
local j
|
||||
local Segments = 10
|
||||
|
||||
i = 1
|
||||
j = #self.Polygon
|
||||
|
||||
while i <= #self.Polygon do
|
||||
self:T( { i, j, self.Polygon[i], self.Polygon[j] } )
|
||||
|
||||
local DeltaX = self.Polygon[j].x - self.Polygon[i].x
|
||||
local DeltaY = self.Polygon[j].y - self.Polygon[i].y
|
||||
|
||||
for Segment = 0, Segments do -- We divide each line in 5 segments and smoke a point on the line.
|
||||
local PointX = self.Polygon[i].x + ( Segment * DeltaX / Segments )
|
||||
local PointY = self.Polygon[i].y + ( Segment * DeltaY / Segments )
|
||||
POINT_VEC2:New( PointX, PointY ):Smoke( SmokeColor )
|
||||
end
|
||||
j = i
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--- Returns if a location is within the zone.
|
||||
-- @param #ZONE_POLYGON self
|
||||
|
||||
Reference in New Issue
Block a user