#ZONE - Added optional coalition filter on GetScannedUnitSet() and GetScannedGroupSet()

This commit is contained in:
Applevangelist
2025-12-14 14:35:50 +01:00
parent 8160aad1bf
commit 093526f4ff
+20 -6
View File
@@ -1168,7 +1168,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
local ZoneCoord = self:GetCoordinate():SetAlt() local ZoneCoord = self:GetCoordinate():SetAlt()
local ZoneRadius = self:GetRadius() local ZoneRadius = self:GetRadius()
--self:F({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()}) --self:I({x = ZoneCoord.x, y=ZoneCoord.y, z=ZoneCoord.z, ZoneRadius = ZoneRadius})
local SphereSearch = { local SphereSearch = {
id = world.VolumeType.SPHERE, id = world.VolumeType.SPHERE,
@@ -1180,6 +1180,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
local function EvaluateZone( ZoneObject ) local function EvaluateZone( ZoneObject )
--if ZoneObject:isExist() then --FF: isExist always returns false for SCENERY objects since DCS 2.2 and still in DCS 2.5 --if ZoneObject:isExist() then --FF: isExist always returns false for SCENERY objects since DCS 2.2 and still in DCS 2.5
if ZoneObject and self:IsVec3InZone(ZoneObject:getPoint()) then if ZoneObject and self:IsVec3InZone(ZoneObject:getPoint()) then
-- Get object category. -- Get object category.
@@ -1265,8 +1266,9 @@ end
--- Get a set of scanned units. --- Get a set of scanned units.
-- @param #ZONE_RADIUS self -- @param #ZONE_RADIUS self
-- @param #number Coalition (optional) Filter for this coalition only.
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone. -- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
function ZONE_RADIUS:GetScannedSetUnit() function ZONE_RADIUS:GetScannedSetUnit(Coalition)
local SetUnit = SET_UNIT:New() local SetUnit = SET_UNIT:New()
@@ -1275,7 +1277,12 @@ function ZONE_RADIUS:GetScannedSetUnit()
local UnitObject = UnitObject -- DCS#Unit local UnitObject = UnitObject -- DCS#Unit
if UnitObject:isExist() then if UnitObject:isExist() then
local FoundUnit = UNIT:FindByName( UnitObject:getName() ) local FoundUnit = UNIT:FindByName( UnitObject:getName() )
if FoundUnit then local FoundCoalition = FoundUnit and FoundUnit:GetCoalition() or nil
local includeoncoalition = true
if Coalition ~= nil and FoundCoalition==Coalition then includeoncoalition = true else includeoncoalition = false end
if Coalition == nil then includeoncoalition = true end
--self:I(string.format("Unit name %s coalition %s filter coalition = %s include = %s",FoundUnit:GetName(),tostring(FoundCoalition),tostring(Coalition),tostring(includeoncoalition)))
if FoundUnit and includeoncoalition then
SetUnit:AddUnit( FoundUnit ) SetUnit:AddUnit( FoundUnit )
else else
local FoundStatic = STATIC:FindByName( UnitObject:getName(), false ) local FoundStatic = STATIC:FindByName( UnitObject:getName(), false )
@@ -1292,11 +1299,13 @@ end
--- Get a set of scanned groups. --- Get a set of scanned groups.
-- @param #ZONE_RADIUS self -- @param #ZONE_RADIUS self
-- @param #number Coalition (optional) Filter for this coalition only.
-- @return Core.Set#SET_GROUP Set of groups. -- @return Core.Set#SET_GROUP Set of groups.
function ZONE_RADIUS:GetScannedSetGroup() function ZONE_RADIUS:GetScannedSetGroup(Coalition)
self.ScanSetGroup=self.ScanSetGroup or SET_GROUP:New() --Core.Set#SET_GROUP self.ScanSetGroup=self.ScanSetGroup or SET_GROUP:New() --Core.Set#SET_GROUP
self.ScanSetGroup:Clear(false)
self.ScanSetGroup.Set={} self.ScanSetGroup.Set={}
if self.ScanData then if self.ScanData then
@@ -1305,7 +1314,12 @@ function ZONE_RADIUS:GetScannedSetGroup()
if UnitObject:isExist() then if UnitObject:isExist() then
local FoundUnit=UNIT:FindByName(UnitObject:getName()) local FoundUnit=UNIT:FindByName(UnitObject:getName())
if FoundUnit then local FoundCoalition = FoundUnit and FoundUnit:GetCoalition() or nil
local includeoncoalition = true
if Coalition ~= nil and FoundCoalition==Coalition then includeoncoalition = true else includeoncoalition = false end
if Coalition == nil then includeoncoalition = true end
--self:I(string.format("Unit name %s coalition %s filter coalition = %s include = %s",FoundUnit:GetName(),tostring(FoundCoalition),tostring(Coalition),tostring(includeoncoalition)))
if FoundUnit and includeoncoalition then
local group=FoundUnit:GetGroup() local group=FoundUnit:GetGroup()
self.ScanSetGroup:AddGroup(group) self.ScanSetGroup:AddGroup(group)
end end
@@ -3380,7 +3394,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {} self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject ) self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject )
table.insert(self.ScanData.SceneryTable,self.ScanData.Scenery[SceneryType][SceneryName]) table.insert(self.ScanData.SceneryTable,self.ScanData.Scenery[SceneryType][SceneryName])
--self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } ) --self:I( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
end end
end end