Load grid error related changes (#10817)
This commit is contained in:
@@ -80,8 +80,11 @@ public sealed class MindSystem : EntitySystem
|
||||
}
|
||||
else if (mind.GhostOnShutdown)
|
||||
{
|
||||
// Changing an entities parents while deleting is VERY sus. This WILL throw exceptions.
|
||||
// TODO: just find the applicable spawn position dirctly without actually updating the transform's parent.
|
||||
Transform(uid).AttachToGridOrMap();
|
||||
var spawnPosition = Transform(uid).Coordinates;
|
||||
|
||||
// Use a regular timer here because the entity has probably been deleted.
|
||||
Timer.Spawn(0, () =>
|
||||
{
|
||||
@@ -96,6 +99,13 @@ public sealed class MindSystem : EntitySystem
|
||||
spawnPosition = _gameTicker.GetObserverSpawnPoint();
|
||||
}
|
||||
|
||||
// TODO refactor observer spawning.
|
||||
if (!spawnPosition.IsValid(EntityManager))
|
||||
{
|
||||
Logger.ErrorS("mind", $"Entity \"{ToPrettyString(uid)}\" for {mind.Mind?.CharacterName} was deleted, and no applicable spawn location is available.");
|
||||
return;
|
||||
}
|
||||
|
||||
var ghost = Spawn("MobObserver", spawnPosition);
|
||||
var ghostComponent = Comp<GhostComponent>(ghost);
|
||||
_ghostSystem.SetCanReturnToBody(ghostComponent, false);
|
||||
|
||||
Reference in New Issue
Block a user