* Added IsSam and IsAAA

#SET
* Corrected EvalFilterFunctions - all must be true
This commit is contained in:
Applevangelist 2023-12-30 16:51:45 +01:00
parent 0347e42fc7
commit f306361317
2 changed files with 44 additions and 17 deletions

View File

@ -171,25 +171,18 @@ do -- SET_BASE
--- [Internal] Check if the condition functions returns true. --- [Internal] Check if the condition functions returns true.
-- @param #SET_BASE self -- @param #SET_BASE self
-- @param Wrapper.Controllable#CONTROLLABLE Object The object to filter for -- @param Wrapper.Controllable#CONTROLLABLE Object The object to filter for
-- @return #boolean If true, at least one condition is true. -- @return #boolean If true, if **all** conditions are true
function SET_BASE:_EvalFilterFunctions(Object) function SET_BASE:_EvalFilterFunctions(Object)
-- All conditions must be true.
-- Any one condition must be true.
for _,_condition in pairs(self.Filter.Functions or {}) do for _,_condition in pairs(self.Filter.Functions or {}) do
local condition=_condition local condition=_condition
-- Call function. -- Call function.
local istrue=condition.func(Object,unpack(condition.arg)) if condition.func(Object,unpack(condition.arg)) == false then
return false
-- Any true will return true.
if istrue then
return true
end end
end end
-- No condition was true. -- No condition was true.
return false return true
end end
--- Clear the Objects in the Set. --- Clear the Objects in the Set.
@ -2049,7 +2042,8 @@ do
end end
if self.Filter.Functions then if self.Filter.Functions then
local MGroupFunc = self:_EvalFilterFunctions(MGroup) local MGroupFunc = false
MGroupFunc = self:_EvalFilterFunctions(MGroup)
MGroupInclude = MGroupInclude and MGroupFunc MGroupInclude = MGroupInclude and MGroupFunc
end end

View File

@ -2763,7 +2763,7 @@ end
--- Switch on/off invisible flag for the group. --- Switch on/off invisible flag for the group.
-- @param #GROUP self -- @param #GROUP self
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled. -- @param #boolean switch If true, Invisible is enabled. If false, Invisible is disabled.
-- @return #GROUP self -- @return #GROUP self
function GROUP:SetCommandInvisible(switch) function GROUP:SetCommandInvisible(switch)
self:F2( self.GroupName ) self:F2( self.GroupName )
@ -2777,7 +2777,7 @@ end
--- Switch on/off immortal flag for the group. --- Switch on/off immortal flag for the group.
-- @param #GROUP self -- @param #GROUP self
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled. -- @param #boolean switch If true, Immortal is enabled. If false, Immortal is disabled.
-- @return #GROUP self -- @return #GROUP self
function GROUP:SetCommandImmortal(switch) function GROUP:SetCommandImmortal(switch)
self:F2( self.GroupName ) self:F2( self.GroupName )
@ -2983,3 +2983,36 @@ function GROUP:GetGroupSTN()
return tSTN,text return tSTN,text
end end
--- [GROUND] Determine if a GROUP is a SAM unit, i.e. has radar or optical tracker and is no mobile AAA.
-- @param #GROUP self
-- @return #boolean IsSAM True if SAM, else false
function GROUP:IsSAM()
local issam = false
local units = self:GetUnits()
for _,_unit in pairs(units or {}) do
local unit = _unit -- Wrapper.Unit#UNIT
if unit:HasSEAD() and unit:IsGround() and (not unit:HasAttribute("Mobile AAA")) then
issam = true
break
end
end
return issam
end
--- [GROUND] Determine if a GROUP is a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
-- @param #GROUP self
-- @return #boolean IsSAM True if AAA, else false
function GROUP:IsAAA()
local issam = true
local units = self:GetUnits()
for _,_unit in pairs(units or {}) do
local unit = _unit -- Wrapper.Unit#UNIT
if unit:HasSEAD() or (not unit:IsGround()) then
issam = false
if unit:HasAttribute("Mobile AAA") then
issam = true
end
end
end
return issam
end