Class FlatRandomRoamExecutor

java.lang.Object
cn.nukkit.entity.ai.executor.FlatRandomRoamExecutor
All Implemented Interfaces:
EntityControl, IBehaviorExecutor
Direct Known Subclasses:
SpaceRandomRoamExecutor, TameHorseExecutor

@PowerNukkitXOnly @Since("1.6.0.0-PNX") public class FlatRandomRoamExecutor extends Object implements EntityControl, IBehaviorExecutor
  • Field Details

    • speed

      protected float speed
    • maxRoamRange

      protected int maxRoamRange
    • frequency

      protected int frequency
    • currentTargetCalTick

      protected int currentTargetCalTick
    • durationTick

      protected int durationTick
    • calNextTargetImmediately

      protected boolean calNextTargetImmediately
    • runningTime

      protected int runningTime
    • avoidWater

      protected boolean avoidWater
    • maxRetryTime

      protected int maxRetryTime
  • Constructor Details

    • FlatRandomRoamExecutor

      public FlatRandomRoamExecutor(float speed, int maxRoamRange, int frequency)
    • FlatRandomRoamExecutor

      public FlatRandomRoamExecutor(float speed, int maxRoamRange, int frequency, boolean calNextTargetImmediately, int runningTime)
    • FlatRandomRoamExecutor

      public FlatRandomRoamExecutor(float speed, int maxRoamRange, int frequency, boolean calNextTargetImmediately, int runningTime, boolean avoidWater, int maxRetryTime)
      Instantiates a new Flat random roam executor.
      Parameters:
      speed - 移动速度
      Movement speed
      maxRoamRange - 随机行走目标点的范围
      The range of the target point that is randomly walked
      frequency - 更新目标点的频率
      How often the target point is updated
      calNextTargetImmediately - 是否立即选择下一个目标点,不管执行频率
      Whether to select the next target point immediately, regardless of the frequency of execution
      runningTime - 执行最大的用时,-1代表不限制
      Maximum time to execute,-1 means no limit
      avoidWater - 是否避开水行走
      Whether to walk away from water
      maxRetryTime - 选取目标点的最大尝试次数
      Pick the maximum number of attempts at the target point
  • Method Details

    • execute

      public boolean execute(@NotNull EntityIntelligent entity)
      Description copied from interface: IBehaviorExecutor
      调度器将会持续执行此执行器,直到返回false,或者执行器被中断
      此方法每gt都会调用

      The scheduler will continue to execute this executor until it returns false or the executor is interrupted
      This method will be called every gt

      Specified by:
      execute in interface IBehaviorExecutor
      Parameters:
      entity - 执行目标实体
      Returns:
      boolean
    • onInterrupt

      public void onInterrupt(EntityIntelligent entity)
      Description copied from interface: IBehaviorExecutor
      行为非正常中断时(例如被更高级行为覆盖)调用

      Called when behavior breaks abnormally (e.g. overridden by higher-level behavior)

      Specified by:
      onInterrupt in interface IBehaviorExecutor
      Parameters:
      entity - 目标实体
    • onStop

      public void onStop(EntityIntelligent entity)
      Description copied from interface: IBehaviorExecutor
      行为正常结束时(execute()方法返回false)调用

      Called when the behavior ends normally (the execute() method returns false)

      Specified by:
      onStop in interface IBehaviorExecutor
      Parameters:
      entity - 目标实体
    • stop

      protected void stop(EntityIntelligent entity)
    • needUpdateTarget

      protected boolean needUpdateTarget(EntityIntelligent entity)
    • next

      protected Vector3 next(EntityIntelligent entity)