From f8d4d4b8d7795f7b8e377c4fcb5fe2a8bd121b23 Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Fri, 1 Jan 2021 15:25:09 +0100 Subject: [PATCH] Fix bug where ghosts weren't being spawned for players after their attached entity was deleted. Turns out creating an entity timer for an entity that has been deleted is a bad idea! Who would have thought? --- Content.Server/GameObjects/Components/Mobs/MindComponent.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs index 027abe368e..72c6eab20b 100644 --- a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs @@ -17,6 +17,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Map; using Robust.Shared.Serialization; +using Robust.Shared.Timers; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -136,7 +137,8 @@ namespace Content.Server.GameObjects.Components.Mobs else { var spawnPosition = Owner.Transform.Coordinates; - Owner.SpawnTimer(0, () => + // Use a regular timer here because the entity has probably been deleted. + Timer.Spawn(0, () => { // Async this so that we don't throw if the grid we're on is being deleted. var mapMan = IoCManager.Resolve();