mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge remote-tracking branch 'refs/remotes/origin/master' into FlightControl
# Conflicts: # Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua # Moose Mission Setup/Moose.lua
This commit is contained in:
commit
de84accffa
@ -542,8 +542,14 @@ function DATABASE:_EventOnBirth( Event )
|
||||
self:F2( { Event } )
|
||||
|
||||
if Event.IniDCSUnit then
|
||||
self:AddUnit( Event.IniDCSUnitName )
|
||||
self:AddGroup( Event.IniDCSGroupName )
|
||||
if Event.IniObjectCategory == 3 then
|
||||
self:AddStatic( Event.IniDCSUnitName )
|
||||
else
|
||||
if Event.IniObjectCategory == 1 then
|
||||
self:AddUnit( Event.IniDCSUnitName )
|
||||
self:AddGroup( Event.IniDCSGroupName )
|
||||
end
|
||||
end
|
||||
self:_EventOnPlayerEnterUnit( Event )
|
||||
end
|
||||
end
|
||||
|
||||
@ -680,7 +680,7 @@ function EVENT:onEvent( Event )
|
||||
Event.IniDCSUnit = Event.initiator
|
||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||
Event.IniUnitName = Event.IniDCSUnitName
|
||||
Event.IniUnit = STATIC:FindByName( Event.IniDCSUnitName )
|
||||
Event.IniUnit = STATIC:FindByName( Event.IniDCSUnitName, false )
|
||||
Event.IniCoalition = Event.IniDCSUnit:getCoalition()
|
||||
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
||||
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
||||
|
||||
@ -119,7 +119,6 @@
|
||||
|
||||
--- The POINT_VEC3 class
|
||||
-- @type POINT_VEC3
|
||||
-- @extends Core.Base#BASE
|
||||
-- @field #number x The x coordinate in 3D space.
|
||||
-- @field #number y The y coordinate in 3D space.
|
||||
-- @field #number z The z coordiante in 3D space.
|
||||
@ -128,6 +127,7 @@
|
||||
-- @field #POINT_VEC3.RoutePointAltType RoutePointAltType
|
||||
-- @field #POINT_VEC3.RoutePointType RoutePointType
|
||||
-- @field #POINT_VEC3.RoutePointAction RoutePointAction
|
||||
-- @extends Core.Base#BASE
|
||||
POINT_VEC3 = {
|
||||
ClassName = "POINT_VEC3",
|
||||
Metric = true,
|
||||
@ -146,9 +146,9 @@ POINT_VEC3 = {
|
||||
|
||||
--- The POINT_VEC2 class
|
||||
-- @type POINT_VEC2
|
||||
-- @extends #POINT_VEC3
|
||||
-- @field Dcs.DCSTypes#Distance x The x coordinate in meters.
|
||||
-- @field Dcs.DCSTypes#Distance y the y coordinate in meters.
|
||||
-- @extends Core.Point#POINT_VEC3
|
||||
POINT_VEC2 = {
|
||||
ClassName = "POINT_VEC2",
|
||||
}
|
||||
|
||||
@ -171,7 +171,6 @@
|
||||
-- ===
|
||||
--
|
||||
-- @module Zone
|
||||
-- @author FlightControl
|
||||
|
||||
|
||||
--- The ZONE_BASE class
|
||||
@ -327,6 +326,12 @@ function ZONE_BASE:GetBoundingSquare()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Bound the zone boundaries with a tires.
|
||||
-- @param #ZONE_BASE self
|
||||
function ZONE_BASE:BoundZone()
|
||||
self:F2()
|
||||
|
||||
end
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_BASE self
|
||||
@ -387,7 +392,7 @@ ZONE_RADIUS = {
|
||||
-- @param Dcs.DCSTypes#Distance Radius The radius of the zone.
|
||||
-- @return #ZONE_RADIUS self
|
||||
function ZONE_RADIUS:New( ZoneName, Vec2, Radius )
|
||||
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) )
|
||||
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) ) -- #ZONE_RADIUS
|
||||
self:F( { ZoneName, Vec2, Radius } )
|
||||
|
||||
self.Radius = Radius
|
||||
@ -396,6 +401,48 @@ function ZONE_RADIUS:New( ZoneName, Vec2, Radius )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Bounds the zone with tires.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param #number Points (optional) The amount of points in the circle.
|
||||
-- @return #ZONE_RADIUS self
|
||||
function ZONE_RADIUS:BoundZone( Points )
|
||||
|
||||
local Point = {}
|
||||
local Vec2 = self:GetVec2()
|
||||
|
||||
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 = Vec2.x + math.cos( Radial ) * self:GetRadius()
|
||||
Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius()
|
||||
|
||||
local Tire = {
|
||||
["country"] = "USA",
|
||||
["category"] = "Fortifications",
|
||||
["canCargo"] = false,
|
||||
["shape_name"] = "H-tyre_B_WF",
|
||||
["type"] = "Black_Tyre_WF",
|
||||
--["unitId"] = Angle + 10000,
|
||||
["y"] = Point.y,
|
||||
["x"] = Point.x,
|
||||
["name"] = string.format( "%s-Tire #%0d", self:GetName(), Angle ),
|
||||
["heading"] = 0,
|
||||
} -- end of ["group"]
|
||||
|
||||
self:E( Tire )
|
||||
|
||||
coalition.addStaticObject( country.id.USA, Tire )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
||||
@ -820,6 +867,52 @@ function ZONE_POLYGON_BASE:Flush()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_POLYGON_BASE self
|
||||
-- @return #ZONE_POLYGON_BASE self
|
||||
function ZONE_POLYGON_BASE:BoundZone( )
|
||||
|
||||
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 )
|
||||
local Tire = {
|
||||
["country"] = "USA",
|
||||
["category"] = "Fortifications",
|
||||
["canCargo"] = false,
|
||||
["shape_name"] = "H-tyre_B_WF",
|
||||
["type"] = "Black_Tyre_WF",
|
||||
["y"] = PointY,
|
||||
["x"] = PointX,
|
||||
["name"] = string.format( "%s-Tire #%0d", self:GetName(), ((i - 1) * Segments) + Segment ),
|
||||
["heading"] = 0,
|
||||
} -- end of ["group"]
|
||||
|
||||
self:E( Tire )
|
||||
|
||||
coalition.addStaticObject( country.id.USA, Tire )
|
||||
|
||||
end
|
||||
j = i
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Smokes the zone boundaries in a color.
|
||||
-- @param #ZONE_POLYGON_BASE self
|
||||
|
||||
@ -48,8 +48,9 @@ STATIC = {
|
||||
-- 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.
|
||||
-- @param #boolean RaiseError Raise an error if not found.
|
||||
-- @return #STATIC
|
||||
function STATIC:FindByName( StaticName )
|
||||
function STATIC:FindByName( StaticName, RaiseError )
|
||||
local StaticFound = _DATABASE:FindStatic( StaticName )
|
||||
|
||||
self.StaticName = StaticName
|
||||
@ -59,8 +60,12 @@ function STATIC:FindByName( StaticName )
|
||||
|
||||
return StaticFound
|
||||
end
|
||||
|
||||
error( "STATIC not found for: " .. StaticName )
|
||||
|
||||
if RaiseError == nil or RaiseError == true then
|
||||
error( "STATIC not found for: " .. StaticName )
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function STATIC:Register( StaticName )
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
---
|
||||
-- Name: ZON-100 - Normal Zone
|
||||
-- Author: FlightControl
|
||||
-- Date Created: 21 Feb 2017
|
||||
--
|
||||
-- # Situation:
|
||||
--
|
||||
-- A ZONE has been defined, which boundaries are smoking.
|
||||
-- A vehicle is driving through the zone perimeters.
|
||||
-- When the vehicle is driving in the zone, a red smoke is fired from the vehicle location.
|
||||
--
|
||||
-- # Test cases:
|
||||
--
|
||||
-- 1. Observe the zone perimeter smoke.
|
||||
-- 2. Observe the vehicle smoking a red smoke when driving through the zone.
|
||||
|
||||
|
||||
local GroupInside = GROUP:FindByName( "Test Inside Polygon" )
|
||||
local GroupOutside = GROUP:FindByName( "Test Outside Polygon" )
|
||||
|
||||
local ZoneA = ZONE:New( "Zone A" )
|
||||
ZoneA:BoundZone( 90 )
|
||||
|
||||
Messager = SCHEDULER:New( nil,
|
||||
function()
|
||||
GroupInside:MessageToAll( ( GroupInside:IsCompletelyInZone( ZoneA ) ) and "Inside Zone A" or "Outside Zone A", 1 )
|
||||
if GroupInside:IsCompletelyInZone( ZoneA ) then
|
||||
GroupInside:GetUnit(1):SmokeRed()
|
||||
end
|
||||
end,
|
||||
{}, 0, 1 )
|
||||
|
||||
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
---
|
||||
-- Name: ZON-502 - Polygon Zone Boundary
|
||||
-- Author: FlightControl
|
||||
-- Date Created: 18 Feb 2017
|
||||
--
|
||||
-- # Situation:
|
||||
--
|
||||
-- A ZONE_POLYGON has been defined, which boundaries are tires.
|
||||
-- A vehicle is driving through the zone perimeters.
|
||||
-- When the vehicle is driving in the zone, a red smoke is fired from the vehicle location.
|
||||
--
|
||||
-- # Test cases:
|
||||
--
|
||||
-- 1. Observe the polygon perimeter smoke.
|
||||
-- 2. Observe the vehicle smoking a red smoke when driving through the zone.
|
||||
|
||||
local GroupInside = GROUP:FindByName( "Test Inside Polygon" )
|
||||
local GroupOutside = GROUP:FindByName( "Test Outside Polygon" )
|
||||
|
||||
local GroupPolygon = GROUP:FindByName( "Polygon A" )
|
||||
|
||||
local PolygonZone = ZONE_POLYGON:New( "Polygon A", GroupPolygon )
|
||||
PolygonZone:BoundZone()
|
||||
|
||||
Messager = SCHEDULER:New( nil,
|
||||
function()
|
||||
GroupInside:MessageToAll( ( GroupInside:IsCompletelyInZone( PolygonZone ) ) and "Inside Polygon A" or "Outside Polygon A", 1 )
|
||||
if GroupInside:IsCompletelyInZone( PolygonZone ) then
|
||||
GroupInside:GetUnit(1):SmokeRed()
|
||||
end
|
||||
end,
|
||||
{}, 0, 1 )
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user