Files
Bubberstation/code/modules/atmospherics/machinery/components/trinary_devices/trinary_devices.dm
SkyratBot 7b4237c692 [MIRROR] Implements usage of the REVERSE_DIR macro throughout the code. [MDB IGNORE] (#22743)
* Implements usage of the REVERSE_DIR macro throughout the code. (#77122)

## About The Pull Request
Replaces a ton of `turn(dir, 180)` calls with the aforementioned macro.

## Why It's Good For The Game
Afaik, `REVERSE_DIR` was coded to be faster than the classic `turn(dir,
180)` call, being a simple set of binary operations. To sum it up, micro
optimization.

## Changelog

N/A

* Implements usage of the REVERSE_DIR macro throughout the code.

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2023-07-28 14:32:01 -04:00

61 lines
1.5 KiB
Plaintext

/obj/machinery/atmospherics/components/trinary
icon = 'icons/obj/machines/atmospherics/trinary_devices.dmi'
dir = SOUTH
initialize_directions = SOUTH|NORTH|WEST
use_power = IDLE_POWER_USE
idle_power_usage = BASE_MACHINE_IDLE_CONSUMPTION
device_type = TRINARY
layer = GAS_FILTER_LAYER
pipe_flags = PIPING_ONE_PER_TURF
vent_movement = NONE
///Flips the node connections so that the first and third ports are swapped
var/flipped = FALSE
/obj/machinery/atmospherics/components/trinary/set_init_directions()
switch(dir)
if(NORTH)
initialize_directions = EAST|NORTH|SOUTH
if(SOUTH)
initialize_directions = SOUTH|WEST|NORTH
if(EAST)
initialize_directions = EAST|WEST|SOUTH
if(WEST)
initialize_directions = WEST|NORTH|EAST
/*
Housekeeping and pipe network stuff
*/
/obj/machinery/atmospherics/components/trinary/get_node_connects()
//Mixer:
//1 and 2 is input
//Node 3 is output
//If we flip the mixer, 1 and 3 shall exchange positions
//Filter:
//Node 1 is input
//Node 2 is filtered output
//Node 3 is rest output
//If we flip the filter, 1 and 3 shall exchange positions
var/node1_connect = REVERSE_DIR(dir)
var/node2_connect = turn(dir, -90)
var/node3_connect = dir
if(flipped)
node1_connect = REVERSE_DIR(node1_connect)
node3_connect = REVERSE_DIR(node3_connect)
return list(node1_connect, node2_connect, node3_connect)
/obj/machinery/atmospherics/components/trinary/proc/set_overlay_offset(pipe_layer)
switch(pipe_layer)
if(1)
return 1
if(5)
return 5
else
return 0