Merge remote-tracking branch 'refs/remotes/origin/master' into 386-ai-designate

This commit is contained in:
FlightControl
2017-04-23 08:48:40 +02:00
8 changed files with 663 additions and 29 deletions

View File

@@ -555,22 +555,23 @@ end
function GROUP:IsPartlyInZone( Zone )
self:F2( { self.GroupName, Zone } )
local PartlyInZone = false
local IsOneUnitInZone = false
local IsOneUnitOutsideZone = false
for UnitID, UnitData in pairs( self:GetUnits() ) do
local Unit = UnitData -- Wrapper.Unit#UNIT
if Zone:IsVec3InZone( Unit:GetVec3() ) then
PartlyInZone = true
IsOneUnitInZone = true
else
-- So, if there were groups in the zone found, and suddenly one NOT in the zone,
-- then the group is partialy in the zone :-)
if PartlyInZone == true then
return true
end
IsOneUnitOutsideZone = true
end
end
return false
if IsOneUnitInZone and IsOneUnitOutsideZone then
return true
else
return false
end
end
--- Returns true if none of the group units of the group are within a @{Zone}.
@@ -590,6 +591,24 @@ function GROUP:IsNotInZone( Zone )
return true
end
--- Returns the number of UNITs that are in the @{Zone}
-- @param #GROUP self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #number The number of UNITs that are in the @{Zone}
function GROUP:CountInZone( Zone )
self:F2( {self.GroupName, Zone} )
local Count = 0
for UnitID, UnitData in pairs( self:GetUnits() ) do
local Unit = UnitData -- Wrapper.Unit#UNIT
if Zone:IsVec3InZone( Unit:GetVec3() ) then
Count = Count + 1
end
end
return Count
end
--- Returns if the group is of an air category.
-- If the group is a helicopter or a plane, then this method will return true, otherwise false.
-- @param #GROUP self