mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
#CONTROLLABLE - Improved IR Markers
This commit is contained in:
parent
ea23162ca9
commit
94ee76fe62
@ -5642,19 +5642,18 @@ end
|
||||
-- @param #number Runtime (Optionally) Run this IR Marker for the given number of seconds, then stop. Use in conjunction with EnableImmediately.
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:NewIRMarker(EnableImmediately, Runtime)
|
||||
--sefl:F("NewIRMarker")
|
||||
if self.ClassName == "GROUP" then
|
||||
self:T2("NewIRMarker")
|
||||
if self:IsInstanceOf("GROUP") then
|
||||
if self.IRMarkerGroup == true then return end
|
||||
self.IRMarkerGroup = true
|
||||
self.IRMarkerUnit = false
|
||||
elseif self.ClassName == "UNIT" then
|
||||
elseif self:IsInstanceOf("UNIT") then
|
||||
if self.IRMarkerUnit == true then return end
|
||||
self.IRMarkerGroup = false
|
||||
self.IRMarkerUnit = true
|
||||
end
|
||||
|
||||
self.spot = nil
|
||||
self.timer = nil
|
||||
self.stoptimer = nil
|
||||
|
||||
self.Runtime = Runtime or 60
|
||||
if EnableImmediately and EnableImmediately == true then
|
||||
self:EnableIRMarker(Runtime)
|
||||
end
|
||||
@ -5667,19 +5666,23 @@ end
|
||||
-- @param #number Runtime (Optionally) Run this IR Marker for the given number of seconds, then stop. Else run until you call `myobject:DisableIRMarker()`.
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:EnableIRMarker(Runtime)
|
||||
--sefl:F("EnableIRMarker")
|
||||
self:T2("EnableIRMarker")
|
||||
if self.IRMarkerGroup == nil then
|
||||
self:NewIRMarker(true,Runtime)
|
||||
return
|
||||
end
|
||||
|
||||
if (self.IRMarkerGroup == true) then
|
||||
self:EnableIRMarkerForGroup()
|
||||
if self:IsInstanceOf("GROUP") then
|
||||
self:EnableIRMarkerForGroup(Runtime)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if self.timer and self.timer:IsRunning() then return self end
|
||||
|
||||
local Runtime = Runtime or self.Runtime
|
||||
self.timer = TIMER:New(CONTROLLABLE._MarkerBlink, self)
|
||||
self.timer:Start(nil, 1 - math.random(1, 5) / 10 / 2, Runtime) -- start randomized
|
||||
self.IRMarkerUnit = true
|
||||
|
||||
return self
|
||||
end
|
||||
@ -5688,14 +5691,13 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:DisableIRMarker()
|
||||
--sefl:F("DisableIRMarker")
|
||||
if (self.IRMarkerGroup == true) then
|
||||
self:T2("DisableIRMarker")
|
||||
if self:IsInstanceOf("GROUP") then
|
||||
self:DisableIRMarkerForGroup()
|
||||
return
|
||||
end
|
||||
|
||||
if self.spot then
|
||||
self.spot:destroy()
|
||||
self.spot = nil
|
||||
end
|
||||
if self.timer and self.timer:IsRunning() then
|
||||
@ -5703,9 +5705,9 @@ function CONTROLLABLE:DisableIRMarker()
|
||||
self.timer = nil
|
||||
end
|
||||
|
||||
if self.ClassName == "GROUP" then
|
||||
if self:IsInstanceOf("GROUP") then
|
||||
self.IRMarkerGroup = nil
|
||||
elseif self.ClassName == "UNIT" then
|
||||
elseif self:IsInstanceOf("UNIT") then
|
||||
self.IRMarkerUnit = nil
|
||||
end
|
||||
|
||||
@ -5714,14 +5716,17 @@ end
|
||||
|
||||
--- [GROUND] Enable the IR markers for a whole group.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param #number Runtime Runtime of the marker in seconds
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:EnableIRMarkerForGroup()
|
||||
--self:F("EnableIRMarkerForGroup")
|
||||
if self.ClassName == "GROUP" then
|
||||
function CONTROLLABLE:EnableIRMarkerForGroup(Runtime)
|
||||
self:T2("EnableIRMarkerForGroup")
|
||||
if self:IsInstanceOf("GROUP")
|
||||
then
|
||||
local units = self:GetUnits() or {}
|
||||
for _,_unit in pairs(units) do
|
||||
_unit:EnableIRMarker()
|
||||
_unit:EnableIRMarker(Runtime)
|
||||
end
|
||||
self.IRMarkerGroup = true
|
||||
end
|
||||
return self
|
||||
end
|
||||
@ -5730,8 +5735,8 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:DisableIRMarkerForGroup()
|
||||
--sefl:F("DisableIRMarkerForGroup")
|
||||
if self.ClassName == "GROUP" then
|
||||
self:T2("DisableIRMarkerForGroup")
|
||||
if self:IsInstanceOf("GROUP") then
|
||||
local units = self:GetUnits() or {}
|
||||
for _,_unit in pairs(units) do
|
||||
_unit:DisableIRMarker()
|
||||
@ -5745,15 +5750,15 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #boolean outcome
|
||||
function CONTROLLABLE:HasIRMarker()
|
||||
if self.IRMarkerGroup == true or self.IRMarkerUnit == true then return true end
|
||||
self:T2("HasIRMarker")
|
||||
if self.timer and self.timer:IsRunning() then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
--- [Internal] This method is called by the scheduler after disabling the IR marker.
|
||||
--- [Internal] This method is called by the scheduler to blink the IR marker.
|
||||
function CONTROLLABLE._StopSpot(spot)
|
||||
if spot then
|
||||
spot:destroy()
|
||||
spot=nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -5761,7 +5766,7 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:_MarkerBlink()
|
||||
--sefl:F("_MarkerBlink")
|
||||
self:T2("_MarkerBlink")
|
||||
if self:IsAlive() ~= true then
|
||||
self:DisableIRMarker()
|
||||
return
|
||||
@ -5772,7 +5777,8 @@ function CONTROLLABLE:_MarkerBlink()
|
||||
local _, _, unitBBHeight, _ = self:GetObjectSize()
|
||||
local unitPos = self:GetPositionVec3()
|
||||
|
||||
if not self.spot then
|
||||
if self.timer:IsRunning() then
|
||||
self:T2("Create Spot")
|
||||
local spot = Spot.createInfraRed(
|
||||
self.DCSUnit,
|
||||
{ x = 0, y = (unitBBHeight + 1), z = 0 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user