From b51e758516150d45a841a4d51d7373fb3e61f681 Mon Sep 17 00:00:00 2001 From: smiki Date: Tue, 30 Sep 2025 21:17:29 +0200 Subject: [PATCH 1/5] [ADDED] SET_OPSGROUP:CountAlive --- Moose Development/Moose/Core/Set.lua | 22 +++++++++++++++++++ .../Moose/Wrapper/Positionable.lua | 18 ++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 06981e95f..5ee275fd5 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -7865,6 +7865,28 @@ do -- SET_OPSGROUP return self end + --- Iterate the SET_OPSGROUP and count how many GROUPs and UNITs are alive. + -- @param #SET_GROUP self + -- @return #number The number of GROUPs alive. + -- @return #number The number of UNITs alive. + function SET_OPSGROUP:CountAlive() + local CountG = 0 + local CountU = 0 + + local Set = self:GetSet() + + for GroupID, GroupData in pairs( Set ) do -- For each GROUP in SET_GROUP + if GroupData and GroupData:IsAlive() then + CountG = CountG + 1 + -- Count Units. + CountU = CountU + GroupData:GetGroup():CountAliveUnits() + end + + end + + return CountG, CountU + end + --- Finds an OPSGROUP based on the group name. -- @param #SET_OPSGROUP self -- @param #string GroupName Name of the group. diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 65b145384..038eefe56 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -361,15 +361,17 @@ function POSITIONABLE:GetCoord() -- Get the current position. local PositionableVec3 = self:GetVec3() - if self.coordinate then - -- Update COORDINATE from 3D vector. - self.coordinate:UpdateFromVec3( PositionableVec3 ) - else - -- New COORDINATE. - self.coordinate = COORDINATE:NewFromVec3( PositionableVec3 ) - end + if PositionableVec3 then + if self.coordinate then + -- Update COORDINATE from 3D vector. + self.coordinate:UpdateFromVec3( PositionableVec3 ) + else + -- New COORDINATE. + self.coordinate = COORDINATE:NewFromVec3( PositionableVec3 ) + end - return self.coordinate + return self.coordinate + end end -- Error message. From 43b4a6834b021d999845a094f4ca2c9d9c6bb97f Mon Sep 17 00:00:00 2001 From: smiki Date: Wed, 1 Oct 2025 14:50:04 +0200 Subject: [PATCH 2/5] [FIXED] ZONE_POLYGON from RECT ME drawing rotation not taken into account. --- Moose Development/Moose/Core/Database.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index a8c814260..20d6c94ce 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -577,13 +577,22 @@ do -- Zones and Pathlines -- For a rectangular polygon drawing, we have the width (y) and height (x). local w=objectData.width local h=objectData.height + local rotation = UTILS.ToRadian(objectData.angle or 0) - -- Create points from center using with and height (width for y and height for x is a bit confusing, but this is how ED implemented it). - local points={} - points[1]={x=vec2.x-h/2, y=vec2.y+w/2} --Upper left - points[2]={x=vec2.x+h/2, y=vec2.y+w/2} --Upper right - points[3]={x=vec2.x+h/2, y=vec2.y-w/2} --Lower right - points[4]={x=vec2.x-h/2, y=vec2.y-w/2} --Lower left + local dx = vec2.x + math.abs(w) + local dy = vec2.y + math.abs(h) + + local sinRot = math.sin(-rotation) + local cosRot = math.cos(-rotation) + dx = (dx / 2) + dy = (dy / 2) + + local points = { + { x = -dx * cosRot - (-dy * sinRot) + vec2.x, y = -dx * sinRot + (-dy * cosRot) + vec2.y }, + { x = dx * cosRot - (-dy * sinRot) + vec2.x, y = dx * sinRot + (-dy * cosRot) + vec2.y }, + { x = dx * cosRot - (dy * sinRot) + vec2.x, y = dx * sinRot + (dy * cosRot) + vec2.y }, + { x = -dx * cosRot - (dy * sinRot) + vec2.x, y = -dx * sinRot + (dy * cosRot) + vec2.y }, + } --local coord=COORDINATE:NewFromVec2(vec2):MarkToAll("MapX, MapY") From f39236c8fd8954f71b9a4921d4b398f6436db5c9 Mon Sep 17 00:00:00 2001 From: smiki Date: Wed, 1 Oct 2025 14:59:59 +0200 Subject: [PATCH 3/5] [FIXED] ZONE_POLYGON from RECT ME drawing rotation not taken into account. --- Moose Development/Moose/Core/Database.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 20d6c94ce..e74461eca 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -579,13 +579,10 @@ do -- Zones and Pathlines local h=objectData.height local rotation = UTILS.ToRadian(objectData.angle or 0) - local dx = vec2.x + math.abs(w) - local dy = vec2.y + math.abs(h) - local sinRot = math.sin(-rotation) local cosRot = math.cos(-rotation) - dx = (dx / 2) - dy = (dy / 2) + local dx = w / 2 + local dy = h / 2 local points = { { x = -dx * cosRot - (-dy * sinRot) + vec2.x, y = -dx * sinRot + (-dy * cosRot) + vec2.y }, From aace98545aed59648b89197ae553efeafbe1dce0 Mon Sep 17 00:00:00 2001 From: smiki Date: Wed, 1 Oct 2025 15:07:18 +0200 Subject: [PATCH 4/5] [FIXED] ZONE_POLYGON from RECT ME drawing rotation not taken into account. --- Moose Development/Moose/Core/Database.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index e74461eca..b66ee1787 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -581,8 +581,8 @@ do -- Zones and Pathlines local sinRot = math.sin(-rotation) local cosRot = math.cos(-rotation) - local dx = w / 2 - local dy = h / 2 + local dx = h / 2 + local dy = w / 2 local points = { { x = -dx * cosRot - (-dy * sinRot) + vec2.x, y = -dx * sinRot + (-dy * cosRot) + vec2.y }, From 935b52c48984a21b8683ccd8b5475032ee08dd31 Mon Sep 17 00:00:00 2001 From: smiki Date: Wed, 1 Oct 2025 15:11:44 +0200 Subject: [PATCH 5/5] [FIXED] ZONE_POLYGON from RECT ME drawing rotation not taken into account. --- Moose Development/Moose/Core/Database.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index b66ee1787..e1a1e732d 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -579,8 +579,8 @@ do -- Zones and Pathlines local h=objectData.height local rotation = UTILS.ToRadian(objectData.angle or 0) - local sinRot = math.sin(-rotation) - local cosRot = math.cos(-rotation) + local sinRot = math.sin(rotation) + local cosRot = math.cos(rotation) local dx = h / 2 local dy = w / 2