factorio-process-data.models.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import * as M from "./factorio-dump.models.ts";
  2. export interface ModList {
  3. mods: { name: string; enabled: boolean }[];
  4. }
  5. export interface PlayerData {
  6. "last-played-version": {
  7. game_version: string;
  8. build_version: number;
  9. build_mode: string;
  10. platform: string;
  11. };
  12. }
  13. export type EffectType = "speed" | "productivity" | "consumption" | "pollution" | "quality";
  14. export const allEffects: EffectType[] = [
  15. "consumption",
  16. "speed",
  17. "productivity",
  18. "pollution",
  19. "quality",
  20. ];
  21. export function isFluidIngredient(
  22. value: M.IngredientPrototype
  23. ): value is M.FluidIngredientPrototype {
  24. return value.type === "fluid";
  25. }
  26. export function isFluidProduct(value: M.ProductPrototype): value is M.FluidProductPrototype {
  27. return value.type === "fluid";
  28. }
  29. export function isResearchProduct(value: M.ProductPrototype): value is M.ProductPrototype {
  30. return false;
  31. }
  32. type Entities<T = string> = Record<string, T>;
  33. export interface DataRawDump {
  34. "agricultural-tower"?: Entities<M.AgriculturalTowerPrototype>;
  35. ammo: Entities<M.AmmoItemPrototype>;
  36. armor: Entities<M.ArmorPrototype>;
  37. "assembling-machine": Entities<M.AssemblingMachinePrototype>;
  38. asteroid?: Entities<M.AsteroidPrototype>;
  39. "asteroid-chunk": Entities<M.AsteroidChunkPrototype>;
  40. "asteroid-collector"?: Entities<M.AsteroidCollectorPrototype>;
  41. beacon: Entities<M.BeaconPrototype>;
  42. boiler: Entities<M.BoilerPrototype>;
  43. capsule: Entities<M.CapsulePrototype>;
  44. "cargo-wagon": Entities<M.CargoWagonPrototype>;
  45. fluid: Entities<M.FluidPrototype>;
  46. "fluid-wagon": Entities<M.FluidWagonPrototype>;
  47. furnace: Entities<M.FurnacePrototype>;
  48. gun: Entities<M.GunPrototype>;
  49. item: Entities<M.ItemPrototype>;
  50. "item-group": Entities<M.ItemGroup>;
  51. "item-subgroup": Entities<M.ItemSubGroup>;
  52. "item-with-entity-data": Entities<M.ItemWithEntityDataPrototype>;
  53. lab: Entities<M.LabPrototype>;
  54. "mining-drill": Entities<M.MiningDrillPrototype>;
  55. module: Entities<M.ModulePrototype>;
  56. "offshore-pump": Entities<M.OffshorePumpPrototype>;
  57. planet: Entities<M.PlanetPrototype>;
  58. plant: Entities<M.PlantPrototype>;
  59. pump: Entities<M.PumpPrototype>;
  60. "rail-planner": Entities<M.RailPlannerPrototype>;
  61. reactor: Entities<M.ReactorPrototype>;
  62. recipe: Entities<M.RecipePrototype>;
  63. "recipe-category": Entities<M.RecipeCategory>;
  64. "repair-tool": Entities<M.RepairToolPrototype>;
  65. resource: Entities<M.ResourceEntityPrototype>;
  66. "rocket-silo": Entities<M.RocketSiloPrototype>;
  67. "rocket-silo-rocket": Entities<M.RocketSiloRocketPrototype>;
  68. "selection-tool": Entities<M.SelectionToolPrototype>;
  69. "space-connection"?: Entities<M.SpaceConnectionPrototype>;
  70. "space-location": Entities<M.SpaceLocationPrototype>;
  71. "space-platform-starter-pack"?: Entities<M.SpacePlatformStarterPackPrototype>;
  72. "spidertron-remote": Entities<M.SpidertronRemotePrototype>;
  73. surface: Entities<M.SurfacePrototype>;
  74. "surface-property": Entities<M.SurfacePropertyPrototype>;
  75. technology: Entities<M.TechnologyPrototype>;
  76. tile: Entities<M.TilePrototype>;
  77. tool: Entities<M.ToolPrototype>;
  78. "transport-belt": Entities<M.TransportBeltPrototype>;
  79. "utility-constants": { default: M.UtilityConstants };
  80. }
  81. export interface Locale {
  82. names: Entities;
  83. }
  84. export type AnyItemPrototype =
  85. | M.AmmoItemPrototype
  86. | M.ArmorPrototype
  87. | M.CapsulePrototype
  88. | M.GunPrototype
  89. | M.ItemPrototype
  90. | M.ItemWithEntityDataPrototype
  91. | M.ItemWithTagsPrototype
  92. | M.ModulePrototype
  93. | M.RailPlannerPrototype
  94. | M.RepairToolPrototype
  95. | M.SelectionToolPrototype
  96. | M.SpacePlatformStarterPackPrototype
  97. | M.SpidertronRemotePrototype
  98. | M.ToolPrototype;
  99. export function isAnyItemPrototype(proto: unknown): proto is AnyItemPrototype {
  100. return (
  101. M.isAmmoItemPrototype(proto) ||
  102. M.isArmorPrototype(proto) ||
  103. M.isCapsulePrototype(proto) ||
  104. M.isGunPrototype(proto) ||
  105. M.isItemPrototype(proto) ||
  106. M.isItemWithEntityDataPrototype(proto) ||
  107. M.isItemWithTagsPrototype(proto) ||
  108. M.isModulePrototype(proto) ||
  109. M.isRailPlannerPrototype(proto) ||
  110. M.isRepairToolPrototype(proto) ||
  111. M.isSelectionToolPrototype(proto) ||
  112. M.isSpacePlatformStarterPackPrototype(proto) ||
  113. M.isSpidertronRemotePrototype(proto) ||
  114. M.isToolPrototype(proto)
  115. );
  116. }
  117. export type AnyEntityPrototype =
  118. | M.BeaconPrototype
  119. | M.AssemblingMachinePrototype
  120. | M.BoilerPrototype
  121. | M.FurnacePrototype
  122. | M.LabPrototype
  123. | M.MiningDrillPrototype
  124. | M.OffshorePumpPrototype
  125. | M.ReactorPrototype
  126. | M.RocketSiloPrototype
  127. | M.TransportBeltPrototype
  128. | M.CargoWagonPrototype
  129. | M.FluidWagonPrototype
  130. | M.PumpPrototype
  131. | M.AsteroidCollectorPrototype
  132. | M.AgriculturalTowerPrototype;
  133. export type AnyLocationPrototype = M.PlanetPrototype | M.SurfacePrototype;
  134. export interface ModDataReport {
  135. machineSpeedZero: string[];
  136. noProducers: string[];
  137. resourceNoMinableProducts: string[];
  138. resourceDuplicate: string[];
  139. disabledRecipeDoesntExist: string[];
  140. }
  141. export type MachineProto =
  142. | M.BoilerPrototype
  143. | M.AssemblingMachinePrototype
  144. | M.RocketSiloPrototype
  145. | M.FurnacePrototype
  146. | M.LabPrototype
  147. | M.MiningDrillPrototype
  148. | M.OffshorePumpPrototype
  149. | M.ReactorPrototype
  150. | M.AsteroidCollectorPrototype
  151. | M.AgriculturalTowerPrototype;
  152. export const anyEntityKeys = [
  153. "beacon",
  154. "assembling-machine",
  155. "boiler",
  156. "furnace",
  157. "lab",
  158. "mining-drill",
  159. "offshore-pump",
  160. "reactor",
  161. "rocket-silo",
  162. "transport-belt",
  163. "cargo-wagon",
  164. "fluid-wagon",
  165. "pump",
  166. "asteroid-collector",
  167. "agricultural-tower",
  168. ] as const;
  169. export const anyItemKeys = [
  170. "item",
  171. "ammo",
  172. "armor",
  173. "capsule",
  174. "gun",
  175. "item-with-entity-data",
  176. "module",
  177. "rail-planner",
  178. "repair-tool",
  179. "selection-tool",
  180. "spidertron-remote",
  181. "space-platform-starter-pack",
  182. "tool",
  183. "fluid",
  184. ] as const;
  185. export const anyLocationKeys = ["surface", "planet"] as const;