Пример #1
0
        public void Update(IGameContext gameContext, IUpdateContext updateContext)
        {
            if (gameContext.World == null)
            {
                return;
            }

            UpdateFrames();

            if (gameContext.World != _currentWorld || _shadowWorld == null)
            {
                if (_shadowWorld != null)
                {
                    _shadowWorld.Dispose();
                }

                _shadowWorld  = _networkFactory.CreateShadowWorld();
                _currentWorld = gameContext.World;

                _shadowWorld.OnMessageRecievedStatisticsAction += OnMessageRecievedStatisticsAction;
            }

            if (_dispatcherChanged.ContainsKey(gameContext.World) &&
                _dispatcherChanged[gameContext.World])
            {
                _shadowWorld.Dispatcher = _dispatchers[gameContext.World];
                _dispatcherChanged[gameContext.World] = false;
                _currentDispatchers[0] = _shadowWorld.Dispatcher;
            }

            using (_profiler.Measure("net-step"))
            {
                _shadowWorld.Update(gameContext, updateContext);
            }
        }