Module.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System.Text.Json;
  2. using System.Text.Json.Serialization;
  3. namespace SOTF_Struct.Generic {
  4. public class Module {
  5. public enum eModuleType : byte {
  6. Empty,
  7. Module_0,
  8. Module_1,
  9. Module_2,
  10. Module_3,
  11. Module_4,
  12. // Module_5,
  13. Module_6,
  14. Module_7
  15. }
  16. public string Version { get; set; } = "0.0.0";
  17. public int ModuleId { get; set; } = 0;
  18. // ModuleId = 0
  19. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  20. public RotationD<double>? ChannelWeights { get; set; }
  21. // Module = 1
  22. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  23. public int? SourceActorType { get; set; }
  24. // ModuleId = 2
  25. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  26. public int? IconIndex { get; set; }
  27. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  28. public bool? ShowBreadcrumbs { get; set; }
  29. // ModuleId = 3
  30. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  31. public int? CurrentState { get; set; }
  32. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  33. public double? TimeRemainingInState { get; set; }
  34. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  35. public bool? PauseDecay { get; set; }
  36. // ModuleId = 4
  37. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  38. public int? AmmoType { get; set; }
  39. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  40. public int? CurrentAmmo { get; set; }
  41. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  42. public List<int>? WeaponModIds { get; set; }
  43. // ModuleID = 6
  44. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  45. public int? VariantNumber { get; set; }
  46. // ModuleId = 7
  47. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  48. public int? RecipeId { get; set; }
  49. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  50. public int? CurrentVolume { get; set; }
  51. public static Module CreateModule(eModuleType mod) {
  52. if (mod == eModuleType.Module_0)
  53. return CreateModule(new RotationD<double>());
  54. if (mod == eModuleType.Module_1)
  55. return new Module() { ModuleId = 1, SourceActorType = 16, Version = "0.0.0" };
  56. else if (mod == eModuleType.Module_2)
  57. return CreateModule(0, false);
  58. else if (mod == eModuleType.Module_3)
  59. return CreateModule(0, 0.0f, false);
  60. else if (mod == eModuleType.Module_4)
  61. return CreateModule(0, 0, new int[] { });
  62. else if (mod == eModuleType.Module_6)
  63. return CreateModule(0);
  64. else if (mod == eModuleType.Module_7)
  65. return CreateModule(0, 0);
  66. return new Module() { Version = "0.0.0" };
  67. }
  68. public static Module CreateModule(RotationD<double> channelWeights) {
  69. return new Module() { ModuleId = 0, ChannelWeights = channelWeights, Version = "0.0.0" };
  70. }
  71. public static Module CreateModule(int IconIndex, bool ShowBreadcrumbs) {
  72. return new Module() { ModuleId = 2, Version = "0.0.0", IconIndex = IconIndex, ShowBreadcrumbs = ShowBreadcrumbs };
  73. }
  74. public static Module CreateModule(int CurrentState, float TimeRemaining, bool PauseDecay) {
  75. return new Module() { ModuleId = 3, Version = "0.0.0", CurrentState = CurrentState, TimeRemainingInState = TimeRemaining, PauseDecay = PauseDecay };
  76. }
  77. public static Module CreateModule(int AmmoType, int CurrentAmmo, int[] WeaponIDs) {
  78. return new Module() { ModuleId = 4, Version = "0.0.0", AmmoType = AmmoType, CurrentAmmo = CurrentAmmo, WeaponModIds = new List<int>(WeaponIDs) };
  79. }
  80. public static Module CreateModule(int VariantNumber) {
  81. return new Module() { ModuleId = 6, Version = "0.0.0", VariantNumber = VariantNumber };
  82. }
  83. public static Module CreateModule(int RecipeId, int CurrentVolume) {
  84. return new Module() { ModuleId = 7, Version = "0.0.0", RecipeId = RecipeId, CurrentVolume = CurrentVolume };
  85. }
  86. }
  87. }