Interface Goal


public interface Goal
One behaviour a mob may pursue, scheduled by its Goals.

Several goals run at once as long as they do not need the same controls: a mob may stroll while it looks at a player. Each tick, a goal that can start takes the controls it needs from the running goals of lower priority; a running goal stops once it no longer should continue or loses one of its controls.

Since:
0.1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    A control of a mob that a running Goal holds.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the goal may start now.
    default Set<Goal.Flag>
    Returns the controls of the mob this goal needs while it runs.
    default boolean
    Returns true if a goal of better priority may take a control from this goal while it runs.
    int
    Returns the priority of this goal; the lower the value, the more important the goal.
    boolean
    Returns true if the goal, once running, should keep running.
    default void
    Called when the goal starts running.
    default void
    Called when the goal stops running, because it ended or was preempted.
    default void
    Called every tick while the goal runs.
  • Method Details

    • priority

      int priority()
      Returns the priority of this goal; the lower the value, the more important the goal.
      Returns:
      the priority of this goal; the lower the value, the more important the goal
      Since:
      0.1.0
    • flags

      default Set<Goal.Flag> flags()
      Returns the controls of the mob this goal needs while it runs.

      Two goals sharing a control never run together. By default a goal needs moving, looking and jumping, so that it runs alone.

      Returns:
      the controls of the mob this goal needs while it runs
      Since:
      0.1.0
    • isInterruptible

      default boolean isInterruptible()
      Returns true if a goal of better priority may take a control from this goal while it runs.
      Returns:
      true if a goal of better priority may take a control from this goal while it runs
      Since:
      0.1.0
    • canStart

      boolean canStart()
      Returns true if the goal may start now.
      Returns:
      true if the goal may start now
      Since:
      0.1.0
    • shouldContinue

      boolean shouldContinue()
      Returns true if the goal, once running, should keep running.
      Returns:
      true if the goal, once running, should keep running
      Since:
      0.1.0
    • start

      default void start()
      Called when the goal starts running.
      Since:
      0.1.0
    • stop

      default void stop()
      Called when the goal stops running, because it ended or was preempted.
      Since:
      0.1.0
    • tick

      default void tick()
      Called every tick while the goal runs.
      Since:
      0.1.0