Function GridNodeBase.OffsetToConnectionDirection

OffsetToConnectionDirection (int dx, int dz)

Converts from a delta (dx, dz) to a neighbour direction.

Public Static
int OffsetToConnectionDirection (

int

dx

X coordinate delta. Should be in the range [-1, 1]. Values outside this range will cause -1 to be returned.

int

dz

Z coordinate delta. Should be in the range [-1, 1]. Values outside this range will cause -1 to be returned.

)

Converts from a delta (dx, dz) to a neighbour direction.

For example, if dx=1 and dz=0, the return value will be 1, which is the direction to the right of a grid coordinate.

If dx=0 and dz=0, the return value will be -1.

Z
|
|

6 2 5
\ | /
-- 3 - X - 1 ----- X
/ | \
7 0 4

|
|