ShopPlatform.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System.Collections.Generic;
  2. namespace ScrapYard.API
  3. {
  4. public class ShopPlatform
  5. {
  6. public readonly ShopPlatformSpacingType Type;
  7. public readonly string Title;
  8. internal List<ShopPlatformEntry> Entries = new List<ShopPlatformEntry>();
  9. internal static List<ShopPlatform> ShopPlatforms = new List<ShopPlatform>();
  10. public static ShopPlatform DefaultObjects
  11. {
  12. get => ShopPlatforms[0];
  13. }
  14. public static ShopPlatform DefaultBlocks
  15. {
  16. get => ShopPlatforms[1];
  17. }
  18. public static ShopPlatform DefaultWalls
  19. {
  20. get => ShopPlatforms[2];
  21. }
  22. public ShopPlatform(string title, ShopPlatformSpacingType spacingType = ShopPlatformSpacingType.Normal)
  23. {
  24. this.Type = spacingType;
  25. this.Title = title;
  26. }
  27. public virtual ShopPlatform Register()
  28. {
  29. ShopPlatforms.Add(this);
  30. return this;
  31. }
  32. public ShopPlatformSpacingType GetShopPlatformSpacingType()
  33. {
  34. return Type;
  35. }
  36. public void AddShopPlatformEntry(ShopPlatformEntry row)
  37. {
  38. Entries.Add(row);
  39. }
  40. public void RemoveShopPlatformEntry(ShopPlatformEntry row)
  41. {
  42. Entries.Remove(row);
  43. }
  44. public ShopPlatformEntry[] GetShopPlatformEntries()
  45. {
  46. return Entries.ToArray();
  47. }
  48. public static ShopPlatform[] GetShopPlatforms()
  49. {
  50. return ShopPlatforms.ToArray();
  51. }
  52. internal int GetSpacesPerRow()
  53. {
  54. int spaces = 0;
  55. switch (Type)
  56. {
  57. case ShopPlatformSpacingType.Normal:
  58. spaces = 7;
  59. break;
  60. case ShopPlatformSpacingType.Near:
  61. spaces = 13;
  62. break;
  63. case ShopPlatformSpacingType.Far:
  64. spaces = 3;
  65. break;
  66. }
  67. return spaces;
  68. }
  69. internal int GetRowsNeeded()
  70. {
  71. return ((Entries.Count - 1) / GetSpacesPerRow()) + 1;
  72. }
  73. }
  74. public enum ShopPlatformSpacingType
  75. {
  76. Normal,
  77. Near,
  78. Far
  79. }
  80. }