From cfed6f515371535c9b62174938f9c1b53d908dc1 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 21 Sep 2021 07:47:43 +0200 Subject: [PATCH] SET - Added SET_CLIENT:CountAlive() --- Moose Development/Moose/Core/Set.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 4ddac7939..44194929f 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -3998,7 +3998,25 @@ do -- SET_CLIENT return self end + + --- Iterate the SET_CLIENT and count alive units. + -- @param #SET_CLIENT self + -- @return #number count + function SET_CLIENT:CountAlive() + local Set = self:GetSet() + + local CountU = 0 + for UnitID, UnitData in pairs(Set) do -- For each GROUP in SET_GROUP + if UnitData and UnitData:IsAlive() then + CountU = CountU + 1 + end + + end + + return CountU + end + --- -- @param #SET_CLIENT self -- @param Wrapper.Client#CLIENT MClient