private void CreateNewWorld() { SetLoadingMessage("Creating Sky..."); Renderer.Sky = new SkyRenderer(); #region Initialize static data bool actionComplete = false; Game.DoLazyAction(new Action(() => { Renderer.InstanceRenderer = new InstanceRenderer(); Renderer.bloom = new BloomComponent(Game) { Settings = BloomSettings.PresetSettings[5] }; Renderer.bloom.Initialize(); SoundManager.Content = Content; if (PlanService != null) { PlanService.Restart(); } MonsterSpawner = new MonsterSpawner(this); EntityFactory.Initialize(this); }), () => { actionComplete = true; return(true); }); while (!actionComplete) { Thread.Sleep(10); } #endregion SetLoadingMessage("Creating Planner ..."); PlanService = new PlanService(); SetLoadingMessage("Creating Liquids ..."); #region liquids Renderer.WaterRenderer = new WaterRenderer(GraphicsDevice); #endregion #region Load Components // Create updateable systems. foreach (var updateSystemFactory in AssetManager.EnumerateModHooks(typeof(UpdateSystemFactoryAttribute), typeof(EngineModule), new Type[] { typeof(WorldManager) })) { UpdateSystems.Add(updateSystemFactory.Invoke(null, new Object[] { this }) as EngineModule); } Time = new WorldTime(); Renderer.Camera = new OrbitCamera(this, // Todo: Is setting the camera position and target redundant here? new Vector3(VoxelConstants.ChunkSizeX, WorldSizeInVoxels.Y - 1.0f, VoxelConstants.ChunkSizeZ), new Vector3(VoxelConstants.ChunkSizeX, WorldSizeInVoxels.Y - 1.0f, VoxelConstants.ChunkSizeZ) + Vector3.Up * 10.0f + Vector3.Backward * 10, MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 0.1f, GameSettings.Default.VertexCullDistance); PersistentData = new PersistentWorldData(); ChunkManager = new ChunkManager(Content, this); Splasher = new Splasher(ChunkManager); Renderer.ChunkRenderer = new ChunkRenderer(ChunkManager); Renderer.Camera.Position = new Vector3(0, 10, 0) + new Vector3(WorldSizeInChunks.X * VoxelConstants.ChunkSizeX, 0, WorldSizeInChunks.Z * VoxelConstants.ChunkSizeZ) * 0.5f; Renderer.Camera.Target = new Vector3(0, 10, 1) + new Vector3(WorldSizeInChunks.X * VoxelConstants.ChunkSizeX, 0, WorldSizeInChunks.Z * VoxelConstants.ChunkSizeZ) * 0.5f; ComponentManager = new ComponentManager(this); ComponentManager.SetRootComponent(new GameComponent(ComponentManager, "root", Matrix.Identity, Vector3.Zero, Vector3.Zero)); #region Prepare Factions Factions = new FactionSet(); //Factions.Initialize(this, Settings.Company); foreach (var faction in Overworld.Natives) { Factions.AddFaction(new Faction(this, faction)); } Point playerOrigin = new Point((int)(Overworld.InstanceSettings.Origin.X), (int)(Overworld.InstanceSettings.Origin.Y)); PlayerFaction = Factions.Factions["Player"]; PlayerFaction.Economy = new Company(PlayerFaction, 300.0m, Overworld.Company); #endregion EventScheduler = new Events.Scheduler(); TutorialManager = new Tutorial.TutorialManager(); TutorialManager.TutorialEnabled = !GameSettings.Default.TutorialDisabledGlobally; Tutorial("new game start"); foreach (var item in Library.EnumerateCraftables()) { if (!String.IsNullOrEmpty(item.Tutorial)) { TutorialManager.AddTutorial(item.Name, item.Tutorial, item.Icon); } } Renderer.Camera.World = this; //Drawer3D.Camera = Camera; #endregion SetLoadingMessage("Creating Particles ..."); Game.DoLazyAction(new Action(() => ParticleManager = new ParticleManager(ComponentManager))); SetLoadingMessage("Creating GameMaster ..."); TaskManager = new TaskManager(); TaskManager.World = this; Time.NewDay += (time) => PayEmployees(); var generatorSettings = new Generation.ChunkGeneratorSettings(MathFunctions.Random.Next(), 0.02f, Overworld) { WorldSizeInChunks = WorldSizeInChunks, SetLoadingMessage = SetLoadingMessage, World = this }; SetLoadingMessage("Generating Chunks..."); Generation.Generator.Generate(Overworld.InstanceSettings.Cell.Bounds, ChunkManager, this, generatorSettings, SetLoadingMessage); CreateInitialEmbarkment(generatorSettings); ChunkManager.NeedsMinimapUpdate = true; ChunkManager.RecalculateBounds(); if (PlayerFaction.Economy.Information == null) { throw new InvalidProgramException(); } if (MathFunctions.RandEvent(0.01f)) { SetLoadingMessage("Reticulating Splines..."); } ChunkManager.StartThreads(); SetLoadingMessage("Presimulating ..."); ShowingWorld = false; OnLoadedEvent(); Thread.Sleep(1000); ShowingWorld = true; SetLoadingMessage("Complete."); LoadStatus = LoadingStatus.Success; }