mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
commit
be1f8cde34
@ -446,6 +446,47 @@ do -- COORDINATE
|
|||||||
|
|
||||||
return gotunits, gotstatics, gotscenery, Units, Statics, Scenery
|
return gotunits, gotstatics, gotscenery, Units, Statics, Scenery
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Scan/find UNITS within a certain radius around the coordinate using the world.searchObjects() DCS API function.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #number radius (Optional) Scan radius in meters. Default 100 m.
|
||||||
|
-- @return Core.Set#SET_UNIT Set of units.
|
||||||
|
function COORDINATE:ScanUnits(radius)
|
||||||
|
|
||||||
|
local _,_,_,units=self:ScanObjects(radius, true, false, false)
|
||||||
|
|
||||||
|
local set=SET_UNIT:New()
|
||||||
|
|
||||||
|
for _,unit in pairs(units) do
|
||||||
|
set:AddUnit(unit)
|
||||||
|
end
|
||||||
|
|
||||||
|
return set
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Find the closest unit to the COORDINATE within a certain radius.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #number radius Scan radius in meters. Default 100 m.
|
||||||
|
-- @return Wrapper.Unit#UNIT The closest unit or #nil if no unit is inside the given radius.
|
||||||
|
function COORDINATE:FindClosestUnit(radius)
|
||||||
|
|
||||||
|
local units=self:ScanUnits(radius)
|
||||||
|
|
||||||
|
local umin=nil --Wrapper.Unit#UNIT
|
||||||
|
local dmin=math.huge
|
||||||
|
for _,_unit in pairs(units.Set) do
|
||||||
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
local coordinate=unit:GetCoordinate()
|
||||||
|
local d=self:Get2DDistance(coordinate)
|
||||||
|
if d<dmin then
|
||||||
|
dmin=d
|
||||||
|
umin=unit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return umin
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Calculate the distance from a reference @{#COORDINATE}.
|
--- Calculate the distance from a reference @{#COORDINATE}.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
|
|||||||
@ -121,7 +121,7 @@ function RADIOQUEUE:Start(delay, dt)
|
|||||||
self.dt=dt or 0.01
|
self.dt=dt or 0.01
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, delay, dt))
|
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, self.delay, self.dt))
|
||||||
|
|
||||||
-- Start Scheduler.
|
-- Start Scheduler.
|
||||||
if self.schedonce then
|
if self.schedonce then
|
||||||
|
|||||||
@ -59,14 +59,19 @@ do -- UserFlag
|
|||||||
--- Set the userflag to a given Number.
|
--- Set the userflag to a given Number.
|
||||||
-- @param #USERFLAG self
|
-- @param #USERFLAG self
|
||||||
-- @param #number Number The number value to be checked if it is the same as the userflag.
|
-- @param #number Number The number value to be checked if it is the same as the userflag.
|
||||||
|
-- @param #number Delay Delay in seconds, before the flag is set.
|
||||||
-- @return #USERFLAG The userflag instance.
|
-- @return #USERFLAG The userflag instance.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- local BlueVictory = USERFLAG:New( "VictoryBlue" )
|
-- local BlueVictory = USERFLAG:New( "VictoryBlue" )
|
||||||
-- BlueVictory:Set( 100 ) -- Set the UserFlag VictoryBlue to 100.
|
-- BlueVictory:Set( 100 ) -- Set the UserFlag VictoryBlue to 100.
|
||||||
--
|
--
|
||||||
function USERFLAG:Set( Number ) --R2.3
|
function USERFLAG:Set( Number, Delay ) --R2.3
|
||||||
|
|
||||||
trigger.action.setUserFlag( self.UserFlagName, Number )
|
if Delay and Delay>0 then
|
||||||
|
self:ScheduleOnce(Delay, USERFLAG.Set, self, Number)
|
||||||
|
else
|
||||||
|
trigger.action.setUserFlag( self.UserFlagName, Number )
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@ -244,8 +244,8 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function CLEANUP_AIRBASE.__:OnEventBirth( EventData )
|
function CLEANUP_AIRBASE.__:OnEventBirth( EventData )
|
||||||
self:F( { EventData } )
|
self:F( { EventData } )
|
||||||
|
|
||||||
if EventData.IniUnit:IsAlive() ~= nil then
|
if EventData and EventData.IniUnit and EventData.IniUnit:IsAlive() ~= nil then
|
||||||
if self:IsInAirbase( EventData.IniUnit:GetVec2() ) then
|
if self:IsInAirbase( EventData.IniUnit:GetVec2() ) then
|
||||||
self.CleanUpList[EventData.IniDCSUnitName] = {}
|
self.CleanUpList[EventData.IniDCSUnitName] = {}
|
||||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniUnit
|
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniUnit
|
||||||
|
|||||||
@ -1764,7 +1764,7 @@ _WAREHOUSEDB = {
|
|||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WAREHOUSE.version="1.0.1"
|
WAREHOUSE.version="1.0.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO: Warehouse todo list.
|
-- TODO: Warehouse todo list.
|
||||||
@ -8404,7 +8404,7 @@ end
|
|||||||
-- @return #string Text about warehouse stock
|
-- @return #string Text about warehouse stock
|
||||||
function WAREHOUSE:_UpdateWarehouseMarkText()
|
function WAREHOUSE:_UpdateWarehouseMarkText()
|
||||||
|
|
||||||
if self.makerOn then
|
if self.markerOn then
|
||||||
|
|
||||||
-- Create a mark with the current assets in stock.
|
-- Create a mark with the current assets in stock.
|
||||||
if self.markerid~=nil then
|
if self.markerid~=nil then
|
||||||
|
|||||||
@ -602,6 +602,26 @@ function POSITIONABLE:IsGround()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns if the unit is of ship category.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return #boolean Ship category evaluation result.
|
||||||
|
function POSITIONABLE:IsShip()
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSUnit then
|
||||||
|
local UnitDescriptor = DCSUnit:getDesc()
|
||||||
|
|
||||||
|
local IsShip = ( UnitDescriptor.category == Unit.Category.SHIP )
|
||||||
|
|
||||||
|
return IsShip
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns true if the POSITIONABLE is in the air.
|
--- Returns true if the POSITIONABLE is in the air.
|
||||||
-- Polymorphic, is overridden in GROUP and UNIT.
|
-- Polymorphic, is overridden in GROUP and UNIT.
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user