2018-07-06 13:30:00 +00:00
|
|
|
package com.eu.habbo.habbohotel.rooms;
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public enum RoomUserRotation {
|
2018-07-06 13:30:00 +00:00
|
|
|
NORTH(0),
|
|
|
|
NORTH_EAST(1),
|
|
|
|
EAST(2),
|
|
|
|
SOUTH_EAST(3),
|
|
|
|
SOUTH(4),
|
|
|
|
SOUTH_WEST(5),
|
|
|
|
WEST(6),
|
|
|
|
NORTH_WEST(7);
|
|
|
|
|
|
|
|
private final int direction;
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
RoomUserRotation(int direction) {
|
2018-07-06 13:30:00 +00:00
|
|
|
this.direction = direction;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public static RoomUserRotation fromValue(int rotation) {
|
|
|
|
rotation %= 8;
|
|
|
|
for (RoomUserRotation rot : values()) {
|
|
|
|
if (rot.getValue() == rotation) {
|
|
|
|
return rot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NORTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RoomUserRotation counterClockwise(RoomUserRotation rotation) {
|
|
|
|
return fromValue(rotation.getValue() + 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RoomUserRotation clockwise(RoomUserRotation rotation) {
|
|
|
|
return fromValue(rotation.getValue() + 9);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getValue() {
|
2018-07-06 13:30:00 +00:00
|
|
|
return this.direction;
|
|
|
|
}
|
|
|
|
|
2019-05-03 04:08:27 +01:00
|
|
|
public RoomUserRotation getOpposite() {
|
|
|
|
switch (this) {
|
|
|
|
case NORTH:
|
|
|
|
return RoomUserRotation.SOUTH;
|
|
|
|
case NORTH_EAST:
|
|
|
|
return RoomUserRotation.SOUTH_WEST;
|
|
|
|
case EAST:
|
|
|
|
return RoomUserRotation.WEST;
|
|
|
|
case SOUTH_EAST:
|
|
|
|
return RoomUserRotation.NORTH_WEST;
|
|
|
|
case SOUTH:
|
|
|
|
return RoomUserRotation.NORTH;
|
|
|
|
case SOUTH_WEST:
|
|
|
|
return RoomUserRotation.NORTH_EAST;
|
|
|
|
case WEST:
|
|
|
|
return RoomUserRotation.EAST;
|
|
|
|
case NORTH_WEST:
|
|
|
|
return RoomUserRotation.SOUTH_EAST;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|