mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
docu changes
This commit is contained in:
parent
a1f5c0ab9b
commit
ca8b0899d0
@ -53,6 +53,7 @@
|
|||||||
-- @module Core.Zone
|
-- @module Core.Zone
|
||||||
-- @image Core_Zones.JPG
|
-- @image Core_Zones.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_BASE
|
--- @type ZONE_BASE
|
||||||
-- @field #string ZoneName Name of the zone.
|
-- @field #string ZoneName Name of the zone.
|
||||||
-- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
-- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
||||||
@ -60,6 +61,7 @@
|
|||||||
-- @field #table Color Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
-- @field #table Color Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
|
||||||
--- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
--- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||||
--
|
--
|
||||||
-- ## Each zone has a name:
|
-- ## Each zone has a name:
|
||||||
@ -106,9 +108,10 @@ ZONE_BASE = {
|
|||||||
ZoneName = "",
|
ZoneName = "",
|
||||||
ZoneProbability = 1,
|
ZoneProbability = 1,
|
||||||
DrawID=nil,
|
DrawID=nil,
|
||||||
Color = {},
|
Color={}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_BASE.BoundingSquare
|
--- The ZONE_BASE.BoundingSquare
|
||||||
-- @type ZONE_BASE.BoundingSquare
|
-- @type ZONE_BASE.BoundingSquare
|
||||||
-- @field DCS#Distance x1 The lower x coordinate (left down)
|
-- @field DCS#Distance x1 The lower x coordinate (left down)
|
||||||
@ -116,6 +119,7 @@ ZONE_BASE = {
|
|||||||
-- @field DCS#Distance x2 The higher x coordinate (right up)
|
-- @field DCS#Distance x2 The higher x coordinate (right up)
|
||||||
-- @field DCS#Distance y2 The higher y coordinate (right up)
|
-- @field DCS#Distance y2 The higher y coordinate (right up)
|
||||||
|
|
||||||
|
|
||||||
--- ZONE_BASE constructor
|
--- ZONE_BASE constructor
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #string ZoneName Name of the zone.
|
-- @param #string ZoneName Name of the zone.
|
||||||
@ -126,9 +130,13 @@ function ZONE_BASE:New( ZoneName )
|
|||||||
|
|
||||||
self.ZoneName = ZoneName
|
self.ZoneName = ZoneName
|
||||||
|
|
||||||
|
--_DATABASE:AddZone(ZoneName,self)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the name of the zone.
|
--- Returns the name of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #string The name of the zone.
|
-- @return #string The name of the zone.
|
||||||
@ -138,6 +146,7 @@ function ZONE_BASE:GetName()
|
|||||||
return self.ZoneName
|
return self.ZoneName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets the name of the zone.
|
--- Sets the name of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
@ -194,6 +203,7 @@ function ZONE_BASE:IsPointVec3InZone( PointVec3 )
|
|||||||
return InZone
|
return InZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the @{DCS#Vec2} coordinate of the zone.
|
--- Returns the @{DCS#Vec2} coordinate of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #nil.
|
-- @return #nil.
|
||||||
@ -217,6 +227,7 @@ function ZONE_BASE:GetPointVec2()
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the @{DCS#Vec3} of the zone.
|
--- Returns the @{DCS#Vec3} of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
|
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
|
||||||
@ -279,6 +290,24 @@ function ZONE_BASE:GetCoordinate( Height ) -- R2.1
|
|||||||
return self.Coordinate
|
return self.Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get 2D distance to a coordinate.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Reference coordinate. Can also be a DCS#Vec2 or DCS#Vec3 object.
|
||||||
|
-- @return #number Distance to the reference coordinate in meters.
|
||||||
|
function ZONE_BASE:Get2DDistance(Coordinate)
|
||||||
|
local a=self:GetVec2()
|
||||||
|
local b={}
|
||||||
|
if Coordinate.z then
|
||||||
|
b.x=Coordinate.x
|
||||||
|
b.y=Coordinate.z
|
||||||
|
else
|
||||||
|
b.x=Coordinate.x
|
||||||
|
b.y=Coordinate.y
|
||||||
|
end
|
||||||
|
local dist=UTILS.VecDist2D(a,b)
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
--- Define a random @{DCS#Vec2} within the zone.
|
--- Define a random @{DCS#Vec2} within the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return DCS#Vec2 The Vec2 coordinates.
|
-- @return DCS#Vec2 The Vec2 coordinates.
|
||||||
@ -315,6 +344,7 @@ function ZONE_BASE:BoundZone()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set color of zone.
|
--- Set color of zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
||||||
@ -383,6 +413,7 @@ function ZONE_BASE:GetDrawID()
|
|||||||
return self.DrawID
|
return self.DrawID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Smokes the zone boundaries in a color.
|
--- Smokes the zone boundaries in a color.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
||||||
@ -447,6 +478,7 @@ function ZONE_BASE:GetZoneMaybe()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
||||||
-- @type ZONE_RADIUS
|
-- @type ZONE_RADIUS
|
||||||
-- @field DCS#Vec2 Vec2 The current location of the zone.
|
-- @field DCS#Vec2 Vec2 The current location of the zone.
|
||||||
@ -642,6 +674,7 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Smokes the zone boundaries in a color.
|
--- Smokes the zone boundaries in a color.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
||||||
@ -673,6 +706,7 @@ function ZONE_RADIUS:SmokeZone( SmokeColor, Points, AddHeight, AngleOffset )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Flares the zone boundaries in a color.
|
--- Flares the zone boundaries in a color.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
||||||
@ -769,6 +803,10 @@ function ZONE_RADIUS:GetVec3( Height )
|
|||||||
return Vec3
|
return Vec3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Scan the zone for the presence of units of the given ObjectCategories.
|
--- Scan the zone for the presence of units of the given ObjectCategories.
|
||||||
-- Note that after a zone has been scanned, the zone can be evaluated by:
|
-- Note that after a zone has been scanned, the zone can be evaluated by:
|
||||||
--
|
--
|
||||||
@ -801,7 +839,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
|||||||
params = {
|
params = {
|
||||||
point = ZoneCoord:GetVec3(),
|
point = ZoneCoord:GetVec3(),
|
||||||
radius = ZoneRadius,
|
radius = ZoneRadius,
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function EvaluateZone( ZoneObject )
|
local function EvaluateZone( ZoneObject )
|
||||||
@ -874,6 +912,7 @@ function ZONE_RADIUS:GetScannedUnits()
|
|||||||
return self.ScanData.Units
|
return self.ScanData.Units
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get a set of scanned units.
|
--- Get a set of scanned units.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
|
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
|
||||||
@ -927,6 +966,7 @@ function ZONE_RADIUS:GetScannedSetGroup()
|
|||||||
return self.ScanSetGroup
|
return self.ScanSetGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Count the number of different coalitions inside the zone.
|
--- Count the number of different coalitions inside the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #number Counted coalitions.
|
-- @return #number Counted coalitions.
|
||||||
@ -979,6 +1019,7 @@ function ZONE_RADIUS:GetScannedCoalition( Coalition )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get scanned scenery type
|
--- Get scanned scenery type
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #table Table of DCS scenery type objects.
|
-- @return #table Table of DCS scenery type objects.
|
||||||
@ -986,6 +1027,7 @@ function ZONE_RADIUS:GetScannedSceneryType( SceneryType )
|
|||||||
return self.ScanData.Scenery[SceneryType]
|
return self.ScanData.Scenery[SceneryType]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get scanned scenery table
|
--- Get scanned scenery table
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #table Table of DCS scenery objects.
|
-- @return #table Table of DCS scenery objects.
|
||||||
@ -993,8 +1035,9 @@ function ZONE_RADIUS:GetScannedScenery()
|
|||||||
return self.ScanData.Scenery
|
return self.ScanData.Scenery
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is All in Zone of Coalition?
|
--- Is All in Zone of Coalition?
|
||||||
-- Check if only the specified coalition is inside the zone and noone else.
|
-- Check if only the specifed coalition is inside the zone and noone else.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number Coalition Coalition ID of the coalition which is checked to be the only one in the zone.
|
-- @param #number Coalition Coalition ID of the coalition which is checked to be the only one in the zone.
|
||||||
-- @return #boolean True, if **only** that coalition is inside the zone and no one else.
|
-- @return #boolean True, if **only** that coalition is inside the zone and no one else.
|
||||||
@ -1007,6 +1050,7 @@ function ZONE_RADIUS:IsAllInZoneOfCoalition( Coalition )
|
|||||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is All in Zone of Other Coalition?
|
--- Is All in Zone of Other Coalition?
|
||||||
-- Check if only one coalition is inside the zone and the specified coalition is not the one.
|
-- Check if only one coalition is inside the zone and the specified coalition is not the one.
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
@ -1023,23 +1067,23 @@ function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition )
|
|||||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is Some in Zone of Coalition?
|
--- Is Some in Zone of Coalition?
|
||||||
-- Check if more than one coalition is inside the zone and the specified coalition is one of them.
|
-- Check if more than one coaltion is inside the zone and the specifed coalition is one of them.
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number Coalition ID of the coalition which is checked to be inside the zone.
|
-- @param #number Coalition ID of the coaliton which is checked to be inside the zone.
|
||||||
-- @return #boolean True if more than one coalition is inside the zone and the specified coalition is one of them.
|
-- @return #boolean True if more than one coalition is inside the zone and the specified coalition is one of them.
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||||
--
|
|
||||||
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is None in Zone of Coalition?
|
--- Is None in Zone of Coalition?
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||||
@ -1047,30 +1091,30 @@ end
|
|||||||
-- @param Coalition
|
-- @param Coalition
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition )
|
-- local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition )
|
||||||
--
|
|
||||||
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self:GetScannedCoalition( Coalition ) == nil
|
return self:GetScannedCoalition( Coalition ) == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is None in Zone?
|
--- Is None in Zone?
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsEmpty = self.Zone:IsNoneInZone()
|
-- local IsEmpty = self.Zone:IsNoneInZone()
|
||||||
--
|
|
||||||
function ZONE_RADIUS:IsNoneInZone()
|
function ZONE_RADIUS:IsNoneInZone()
|
||||||
|
|
||||||
return self:CountScannedCoalitions() == 0
|
return self:CountScannedCoalitions() == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Searches the zone
|
--- Searches the zone
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param ObjectCategories A list of categories, which are members of Object.Category
|
-- @param ObjectCategories A list of categories, which are members of Object.Category
|
||||||
@ -1089,11 +1133,12 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
|
|||||||
params = {
|
params = {
|
||||||
point = ZoneCoord:GetVec3(),
|
point = ZoneCoord:GetVec3(),
|
||||||
radius = ZoneRadius / 2,
|
radius = ZoneRadius / 2,
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function EvaluateZone( ZoneDCSUnit )
|
local function EvaluateZone( ZoneDCSUnit )
|
||||||
|
|
||||||
|
|
||||||
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
||||||
|
|
||||||
return EvaluateFunction( ZoneUnit )
|
return EvaluateFunction( ZoneUnit )
|
||||||
@ -1135,24 +1180,54 @@ end
|
|||||||
|
|
||||||
--- Returns a random Vec2 location within the zone.
|
--- Returns a random Vec2 location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 100 times to find the right type!
|
||||||
-- @return DCS#Vec2 The random location within the zone.
|
-- @return DCS#Vec2 The random location within the zone.
|
||||||
function ZONE_RADIUS:GetRandomVec2( inner, outer )
|
function ZONE_RADIUS:GetRandomVec2(inner, outer, surfacetypes)
|
||||||
self:F( self.ZoneName, inner, outer )
|
|
||||||
|
|
||||||
local Point = {}
|
|
||||||
local Vec2 = self:GetVec2()
|
local Vec2 = self:GetVec2()
|
||||||
local _inner = inner or 0
|
local _inner = inner or 0
|
||||||
local _outer = outer or self:GetRadius()
|
local _outer = outer or self:GetRadius()
|
||||||
|
|
||||||
local angle = math.random() * math.pi * 2;
|
if surfacetypes and type(surfacetypes)~="table" then
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random( _inner, _outer );
|
surfacetypes={surfacetypes}
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random( _inner, _outer );
|
end
|
||||||
|
|
||||||
self:T( { Point } )
|
local function _getpoint()
|
||||||
|
local point = {}
|
||||||
|
local angle = math.random() * math.pi * 2
|
||||||
|
point.x = Vec2.x + math.cos(angle) * math.random(_inner, _outer)
|
||||||
|
point.y = Vec2.y + math.sin(angle) * math.random(_inner, _outer)
|
||||||
|
return point
|
||||||
|
end
|
||||||
|
|
||||||
return Point
|
local function _checkSurface(point)
|
||||||
|
local stype=land.getSurfaceType(point)
|
||||||
|
for _,sf in pairs(surfacetypes) do
|
||||||
|
if sf==stype then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local point=_getpoint()
|
||||||
|
|
||||||
|
if surfacetypes then
|
||||||
|
local N=1 ; local Nmax=100 ; local gotit=false
|
||||||
|
while gotit==false and N<=Nmax do
|
||||||
|
gotit=_checkSurface(point)
|
||||||
|
if gotit then
|
||||||
|
--env.info(string.format("Got random coordinate with surface type %d after N=%d/%d iterations", land.getSurfaceType(point), N, Nmax))
|
||||||
|
else
|
||||||
|
point=_getpoint()
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return point
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
@ -1185,6 +1260,7 @@ function ZONE_RADIUS:GetRandomVec3( inner, outer )
|
|||||||
return { x = Vec2.x, y = self.y, z = Vec2.y }
|
return { x = Vec2.x, y = self.y, z = Vec2.y }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
@ -1200,24 +1276,28 @@ function ZONE_RADIUS:GetRandomPointVec3( inner, outer )
|
|||||||
return PointVec3
|
return PointVec3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone.
|
--- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
-- @return Core.Point#COORDINATE
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 1000 times to find the right type!
|
||||||
function ZONE_RADIUS:GetRandomCoordinate( inner, outer )
|
-- @return Core.Point#COORDINATE The random coordinate.
|
||||||
self:F( self.ZoneName, inner, outer )
|
function ZONE_RADIUS:GetRandomCoordinate(inner, outer, surfacetypes)
|
||||||
|
|
||||||
local Coordinate = COORDINATE:NewFromVec2( self:GetRandomVec2( inner, outer ) )
|
local vec2=self:GetRandomVec2(inner, outer, surfacetypes)
|
||||||
|
|
||||||
self:T3( { Coordinate = Coordinate } )
|
local Coordinate = COORDINATE:NewFromVec2(vec2)
|
||||||
|
|
||||||
return Coordinate
|
return Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE
|
--- @type ZONE
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE class, defined by the zone name as defined within the Mission Editor.
|
--- The ZONE class, defined by the zone name as defined within the Mission Editor.
|
||||||
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
@ -1250,6 +1330,7 @@ ZONE = {
|
|||||||
ClassName="ZONE",
|
ClassName="ZONE",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Constructor of ZONE taking the zone name.
|
--- Constructor of ZONE taking the zone name.
|
||||||
-- @param #ZONE self
|
-- @param #ZONE self
|
||||||
-- @param #string ZoneName The name of the zone as defined within the mission editor.
|
-- @param #string ZoneName The name of the zone as defined within the mission editor.
|
||||||
@ -1269,7 +1350,7 @@ function ZONE:New( ZoneName )
|
|||||||
|
|
||||||
-- Error!
|
-- Error!
|
||||||
if not Zone then
|
if not Zone then
|
||||||
error( "Zone " .. ZoneName .. " does not exist." )
|
env.error( "ERROR: Zone " .. ZoneName .. " does not exist!" )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1296,10 +1377,13 @@ function ZONE:FindByName( ZoneName )
|
|||||||
return ZoneFound
|
return ZoneFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_UNIT
|
--- @type ZONE_UNIT
|
||||||
-- @field Wrapper.Unit#UNIT ZoneUNIT
|
-- @field Wrapper.Unit#UNIT ZoneUNIT
|
||||||
-- @extends Core.Zone#ZONE_RADIUS
|
-- @extends Core.Zone#ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- # ZONE_UNIT class, extends @{Zone#ZONE_RADIUS}
|
--- # ZONE_UNIT class, extends @{Zone#ZONE_RADIUS}
|
||||||
--
|
--
|
||||||
-- The ZONE_UNIT class defined by a zone attached to a @{Wrapper.Unit#UNIT} with a radius and optional offsets.
|
-- The ZONE_UNIT class defined by a zone attached to a @{Wrapper.Unit#UNIT} with a radius and optional offsets.
|
||||||
@ -1351,6 +1435,7 @@ function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Unit#UNIT}.
|
--- Returns the current location of the @{Wrapper.Unit#UNIT}.
|
||||||
-- @param #ZONE_UNIT self
|
-- @param #ZONE_UNIT self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Unit#UNIT}location and the offset, if any.
|
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Unit#UNIT}location and the offset, if any.
|
||||||
@ -1437,6 +1522,7 @@ end
|
|||||||
--- @type ZONE_GROUP
|
--- @type ZONE_GROUP
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
|
--- The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
@ -1464,6 +1550,7 @@ function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Group}.
|
--- Returns the current location of the @{Wrapper.Group}.
|
||||||
-- @param #ZONE_GROUP self
|
-- @param #ZONE_GROUP self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
||||||
@ -1517,10 +1604,12 @@ function ZONE_GROUP:GetRandomPointVec2( inner, outer )
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_POLYGON_BASE
|
--- @type ZONE_POLYGON_BASE
|
||||||
-- --@field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
-- --@field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
||||||
-- @extends #ZONE_BASE
|
-- @extends #ZONE_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_POLYGON_BASE class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
--- The ZONE_POLYGON_BASE class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||||
@ -1658,6 +1747,7 @@ function ZONE_POLYGON_BASE:GetVertexCoordinate( Index )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get a list of verticies of the polygon.
|
--- Get a list of verticies of the polygon.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return <DCS#Vec2> List of DCS#Vec2 verticies defining the edges of the polygon.
|
-- @return <DCS#Vec2> List of DCS#Vec2 verticies defining the edges of the polygon.
|
||||||
@ -1753,6 +1843,7 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported!
|
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported!
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
@ -1772,6 +1863,7 @@ function ZONE_POLYGON_BASE:DrawZone( Coalition, Color, Alpha, FillColor, FillAlp
|
|||||||
FillColor=FillColor or Color
|
FillColor=FillColor or Color
|
||||||
FillAlpha=FillAlpha or self:GetColorAlpha()
|
FillAlpha=FillAlpha or self:GetColorAlpha()
|
||||||
|
|
||||||
|
|
||||||
if #self._.Polygon==4 then
|
if #self._.Polygon==4 then
|
||||||
|
|
||||||
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
||||||
@ -1789,6 +1881,7 @@ function ZONE_POLYGON_BASE:DrawZone( Coalition, Color, Alpha, FillColor, FillAlp
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1823,6 +1916,7 @@ function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Flare the zone boundaries in a color.
|
--- Flare the zone boundaries in a color.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
||||||
@ -1858,6 +1952,9 @@ function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if a location is within the zone.
|
--- Returns if a location is within the zone.
|
||||||
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
@ -1876,7 +1973,8 @@ function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
|||||||
while Next <= #self._.Polygon do
|
while Next <= #self._.Polygon do
|
||||||
self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } )
|
self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } )
|
||||||
if ( ( ( self._.Polygon[Next].y > Vec2.y ) ~= ( self._.Polygon[Prev].y > Vec2.y ) ) and
|
if ( ( ( self._.Polygon[Next].y > Vec2.y ) ~= ( self._.Polygon[Prev].y > Vec2.y ) ) and
|
||||||
(Vec2.x < (self._.Polygon[Prev].x - self._.Polygon[Next].x) * (Vec2.y - self._.Polygon[Next].y) / (self._.Polygon[Prev].y - self._.Polygon[Next].y) + self._.Polygon[Next].x)) then
|
( Vec2.x < ( self._.Polygon[Prev].x - self._.Polygon[Next].x ) * ( Vec2.y - self._.Polygon[Next].y ) / ( self._.Polygon[Prev].y - self._.Polygon[Next].y ) + self._.Polygon[Next].x )
|
||||||
|
) then
|
||||||
InPolygon = not InPolygon
|
InPolygon = not InPolygon
|
||||||
end
|
end
|
||||||
self:T2( { InPolygon = InPolygon } )
|
self:T2( { InPolygon = InPolygon } )
|
||||||
@ -1892,28 +1990,30 @@ end
|
|||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return DCS#Vec2 The Vec2 coordinate.
|
-- @return DCS#Vec2 The Vec2 coordinate.
|
||||||
function ZONE_POLYGON_BASE:GetRandomVec2()
|
function ZONE_POLYGON_BASE:GetRandomVec2()
|
||||||
self:F2()
|
|
||||||
|
|
||||||
--- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
-- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
||||||
local Vec2Found = false
|
|
||||||
local Vec2
|
-- Get the bounding square.
|
||||||
local BS = self:GetBoundingSquare()
|
local BS = self:GetBoundingSquare()
|
||||||
|
|
||||||
self:T2( BS )
|
local Nmax=1000 ; local n=0
|
||||||
|
while n<Nmax do
|
||||||
|
|
||||||
while Vec2Found == false do
|
-- Random point in the bounding square.
|
||||||
Vec2 = { x = math.random( BS.x1, BS.x2 ), y = math.random( BS.y1, BS.y2 ) }
|
local Vec2={x=math.random(BS.x1, BS.x2), y=math.random(BS.y1, BS.y2)}
|
||||||
self:T2( Vec2 )
|
|
||||||
|
-- Check if this is in the polygon.
|
||||||
if self:IsVec2InZone(Vec2) then
|
if self:IsVec2InZone(Vec2) then
|
||||||
Vec2Found = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:T2( Vec2 )
|
|
||||||
|
|
||||||
return Vec2
|
return Vec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
n=n+1
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E("Could not find a random point in the polygon zone!")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return @{Core.Point#POINT_VEC2}
|
-- @return @{Core.Point#POINT_VEC2}
|
||||||
@ -1940,6 +2040,7 @@ function ZONE_POLYGON_BASE:GetRandomPointVec3()
|
|||||||
return PointVec3
|
return PointVec3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Return a @{Core.Point#COORDINATE} object representing a random 3D point at landheight within the zone.
|
--- Return a @{Core.Point#COORDINATE} object representing a random 3D point at landheight within the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return Core.Point#COORDINATE
|
-- @return Core.Point#COORDINATE
|
||||||
@ -1953,6 +2054,7 @@ function ZONE_POLYGON_BASE:GetRandomCoordinate()
|
|||||||
return Coordinate
|
return Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the bounding square the zone.
|
--- Get the bounding square the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square.
|
-- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square.
|
||||||
@ -2018,17 +2120,18 @@ end
|
|||||||
--- @type ZONE_POLYGON
|
--- @type ZONE_POLYGON
|
||||||
-- @extends #ZONE_POLYGON_BASE
|
-- @extends #ZONE_POLYGON_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
--- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
||||||
--
|
--
|
||||||
-- You can declare a ZONE_POLYGON using the DCS mission editor by adding the ~ZONE_POLYGON tag in the group name.
|
-- You can declare a ZONE_POLYGON using the DCS mission editor by adding the #ZONE_POLYGON tag in the group name.
|
||||||
--
|
--
|
||||||
-- So, imagine you have a group declared in the mission editor, with group name `DefenseZone~ZONE_POLYGON`.
|
-- So, imagine you have a group declared in the mission editor, with group name `DefenseZone#ZONE_POLYGON`.
|
||||||
-- Then during mission startup, when loading Moose.lua, this group will be detected as a ZONE_POLYGON declaration.
|
-- Then during mission startup, when loading Moose.lua, this group will be detected as a ZONE_POLYGON declaration.
|
||||||
-- Within the background, a ZONE_POLYGON object will be created within the @{Core.Database} using the properties of the group.
|
-- Within the background, a ZONE_POLYGON object will be created within the @{Core.Database} using the properties of the group.
|
||||||
-- The ZONE_POLYGON name will be the group name without the ~ZONE_POLYGON tag.
|
-- The ZONE_POLYGON name will be the group name without the #ZONE_POLYGON tag.
|
||||||
--
|
--
|
||||||
-- So, you can search yourself for the ZONE_POLYGON by using the @{#ZONE_POLYGON.FindByName}() method.
|
-- So, you can search yourself for the ZONE_POLYGON by using the @{#ZONE_POLYGON.FindByName}() method.
|
||||||
-- In this example, `local PolygonZone = ZONE_POLYGON:FindByName( "DefenseZone" )` would return the ZONE_POLYGON object
|
-- In this example, `local PolygonZone = ZONE_POLYGON:FindByName( "DefenseZone" )` would return the ZONE_POLYGON object
|
||||||
@ -2065,6 +2168,7 @@ function ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Constructor to create a ZONE_POLYGON instance, taking the zone name and the **name** of the @{Wrapper.Group#GROUP} defined within the Mission Editor.
|
--- Constructor to create a ZONE_POLYGON instance, taking the zone name and the **name** of the @{Wrapper.Group#GROUP} defined within the Mission Editor.
|
||||||
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON.
|
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON.
|
||||||
-- @param #ZONE_POLYGON self
|
-- @param #ZONE_POLYGON self
|
||||||
@ -2085,6 +2189,7 @@ function ZONE_POLYGON:NewFromGroupName( GroupName )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Find a polygon zone in the _DATABASE using the name of the polygon zone.
|
--- Find a polygon zone in the _DATABASE using the name of the polygon zone.
|
||||||
-- @param #ZONE_POLYGON self
|
-- @param #ZONE_POLYGON self
|
||||||
-- @param #string ZoneName The name of the polygon zone.
|
-- @param #string ZoneName The name of the polygon zone.
|
||||||
@ -2098,8 +2203,12 @@ end
|
|||||||
do -- ZONE_AIRBASE
|
do -- ZONE_AIRBASE
|
||||||
|
|
||||||
--- @type ZONE_AIRBASE
|
--- @type ZONE_AIRBASE
|
||||||
|
-- @field #boolean isShip If `true`, airbase is a ship.
|
||||||
|
-- @field #boolean isHelipad If `true`, airbase is a helipad.
|
||||||
|
-- @field #boolean isAirdrome If `true`, airbase is an airdrome.
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_AIRBASE class defines by a zone around a @{Wrapper.Airbase#AIRBASE} with a radius.
|
--- The ZONE_AIRBASE class defines by a zone around a @{Wrapper.Airbase#AIRBASE} with a radius.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
@ -2108,6 +2217,8 @@ do -- ZONE_AIRBASE
|
|||||||
ClassName="ZONE_AIRBASE",
|
ClassName="ZONE_AIRBASE",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Constructor to create a ZONE_AIRBASE instance, taking the zone name, a zone @{Wrapper.Airbase#AIRBASE} and a radius.
|
--- Constructor to create a ZONE_AIRBASE instance, taking the zone name, a zone @{Wrapper.Airbase#AIRBASE} and a radius.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @param #string AirbaseName Name of the airbase.
|
-- @param #string AirbaseName Name of the airbase.
|
||||||
@ -2124,6 +2235,20 @@ do -- ZONE_AIRBASE
|
|||||||
self._.ZoneAirbase = Airbase
|
self._.ZoneAirbase = Airbase
|
||||||
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
||||||
|
|
||||||
|
if Airbase:IsShip() then
|
||||||
|
self.isShip=true
|
||||||
|
self.isHelipad=false
|
||||||
|
self.isAirdrome=false
|
||||||
|
elseif Airbase:IsHelipad() then
|
||||||
|
self.isShip=false
|
||||||
|
self.isHelipad=true
|
||||||
|
self.isAirdrome=false
|
||||||
|
elseif Airbase:IsAirdrome() then
|
||||||
|
self.isShip=false
|
||||||
|
self.isHelipad=false
|
||||||
|
self.isAirdrome=true
|
||||||
|
end
|
||||||
|
|
||||||
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
||||||
_EVENTDISPATCHER:CreateEventNewZone( self )
|
_EVENTDISPATCHER:CreateEventNewZone( self )
|
||||||
|
|
||||||
@ -2137,9 +2262,9 @@ do -- ZONE_AIRBASE
|
|||||||
return self._.ZoneAirbase
|
return self._.ZoneAirbase
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Group}.
|
--- Returns the current location of the AIRBASE.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the AIRBASE location.
|
||||||
function ZONE_AIRBASE:GetVec2()
|
function ZONE_AIRBASE:GetVec2()
|
||||||
self:F( self.ZoneName )
|
self:F( self.ZoneName )
|
||||||
|
|
||||||
@ -2157,24 +2282,6 @@ do -- ZONE_AIRBASE
|
|||||||
return ZoneVec2
|
return ZoneVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a random location within the zone of the @{Wrapper.Group}.
|
|
||||||
-- @param #ZONE_AIRBASE self
|
|
||||||
-- @return DCS#Vec2 The random location of the zone based on the @{Wrapper.Group} location.
|
|
||||||
function ZONE_AIRBASE:GetRandomVec2()
|
|
||||||
self:F( self.ZoneName )
|
|
||||||
|
|
||||||
local Point = {}
|
|
||||||
local Vec2 = self._.ZoneAirbase:GetVec2()
|
|
||||||
|
|
||||||
local angle = math.random() * math.pi * 2;
|
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius();
|
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius();
|
|
||||||
|
|
||||||
self:T( { Point } )
|
|
||||||
|
|
||||||
return Point
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
@ -2190,4 +2297,5 @@ do -- ZONE_AIRBASE
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user