code/__DEFINES/directional.dm 
TEXT_NORTH | North direction as a string "[1]" |
---|---|
TEXT_SOUTH | South direction as a string "[2]" |
TEXT_EAST | East direction as a string "[4]" |
TEXT_WEST | West direction as a string "[8]" |
ISDIAGONALDIR | 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
True if the dir is diagonal, false otherwise |
ISCARDINALDIR | True if direction is cardinal and false if not |
NSCOMPONENT | True if the dir is north or south, false therwise |
EWCOMPONENT | True if the dir is east/west, false otherwise |
REVERSE_DIR | 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) Inverse direction, taking into account UP|DOWN if necessary. |
NSDIRFLIP | Flips the dir for north/south directions |
EWDIRFLIP | Flips the dir for east/west directions |
Define Details
EWCOMPONENT 
True if the dir is east/west, false otherwise
EWDIRFLIP 
Flips the dir for east/west directions
ISCARDINALDIR 
True if direction is cardinal and false if not
ISDIAGONALDIR 
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
True if the dir is diagonal, false otherwise
NSCOMPONENT 
True if the dir is north or south, false therwise
NSDIRFLIP 
Flips the dir for north/south directions
REVERSE_DIR 
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) Inverse direction, taking into account UP|DOWN if necessary.
TEXT_EAST 
East direction as a string "[4]"
TEXT_NORTH 
North direction as a string "[1]"
TEXT_SOUTH 
South direction as a string "[2]"
TEXT_WEST 
West direction as a string "[8]"