/// <summary> /// Called when a player leaves a Sub World. /// Unloads all the chunks in the sub world, and sets the players position back /// to the world entrance. /// </summary> public void LeaveSubworld() { Debug.Log("leaving subworld"); if (CurrentSubworld != null) { foreach (LoadedChunk c in SubworldChunks) { Destroy(c.gameObject); } CRManager.LeaveSubworld(); Player.SetPosition(CurrentSubworld.WorldEntrance); CurrentSubworld = null; LoadedChunksCentre = null; GameManager.EntityManager.LeaveSubworld(); } }
/// <summary> /// Called when a player leaves a Sub World. /// Unloads all the chunks in the sub world, and sets the players position back /// to the world entrance. /// </summary> public void LeaveSubworld() { Debug.Log("leaving subworld"); if (CurrentSubworld != null) { EntityManager.Instance?.LeaveSubworld(); CRManager.LeaveSubworld(); Player.SetPosition(CurrentSubworld.ExternalEntrancePos.AsVector3()); WaitAndPathScanCoroutine(); //CurrentSubworld = null; LoadedChunksCentre = null; CurrentSubworld = null; //Rescan pathfinding } }