Exemple #1
0
        public void FeedData()
        {
            if (!isActiveAndEnabled)
            {
                return;
            }
            Debug.Log("Feed data from file");

            commandPointer = 0;

            var cmdBuffer   = UnityServerAPI.RPCGetCommandBuffer();
            var frameBuffer = UnityServerAPI.RPCGetFrameBuffer();

            var dataList = ReadFromBinaryFile <List <SerializableData> >(pathToFile);

            frameList = (
                from d in dataList
                where d.GetType() == typeof(SerializableFrameState)
                select d as SerializableFrameState
                ).ToList();
            commandList = (
                from d in dataList
                where d.GetType() == typeof(SerializableCommand)
                select d as SerializableCommand
                ).ToList();

            frameList.ForEach(f => UnityServerAPI.RPCGetFrameBuffer().Write(f));
        }
        public void ExecutePendingCommands()
        {
            RPCCommandBuffer cmdBuffer = UnityServerAPI.RPCGetCommandBuffer();
            int nCmd = cmdBuffer.GetNumOfAvailableElements();

            for (int i = 0; i < nCmd; i++)
            {
                Command cmd = cmdBuffer.ReadAndErase(0);
                commandHandler.HandleCommand(cmd);
            }
        }
Exemple #3
0
        private void FeedCommands(int frameId)
        {
            if (!isActiveAndEnabled)
            {
                return;
            }
            int prevCommandPointer = commandPointer;

            while (commandList.Count > commandPointer && frameId == commandList[commandPointer].frameId)
            {
                UnityServerAPI.RPCGetCommandBuffer().Write(commandList[commandPointer]);
                commandPointer++;
            }
            if (commandPointer > prevCommandPointer)
            {
                KinematicsServer.instance.ExecutePendingCommands();
            }
        }