Class ShootExecutor

java.lang.Object
cn.nukkit.entity.ai.executor.ShootExecutor
All Implemented Interfaces:
EntityControl, IBehaviorExecutor

public class ShootExecutor extends Object implements EntityControl, IBehaviorExecutor
  • Field Details

    • memory

      protected MemoryType<? extends Entity> memory
    • speed

      protected float speed
    • maxShootDistanceSquared

      protected int maxShootDistanceSquared
    • clearDataWhenLose

      protected boolean clearDataWhenLose
    • coolDownTick

      protected final int coolDownTick
    • pullBowTick

      protected final int pullBowTick
    • target

      protected Entity target
      用来指定特定的攻击目标.

      Used to specify a specific attack target.

    • item

      protected Supplier<Item> item
      用来射击的物品
  • Constructor Details

    • ShootExecutor

      public ShootExecutor(Supplier<Item> item, MemoryType<? extends Entity> memory, float speed, int maxShootDistance, boolean clearDataWhenLose, int coolDownTick, int pullBowTick)
      射击执行器
      Parameters:
      item - the item
      memory - 用于读取攻击目标的记忆
      Used to read the memory of the attack target
      speed - 移动向攻击目标的速度
      The speed of movement towards the attacking target
      maxShootDistance - 允许射击的最大距离,只有在这个距离内才能射击
      The maximum distance at which it is permissible to shoot, and only at this distance can be fired
      clearDataWhenLose - 失去目标时清空记忆
      Clear your memory when you lose your target
      coolDownTick - 攻击冷却时间(单位tick)
      Attack cooldown (tick)
      pullBowTick - 每次攻击动画用时(单位tick)
      Attack Animation time(tick)
  • Method Details

    • execute

      public boolean execute(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
    • 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 - 目标实体
    • 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 - 目标实体
    • bowShoot

      protected void bowShoot(ItemBow bow, EntityLiving entity)