コード例 #1
0
 public void ServerUpdateSerializer_Serialization_Empty()
 {
     byte[] serializedData = new byte[1024];
     {
         EntityArray    entityArray    = EntityTests.CreateStandardEntityArray();
         EntitySnapshot entitySnapshot = new EntitySnapshot(3, EntityTests.CreateComponentsDefinition());
         entitySnapshot.Update(66, entityArray);
         OutgoingMessage outgoingMessage = new OutgoingMessage(serializedData);
         ServerUpdateSerializer.Serialize(outgoingMessage, null, entitySnapshot, 63, 13);
         serializedData = outgoingMessage.ToArray();
     }
     {
         EntitySnapshot entitySnapshot = new EntitySnapshot(3, EntityTests.CreateComponentsDefinition());
         ServerUpdateSerializer.Deserialize(new IncomingMessage(serializedData), new EntitySnapshot[0], entitySnapshot, out int latestClientTickAcknowledgedByServer, out int clientCommandingEntityID);
         Assert.AreEqual(63, latestClientTickAcknowledgedByServer);
         Assert.AreEqual(13, clientCommandingEntityID);
         Assert.AreEqual(66, entitySnapshot.ServerFrameTick);
         EntityTests.AssertStandardEntityArray(entitySnapshot.EntityArray);
     }
 }
コード例 #2
0
 public void ServerUpdateSerializer_DeserializeIfNewer_IsNewer()
 {
     byte[] serializedData = new byte[1024];
     {
         EntitySnapshot entitySnapshot = new EntitySnapshot(3, EntityTests.CreateComponentsDefinition());
         entitySnapshot.Update(68, entitySnapshot.EntityArray);
         OutgoingMessage outgoingMessage = new OutgoingMessage(serializedData);
         ServerUpdateSerializer.Serialize(outgoingMessage, null, entitySnapshot, 73, 17);
         serializedData = outgoingMessage.ToArray();
     }
     {
         EntityArray    entityArray    = EntityTests.CreateStandardEntityArray();
         EntitySnapshot entitySnapshot = new EntitySnapshot(3, EntityTests.CreateComponentsDefinition());
         entitySnapshot.Update(65, entityArray);
         Assert.IsTrue(ServerUpdateSerializer.DeserializeIfNewer(new IncomingMessage(serializedData), new EntitySnapshot[0], entitySnapshot, out int latestClientTickAcknowledgedByServer, out int clientCommandingEntityID));
         Assert.AreEqual(73, latestClientTickAcknowledgedByServer);
         Assert.AreEqual(17, clientCommandingEntityID);
         Assert.AreEqual(68, entitySnapshot.ServerFrameTick);
         Assert.IsFalse(entitySnapshot.EntityArray.TryGetEntity(0, out _));
         Assert.IsFalse(entitySnapshot.EntityArray.TryGetEntity(1, out _));
         Assert.IsFalse(entitySnapshot.EntityArray.TryGetEntity(2, out _));
     }
 }
コード例 #3
0
        public void Components_ResetOnEntityCreate()
        {
            EntityArray entityArray = new EntityArray(1, EntityTests.CreateComponentsDefinition());

            Assert.IsTrue(entityArray.TryCreateEntity(out Entity newEntityA));
            ref PositionComponent2D positionComponentA = ref entityArray.GetComponentArray <PositionComponent2D>().AddComponent(newEntityA);