From fa800485f12d0c65190c5ab4073359158eb4d728 Mon Sep 17 00:00:00 2001 From: data-bomb Date: Sat, 23 Mar 2024 16:40:51 -0700 Subject: [PATCH] Fix Bug in Surrender - Surrender would not remove anything after the first construction site due to a bug --- Si_SurrenderCommand/Si_SurrenderCommand.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Si_SurrenderCommand/Si_SurrenderCommand.cs b/Si_SurrenderCommand/Si_SurrenderCommand.cs index d3b33ef..776bde6 100644 --- a/Si_SurrenderCommand/Si_SurrenderCommand.cs +++ b/Si_SurrenderCommand/Si_SurrenderCommand.cs @@ -30,8 +30,9 @@ You should have received a copy of the GNU General Public License using SilicaAdminMod; using System; using UnityEngine; +using System.Collections.Generic; -[assembly: MelonInfo(typeof(SurrenderCommand), "Surrender Command", "1.2.3", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(SurrenderCommand), "Surrender Command", "1.2.4", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -98,7 +99,9 @@ public static void Command_Surrender(Player? callerPlayer, String args) HelperMethods.ReplyToCommand_Player(callerPlayer, "used !surrender to end"); Team SurrenderTeam = callerPlayer.Team; - // destroy all construction sites on team that's surrendering + List sitesToDestroy = new List(); + + // find all construction sites we should destroy form the team that's surrendering foreach (ConstructionSite constructionSite in ConstructionSite.ConstructionSites) { if (constructionSite == null || constructionSite.Team == null) @@ -111,6 +114,11 @@ public static void Command_Surrender(Player? callerPlayer, String args) continue; } + sitesToDestroy.Add(constructionSite); + } + + foreach (ConstructionSite constructionSite in sitesToDestroy) + { constructionSite.Deinit(false); }