示例#1
0
        private void UpdatePlayerEntry()
        {
            if (_playerCar != _playerEntry?.Car)
            {
                if (_playerEntry != null)
                {
                    NonfilteredList.Remove(_playerEntry);
                    _playerEntry = null;
                }

                if (Mode != BuiltInGridMode.Custom || IgnoreStartingPosition)
                {
                    return;
                }
                _playerEntry = _playerCar == null ? null : new RaceGridPlayerEntry(_playerCar);
            }

            if (_playerEntry == null)
            {
                return;
            }
            if (Mode == BuiltInGridMode.Custom)
            {
                var index = NonfilteredList.IndexOf(_playerEntry);
                var pos   = StartingPosition - 1;

                if (index == -1)
                {
                    if (pos > NonfilteredList.Count)
                    {
                        NonfilteredList.Add(_playerEntry);
                    }
                    else if (pos >= 0)
                    {
                        NonfilteredList.Insert(pos, _playerEntry);
                    }
                }
                else
                {
                    if (pos < 0)
                    {
                        NonfilteredList.RemoveAt(index);
                    }
                    else if (pos != index)
                    {
                        NonfilteredList.Move(index, pos);
                    }
                }
            }
            else if (NonfilteredList.Contains(_playerEntry))
            {
                NonfilteredList.Remove(_playerEntry);
                _playerEntry = null;
            }
        }
示例#2
0
        private void UpdatePlayerEntry() {
            if (_playerCar != _playerEntry?.Car) {
                if (_playerEntry != null) {
                    NonfilteredList.Remove(_playerEntry);
                    _playerEntry = null;
                }

                if (Mode != BuiltInGridMode.Custom || IgnoreStartingPosition) return;
                _playerEntry = _playerCar == null ? null : new RaceGridPlayerEntry(_playerCar);
            }

            if (_playerEntry == null) return;
            if (Mode == BuiltInGridMode.Custom) {
                var index = NonfilteredList.IndexOf(_playerEntry);
                var pos = StartingPosition - 1;

                if (index == -1) {
                    if (pos > NonfilteredList.Count) {
                        NonfilteredList.Add(_playerEntry);
                    } else if (pos >= 0) {
                        NonfilteredList.Insert(pos, _playerEntry);
                    }
                } else {
                    if (pos < 0) {
                        NonfilteredList.RemoveAt(index);
                    } else if (pos != index) {
                        NonfilteredList.Move(index, pos);
                    }
                }
            } else if (NonfilteredList.Contains(_playerEntry)) {
                NonfilteredList.Remove(_playerEntry);
                _playerEntry = null;
            }
        }