Space Station 13 - Modules - TypesDefine Details

code/__DEFINES/directions.dm

NO_DIRECTIONdefine purely for readability, cables especially need to use this as NO_DIRECTION represents a "node"
FLIP_DIR_HORIZONTALLYUsing the ^ operator or XOR, we can compared TRUE East and West bits against our direction, since XOR will only return TRUE if one bit is False and the other is True, if East is 0, that bit will return TRUE and if West is 1, then that bit will return 0 hence EAST (0010) XOR EAST|WEST (0011) --> WEST (0001) Flips a direction along the horizontal axis, will convert E -> W, W -> E, NE -> NW, SE -> SW, etc
FLIP_DIR_VERTICALLYFlips a direction along the vertical axis, will convert N -> S, S -> N, NE -> SE, SW -> NW, etc
IS_DIR_DIAGONALfor directions, each cardinal direction only has 1 TRUE bit, so 1000 or 0100 for example, so when you subtract 1 from a cardinal direction it results in that directions initial TRUE bit always switching to FALSE, so if you & check it against its initial self, it will return false, indicating that the direction is straight and not diagonal returns TRUE if direction is diagonal and false if not
IS_DIR_CARDINALreturns TRUE if direction is cardinal and false if not

Define Details

FLIP_DIR_HORIZONTALLY

Using the ^ operator or XOR, we can compared TRUE East and West bits against our direction, since XOR will only return TRUE if one bit is False and the other is True, if East is 0, that bit will return TRUE and if West is 1, then that bit will return 0 hence EAST (0010) XOR EAST|WEST (0011) --> WEST (0001) Flips a direction along the horizontal axis, will convert E -> W, W -> E, NE -> NW, SE -> SW, etc

FLIP_DIR_VERTICALLY

Flips a direction along the vertical axis, will convert N -> S, S -> N, NE -> SE, SW -> NW, etc

IS_DIR_CARDINAL

returns TRUE if direction is cardinal and false if not

IS_DIR_DIAGONAL

for directions, each cardinal direction only has 1 TRUE bit, so 1000 or 0100 for example, so when you subtract 1 from a cardinal direction it results in that directions initial TRUE bit always switching to FALSE, so if you & check it against its initial self, it will return false, indicating that the direction is straight and not diagonal returns TRUE if direction is diagonal and false if not

NO_DIRECTION

define purely for readability, cables especially need to use this as NO_DIRECTION represents a "node"