Interface IStructureComponent

All Known Implementing Classes:
BigDoor, Clock, Drawbridge, Flag, GarageDoor, Portcullis, RevolvingDoor, SlidingDoor, Windmill

public interface IStructureComponent
Represents a component of a structure.

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.

  • Method Details

    • canMovePerpetually

      default boolean canMovePerpetually(IStructureConst structure)
      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:
      true if the structure can move perpetually, false otherwise.
    • isNorthSouthAnimated

      default boolean isNorthSouthAnimated(IStructureConst structure)
      Checks if the structure is animated in the north-south direction.
      Parameters:
      structure - The structure to check.
      Returns:
      true if the structure is animated in the north-south direction, false otherwise.
    • canSkipAnimation

      default boolean canSkipAnimation(IStructureConst structure)
      Determines if this component can skip the animation.

      See Structure.canSkipAnimation() for more information.

      This method defaults to true if the structure has the Property.OPEN_STATUS property, as this implies that the structure has different states and a toggle without animation is a valid operation.

      Returns:
      true if the animation can be skipped, false otherwise.
    • calculateAnimationCycleDistance

      double calculateAnimationCycleDistance(IStructureConst structure)
      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

      Rectangle calculateAnimationRange(IStructureConst structure)
      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 new IAnimationComponent for 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 Animator for this type of structure.
    • getPotentialNewCoordinates

      Optional<Cuboid> getPotentialNewCoordinates(IStructureConst structure)
      Finds the new minimum and maximum coordinates (represented by a Cuboid) of this structure that would be the result of toggling it.
      Parameters:
      structure - The structure to calculate the animation range for.
      Returns:
      The Cuboid that would represent the structure if it was toggled right now.
    • getCurrentToggleDirection

      default MovementDirection getCurrentToggleDirection(IStructureConst structure)
      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

      default MovementDirection getCycledOpenDirection(IStructureConst structure)
      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

      default double calculateAnimationTime(IStructureConst structure, double target)
      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

      static MovementDirection cycleCardinalDirection(MovementDirection direction)
      Cycles the cardinal direction.

      For example, if the input is MovementDirection.NORTH, it will return MovementDirection.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.