Exemple #1
0
        public bool TryUpdate(out List <IGameCommand> commands)
        {
            // we can only update if the client has received an update from the server
            if (_clientHandler.HasUpdate == false)
            {
                commands = null;
                return(false);
            }

            // we can only update if enough time has elapsed since the last update and there is not
            // a large backlog
            if (_clientHandler.HasLargeBacklog == false &&
                _clientUpdateAccumulator > _updateDeltaMs == false)
            {
                commands = null;
                return(false);
            }

            // we can update!

            // reset interpolation (hopefully it was near 1.0)
            _interpolationAccumulator = 0;

            // reduce the amount of time we have until we can do our next client update
            _clientUpdateAccumulator -= _updateDeltaMs;

            // and actually get the update
            commands = _clientHandler.PopUpdate();
            return(true);
        }