Beispiel #1
0
        public override void AddLocalInput(BackrollPlayerHandle player, ref T input)
        {
            GameInput gameInput;

            gameInput      = GameInput.Create <T>(GameInput.kNullFrame, ref input);
            _current_input = gameInput;
        }
Beispiel #2
0
        public override void AddLocalInput(BackrollPlayerHandle player,
                                           ref T playerInput)
        {
            int       queue;
            GameInput input;

            if (_sync.InRollback)
            {
                throw new BackrollException(BackrollErrorCode.InRollback);
            }
            if (IsSynchronizing)
            {
                throw new BackrollException(BackrollErrorCode.NotSynchronized);
            }

            queue = PlayerHandleToQueue(player);
            input = GameInput.Create <T>(GameInput.kNullFrame, ref playerInput);

            // Feed the input for the current frame into the synchronzation layer.
            if (!_sync.AddLocalInput(queue, ref input))
            {
                throw new BackrollException(BackrollErrorCode.PredictionThreshold);
            }

            if (input.Frame == GameInput.kNullFrame)
            {
                return;
            }
            // xxx: <- comment why this is the case
            // Update the local connect status state to indicate that we've got a
            // confirmed local frame for this player.  this must come first so it
            // gets incorporated into the next packet we send.

            Debug.LogFormat("setting local connect status for local queue {} to {}",
                            queue, input.Frame);
            _localConnectStatus[queue].LastFrame = input.Frame;

            // Send the input to all the remote players.
            for (int i = 0; i < PlayerCount; i++)
            {
                if (!_players[i].IsLocal)
                {
                    _players[i].SendInput(input);
                }
            }
        }