Skip to content

Commit

Permalink
Fix Bug in Surrender
Browse files Browse the repository at this point in the history
- Surrender would not remove anything after the first construction site due to a bug
  • Loading branch information
data-bomb committed Mar 23, 2024
1 parent e2aab78 commit fa80048
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Si_SurrenderCommand/Si_SurrenderCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

Expand Down Expand Up @@ -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<ConstructionSite> sitesToDestroy = new List<ConstructionSite>();

// 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)
Expand All @@ -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);
}

Expand Down

0 comments on commit fa80048

Please sign in to comment.