Exemple #1
0
        public void Rpc_SerializedRpcFlow_Works()
        {
            using (var testWorld = new NetCodeTestWorld())
            {
                testWorld.Bootstrap(true,
                                    typeof(SerializedClientRcpSendSystem),
                                    typeof(SerializedServerRpcReceiveSystem),
                                    typeof(SerializedRpcCommandRequestSystem));
                testWorld.CreateWorlds(true, 1);

                int SendCount = 1;
                var SendCmd   = new SerializedRpcCommand
                {
                    intValue = 123456, shortValue = 32154, floatValue = 12345.67f
                };
                SerializedClientRcpSendSystem.SendCount = SendCount;
                SerializedClientRcpSendSystem.Cmd       = SendCmd;

                SerializedServerRpcReceiveSystem.ReceivedCount = 0;

                float frameTime = 1.0f / 60.0f;
                // Connect and make sure the connection could be established
                Assert.IsTrue(testWorld.Connect(frameTime, 4));

                for (int i = 0; i < 33; ++i)
                {
                    testWorld.Tick(16f / 1000f);
                }

                Assert.AreEqual(SendCount, SerializedServerRpcReceiveSystem.ReceivedCount);
                Assert.AreEqual(SendCmd, SerializedServerRpcReceiveSystem.ReceivedCmd);
            }
        }
Exemple #2
0
 protected override void OnUpdate()
 {
     Entities.ForEach((Entity entity, ref SerializedRpcCommand cmd, ref ReceiveRpcCommandRequestComponent req) =>
     {
         ReceivedCmd = cmd;
         PostUpdateCommands.DestroyEntity(entity);
         ++ReceivedCount;
     });
 }