From bfda34e94d2cc52c2d7d86679ea7ea0a1a8e7bc9 Mon Sep 17 00:00:00 2001 From: Grey-Echo Date: Sat, 22 Apr 2017 01:06:35 +0200 Subject: [PATCH] Implement SET_GROUP:AnyCompletelyInZone Also renames the 2 previously implemented funcitons --- Moose Development/Moose/Core/Set.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 96ad77579..9827670cf 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -961,7 +961,7 @@ function SET_GROUP:ForEachGroupNotInZone( ZoneObject, IteratorFunction, ... ) return self end ---- Iterate the SET_GROUP and return true if all the @{Wrapper.Group#GROUP} are completly in the @{Core.Zone#ZONE} +--- Iterate the SET_GROUP and return true if all the @{Wrapper.Group#GROUP} are completely in the @{Core.Zone#ZONE} -- @param #SET_GROUP self -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. -- @return #boolean true if all the @{Wrapper.Group#GROUP} are completly in the @{Core.Zone#ZONE}, false otherwise @@ -975,7 +975,7 @@ end -- else -- MESSAGE:New("Some or all SET's GROUP are outside zone !", 10):ToAll() -- end -function SET_GROUP:IsCompletelyInZone(Zone) +function SET_GROUP:AllCompletelyInZone(Zone) self:F2(Zone) local Set = self:GetSet() for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP @@ -986,11 +986,11 @@ function SET_GROUP:IsCompletelyInZone(Zone) return true end ---- Iterate the SET_GROUP and return true if at least one of the @{Wrapper.Group#GROUP} is completly inside the @{Core.Zone#ZONE} +--- Iterate the SET_GROUP and return true if at least one of the @{Wrapper.Group#GROUP} is completely inside the @{Core.Zone#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 completly inside the @{Core.Zone#ZONE}, false otherwise. -function SET_GROUP:HasGroupCompletelyInZone(Zone) +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 @@ -1001,6 +1001,22 @@ function SET_GROUP:HasGroupCompletelyInZone(Zone) 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} +-- @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 completly inside the @{Core.Zone#ZONE}, false otherwise. +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:IsPartlyInZone(Zone) then + return true + end + end + return false +end + ----- Iterate the SET_GROUP and call an interator function for each **alive** player, providing the Group of the player and optional parameters. ---- @param #SET_GROUP self ---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_GROUP. The function needs to accept a GROUP parameter.