public SnapshotNetComponent(AOSClient client) : base(client) { snapshotSystem = new SnapshotSystem(client); charSnapshotSystem = new CharacterSnapshotSystem(this, snapshotSystem); objectComponent = client.GetComponent <ObjectNetComponent>(); objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated; objectComponent.OnCreatableDestroyed += ObjectComponent_OnCreatableDestroyed; DashCMD.AddScreen(new DashCMDScreen("snapshot", "Displays information about the snapshot system.", true, (screen) => { screen.WriteLine("Snapshot Round-Trip Time: {0}s", rtt); screen.WriteLine("Last Outbound Snapshot:", ConsoleColor.Cyan); screen.WriteLine("PacketHeader: {0} bytes", lastOutboundPacketStats.PacketHeader); screen.WriteLine("Acks: {0} bytes", lastOutboundPacketStats.Acks); screen.WriteLine("PlayerData: {0} bytes", lastOutboundPacketStats.PlayerData); screen.WriteLine("Total: {0} bytes", lastOutboundPacketStats.Total); }) { SleepTime = 30 }); DashCMD.SetCVar("cl_tickrate", DEFAULT_TICKRATE); DashCMD.SetCVar("cl_await_sv_snap", false); //DashCMD.SetCVar("cl_tickrate", 25); //DashCMD.SetCVar("cl_await_sv_snap", true); syncTime = tickrate; }
public MPPlayer(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(renderer, world, camera, position, team) { if (!DashCMD.IsCVarDefined("log_mpplayer")) { DashCMD.SetCVar("log_mpplayer", false); } }
public CharacterSnapshotSystem(SnapshotNetComponent snapshotComponent, SnapshotSystem deltaSnapshotSystem) { this.snapshotComponent = snapshotComponent; this.deltaSnapshotSystem = deltaSnapshotSystem; players = new Dictionary <ushort, ClientPlayer>(); DashCMD.SetCVar("log_css", false); }
public SnapshotSystem(NetMessenger messenger) { idAllocator = new IdAllocatorUInt16(); interfaces = new Dictionary <NetConnection, SnapshotConnectionInterface>(); snapshotsAwaitingDeltaSupport = new HashSet <Snapshot>(); channel = messenger.GetChannel((ushort)AOSChannelType.SnapshotSystem); channel.AddRemoteEvent("AllocateSnapshotId", R_AllocateSnapshotId); DashCMD.SetCVar("log_snapshots", false); }
public SnapshotNetComponent(AOSServer server) : base(server) { snapshotSystem = new SnapshotSystem(server); charSnapshotSystem = new CharacterSnapshotSystem(this, snapshotSystem); ConnectionStates = new Dictionary <NetConnection, NetConnectionSnapshotState>(); objectComponent = server.GetComponent <ObjectNetComponent>(); objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated; objectComponent.OnCreatableDestroyed += ObjectComponent_OnCreatableDestroyed; DashCMD.AddScreen(new DashCMDScreen("snapshot", "Displays information about the snapshot system.", true, (screen) => { try { foreach (KeyValuePair <NetConnection, NetConnectionSnapshotState> pair in ConnectionStates) { SnapshotStats stats = pair.Value.Stats; screen.WriteLine("[{0}]:", pair.Key); screen.WriteLine("Snapshot Round-Trip Time: {0}", pair.Value.RoundTripTime); screen.WriteLine("PacketHeader: {0} bytes", stats.PacketHeader); screen.WriteLine("Acks: {0} bytes", stats.Acks); screen.WriteLine("PlayerData: {0} bytes", stats.PlayerData); screen.WriteLine("TerrainData: {0} bytes", stats.TerrainData); screen.WriteLine("Total: {0} bytes", stats.Total); screen.WriteLine(""); } } catch (Exception) { } }) { SleepTime = 30 }); DashCMD.SetCVar("sv_tickrate", DEFAULT_TICKRATE); DashCMD.SetCVar("sv_await_cl_snap", false); DashCMD.SetCVar <ushort>("ag_max_cl_tickrate", 100); DashCMD.SetCVar("ag_cl_force_await_snap", false); //DashCMD.SetCVar("sv_tickrate", 25); //DashCMD.SetCVar("sv_await_cl_snap", true); //DashCMD.SetCVar<ushort>("ag_max_cl_tickrate", 30); //DashCMD.SetCVar("ag_cl_force_await_snap", true); }
void InitializeCMD() { if (DashCMD.IsCommandDefined("time")) { return; } DashCMD.SetCVar <float>("time_autoshift", 0); //DashCMD.AddCommand("saveworld", "Saves the current world to file", "saveworld <filename>", // (args) => // { // if (args.Length != 1) // DashCMD.ShowSyntax("saveworld"); // else // { // string fileName = args[0]; // WorldIO.Save(fileName, new WorldDescription(Terrain)); // DashCMD.WriteImportant("Saved world: {0}.aosw", fileName); // } // }); DashCMD.AddCommand("time", "Changes the time of day", "time [0-24]", (args) => { if (args.Length == 0) { DashCMD.WriteLine("Current Time: {0}", timeOfDay); } else { try { float newTime = float.Parse(args[0]); newTime = MathHelper.Clamp(newTime, 0, 24); timeOfDay = newTime; } catch (Exception) { DashCMD.WriteError("Invalid time."); } } }); }
public MultiplayerScreen(MainWindow window) : base(window, "Multiplayer") { debugRenderer = Renderer.GetRenderer3D <DebugRenderer>(); gamemodes = new Dictionary <GamemodeType, NetworkedGamemode>() { { GamemodeType.TDM, new TDMGamemode(this) }, { GamemodeType.CTF, new CTFGamemode(this) } }; // Build the UI elements theme = AssetManager.CreateDefaultGameTheme(); font = theme.GetField <BMPFont>(null, "SmallFont"); hud = new HUD(Renderer); loadingBar = new MultiplayerLoadingBar(GUISystem, theme); chat = new ChatBox(new UDim2(0, 40, 1f, -240), new UDim2(0, 350, 0, 165), theme, this); menu = new MultiplayerMenu(GUISystem, theme, Window); menu.OnClosed += Menu_OnClosed; announcementLabel = new GUILabel(new UDim2(0.5f, 0, 0.5f, 0), UDim2.Zero, "", TextAlign.Center, theme); announcementLabel.Font = AssetManager.LoadFont("karmasuture-32"); announcementLabel.Visible = false; // Add each UI element GUIArea.AddTopLevel(chat, announcementLabel); GUISystem.Add(loadingBar, menu); Windows.Add(loadingBar); Windows.Add(menu); // Setup default multiplayer cvars DashCMD.SetCVar("cl_impacts", false); DashCMD.SetCVar("cl_interp", 0.5f); // Client interpolation with server position DashCMD.SetCVar("cl_interp_movement_smooth", 1f); // Client player movement smoothing (1f = no smoothing) DashCMD.SetCVar("cl_interp_rep", 20f); // Replicated entities interpolation DashCMD.SetCVar("cl_max_error_dist", 12f); // Max distance the client's position can be off from the server's }
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"); }