Class WeightedAction

java.lang.Object
com.hypixel.hytale.server.npc.corecomponents.AnnotatedComponentBase
com.hypixel.hytale.server.npc.corecomponents.WeightedAction
All Implemented Interfaces:
Action, RoleStateChange, IAnnotatedComponent, IComponentExecutionControl

public class WeightedAction extends AnnotatedComponentBase implements Action
  • Constructor Details

  • Method Details

    • getWeight

      public double getWeight()
    • canExecute

      public boolean canExecute(@Nonnull Ref<EntityStore> ref, @Nonnull ExecutionSupport executionSupport, @Nullable InfoProvider sensorInfo, double dt, @Nonnull Store<EntityStore> store)
      Description copied from interface: Action
      Test if an action can be executed
      Specified by:
      canExecute in interface Action
      Parameters:
      ref - The entity ref
      executionSupport - The execution support
      sensorInfo - SensorInfo with PositionProvider, PathProvider, etc if required
      dt - The interval in seconds for this calculation
      store - The component store
      Returns:
      true if action can be executed else false to skip execution
    • execute

      public boolean execute(@Nonnull Ref<EntityStore> ref, @Nonnull ExecutionSupport executionSupport, @Nullable InfoProvider sensorInfo, double dt, @Nonnull Store<EntityStore> store)
      Description copied from interface: Action
      Execute action
      Specified by:
      execute in interface Action
      Parameters:
      ref - The entity ref
      executionSupport - The execution support
      sensorInfo - SensorInfo with PositionProvider, PathProvider, etc if required
      dt - The interval in seconds for this calculation
      store - The component store
      Returns:
      true when executed action has finished else false when execution is not completed yet
    • activate

      public void activate(ExecutionSupport executionSupport, InfoProvider infoProvider)
      Description copied from interface: Action
      Called when the action is activated. In normal lists, this will be called for all actions in the list that can be executed. In blocking sequences, this will be called prior to beginning the first execution of the action in the current cycle.
      Specified by:
      activate in interface Action
      Parameters:
      executionSupport - The execution support
      infoProvider - the InfoProvider from the parent sensor.
    • deactivate

      public void deactivate(ExecutionSupport executionSupport, InfoProvider infoProvider)
      Description copied from interface: Action
      Called when the action is deactivated. In normal lists, this will be called if the action cannot be executed. In blocking sequences, this will be called when the execution of the action completes before moving to the next action.
      Specified by:
      deactivate in interface Action
      Parameters:
      executionSupport - The execution support
      infoProvider - the InfoProvider from the parent sensor.
    • isActivated

      public boolean isActivated()
      Description copied from interface: Action
      Checks if this action has been activated.
      Specified by:
      isActivated in interface Action
      Returns:
      true if activated, false if not.
    • getInfo

      public void getInfo(ExecutionSupport executionSupport, ComponentInfo holder)
      Description copied from interface: IAnnotatedComponent
      Populates the ComponentInfo holder with any relevant information relating to this particular component
      Specified by:
      getInfo in interface IAnnotatedComponent
      Overrides:
      getInfo in class AnnotatedComponentBase
      Parameters:
      executionSupport - per-execution context
      holder - the ComponentInfo instance to populate
    • processDelay

      public boolean processDelay(float dt)
      Description copied from interface: IComponentExecutionControl
      Tick down the internal delay on this core component
      Specified by:
      processDelay in interface IComponentExecutionControl
      Parameters:
      dt - the tick duration
      Returns:
      whether this component has finished processing its internal delay
    • clearOnce

      public void clearOnce()
      Specified by:
      clearOnce in interface IComponentExecutionControl
    • setOnce

      public void setOnce()
      Specified by:
      setOnce in interface IComponentExecutionControl
    • isTriggered

      public boolean isTriggered()
      Specified by:
      isTriggered in interface IComponentExecutionControl
    • registerWithSupport

      public void registerWithSupport(ExecutionSupport executionSupport)
      Specified by:
      registerWithSupport in interface RoleStateChange
    • motionControllerChanged

      public void motionControllerChanged(@Nullable Ref<EntityStore> ref, @Nonnull NPCEntity npcComponent, MotionController motionController, @Nullable ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      motionControllerChanged in interface RoleStateChange
    • loaded

      public void loaded(ExecutionSupport executionSupport)
      Specified by:
      loaded in interface RoleStateChange
    • spawned

      public void spawned(ExecutionSupport executionSupport)
      Specified by:
      spawned in interface RoleStateChange
    • unloaded

      public void unloaded(ExecutionSupport executionSupport)
      Specified by:
      unloaded in interface RoleStateChange
    • removed

      public void removed(ExecutionSupport executionSupport)
      Specified by:
      removed in interface RoleStateChange
    • teleported

      public void teleported(ExecutionSupport executionSupport, World from, World to)
      Specified by:
      teleported in interface RoleStateChange
    • isBusy

      public boolean isBusy()
      Description copied from interface: Action
      Whether this action has work in flight that spans ticks (e.g. a deferred/delayed continuation bound to this instance). Used by ForEach's per-target instance pool to avoid recycling a slot whose action is still mid-execution. Defaults to false.
      Specified by:
      isBusy in interface Action