package nl.sbdeveloper.themeparkplus.api.enums;

import org.bukkit.block.BlockFace;

public enum WalkingDirection {
    /**
     * The walking direction.
     * We can't use BlockFace here, because we only support 4 directions.
     */
    NORTH,
    EAST,
    SOUTH,
    WEST;

    public BlockFace getBlockFace() {
        return BlockFace.valueOf(name());
    }

    public static WalkingDirection getDirection(int xOld, int zOld, int xNew, int zNew) {
        int changeInX = xNew - xOld;
        int changeInZ = zNew - zOld;

        if (changeInZ != 0 && changeInX == 0) {
            if (changeInZ < 0) {
                return WalkingDirection.NORTH;
            } else {
                return WalkingDirection.SOUTH;
            }
        } else if (changeInX != 0 && changeInZ == 0) {
            if (changeInX < 0) {
                return WalkingDirection.WEST;
            } else {
                return WalkingDirection.EAST;
            }
        }
        return null;
    }
}
