Esempio n. 1
0
 public void Process(Packets.GameSnapshotDelta gameSnapshotDelta)
 {
     ProcessEcDictDelta(gameSnapshotDelta.Positions);
     ProcessEcDictDelta(gameSnapshotDelta.ShapeRectangles);
     ProcessEcDictDelta(gameSnapshotDelta.Characters);
     ProcessEcDictDelta(gameSnapshotDelta.Projectiles);
     ProcessEcDictDelta(gameSnapshotDelta.Items);
     ProcessEcDictDelta(gameSnapshotDelta.Doors);
     ProcessEcDictDelta(gameSnapshotDelta.OrientationCardinals);
     ProcessEcDictDelta(gameSnapshotDelta.Playables);
     ProcessEcDictDelta(gameSnapshotDelta.Inventories);
 }
Esempio n. 2
0
        public void SendSnapshots()
        {
            foreach (NetClient client in netServer.clients.Values)
            {
                if (client.ShouldSendSnapshot)
                {
                    client.ackedTickOpt.Match(
                        some: ackedTick => {
                        Option <Packets.GameSnapshot> baseSnapOpt =
                            gameSnapshotCache.GetCached(ackedTick);

                        baseSnapOpt.Match(
                            some: baseSnap => {
                            // Create delta
                            var currentSnap = gameSnapshotCache.GetCurrent();
                            var deltaSnap   = new Packets.GameSnapshotDelta(
                                currentSnap,
                                baseSnap
                                );

                            netServer.Send(client.Id, deltaSnap);
                        },
                            none: () => {
                            // Base snapshot has been discarded, so we
                            // can't use delta compression. Therefore we
                            // have to send a full snapshot.
                            client.SetSnapRateState(NetClient.SnapRateState.Recovery);
                            var currentSnap = gameSnapshotCache.GetCurrent();
                            netServer.Send(client.Id, currentSnap);
                        }
                            );
                    },
                        none: () => {
                        // Client hasn't acked a single snapshot yet, so we
                        // have to send them a full snapshot.
                        var currentSnap = gameSnapshotCache.GetCurrent();
                        netServer.Send(client.Id, currentSnap);
                    }
                        );
                }
            }
        }
Esempio n. 3
0
 public void Process(Packets.GameSnapshotDelta gameSnapshotDelta)
 {
     ecsRegistry.Process(gameSnapshotDelta);
 }
Esempio n. 4
0
 private void StoreGameSnapshotDelta(
     Packets.GameSnapshotDelta gameSnapshotPacketDelta
     )
 {
     packetsReceived.gameSnapshotDeltas.Enqueue(gameSnapshotPacketDelta);
 }