private void Initialize(WorldSettings settings) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); WorldSettingsSavingPath = Application.persistentDataPath + "/Worlds"; string chunkSavingDirectory = WorldSettingsSavingPath + $"/{settings.Name}/Chunks"; ChunkManager = new ChunkManager(settings, MainCamera, m_PlayerTransform, chunkSavingDirectory, DataManager.ChunkMaterial, DataManager.LiquidMaterial); EntityManager = new EntityManager(DataManager.BlockEntityMaterial, m_Player); m_PlayerTransform.position = (settings.Position.y < 0 || settings.Position.y >= WorldConsts.WorldHeight) ? new Vector3(0, WorldConsts.WorldHeight, 0) : settings.Position; m_PlayerTransform.localRotation = settings.BodyRotation; m_CameraTransform.localRotation = settings.CameraRotation; ChunkManager.OnChunksReadyWhenStartingUp += () => { ScreenCapture.CaptureScreenshot(WorldSettingsSavingPath + "/" + Settings.Name + "/Thumbnail.png"); // 没办法 if (Settings.Position.y < 0 || Settings.Position.y >= WorldConsts.WorldHeight) { Chunk chunk = ChunkManager.GetChunkByNormalizedPosition(0, 0); m_PlayerTransform.position = new Vector3(0, chunk.GetTopNonAirIndex(0, 0) + 5, 0); } m_Player.enabled = true; Destroy(m_LoadingMenu); }; ChunkManager.StartChunksUpdatingThread(); ChunkManager.StartChunksBuildingThread(); Initialized = true; }