Wed, 27 Aug 2025 10:26:12 +0300
Lots of stuff
14 | 1 | require("sb-util") |
2 | ||
3 | ---@param fluid_box data.FluidBox? | |
4 | local function mangle_fluid_box(fluid_box) | |
5 | if fluid_box | |
6 | then | |
7 | for _, pipe_connection in pairs (fluid_box.pipe_connections) | |
8 | do | |
9 | pipe_connection.position = {0, 0} | |
10 | end | |
11 | end | |
12 | end | |
13 | ||
14 | local function supported(entity_type) | |
15 | if (entity_type == "rail-support" or entity_type == "rail-ramp") | |
16 | and not feature_flags.rail_bridges | |
17 | then | |
18 | return false | |
19 | else | |
20 | return true | |
21 | end | |
22 | end | |
23 | ||
24 | -- Make a bunch of dummy entities for collision testing purposes | |
25 | local new_entities = {} | |
26 | for _, entity_type in pairs (entity_categories) | |
27 | do | |
28 | for _, base_entity in pairs (supported(entity_type) and data.raw[entity_type] or {}) | |
29 | do | |
30 | if has_flag(base_entity, "player-creation") | |
31 | then | |
32 | local new_entity = table.deepcopy (base_entity) | |
33 | new_entity.name = "collision-tester-"..base_entity.name | |
34 | new_entity.circuit_connector = nil | |
35 | new_entity.next_upgrade = nil | |
36 | new_entity.fast_replaceable_group = nil | |
19 | 37 | new_entity.hidden = true |
14 | 38 | mangle_fluid_box(new_entity.fluid_box) |
39 | for _, fluid_box in pairs (new_entity.fluid_boxes or {}) | |
40 | do | |
41 | mangle_fluid_box(fluid_box) | |
42 | end | |
43 | mangle_fluid_box(new_entity.input_fluid_box) | |
44 | mangle_fluid_box(new_entity.output_fluid_box) | |
45 | mangle_fluid_box(new_entity.fuel_fluid_box) | |
46 | mangle_fluid_box(new_entity.oxidizer_fluid_box) | |
47 | if new_entity.type == "mining-drill" | |
48 | or new_entity.type == "assembling-machine" | |
49 | or new_entity.type == "fusion-generator" | |
50 | or new_entity.type == "fusion-reactor" | |
51 | or new_entity.type == "inserter" | |
52 | or new_entity.type == "thruster" | |
53 | or new_entity.type == "cargo-bay" | |
54 | or new_entity.type == "cargo-landing-pad" | |
55 | or new_entity.type == "transport-belt" | |
56 | or new_entity.type == "splitter" | |
57 | or new_entity.type == "container" | |
58 | or new_entity.type == "loader" | |
59 | or new_entity.type == "pump" | |
60 | or new_entity.type == "rocket-silo" | |
61 | or new_entity.type == "solar-panel" | |
62 | then | |
63 | -- I'd use simple entities here, but they need to be rotatable | |
64 | new_entity.type = "assembling-machine" | |
65 | new_entity.input_fluid_box = nil | |
66 | new_entity.output_fluid_box = nil | |
67 | new_entity.fluid_boxes = {} | |
68 | new_entity.energy_usage = "1W" | |
69 | new_entity.energy_source = {type="void"} | |
70 | new_entity.crafting_speed = 1 | |
71 | new_entity.crafting_categories = {"crafting"} | |
72 | new_entity.fixed_recipe = nil | |
73 | new_entity.module_slots = 0 | |
74 | end | |
75 | if (new_entity.type == "cargo-landing-pad" or new_entity.type == "cargo-bay") | |
76 | and new_entity.graphics_set | |
77 | then | |
78 | new_entity.graphics_set.connections = nil | |
79 | end | |
80 | if (new_entity.type == "cargo-bay") | |
81 | and new_entity.platform_graphics_set | |
82 | then | |
83 | new_entity.platform_graphics_set.connections = nil | |
84 | end | |
85 | table.insert (new_entities, new_entity) | |
86 | end | |
87 | end | |
88 | end | |
89 | ||
90 | data:extend (new_entities) |