From bab02fca8aa8d2c1b666638015298ff85003999f Mon Sep 17 00:00:00 2001 From: NotAlwaysTrue <2136846186@qq.com> Date: Mon, 22 Dec 2025 17:16:49 +0800 Subject: [PATCH] Tried to fix all errors realted to UniqueEvent and Events(Collection was modified) --- .../BarotraumaServer/ServerSource/Networking/GameServer.cs | 2 +- .../BarotraumaShared/SharedSource/Characters/HumanPrefab.cs | 2 +- Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs index d3aa1d893..3cacc8013 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs @@ -1218,7 +1218,7 @@ namespace Barotrauma.Networking errorLines.Add(""); errorLines.Add("EntitySpawner events:"); - foreach (var entityEvent in entityEventManager.UniqueEvents) + foreach (var entityEvent in entityEventManager.UniqueEvents.ToList()) { if (entityEvent.Entity is EntitySpawner) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/HumanPrefab.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/HumanPrefab.cs index 67b0141e4..04bb60aa3 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/HumanPrefab.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/HumanPrefab.cs @@ -282,7 +282,7 @@ namespace Barotrauma #if SERVER if (GameMain.Server != null && Entity.Spawner != null && createNetworkEvents) { - if (GameMain.Server.EntityEventManager.UniqueEvents.Any(ev => ev.Entity == item)) + if (GameMain.Server.EntityEventManager.UniqueEvents.ToList().Any(ev => ev.Entity == item)) { string errorMsg = $"Error while spawning job items. Item {item.Name} created network events before the spawn event had been created."; DebugConsole.ThrowError(errorMsg); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs index 8ea5d7839..0e3e8ae0a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs @@ -170,7 +170,7 @@ namespace Barotrauma #if SERVER if (GameMain.Server != null && Entity.Spawner != null) { - if (GameMain.Server.EntityEventManager.UniqueEvents.Any(ev => ev.Entity == item)) + if (GameMain.Server.EntityEventManager.UniqueEvents.ToList().Any(ev => ev.Entity == item)) { string errorMsg = $"Error while spawning job items. Item {item.Name} created network events before the spawn event had been created."; DebugConsole.ThrowError(errorMsg);