public MatchScreen(ServerGame game) : base(game, "Match") { gamemodes = new Dictionary <GamemodeType, NetworkedGamemode>() { { GamemodeType.TDM, new TDMGamemode(this) }, { GamemodeType.CTF, new CTFGamemode(this) } }; // Setup default multiplayer cvars DashCMD.SetCVar("ch_infammo", false); DashCMD.SetCVar("ch_infhealth", false); DashCMD.SetCVar("mp_friendlyfire", false); DashCMD.SetCVar("sv_impacts", false); DashCMD.SetCVar("sv_hitboxes", false); DashCMD.SetCVar("rp_rollback_constant", false); DashCMD.SetCVar("rp_rollback_factor", 0.5f); DashCMD.SetCVar("rp_rollback_offset", 0); DashCMD.SetCVar("rp_usetargetping", false); DashCMD.SetCVar("gm_neverend", false); DashCMD.AddCommand("world", "Changes the world", "world [filename | *]", (args) => { if (args.Length != 1) { DashCMD.WriteImportant("Current World: {0}", World.CurrentWorldName); } else { string worldFile = args[0]; ChangeWorld(worldFile); } }); DashCMD.AddCommand("worlds", "Lists all worlds", "worlds", (args) => { string[] worlds = Directory.GetFiles("Content/Worlds"); DashCMD.WriteImportant("Available Worlds ({0}):", worlds.Length); for (int i = 0; i < worlds.Length; i++) { DashCMD.WriteStandard(" {0}", Path.GetFileNameWithoutExtension(worlds[i])); } }); DashCMD.AddCommand("gamemode", "Changes the gamemode", "gamemode [mode]", (args) => { if (args.Length != 1) { DashCMD.WriteImportant("Current Gamemode: {0}", currentGamemode != null ? currentGamemode.Type.ToString() : "None"); } else { GamemodeType type; if (Enum.TryParse(args[0], true, out type)) { ChangeWorld(World.CurrentWorldName, type); } else { DashCMD.WriteError("Gamemode '{0}' does not exist!", type); } } }); DashCMD.AddCommand("say", "Announces a global message", "say <message>", (args) => { if (args.Length == 0) { DashCMD.ShowSyntax("say"); } else { Announce(DashCMD.CombineArgs(args), 5); } }); DashCMD.AddCommand("chat", "Sends a chat message from the user 'SERVER'", "chat <message>", (args) => { if (args.Length == 0) { DashCMD.ShowSyntax("chat"); } else { Chat(DashCMD.CombineArgs(args)); } }); }
protected override void Load() { base.Load(); LogOpenGLDrivers(); //if (AL.Efx == null) // throw new Exception("Sound card does not support OpenAL Efx!"); AL.DistanceModel(ALDistanceModel.LinearDistance); // 1 meter = 1 block Camera.Active.AudioListener.EfxMetersPerUnit = 1f / Block.CUBE_SIZE; LoadFromConfig(); DashCMD.SetCVar("r_vsync", GetVSync()); DashCMD.SetCVar("r_targfps", TargetFrameRate); DashCMD.SetCVar("r_exp_shadows", false); GLError.Begin(); Renderer.AddRenderer(new VoxelRenderer(Renderer)); Renderer.AddRenderer(new EntityRenderer(Renderer)); Renderer.AddRenderer(new ChunkRenderer(Renderer)); Renderer.AddRenderer(new DebugRenderer(Renderer)); Light sun = new Light(new Vector3(2, 1, 2), LightType.Directional, 1.75f, new Color(255, 255, 255, 255)); Renderer.Lights.Add(sun); Renderer.Sun = sun; Camera.Active.SetMode(CameraMode.ArcBall); Camera.Active.SmoothCamera = true; StaticGui = new StaticGui(this, Renderer); SetupDefaultBinds(); AddScreen(new MainMenuScreen(this)); AddScreen(new SingleplayerScreen(this)); AddScreen(new MultiplayerScreen(this)); AddScreen(new NewText.NewTextScreen(this)); DashCMD.AddScreen(new DashCMDScreen("dt", "", true, (screen) => { screen.WriteLine("DeltaTime: {0}s", lastDeltaTime); }) { SleepTime = 30 }); #if DEBUG DashCMD.AddCommand("connect", "Connects to a server", "connect <ip:port>", (args) => { if (args.Length < 1) { DashCMD.ShowSyntax("connect"); return; } string[] parts = args[0].Split(':'); if (parts.Length != 2) { DashCMD.WriteError("Invalid arguments. (connect ip:port)"); return; } IPAddress ip; if (!NetHelper.TryParseIP(parts[0], out ip)) { DashCMD.WriteError("Invalid ip address"); return; } int port; if (!int.TryParse(parts[1], out port)) { DashCMD.WriteError("Invalid port."); return; } SwitchScreen("Multiplayer", new IPEndPoint(ip, port), "TestPlayer1"); }); #endif SwitchScreen("MainMenu"); }