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
|
--- Scan the zone
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param ObjectCategories
|
||||||
-- @param Coalition
|
-- @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 ZoneCoord = self:GetCoordinate()
|
||||||
local ZoneRadius = self:GetRadius()
|
local ZoneRadius = self:GetRadius()
|
||||||
@ -595,41 +598,64 @@ function ZONE_RADIUS:Scan()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function EvaluateZone( ZoneDCSUnit )
|
local function EvaluateZone( ZoneObject )
|
||||||
if ZoneDCSUnit:isExist() then
|
if ZoneObject:isExist() then
|
||||||
local CategoryDCSUnit = ZoneDCSUnit:getCategory()
|
local ObjectCategory = ZoneObject:getCategory()
|
||||||
if ( CategoryDCSUnit == Object.Category.UNIT and ZoneDCSUnit:isActive() ) or
|
if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isActive() ) or
|
||||||
CategoryDCSUnit == Object.Category.STATIC then
|
ObjectCategory == Object.Category.STATIC then
|
||||||
local CoalitionDCSUnit = ZoneDCSUnit:getCoalition()
|
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||||
self.Coalitions[CoalitionDCSUnit] = true
|
self.ScanData.Coalitions[CoalitionDCSUnit] = true
|
||||||
self:E( { Name = ZoneDCSUnit:getName(), Coalition = CoalitionDCSUnit } )
|
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
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
world.searchObjects( { Object.Category.UNIT, Object.Category.STATIC }, SphereSearch, EvaluateZone )
|
world.searchObjects( ObjectCategories, SphereSearch, EvaluateZone )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function ZONE_RADIUS:CountCoalitions()
|
function ZONE_RADIUS:CountScannedCoalitions()
|
||||||
|
|
||||||
local Count = 0
|
local Count = 0
|
||||||
|
|
||||||
for CoalitionID, Coalition in pairs( self.Coalitions ) do
|
for CoalitionID, Coalition in pairs( self.ScanData.Coalitions ) do
|
||||||
Count = Count + 1
|
Count = Count + 1
|
||||||
end
|
end
|
||||||
return Count
|
return Count
|
||||||
end
|
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?
|
--- Is All in Zone of Coalition?
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param Coalition
|
-- @param Coalition
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function ZONE_RADIUS:IsAllInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsAllInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self:CountCoalitions() == 1 and self.Coalitions[Coalition] == true
|
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -639,8 +665,8 @@ end
|
|||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition )
|
function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition )
|
||||||
|
|
||||||
self:E( { Coalitions = self.Coalitions, Count = self:CountCoalitions() } )
|
self:E( { Coalitions = self.Coalitions, Count = self:CountScannedCoalitions() } )
|
||||||
return self:CountCoalitions() == 1 and self.Coalitions[Coalition] == nil
|
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -650,7 +676,7 @@ end
|
|||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self:CountCoalitions() > 1 and self.Coalitions[Coalition] == true
|
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -660,7 +686,7 @@ end
|
|||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self.Coalitions[Coalition] == nil
|
return self:GetScannedCoalition( Coalition ) == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -669,7 +695,7 @@ end
|
|||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function ZONE_RADIUS:IsNoneInZone()
|
function ZONE_RADIUS:IsNoneInZone()
|
||||||
|
|
||||||
return self:CountCoalitions() == 0
|
return self:CountScannedCoalitions() == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -695,11 +721,11 @@ function ZONE_RADIUS:GetCoalition()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Searches the zone
|
--- Searches the zone
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param ObjectCategories A list of categories, which are members of Object.Category
|
||||||
-- @param EvaluateFunction
|
-- @param EvaluateFunction
|
||||||
function ZONE_RADIUS:SearchZone( EvaluateFunction )
|
function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
|
||||||
|
|
||||||
local SearchZoneResult = true
|
local SearchZoneResult = true
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ do -- ZoneGoal
|
|||||||
local State = self:GetState()
|
local State = self:GetState()
|
||||||
self:E( { State = self:GetState() } )
|
self:E( { State = self:GetState() } )
|
||||||
|
|
||||||
self.Zone:Scan()
|
self.Zone:Scan( { Object.Category.UNIT, Object.Category.STATIC } )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user