public void SetPeer(IRailNetPeer netPeer) { RailDebug.Assert(this.serverPeer == null, "Overwriting peer"); this.serverPeer = new RailClientPeer(netPeer, this.Interpreter); this.serverPeer.PacketReceived += this.OnPacketReceived; this.serverPeer.EventReceived += base.OnEventReceived; }
public RailClient() { RailConnection.IsServer = false; this.serverPeer = null; this.localTick = Tick.START; this.Room.Initialize(Tick.INVALID); this.pendingEntities = new Dictionary<EntityId, RailEntity>(EntityId.Comparer); this.knownEntities = new Dictionary<EntityId, RailEntity>(EntityId.Comparer); this.toRemove = new List<RailEntity>(); }
private static void DisplayPersistenceInfo() { List <SPeer> peers = new List <SPeer>(); if (CoopClient.Instance.Persistence != null) { RailClientPeer peer = CoopClient.Instance.Persistence.Peer; if (peer != null) { SPeer peerInfo = new SPeer(); peerInfo.Peer = peer; peerInfo.Type = SPeer.EType.ClientSide; peers.Add(peerInfo); } } if (CoopServer.Instance.Persistence != null) { foreach (RailServerPeer peer in CoopServer.Instance.Persistence.ConnectedClients) { SPeer peerInfo = new SPeer(); peerInfo.Peer = peer; peerInfo.Type = SPeer.EType.ServerSide; peers.Add(peerInfo); } } Imgui.Columns(5); Imgui.Text("Type"); peers.ForEach(p => Imgui.Text(p.Type.ToString())); Imgui.NextColumn(); Imgui.Text("Local tick"); peers.ForEach(p => Imgui.Text(p.Peer.LocalTick.ToString())); Imgui.NextColumn(); Imgui.Text("Latest remote tick"); peers.ForEach(p => Imgui.Text(p.Peer.RemoteClock.LatestRemote.ToString())); Imgui.NextColumn(); Imgui.Text("Estimated remote tick"); peers.ForEach(p => Imgui.Text(p.Peer.RemoteClock.EstimatedRemote.ToString())); Imgui.NextColumn(); Imgui.Text("LatestRemote - EstimatedRemote"); Imgui.Separator(); peers.ForEach(p => Imgui.Text($"{p.Slack}")); Imgui.Columns(); }