Пример #1
0
 public void On_End()
 {
     if (_state.CurrentPhase == TimerPhase.Running && _settings.AutoEnd)
     {
         while (_state.CurrentSplitIndex < _state.Run.Count - 1)
         {
             _timer.SkipSplit();
         }
         _timer.Split();
     }
 }
        public virtual void Update(LiveSplitState state, TimerModel timer)
        {
            if (!game.Attach())
            {
                return;
            }
            switch (state.CurrentPhase)
            {
            case TimerPhase.NotRunning:
                if (StartTimer())
                {
                    timer.Start();
                }
                return;

            case TimerPhase.Running:
            case TimerPhase.Paused:
                if (ProvidesGameTime)
                {
                    TimeSpan?igt = GameTime();
                    if (!state.IsGameTimeInitialized)
                    {
                        timer.InitializeGameTime();
                    }
                    state.IsGameTimePaused = true;
                    state.SetGameTime(igt);
                }

                while (true)
                {
                    var cursplit = state.CurrentSplitIndex;
                    if (cursplit <= lastsplit || cursplit >= state.Run.Count)
                    {
                        return;
                    }

                    Match  m         = split_regex.Match(state.Run[cursplit].Name);
                    string splitname = m.Success ? m.Groups[2].Value.Normalize().ToLowerInvariant() : "";
                    if (!splits.ContainsKey(splitname))
                    {
                        timer.SkipSplit();
                    }
                    else if (intsplits[splits[splitname]]())
                    {
                        if (DateTime.UtcNow - lastsplitat < TimeSpan.FromMilliseconds(100))
                        {
                            timer.SkipSplit();
                        }
                        else
                        {
                            timer.Split();
                        }
                    }
                    else
                    {
                        return;
                    }
                    lastsplitat = DateTime.UtcNow;
                    lastsplit   = cursplit;
                }
            }
        }