mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
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:
parent
497a2c17d0
commit
980053916b
@ -1004,14 +1004,14 @@ function SET_GROUP:AnyCompletelyInZone(Zone)
|
|||||||
self:F2(Zone)
|
self:F2(Zone)
|
||||||
local Set = self:GetSet()
|
local Set = self:GetSet()
|
||||||
for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP
|
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
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
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 #SET_GROUP self
|
||||||
-- @param Core.Zone#ZONE ZoneObject The Zone to be tested for.
|
-- @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.
|
-- @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
|
-- if MySetGroup:AnyPartlyInZone(MyZone) then
|
||||||
-- MESSAGE:New("At least one GROUP has at least one UNIT in zone !", 10):ToAll()
|
-- MESSAGE:New("At least one GROUP has at least one UNIT in zone !", 10):ToAll()
|
||||||
-- else
|
-- else
|
||||||
-- MESSAGE:New("No GROUP is completely in zone !", 10):ToAll()
|
-- MESSAGE:New("No UNIT of any GROUP is in zone !", 10):ToAll()
|
||||||
-- end
|
-- end
|
||||||
function SET_GROUP:AnyPartlyInZone(Zone)
|
function SET_GROUP:AnyPartlyInZone(Zone)
|
||||||
self:F2(Zone)
|
self:F2(Zone)
|
||||||
@ -1050,7 +1050,7 @@ end
|
|||||||
-- if MySetGroup:NoneInZone(MyZone) then
|
-- if MySetGroup:NoneInZone(MyZone) then
|
||||||
-- MESSAGE:New("No GROUP is completely in zone !", 10):ToAll()
|
-- MESSAGE:New("No GROUP is completely in zone !", 10):ToAll()
|
||||||
-- else
|
-- 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
|
-- end
|
||||||
function SET_GROUP:NoneInZone(Zone)
|
function SET_GROUP:NoneInZone(Zone)
|
||||||
self:F2(Zone)
|
self:F2(Zone)
|
||||||
|
|||||||
@ -555,22 +555,23 @@ end
|
|||||||
function GROUP:IsPartlyInZone( Zone )
|
function GROUP:IsPartlyInZone( Zone )
|
||||||
self:F2( { self.GroupName, Zone } )
|
self:F2( { self.GroupName, Zone } )
|
||||||
|
|
||||||
local PartlyInZone = false
|
local IsOneUnitInZone = false
|
||||||
|
local IsOneUnitOutsideZone = false
|
||||||
|
|
||||||
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
if Zone:IsVec3InZone( Unit:GetVec3() ) then
|
if Zone:IsVec3InZone( Unit:GetVec3() ) then
|
||||||
PartlyInZone = true
|
IsOneUnitInZone = true
|
||||||
else
|
else
|
||||||
-- So, if there were groups in the zone found, and suddenly one NOT in the zone,
|
IsOneUnitOutsideZone = true
|
||||||
-- then the group is partialy in the zone :-)
|
|
||||||
if PartlyInZone == true then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
if IsOneUnitInZone and IsOneUnitOutsideZone then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns true if none of the group units of the group are within a @{Zone}.
|
--- Returns true if none of the group units of the group are within a @{Zone}.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user