mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
@@ -562,6 +562,118 @@ function ZONE_RADIUS:GetVec3( Height )
|
||||
end
|
||||
|
||||
|
||||
--- Scan the zone
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param Coalition
|
||||
function ZONE_RADIUS:Scan()
|
||||
|
||||
self.Coalitions = {}
|
||||
|
||||
local ZoneCoord = self:GetCoordinate()
|
||||
local ZoneRadius = self:GetRadius()
|
||||
|
||||
self:E({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()})
|
||||
|
||||
local SphereSearch = {
|
||||
id = world.VolumeType.SPHERE,
|
||||
params = {
|
||||
point = ZoneCoord:GetVec3(),
|
||||
radius = ZoneRadius,
|
||||
}
|
||||
}
|
||||
|
||||
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 } )
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
world.searchObjects( { Object.Category.UNIT, Object.Category.STATIC }, SphereSearch, EvaluateZone )
|
||||
|
||||
end
|
||||
|
||||
|
||||
function ZONE_RADIUS:CountCoalitions()
|
||||
|
||||
local Count = 0
|
||||
|
||||
for CoalitionID, Coalition in pairs( self.Coalitions ) do
|
||||
Count = Count + 1
|
||||
end
|
||||
return Count
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
--- Is All in Zone of Other Coalition?
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param Coalition
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition )
|
||||
|
||||
self:E( { Coalitions = self.Coalitions, Count = self:CountCoalitions() } )
|
||||
return self:CountCoalitions() == 1 and self.Coalitions[Coalition] == nil
|
||||
end
|
||||
|
||||
|
||||
--- Is Some in Zone of Coalition?
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param Coalition
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
||||
|
||||
return self:CountCoalitions() > 1 and self.Coalitions[Coalition] == true
|
||||
end
|
||||
|
||||
|
||||
--- Is None in Zone of Coalition?
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param Coalition
|
||||
-- @return #boolean
|
||||
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
||||
|
||||
return self.Coalitions[Coalition] == nil
|
||||
end
|
||||
|
||||
|
||||
--- Get the Zone Coalitions.
|
||||
-- Returns nil if there are none ot two coalitions in the zone!
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @return Coalitions
|
||||
function ZONE_RADIUS:GetCoalition()
|
||||
|
||||
local Count = 0
|
||||
local ReturnCoalition = nil
|
||||
|
||||
for CoalitionID, Coalition in pairs( self.Coalitions ) do
|
||||
Count = Count + 1
|
||||
ReturnCoalition = CoalitionID
|
||||
end
|
||||
|
||||
if Count ~= 1 then
|
||||
ReturnCoalition = nil
|
||||
end
|
||||
|
||||
return ReturnCoalition
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Searches the zone
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param EvaluateFunction
|
||||
@@ -582,11 +694,11 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction )
|
||||
}
|
||||
}
|
||||
|
||||
local function EvaluateZone( DCSZoneUnit )
|
||||
local function EvaluateZone( ZoneDCSUnit )
|
||||
|
||||
env.info( DCSZoneUnit:getName() )
|
||||
env.info( ZoneDCSUnit:getName() )
|
||||
|
||||
local ZoneUnit = UNIT:Find( DCSZoneUnit )
|
||||
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
||||
|
||||
return EvaluateFunction( ZoneUnit )
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user