mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-27 15:37:28 +00:00
@@ -186,6 +186,8 @@ function DATABASE:AddUnit( DCSUnitName, force )
|
|||||||
|
|
||||||
-- Register unit
|
-- Register unit
|
||||||
self.UNITS[DCSunitName]=UNIT:Register(DCSunitName)
|
self.UNITS[DCSunitName]=UNIT:Register(DCSunitName)
|
||||||
|
else
|
||||||
|
self.UNITS[DCSunitName]:ResetOptionCacheIfDCSObjectChanged()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.UNITS[DCSunitName]
|
return self.UNITS[DCSunitName]
|
||||||
@@ -802,6 +804,8 @@ function DATABASE:AddGroup( GroupName, force )
|
|||||||
if not self.GROUPS[GroupName] or force == true then
|
if not self.GROUPS[GroupName] or force == true then
|
||||||
self:T( { "Add GROUP:", GroupName } )
|
self:T( { "Add GROUP:", GroupName } )
|
||||||
self.GROUPS[GroupName] = GROUP:Register( GroupName )
|
self.GROUPS[GroupName] = GROUP:Register( GroupName )
|
||||||
|
else
|
||||||
|
self.GROUPS[GroupName]:ResetOptionCacheIfDCSObjectChanged()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.GROUPS[GroupName]
|
return self.GROUPS[GroupName]
|
||||||
|
|||||||
@@ -3283,34 +3283,22 @@ end
|
|||||||
-- @param #number OptionValue Value of the option
|
-- @param #number OptionValue Value of the option
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:SetOption( OptionID, OptionValue )
|
function CONTROLLABLE:SetOption( OptionID, OptionValue )
|
||||||
|
|
||||||
local setnewoption = false
|
|
||||||
|
|
||||||
-- Check if option has changed against cached option
|
|
||||||
local ID = tostring(OptionID)
|
local ID = tostring(OptionID)
|
||||||
if self.ControllableOptions then
|
if OptionValue ~= nil and self.ControllableOptions and self.ControllableOptions[ID] == OptionValue then
|
||||||
if (self.ControllableOptions[ID] ~= OptionValue) or (self.ControllableOptions[ID]==nil) then
|
return self
|
||||||
setnewoption = true
|
|
||||||
self.ControllableOptions[ID] = OptionValue
|
|
||||||
--self:I(string.format("CONTROLLABLE %s: Option CHANGE for option %d: New value: %s!",self.ControllableName, OptionID, tostring(OptionValue)))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- change option if changed
|
|
||||||
if setnewoption == true then
|
|
||||||
local DCSControllable = self:GetDCSObject()
|
|
||||||
if DCSControllable then
|
|
||||||
local Controller = self:_GetController()
|
|
||||||
--self:I(string.format("CONTROLLABLE %s: Setting OPTION %d: to value: %s!",self.ControllableName, OptionID, tostring(OptionValue)))
|
|
||||||
Controller:setOption( OptionID, OptionValue )
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
--else
|
|
||||||
--self:I(string.format("CONTROLLABLE %s: Option NO CHANGE for option %d: Same value: %s!",self.ControllableName, OptionID, tostring(OptionValue)))
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = DCSControllable:getController()
|
||||||
|
Controller:setOption( OptionID, OptionValue )
|
||||||
|
self.ControllableOptions = self.ControllableOptions or {}
|
||||||
|
self.ControllableOptions[ID] = OptionValue
|
||||||
|
self.ControllableOptionDCSObject = DCSControllable
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Query a (cached) option. Requires the option has been set with Moose(!) before.
|
--- Query a (cached) option. Requires the option has been set with Moose(!) before.
|
||||||
@@ -3325,6 +3313,27 @@ function CONTROLLABLE:QueryCachedOption(OptionID)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Reset cached options for this controllable.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:ResetOptionCache()
|
||||||
|
self.ControllableOptions = {}
|
||||||
|
self.ControllableOptionDCSObject = self:GetDCSObject()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Reset cached options when the underlying DCS object has changed.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:ResetOptionCacheIfDCSObjectChanged()
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if self.ControllableOptionDCSObject ~= DCSControllable then
|
||||||
|
self.ControllableOptions = {}
|
||||||
|
self.ControllableOptionDCSObject = DCSControllable
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set option for Rules of Engagement (ROE).
|
--- Set option for Rules of Engagement (ROE).
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param #number ROEvalue ROE value. See ENUMS.ROE.
|
-- @param #number ROEvalue ROE value. See ENUMS.ROE.
|
||||||
|
|||||||
@@ -2272,9 +2272,8 @@ function GROUP:Respawn( Template, Reset )
|
|||||||
-- Reset events.
|
-- Reset events.
|
||||||
self:ResetEvents()
|
self:ResetEvents()
|
||||||
|
|
||||||
-- Reset options
|
-- Reset options.
|
||||||
self.ControllableOptions = nil
|
self:ResetOptionCache()
|
||||||
self.ControllableOptions = {}
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user