Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java

72 lines
1.6 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.rooms;
2018-12-22 11:39:00 +01:00
public enum RoomUserRotation
{
2018-07-06 15:30:00 +02: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;
RoomUserRotation(int direction)
{
this.direction = direction;
}
public int getValue()
{
return this.direction;
}
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 15:30:00 +02: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);
}
}