mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Implement the new SET_GROUP:AnyPartlyInZone()
This commit is contained in:
parent
fb6bb635c6
commit
18756eb61e
@ -1045,7 +1045,7 @@ end
|
|||||||
-- else
|
-- else
|
||||||
-- MESSAGE:New("No UNIT of any GROUP is 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:AnyInZone(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
|
||||||
@ -1056,6 +1056,40 @@ function SET_GROUP:AnyPartlyInZone(Zone)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Iterate the SET_GROUP and return true if at least one @{GROUP} of the @{SET_GROUP} is partly in @{ZONE}.
|
||||||
|
-- Will return false if a @{GROUP} is fully in the @{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.
|
||||||
|
-- @usage
|
||||||
|
-- local MyZone = ZONE:New("Zone1")
|
||||||
|
-- local MySetGroup = SET_GROUP:New()
|
||||||
|
-- MySetGroup:AddGroupsByName({"Group1", "Group2"})
|
||||||
|
--
|
||||||
|
-- if MySetGroup:AnyPartlyInZone(MyZone) then
|
||||||
|
-- MESSAGE:New("At least one GROUP is partially in the zone, but none are fully in it !", 10):ToAll()
|
||||||
|
-- else
|
||||||
|
-- MESSAGE:New("No GROUP are in zone, or one GROUP is completely in it !", 10):ToAll()
|
||||||
|
-- end
|
||||||
|
function SET_GROUP:AnyPartlyInZone(Zone)
|
||||||
|
self:F2(Zone)
|
||||||
|
local IsPartlyInZone = false
|
||||||
|
local Set = self:GetSet()
|
||||||
|
for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP
|
||||||
|
if GroupData:IsCompletelyInZone(Zone) then
|
||||||
|
return false
|
||||||
|
elseif GroupData:IsPartlyInZone(Zone) then
|
||||||
|
IsPartlyInZone = true -- at least one GROUP is partly in zone
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if IsPartlyInZone then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Iterate the SET_GROUP and return true if no @{GROUP} of the @{SET_GROUP} is in @{ZONE}
|
--- Iterate the SET_GROUP and return true if no @{GROUP} of the @{SET_GROUP} is in @{ZONE}
|
||||||
-- This could also be achieved with `not SET_GROUP:AnyPartlyInZone(Zone)`, but it's easier for the
|
-- This could also be achieved with `not SET_GROUP:AnyPartlyInZone(Zone)`, but it's easier for the
|
||||||
-- mission designer to add a dedicated method
|
-- mission designer to add a dedicated method
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user