|
31 | 31 | ///The image showing the gases inside of the tank
|
32 | 32 | var/image/window
|
33 | 33 |
|
| 34 | + /// The open node directions of the tank, assuming that the tank is facing NORTH. |
| 35 | + var/open_ports = NONE |
34 | 36 | /// The volume of the gas mixture
|
35 | 37 | var/volume = 2500 //in liters
|
36 | 38 | /// The max pressure of the gas mixture before damaging the tank
|
|
104 | 106 |
|
105 | 107 | // Mapped in tanks should automatically connect to adjacent pipenets in the direction set in dir
|
106 | 108 | if(mapload)
|
107 |
| - initialize_directions = dir |
| 109 | + set_portdir_relative(dir, TRUE) |
| 110 | + set_init_directions() |
108 | 111 |
|
109 | 112 | return INITIALIZE_HINT_LATELOAD
|
110 | 113 |
|
|
156 | 159 | refresh_window()
|
157 | 160 |
|
158 | 161 | ///////////////////////////////////////////////////////////////////
|
159 |
| -// Pipenet stuff |
160 |
| - |
161 |
| -/obj/machinery/atmospherics/components/tank/return_analyzable_air() |
162 |
| - return air_contents |
| 162 | +// Port stuff |
| 163 | + |
| 164 | +/** |
| 165 | + * Enables/Disables a port direction in var/open_ports. \ |
| 166 | + * Use this, then call set_init_directions() instead of setting initialize_directions directly \ |
| 167 | + * This system exists because tanks not having all initialize_directions set correctly breaks shuttle rotations |
| 168 | + */ |
| 169 | +/obj/machinery/atmospherics/components/tank/proc/set_portdir_relative(relative_port_dir, enable) |
| 170 | + ASSERT(!isnull(enable)) |
| 171 | + |
| 172 | + // Rotate the given dir so that it's relative to north |
| 173 | + var/port_dir |
| 174 | + if(dir == NORTH) // We're already facing north, no rotation needed |
| 175 | + port_dir = relative_port_dir |
| 176 | + else |
| 177 | + var/offnorth_angle = dir2angle(dir) |
| 178 | + port_dir = turn(relative_port_dir, offnorth_angle) |
163 | 179 |
|
164 |
| -/obj/machinery/atmospherics/components/tank/return_airs_for_reconcilation(datum/pipeline/requester) |
165 |
| - . = ..() |
166 |
| - if(!air_contents) |
| 180 | + if(enable) |
| 181 | + open_ports |= port_dir |
| 182 | + else |
| 183 | + open_ports &= ~port_dir |
| 184 | + |
| 185 | +/** |
| 186 | + * Toggles a port direction in var/open_ports \ |
| 187 | + * Use this, then call set_init_directions() instead of setting initialize_directions directly \ |
| 188 | + * This system exists because tanks not having all initialize_directions set correctly breaks shuttle rotations |
| 189 | + */ |
| 190 | +/obj/machinery/atmospherics/components/tank/proc/toggle_portdir_relative(relative_port_dir) |
| 191 | + var/toggle = ((initialize_directions & relative_port_dir) ? FALSE : TRUE) |
| 192 | + set_portdir_relative(relative_port_dir, toggle) |
| 193 | + |
| 194 | +/obj/machinery/atmospherics/components/tank/set_init_directions() |
| 195 | + if(!open_ports) |
| 196 | + initialize_directions = NONE |
167 | 197 | return
|
168 |
| - . += air_contents |
169 | 198 |
|
170 |
| -/obj/machinery/atmospherics/components/tank/return_pipenets_for_reconcilation(datum/pipeline/requester) |
171 |
| - . = ..() |
172 |
| - var/datum/merger/merge_group = GetMergeGroup(merger_id, merger_typecache) |
173 |
| - for(var/obj/machinery/atmospherics/components/tank/tank as anything in merge_group.members) |
174 |
| - . += tank.parents |
| 199 | + //We're rotating open_ports relative to dir, and |
| 200 | + //setting initialize_directions to that rotated dir |
| 201 | + var/relative_port_dirs = NONE |
| 202 | + var/dir_angle = dir2angle(dir) |
| 203 | + for(var/cardinal in GLOB.cardinals) |
| 204 | + var/current_dir = cardinal & open_ports |
| 205 | + if(!current_dir) |
| 206 | + continue |
175 | 207 |
|
176 |
| -/obj/machinery/atmospherics/components/tank/proc/toggle_side_port(new_dir) |
177 |
| - if(initialize_directions & new_dir) |
178 |
| - initialize_directions &= ~new_dir |
179 |
| - else |
180 |
| - initialize_directions |= new_dir |
| 208 | + var/rotated_dir = turn(current_dir, -dir_angle) |
| 209 | + relative_port_dirs |= rotated_dir |
| 210 | + |
| 211 | + initialize_directions = relative_port_dirs |
| 212 | + |
| 213 | +/obj/machinery/atmospherics/components/tank/proc/toggle_side_port(port_dir) |
| 214 | + toggle_portdir_relative(port_dir) |
| 215 | + set_init_directions() |
181 | 216 |
|
182 | 217 | for(var/i in 1 to length(nodes))
|
183 | 218 | var/obj/machinery/atmospherics/components/node = nodes[i]
|
|
200 | 235 |
|
201 | 236 | update_parents()
|
202 | 237 |
|
| 238 | +/////////////////////////////////////////////////////////////////// |
| 239 | +// Pipenet stuff |
| 240 | + |
| 241 | +/obj/machinery/atmospherics/components/tank/return_analyzable_air() |
| 242 | + return air_contents |
| 243 | + |
| 244 | +/obj/machinery/atmospherics/components/tank/return_airs_for_reconcilation(datum/pipeline/requester) |
| 245 | + . = ..() |
| 246 | + if(!air_contents) |
| 247 | + return |
| 248 | + . += air_contents |
| 249 | + |
| 250 | +/obj/machinery/atmospherics/components/tank/return_pipenets_for_reconcilation(datum/pipeline/requester) |
| 251 | + . = ..() |
| 252 | + var/datum/merger/merge_group = GetMergeGroup(merger_id, merger_typecache) |
| 253 | + for(var/obj/machinery/atmospherics/components/tank/tank as anything in merge_group.members) |
| 254 | + . += tank.parents |
| 255 | + |
203 | 256 | ///////////////////////////////////////////////////////////////////
|
204 | 257 | // Merger handling
|
205 | 258 |
|
|
0 commit comments