ServerSession = sPlayerMan.GetSessionById(ClientSession.UserId);
// Spawn player entity & attach
- EntityUid? old = default;
+ NetEntity? old = default;
await Server.WaitPost(() =>
{
// Fuck you mind system I want an hour of my life back
// Mind system is a time vampire
SEntMan.System<SharedMindSystem>().WipeMind(ServerSession.ContentData()?.Mind);
- old = cPlayerMan.LocalEntity;
+ CEntMan.TryGetNetEntity(cPlayerMan.LocalEntity, out old);
SPlayer = SEntMan.SpawnEntity(PlayerPrototype, SEntMan.GetCoordinates(PlayerCoords));
Player = SEntMan.GetNetEntity(SPlayer);
Server.PlayerMan.SetAttachedEntity(ServerSession, SPlayer);
// Delete old player entity.
await Server.WaitPost(() =>
{
- if (old != null)
- SEntMan.DeleteEntity(old.Value);
+ if (SEntMan.TryGetEntity(old, out var uid))
+ SEntMan.DeleteEntity(uid);
});
// Change UI state to in-game.