public static bool ServerOrSingle_MapCreate() { GameNetworkServer server = GameNetworkServer.Instance; Control mapLoadingWindow = null; //show map loading window mapLoadingWindow = ControlDeclarationManager.Instance.CreateControl("Gui\\MapLoadingWindow.gui"); if (mapLoadingWindow != null) { mapLoadingWindow.Text = "Procedural map creation"; GameEngineApp.Instance.ControlManager.Controls.Add(mapLoadingWindow); } //delete all GameWindow's GameEngineApp.Instance.DeleteAllGameWindows(); MapSystemWorld.MapDestroy(); EngineApp.Instance.RenderScene(); //create world if need WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType; if (World.Instance == null || World.Instance.Type != worldType) { WorldSimulationTypes worldSimulationType; EntitySystemWorld.NetworkingInterface networkingInterface = null; if (server != null) { worldSimulationType = WorldSimulationTypes.ServerAndClient; networkingInterface = server.EntitySystemService.NetworkingInterface; } else { worldSimulationType = WorldSimulationTypes.Single; } if (!EntitySystemWorld.Instance.WorldCreate(worldSimulationType, worldType, networkingInterface)) { Log.Fatal("ExampleOfProceduralMapCreation: ServerOrSingle_MapCreate: EntitySystemWorld.Instance.WorldCreate failed."); } } //create map GameMapType gameMapType = EntityTypes.Instance.GetByName("GameMap") as GameMapType; if (gameMapType == null) { Log.Fatal("ExampleOfProceduralMapCreation: ServerOrSingle_MapCreate: \"GameMap\" type is not defined."); } GameMap gameMap = (GameMap)Entities.Instance.Create(gameMapType, World.Instance); gameMap.ShadowFarDistance = 60; gameMap.ShadowColor = new ColorValue(.5f, .5f, .5f); //create MapObjects ServerOrSingle_CreateEntities(); //post create map gameMap.PostCreate(); //inform clients about world created if (server != null) { server.EntitySystemService.WorldWasCreated(); } //Error foreach (Control control in GameEngineApp.Instance.ControlManager.Controls) { if (control is MessageBoxWindow && !control.IsShouldDetach()) { return(false); } } GameEngineApp.Instance.CreateGameWindowForMap(); //play music if (GameMap.Instance != null) { GameMusic.MusicPlay(GameMap.Instance.GameMusic, true); } return(true); }