/// <summary> /// Requests a door to open if necessary. /// </summary> /// <param name="door">The door that is being traversed.</param> /// <param name="doorCell">The cell where the navigator is moving.</param> /// <param name="navCell">The cell where the navigator is standing now.</param> private void RequestOpenDoor(AirlockDoor door, int doorCell, int navCell) { int baseCell = door.GetBaseCell(), dx; // Based on coordinates, determine what is required of the door CellOffset targetOffset = Grid.GetOffset(baseCell, doorCell), navOffset = Grid.GetOffset(doorCell, navCell); dx = targetOffset.x; if (dx > 0) { // Right side door if (navOffset.x > 0) { doors.Add(door, DoorRequestType.EnterRight); door.EnterRight?.Queue(); } else { doors.Add(door, DoorRequestType.ExitRight); door.ExitRight?.Queue(); } } else if (dx < 0) { // Left side door if (navOffset.x > 0) { doors.Add(door, DoorRequestType.ExitLeft); door.ExitLeft?.Queue(); } else { doors.Add(door, DoorRequestType.EnterLeft); door.EnterLeft?.Queue(); } } // Else, entering center cell which is "always" passable }