NScumm.Scumm.ScummEngine.Loop C# (CSharp) Метод

Loop() защищенный Метод

protected Loop ( ) : System.TimeSpan
Результат System.TimeSpan
        protected virtual TimeSpan Loop()
        {
            var t = DateTime.Now;
            int delta = deltaTicks;

            if (Game.Version >= 3)
            {
                _variables[VariableTimer1.Value] += delta;
                _variables[VariableTimer2.Value] += delta;
                _variables[VariableTimer3.Value] += delta;

                if (Game.GameId == GameId.Indy3)
                {
                    _variables[39] += delta;
                    _variables[40] += delta;
                    _variables[41] += delta;
                }
            }

            if (delta > 15)
                delta = 15;

            DecreaseScriptDelay(delta);

            UpdateTalkDelay(delta);

            // Record the current ego actor before any scripts (including input scripts)
            // get a chance to run.
            var oldEgo = VariableEgo.HasValue ? Variables[VariableEgo.Value] : 0;

            // In V1-V3 games, CHARSET_1 is called much earlier than in newer games.
            // See also bug #770042 for a case were this makes a difference.
            if (Game.Version <= 3)
                Charset();

            ProcessInput();

            UpdateVariables();

            if (_game.Features.HasFlag(GameFeatures.AudioTracks))
            {
                // Covered automatically by the Sound class
            }
            else if (VariableMusicTimer.HasValue)
            {
                if (MusicEngine != null)
                {
                    // The music engine generates the timer data for us.
                    _variables[VariableMusicTimer.Value] = MusicEngine.GetMusicTimer();
                }
            }

            if (VariableGameLoaded.HasValue)
                _variables[VariableGameLoaded.Value] = 0;

            load_game:
            SaveLoad();

            if (_completeScreenRedraw)
            {
                _charset.HasMask = false;

                if (Game.Version > 3)
                {
                    for (int i = 0; i < Verbs.Length; i++)
                    {
                        DrawVerb(i, 0);
                    }
                }
                else
                {
                    RedrawVerbs();
                }

                HandleMouseOver(false);

                _completeScreenRedraw = false;
                _fullRedraw = true;
            }

            RunAllScripts();
            CheckExecVerbs();
            CheckAndRunSentenceScript();

            if (HasToQuit)
                return TimeSpan.Zero;

            // HACK: If a load was requested, immediately perform it. This avoids
            // drawing the current room right after the load is request but before
            // it is performed. That was annoying esp. if you loaded while a SMUSH
            // cutscene was playing.
            if (_saveLoadFlag != 0 && _saveLoadFlag != 1)
            {
                goto load_game;
            }

            TownsProcessPalCycleField();

            if (_currentRoom == 0)
            {
                Charset();
                DrawDirtyScreenParts();
            }
            else
            {
                WalkActors();
                MoveCamera();
                UpdateObjectStates();
                Charset();

                HandleDrawing();

                HandleActors();

                _fullRedraw = false;

                HandleEffects();

                //if (VAR_MAIN_SCRIPT != 0xFF && VAR(VAR_MAIN_SCRIPT) != 0) {
                //    runScript(VAR(VAR_MAIN_SCRIPT), 0, 0, 0);
                //}

                // Handle mouse over effects (for verbs).
                HandleMouseOver(oldEgo != Variables[VariableEgo.Value]);

                // Render everything to the screen.
                UpdatePalette();
                DrawDirtyScreenParts();

                // FIXME / TODO: Try to move the following to HandleSound or
                // scummLoop_handleActors (but watch out for regressions!)
                if (Game.Version <= 5)
                {
                    PlayActorSounds();
                }
            }

            HandleSound();

            _camera.LastPosition = _camera.CurrentPosition;

            //_res.increaseExpireCounter();

            AnimateCursor();

            // show or hide mouse
            _gfxManager.IsCursorVisible = _cursor.State > 0;

            return GetTimeToWaitBeforeLoop(DateTime.Now - t);
        }
ScummEngine