SongCoreBeatmapLevelPackCollectionSO.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using SongCore.Utilities;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace SongCore.OverrideClasses
  5. {
  6. public class SongCoreBeatmapLevelPackCollectionSO : BeatmapLevelPackCollectionSO
  7. {
  8. internal List<CustomBeatmapLevelPack> _customBeatmapLevelPacks = new List<CustomBeatmapLevelPack>();
  9. public SongCoreBeatmapLevelPackCollectionSO()
  10. {
  11. }
  12. public static SongCoreBeatmapLevelPackCollectionSO CreateNew()
  13. {
  14. var newCollection = CreateInstance<SongCoreBeatmapLevelPackCollectionSO>();
  15. newCollection._allBeatmapLevelPacks = new IBeatmapLevelPack[] { };
  16. newCollection.UpdateArray();
  17. return newCollection;
  18. }
  19. public void AddLevelPack(CustomBeatmapLevelPack pack)
  20. {
  21. if (pack != null && !_customBeatmapLevelPacks.Contains(pack))
  22. {
  23. _customBeatmapLevelPacks.Add(pack);
  24. UpdateArray();
  25. }
  26. }
  27. public void RemoveLevelPack(CustomBeatmapLevelPack pack)
  28. {
  29. if (pack != null && _customBeatmapLevelPacks.Contains(pack))
  30. {
  31. _customBeatmapLevelPacks.Remove(pack);
  32. UpdateArray();
  33. }
  34. }
  35. private void UpdateArray()
  36. {
  37. _allBeatmapLevelPacks = _customBeatmapLevelPacks.ToArray();
  38. }
  39. }
  40. }