From 090433f661b92bec46df50e82e669cea1e5123e6 Mon Sep 17 00:00:00 2001 From: data-bomb Date: Tue, 21 May 2024 16:31:24 -0700 Subject: [PATCH] Kill the Queen on a Surrender - Adds destruction of all units (including the Queen) when a team surrenders --- Si_SurrenderCommand/Si_SurrenderCommand.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Si_SurrenderCommand/Si_SurrenderCommand.cs b/Si_SurrenderCommand/Si_SurrenderCommand.cs index 776bde6..7e91d92 100644 --- a/Si_SurrenderCommand/Si_SurrenderCommand.cs +++ b/Si_SurrenderCommand/Si_SurrenderCommand.cs @@ -32,7 +32,7 @@ You should have received a copy of the GNU General Public License using UnityEngine; using System.Collections.Generic; -[assembly: MelonInfo(typeof(SurrenderCommand), "Surrender Command", "1.2.4", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(SurrenderCommand), "Surrender Command", "1.2.5", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -125,8 +125,26 @@ public static void Command_Surrender(Player? callerPlayer, String args) // destroy all structures on team that's surrendering for (int i = 0; i < SurrenderTeam.Structures.Count; i++) { + if (SurrenderTeam.Structures[i] == null) + { + MelonLogger.Warning("Found null structure during surrender command."); + continue; + } + SurrenderTeam.Structures[i].DamageManager.SetHealth01(0.0f); } + + // and destroy all units (especially the queen) + for (int i = 0; i < SurrenderTeam.Units.Count; i++) + { + if (SurrenderTeam.Units[i] == null) + { + MelonLogger.Warning("Found null unit during surrender command."); + continue; + } + + SurrenderTeam.Units[i].DamageManager.SetHealth01(0.0f); + } } } } \ No newline at end of file