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.
|
-- @param #number Runtime (Optionally) Run this IR Marker for the given number of seconds, then stop. Use in conjunction with EnableImmediately.
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:NewIRMarker(EnableImmediately, Runtime)
|
function CONTROLLABLE:NewIRMarker(EnableImmediately, Runtime)
|
||||||
--sefl:F("NewIRMarker")
|
self:T2("NewIRMarker")
|
||||||
if self.ClassName == "GROUP" then
|
if self:IsInstanceOf("GROUP") then
|
||||||
|
if self.IRMarkerGroup == true then return end
|
||||||
self.IRMarkerGroup = true
|
self.IRMarkerGroup = true
|
||||||
self.IRMarkerUnit = false
|
self.IRMarkerUnit = false
|
||||||
elseif self.ClassName == "UNIT" then
|
elseif self:IsInstanceOf("UNIT") then
|
||||||
|
if self.IRMarkerUnit == true then return end
|
||||||
self.IRMarkerGroup = false
|
self.IRMarkerGroup = false
|
||||||
self.IRMarkerUnit = true
|
self.IRMarkerUnit = true
|
||||||
end
|
end
|
||||||
|
|
||||||
self.spot = nil
|
|
||||||
self.timer = nil
|
|
||||||
self.stoptimer = nil
|
|
||||||
|
|
||||||
|
self.Runtime = Runtime or 60
|
||||||
if EnableImmediately and EnableImmediately == true then
|
if EnableImmediately and EnableImmediately == true then
|
||||||
self:EnableIRMarker(Runtime)
|
self:EnableIRMarker(Runtime)
|
||||||
end
|
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()`.
|
-- @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
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:EnableIRMarker(Runtime)
|
function CONTROLLABLE:EnableIRMarker(Runtime)
|
||||||
--sefl:F("EnableIRMarker")
|
self:T2("EnableIRMarker")
|
||||||
if self.IRMarkerGroup == nil then
|
if self.IRMarkerGroup == nil then
|
||||||
self:NewIRMarker(true,Runtime)
|
self:NewIRMarker(true,Runtime)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.IRMarkerGroup == true) then
|
if self:IsInstanceOf("GROUP") then
|
||||||
self:EnableIRMarkerForGroup()
|
self:EnableIRMarkerForGroup(Runtime)
|
||||||
return
|
return
|
||||||
end
|
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 = TIMER:New(CONTROLLABLE._MarkerBlink, self)
|
||||||
self.timer:Start(nil, 1 - math.random(1, 5) / 10 / 2, Runtime) -- start randomized
|
self.timer:Start(nil, 1 - math.random(1, 5) / 10 / 2, Runtime) -- start randomized
|
||||||
|
self.IRMarkerUnit = true
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -5688,14 +5691,13 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:DisableIRMarker()
|
function CONTROLLABLE:DisableIRMarker()
|
||||||
--sefl:F("DisableIRMarker")
|
self:T2("DisableIRMarker")
|
||||||
if (self.IRMarkerGroup == true) then
|
if self:IsInstanceOf("GROUP") then
|
||||||
self:DisableIRMarkerForGroup()
|
self:DisableIRMarkerForGroup()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.spot then
|
if self.spot then
|
||||||
self.spot:destroy()
|
|
||||||
self.spot = nil
|
self.spot = nil
|
||||||
end
|
end
|
||||||
if self.timer and self.timer:IsRunning() then
|
if self.timer and self.timer:IsRunning() then
|
||||||
@ -5703,9 +5705,9 @@ function CONTROLLABLE:DisableIRMarker()
|
|||||||
self.timer = nil
|
self.timer = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.ClassName == "GROUP" then
|
if self:IsInstanceOf("GROUP") then
|
||||||
self.IRMarkerGroup = nil
|
self.IRMarkerGroup = nil
|
||||||
elseif self.ClassName == "UNIT" then
|
elseif self:IsInstanceOf("UNIT") then
|
||||||
self.IRMarkerUnit = nil
|
self.IRMarkerUnit = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -5714,14 +5716,17 @@ end
|
|||||||
|
|
||||||
--- [GROUND] Enable the IR markers for a whole group.
|
--- [GROUND] Enable the IR markers for a whole group.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #number Runtime Runtime of the marker in seconds
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:EnableIRMarkerForGroup()
|
function CONTROLLABLE:EnableIRMarkerForGroup(Runtime)
|
||||||
--self:F("EnableIRMarkerForGroup")
|
self:T2("EnableIRMarkerForGroup")
|
||||||
if self.ClassName == "GROUP" then
|
if self:IsInstanceOf("GROUP")
|
||||||
|
then
|
||||||
local units = self:GetUnits() or {}
|
local units = self:GetUnits() or {}
|
||||||
for _,_unit in pairs(units) do
|
for _,_unit in pairs(units) do
|
||||||
_unit:EnableIRMarker()
|
_unit:EnableIRMarker(Runtime)
|
||||||
end
|
end
|
||||||
|
self.IRMarkerGroup = true
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -5730,8 +5735,8 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:DisableIRMarkerForGroup()
|
function CONTROLLABLE:DisableIRMarkerForGroup()
|
||||||
--sefl:F("DisableIRMarkerForGroup")
|
self:T2("DisableIRMarkerForGroup")
|
||||||
if self.ClassName == "GROUP" then
|
if self:IsInstanceOf("GROUP") then
|
||||||
local units = self:GetUnits() or {}
|
local units = self:GetUnits() or {}
|
||||||
for _,_unit in pairs(units) do
|
for _,_unit in pairs(units) do
|
||||||
_unit:DisableIRMarker()
|
_unit:DisableIRMarker()
|
||||||
@ -5745,15 +5750,15 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #boolean outcome
|
-- @return #boolean outcome
|
||||||
function CONTROLLABLE:HasIRMarker()
|
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
|
return false
|
||||||
end
|
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)
|
function CONTROLLABLE._StopSpot(spot)
|
||||||
if spot then
|
if spot then
|
||||||
spot:destroy()
|
spot:destroy()
|
||||||
spot=nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -5761,7 +5766,7 @@ end
|
|||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:_MarkerBlink()
|
function CONTROLLABLE:_MarkerBlink()
|
||||||
--sefl:F("_MarkerBlink")
|
self:T2("_MarkerBlink")
|
||||||
if self:IsAlive() ~= true then
|
if self:IsAlive() ~= true then
|
||||||
self:DisableIRMarker()
|
self:DisableIRMarker()
|
||||||
return
|
return
|
||||||
@ -5772,7 +5777,8 @@ function CONTROLLABLE:_MarkerBlink()
|
|||||||
local _, _, unitBBHeight, _ = self:GetObjectSize()
|
local _, _, unitBBHeight, _ = self:GetObjectSize()
|
||||||
local unitPos = self:GetPositionVec3()
|
local unitPos = self:GetPositionVec3()
|
||||||
|
|
||||||
if not self.spot then
|
if self.timer:IsRunning() then
|
||||||
|
self:T2("Create Spot")
|
||||||
local spot = Spot.createInfraRed(
|
local spot = Spot.createInfraRed(
|
||||||
self.DCSUnit,
|
self.DCSUnit,
|
||||||
{ x = 0, y = (unitBBHeight + 1), z = 0 },
|
{ x = 0, y = (unitBBHeight + 1), z = 0 },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user