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?
This commit is contained in:
Vera Aguilera Puerto
2021-01-01 15:25:09 +01:00
parent 633ae5bc90
commit f8d4d4b8d7

View File

@@ -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<IMapManager>();