mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Scenery Search methods
This commit is contained in:
parent
712b77b590
commit
8542823692
@ -577,10 +577,13 @@ end
|
||||
|
||||
--- Scan the zone
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param ObjectCategories
|
||||
-- @param Coalition
|
||||
function ZONE_RADIUS:Scan()
|
||||
function ZONE_RADIUS:Scan( ObjectCategories )
|
||||
|
||||
self.Coalitions = {}
|
||||
self.ScanData = {}
|
||||
self.ScanData.Coalitions = {}
|
||||
self.ScanData.Scenery = {}
|
||||
|
||||
local ZoneCoord = self:GetCoordinate()
|
||||
local ZoneRadius = self:GetRadius()
|
||||
@ -595,41 +598,64 @@ function ZONE_RADIUS:Scan()
|
||||
}
|
||||
}
|
||||
|
||||
local function EvaluateZone( ZoneDCSUnit )
|
||||
if ZoneDCSUnit:isExist() then
|
||||
local CategoryDCSUnit = ZoneDCSUnit:getCategory()
|
||||
if ( CategoryDCSUnit == Object.Category.UNIT and ZoneDCSUnit:isActive() ) or
|
||||
CategoryDCSUnit == Object.Category.STATIC then
|
||||
local CoalitionDCSUnit = ZoneDCSUnit:getCoalition()
|
||||
self.Coalitions[CoalitionDCSUnit] = true
|
||||
self:E( { Name = ZoneDCSUnit:getName(), Coalition = CoalitionDCSUnit } )
|
||||
local function EvaluateZone( ZoneObject )
|
||||
if ZoneObject:isExist() then
|
||||
local ObjectCategory = ZoneObject:getCategory()
|
||||
if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isActive() ) or
|
||||
ObjectCategory == Object.Category.STATIC then
|
||||
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||
self.ScanData.Coalitions[CoalitionDCSUnit] = true
|
||||
self:E( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
|
||||
end
|
||||
if ObjectCategory == Object.Category.SCENERY then
|
||||
local SceneryType = ZoneObject:getTypeName()
|
||||
local SceneryName = ZoneObject:getName()
|
||||
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
|
||||
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject )
|
||||
self:E( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
world.searchObjects( { Object.Category.UNIT, Object.Category.STATIC }, SphereSearch, EvaluateZone )
|
||||
world.searchObjects( ObjectCategories, SphereSearch, EvaluateZone )
|
||||
|
||||
end
|
||||
|
||||
|
||||
function ZONE_RADIUS:CountCoalitions()
|
||||
function ZONE_RADIUS:CountScannedCoalitions()
|
||||
|
||||
local Count = 0
|
||||
|
||||
for CoalitionID, Coalition in pairs( self.Coalitions ) do
|
||||
for CoalitionID, Coalition in pairs( self.ScanData.Coalitions ) do
|
||||
Count = Count + 1
|
||||
end
|
||||
return Count
|
||||
end
|
||||
|
||||
|
||||
function ZONE_RADIUS:GetScannedCoalition( Coalition )
|
||||
return self.ScanData.Coalitions[Coalition]
|
||||
end
|
||||
|
||||
|
||||
function ZONE_RADIUS:GetScannedSceneryType( SceneryType )
|
||||
return self.ScanData.Scenery[SceneryType]
|
||||
end
|
||||
|
||||
|
||||
function ZONE_RADIUS:GetScannedScenery()
|
||||
return self.ScanData.Scenery
|
||||
end
|
||||
|
||||
|
||||
--- Is All in Zone of Coalition?
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param Coalition
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsAllInZoneOfCoalition( Coalition )
|
||||
|
||||
return self:CountCoalitions() == 1 and self.Coalitions[Coalition] == true
|
||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
||||
end
|
||||
|
||||
|
||||
@ -639,8 +665,8 @@ end
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition )
|
||||
|
||||
self:E( { Coalitions = self.Coalitions, Count = self:CountCoalitions() } )
|
||||
return self:CountCoalitions() == 1 and self.Coalitions[Coalition] == nil
|
||||
self:E( { Coalitions = self.Coalitions, Count = self:CountScannedCoalitions() } )
|
||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
||||
end
|
||||
|
||||
|
||||
@ -650,7 +676,7 @@ end
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
||||
|
||||
return self:CountCoalitions() > 1 and self.Coalitions[Coalition] == true
|
||||
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
||||
end
|
||||
|
||||
|
||||
@ -660,7 +686,7 @@ end
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
||||
|
||||
return self.Coalitions[Coalition] == nil
|
||||
return self:GetScannedCoalition( Coalition ) == nil
|
||||
end
|
||||
|
||||
|
||||
@ -669,7 +695,7 @@ end
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsNoneInZone()
|
||||
|
||||
return self:CountCoalitions() == 0
|
||||
return self:CountScannedCoalitions() == 0
|
||||
end
|
||||
|
||||
|
||||
@ -695,11 +721,11 @@ function ZONE_RADIUS:GetCoalition()
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Searches the zone
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param ObjectCategories A list of categories, which are members of Object.Category
|
||||
-- @param EvaluateFunction
|
||||
function ZONE_RADIUS:SearchZone( EvaluateFunction )
|
||||
function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
|
||||
|
||||
local SearchZoneResult = true
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ do -- ZoneGoal
|
||||
local State = self:GetState()
|
||||
self:E( { State = self:GetState() } )
|
||||
|
||||
self.Zone:Scan()
|
||||
self.Zone:Scan( { Object.Category.UNIT, Object.Category.STATIC } )
|
||||
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user