public void DeleteEntry(RaceGridEntry entry) { if (entry is RaceGridPlayerEntry) { StartingPosition = 0; return; } NonfilteredList.Remove(entry); if (Mode == BuiltInGridMode.Custom) { UpdateOpponentsNumber(); } else { Mode = BuiltInGridMode.CandidatesManual; } UpdateExceeded(); }
public bool Same(RaceGridEntry other) { return(GetType().Name == other.GetType().Name&& Car == other.Car && CarSkin == other.CarSkin && Name == other.Name && Nationality == other.Nationality && AiLevel == other.AiLevel); }
public void InsertEntry(int index, [NotNull] RaceGridEntry entry) { var oldIndex = NonfilteredList.IndexOf(entry); var count = NonfilteredList.Count; var isNew = oldIndex == -1; var limit = isNew ? count : count - 1; if (index < 0 || index > limit) { index = limit; } if (oldIndex == index) { return; } if (Mode.CandidatesMode) { if (isNew) { Mode = BuiltInGridMode.CandidatesManual; var existed = NonfilteredList.FirstOrDefault(x => x.Same(entry)); if (existed != null) { existed.CandidatePriority++; } else { NonfilteredList.Add(entry); } return; } NonfilteredList.ReplaceEverythingBy(NonfilteredList.Sort(Compare)); NonfilteredList.Move(oldIndex, index); try { _modeKeepOrder = true; Mode = BuiltInGridMode.Custom; } finally { _modeKeepOrder = false; } } else if (isNew) { if (index == count) { NonfilteredList.Add(entry); } else { NonfilteredList.Insert(index, entry); } UpdateOpponentsNumber(); } else if (index != oldIndex) { NonfilteredList.Move(oldIndex, index); } if (StartingPosition != 0) { StartingPositionLimited = NonfilteredList.IndexOf(_playerEntry) + 1; } UpdateExceeded(); }
public void AddEntry([NotNull] RaceGridEntry entry) { InsertEntry(-1, entry); }
public bool Same(RaceGridEntry other) { return GetType().Name == other.GetType().Name && Car == other.Car && CarSkin == other.CarSkin && Name == other.Name && Nationality == other.Nationality && AiLevel == other.AiLevel; }