Skip to content

Commit

Permalink
add new api to check for rotation/flip changes (#24)
Browse files Browse the repository at this point in the history
* add new api to check for rotation/flip changes

Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>

* add a bit javadoc

Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>

---------

Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
  • Loading branch information
Glease authored Sep 13, 2023
1 parent 8309567 commit b6d2af2
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,28 @@ default boolean isNewExtendedFacingValid(ExtendedFacing alignment) {
return getAlignmentLimits()
.isNewExtendedFacingValid(alignment.getDirection(), alignment.getRotation(), alignment.getFlip());
}

/**
* Check if this object support a flip change, assuming both direction and rotation is not changed.
*/
default boolean isFlipChangeAllowed() {
ExtendedFacing facing = getExtendedFacing();
for (Flip flip : Flip.VALUES) {
if (flip == getFlip()) continue;
if (isNewExtendedFacingValid(facing.with(flip))) return true;
}
return false;
}

/**
* Check if this object support a rotation change, assuming both direction and flip is not changed.
*/
default boolean isRotationChangeAllowed() {
ExtendedFacing facing = getExtendedFacing();
for (Rotation rotation : Rotation.VALUES) {
if (rotation == getRotation()) continue;
if (isNewExtendedFacingValid(facing.with(rotation))) return true;
}
return false;
}
}

0 comments on commit b6d2af2

Please sign in to comment.