private static IEnumerator WaitAndAddChunk(Vector3 chunk)
        {
            yield return(new WaitForSeconds(0.5f));

            Int3 owningChunk = new Int3((int)chunk.x, (int)chunk.y, (int)chunk.z);

            loadedChunks.AddChunk(owningChunk);
            chunkAwarePacketReceiver.ChunkLoaded(owningChunk);
        }
Ejemplo n.º 2
0
        public void TestInitialize()
        {
            loadedChunks   = new LoadedChunks();
            packetReceiver = new ChunkAwarePacketReceiver(loadedChunks);

            loadedChunk   = loadedChunks.GetChunk(loadedActionPosition);
            unloadedChunk = loadedChunks.GetChunk(unloadedActionPosition);

            loadedChunks.AddChunk(loadedChunk);
        }
Ejemplo n.º 3
0
        public void PacketPrioritizedAfterBeingDeferred()
        {
            Packet packet1 = new TestActionPacket(playerId, unloadedActionPosition);

            packetReceiver.PacketReceived(packet1);

            Assert.AreEqual(0, packetReceiver.GetReceivedPackets().Count);

            Packet packet2 = new TestNonActionPacket(playerId);

            packetReceiver.PacketReceived(packet2);

            loadedChunks.AddChunk(unloadedChunk);
            packetReceiver.ChunkLoaded(unloadedChunk);

            Queue <Packet> packets = packetReceiver.GetReceivedPackets();

            Assert.AreEqual(2, packets.Count);
            Assert.AreEqual(packet1, packets.Dequeue());
            Assert.AreEqual(packet2, packets.Dequeue());
        }