Solves a bug in GROUP:IsPartlyInZone()

If only the first UNITs of the GROUP where outside the ZONE, the function would still return false
This behaviour is fixed by this commit.
This commit is contained in:
Grey-Echo 2017-04-22 11:15:16 +02:00
parent 497a2c17d0
commit 980053916b
2 changed files with 13 additions and 12 deletions

View File

@ -1004,14 +1004,14 @@ function SET_GROUP:AnyCompletelyInZone(Zone)
self:F2(Zone)
local Set = self:GetSet()
for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP
if GroupData:IsCompletlyInZone(Zone) then
if GroupData:IsCompletelyInZone(Zone) then
return true
end
end
return false
end
--- Iterate the SET_GROUP and return true if at least one least one @{#UNIT} of one @{GROUP} of the @{SET_GROUP} is in @{ZONE}
--- Iterate the SET_GROUP and return true if at least one @{#UNIT} of one @{GROUP} of the @{SET_GROUP} is in @{ZONE}
-- @param #SET_GROUP self
-- @param Core.Zone#ZONE ZoneObject The Zone to be tested for.
-- @return #boolean true if at least one of the @{Wrapper.Group#GROUP} is partly or completly inside the @{Core.Zone#ZONE}, false otherwise.
@ -1023,7 +1023,7 @@ end
-- if MySetGroup:AnyPartlyInZone(MyZone) then
-- MESSAGE:New("At least one GROUP has at least one UNIT in zone !", 10):ToAll()
-- else
-- MESSAGE:New("No GROUP is completely in zone !", 10):ToAll()
-- MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll()
-- end
function SET_GROUP:AnyPartlyInZone(Zone)
self:F2(Zone)
@ -1050,7 +1050,7 @@ end
-- if MySetGroup:NoneInZone(MyZone) then
-- MESSAGE:New("No GROUP is completely in zone !", 10):ToAll()
-- else
-- MESSAGE:New("At least one GROUP has at least one UNIT in zone !", 10):ToAll()
-- MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll()
-- end
function SET_GROUP:NoneInZone(Zone)
self:F2(Zone)

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}.