Interface IStructureComponent
- All Known Implementing Classes:
BigDoor,Clock,Drawbridge,Flag,GarageDoor,Portcullis,RevolvingDoor,SlidingDoor,Windmill
A structure component is used to define the behavior of a structure. This includes the type of animation, the animation time, etc.
When the Structure class is constructed calls any methods from this interface, it will do so under a lock.
The methods in this interface are not meant to be called directly. Instead, use the methods in the Structure
class.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classSimple nested class to hold the logger for this interface. -
Method Summary
Modifier and TypeMethodDescriptiondoublecalculateAnimationCycleDistance(IStructureConst structure) Calculate the animation cycle distance for this structure.calculateAnimationRange(IStructureConst structure) Calculate the animation range for this structure.default doublecalculateAnimationTime(IStructureConst structure, double target) Gets the animation time (in seconds) of this structure.default booleancanMovePerpetually(IStructureConst structure) Checks if the structure can move perpetually.default booleancanSkipAnimation(IStructureConst structure) Determines if this component can skip the animation.constructAnimationComponent(IStructureConst structure, AnimationRequestData data) Creates a newIAnimationComponentfor the provided structure and data for this structure component.static MovementDirectioncycleCardinalDirection(MovementDirection direction) Cycles the cardinal direction.default MovementDirectiongetCurrentToggleDirection(IStructureConst structure) Gets the direction the structure would go given its current state.default MovementDirectiongetCycledOpenDirection(IStructureConst structure) Cycle the toggle direction.getPotentialNewCoordinates(IStructureConst structure) Finds the new minimum and maximum coordinates (represented by aCuboid) of this structure that would be the result of toggling it.default booleanisNorthSouthAnimated(IStructureConst structure) Checks if the structure is animated in the north-south direction.
-
Method Details
-
canMovePerpetually
Checks if the structure can move perpetually.This applies to structure types that have no end state, such as a flag, a clock, or a windmill.
This method defaults to
false.- Parameters:
structure- The structure to check.- Returns:
trueif the structure can move perpetually,falseotherwise.
-
isNorthSouthAnimated
Checks if the structure is animated in the north-south direction.- Parameters:
structure- The structure to check.- Returns:
trueif the structure is animated in the north-south direction,falseotherwise.
-
canSkipAnimation
Determines if this component can skip the animation.See
Structure.canSkipAnimation()for more information.This method defaults to
trueif the structure has theProperty.OPEN_STATUSproperty, as this implies that the structure has different states and a toggle without animation is a valid operation.- Returns:
trueif the animation can be skipped,falseotherwise.
-
calculateAnimationCycleDistance
Calculate the animation cycle distance for this structure.This method should not be called directly. Instead, use
Structure.getAnimationCycleDistance(). See the documentation for that method for more information.- Parameters:
structure- The structure to calculate the animation cycle distance for.- Returns:
- The distance traveled per animation cycle by the block that travels the furthest.
-
calculateAnimationRange
Calculate the animation range for this structure.This method should not be called directly. Instead, use
Structure.getAnimationRange(). See the documentation for that method for more information.- Parameters:
structure- The structure to calculate the animation range for.- Returns:
- The animation range for this structure.
-
constructAnimationComponent
IAnimationComponent constructAnimationComponent(IStructureConst structure, AnimationRequestData data) Creates a newIAnimationComponentfor the provided structure and data for this structure component.- Parameters:
structure- The structure to calculate the animation range for.data- The data for the toggle request.- Returns:
- A new
Animatorfor this type of structure.
-
getPotentialNewCoordinates
Finds the new minimum and maximum coordinates (represented by aCuboid) of this structure that would be the result of toggling it.- Parameters:
structure- The structure to calculate the animation range for.- Returns:
- The
Cuboidthat would represent the structure if it was toggled right now.
-
getCurrentToggleDirection
Gets the direction the structure would go given its current state.- Parameters:
structure- The structure to calculate the animation range for.- Returns:
- The direction the structure would go if it were to be toggled.
-
getCycledOpenDirection
Cycle the toggle direction.See
Structure.getCycledOpenDirection()for more information.- Parameters:
structure- The structure to get the cycled open direction for.- Returns:
- The 'next' toggle direction.
-
calculateAnimationTime
Gets the animation time (in seconds) of this structure.This basically returns max(target,
IStructureConst.getMinimumAnimationTime()), logging a message in case the target time is too low.- Parameters:
target- The target time.- Returns:
- The target time if it is bigger than the minimum time, otherwise the minimum.
-
cycleCardinalDirection
Cycles the cardinal direction.For example, if the input is
MovementDirection.NORTH, it will returnMovementDirection.EAST.If the input is not a cardinal direction, it will return
MovementDirection.NORTH.- Parameters:
direction- The direction to cycle.- Returns:
- The next cardinal direction.
-