public override void Start() { if (AOSServer.Instance == null) { throw new InvalidOperationException("Cannot start networked gamemode, no net server has been created!"); } Server = AOSServer.Instance; objectComponent = Server.GetComponent <ObjectNetComponent>(); NetPlayerComponent = Server.GetComponent <NetPlayerComponent>(); NetChannel = Server.GetChannel(AOSChannelType.Gamemode); base.Start(); }
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); }
public ServerWorld() { players = new ConcurrentDictionary <NetConnection, ServerMPPlayer>(); physEntities = new Dictionary <ushort, GameObject>(); server = AOSServer.Instance; snapshotComponent = server.GetComponent <SnapshotNetComponent>(); objectComponent = server.GetComponent <ObjectNetComponent>(); channel = server.GetChannel(AOSChannelType.World); channel.AddRemoteEvent("Server_SetBlock", R_SetBlock); channel.AddRemoteEvent("Server_ThrowGrenade", R_ThrowGrenade); channel.AddRemoteEvent("Server_ShootMelon", R_ShootMelon); objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated; objectComponent.OnCreatableDestroyed += ObjectComponent_OnCreatableDestroyed; snapshotComponent.OnWorldSnapshotOutbound += Server_OnWorldSnapshotOutbound; InitializeCMD(); ConfigSection gameSection = Program.Config.GetSection("Game"); if (gameSection == null) { DashCMD.WriteError("[server.cfg - ServerWorld] Section 'Game' is missing!"); } else { string worldFile = gameSection.GetString("world-file"); if (!string.IsNullOrWhiteSpace(worldFile)) { LoadFromFile(worldFile); } else { DashCMD.WriteError("[server.cfg - ServerWorld] Game.world-file is missing!"); } } }