model.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. type Entity = {
  2. entity_number: number;
  3. name: string;
  4. position: {
  5. x: number;
  6. y: number;
  7. };
  8. direction: 1 | 2 | 3 | 4;
  9. };
  10. export type BlueprintSignal = {
  11. type?: string;
  12. name: string;
  13. quality?: string;
  14. };
  15. type NetworkState = {
  16. red: boolean;
  17. green: boolean;
  18. };
  19. export type DeciderCondition = {
  20. first_signal: BlueprintSignal;
  21. comparator: "<" | ">" | "=" | "≥" | "≤" | "≠";
  22. compare_type?: "and" | "or";
  23. first_signal_networks?: NetworkState;
  24. } & ({ second_signal: BlueprintSignal; second_signal_networks?: NetworkState } | { constant?: number });
  25. type DeciderOutput = {
  26. signal: BlueprintSignal;
  27. } & ({ copy_count_from_input: false; constant?: number } | { networks?: { red: boolean; green: boolean } });
  28. export type DeciderCombinator = Entity & {
  29. name: "decider-combinator";
  30. control_behavior: {
  31. decider_conditions: {
  32. conditions?: DeciderCondition[];
  33. outputs?: DeciderOutput[];
  34. else_outputs?: DeciderOutput[];
  35. };
  36. };
  37. player_description: string;
  38. };
  39. export type Blueprint = {
  40. blueprint: {
  41. item: "blueprint";
  42. version: 562954249109505;
  43. icons: Array<{ signal: BlueprintSignal; index: 1 | 2 | 3 | 4 }>;
  44. entities: [];
  45. /**Each wires is represented by 4 number
  46. * [a, b, c, d]
  47. * a : entity_number of first entity
  48. * b : wire connector (1-4) of first entity
  49. * a : entity_number of second entity
  50. * b : wire connector (1-4) of second entity
  51. * Most entity have only 2 connector (red and green circuit)
  52. * Decider Combinator, Arithmetic Combinator and Selector Combinator have 4 connectors (2 inputs, 2 outputs)
  53. * 1 & 3 red
  54. * 2 & 4 green
  55. */
  56. wires: Array<Array<number>>;
  57. };
  58. };