Class BehaviorGroup
java.lang.Object
cn.nukkit.entity.ai.behaviorgroup.BehaviorGroup
- All Implemented Interfaces:
IBehaviorGroup
@PowerNukkitXOnly
@Since("1.6.0.0-PNX")
public class BehaviorGroup
extends Object
implements IBehaviorGroup
标准行为组实现
-
Field Summary
Modifier and TypeFieldDescription用于存储行为距离上次评估逝去的gt数全部行为protected final Set<IController>
控制器用于存储核心行为距离上次评估逝去的gt数不会被其他行为覆盖的"核心“行为protected int
记录距离上次路径更新过去的gt数protected boolean
protected final IMemoryStorage
记忆存储器protected static int
决定多少gt更新一次路径protected final SimpleRouteFinder
寻路器(非异步,因为没必要,生物AI本身就是并行的)protected RouteFindingManager.RouteFindingTask
寻路任务正在运行的行为正在运行的”核心“行为用于存储传感器距离上次刷新逝去的gt数传感器 -
Constructor Summary
ConstructorDescriptionBehaviorGroup
(int startRouteUpdateTick, Set<IBehavior> coreBehaviors, Set<IBehavior> behaviors, Set<ISensor> sensors, Set<IController> controllers, SimpleRouteFinder routeFinder) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToRunningBehaviors
(EntityIntelligent entity, Set<IBehavior> behaviors) 添加评估成功后的行为到runningBehaviors
void
applyController
(EntityIntelligent entity) 应用行为内部所有的控制器IController
protected int
calcActiveDelay
(EntityIntelligent entity, int originalDelay) 计算活跃实体延迟void
collectSensorData
(EntityIntelligent entity) 调用行为组内部的所有传感器ISensor
,并将传感器返回的记忆数据写入到记忆存储器中IMemoryStorage
void
debugTick
(EntityIntelligent entity) 当EntityAI
.DEBUG == true 时此方法每1gt调用一次,用于debug模式相关内容的刷新void
evaluateBehaviors
(EntityIntelligent entity) 评估所有行为void
调用行为组内部的所有核心行为IBehavior
的评估器IBehaviorEvaluator
用于存储行为距离上次评估逝去的gt数全部行为控制器用于存储核心行为距离上次评估逝去的gt数不会被其他行为覆盖的"核心“行为int
记录距离上次路径更新过去的gt数记忆存储器寻路器(非异步,因为没必要,生物AI本身就是并行的)寻路任务正在运行的行为正在运行的”核心“行为用于存储传感器距离上次刷新逝去的gt数传感器protected void
protected void
中断所有正在运行的行为boolean
void
setCurrentRouteUpdateTick
(int currentRouteUpdateTick) 记录距离上次路径更新过去的gt数void
setForceUpdateRoute
(boolean forceUpdateRoute) 要求下一gt立即更新路径void
setRouteFindingTask
(RouteFindingManager.RouteFindingTask routeFindingTask) 寻路任务void
运行并刷新正在运行的行为void
调用行为组内部所有被激活的核心行为IBehavior
的执行器IBehaviorExecutor
protected void
updateMoveDirection
(EntityIntelligent entity) void
updateRoute
(EntityIntelligent entity) 通过行为组使用的寻路器更新当前位置到目标位置路径
-
Field Details
-
ROUTE_UPDATE_CYCLE
protected static int ROUTE_UPDATE_CYCLE决定多少gt更新一次路径 -
coreBehaviors
不会被其他行为覆盖的"核心“行为 -
behaviors
全部行为 -
sensors
传感器 -
controllers
控制器 -
runningCoreBehaviors
正在运行的”核心“行为 -
runningBehaviors
正在运行的行为 -
coreBehaviorPeriodTimer
用于存储核心行为距离上次评估逝去的gt数 -
behaviorPeriodTimer
用于存储行为距离上次评估逝去的gt数 -
sensorPeriodTimer
用于存储传感器距离上次刷新逝去的gt数 -
memoryStorage
记忆存储器 -
routeFinder
寻路器(非异步,因为没必要,生物AI本身就是并行的) -
routeFindingTask
寻路任务 -
currentRouteUpdateTick
protected int currentRouteUpdateTick记录距离上次路径更新过去的gt数 -
forceUpdateRoute
protected boolean forceUpdateRoute
-
-
Constructor Details
-
BehaviorGroup
public BehaviorGroup(int startRouteUpdateTick, Set<IBehavior> coreBehaviors, Set<IBehavior> behaviors, Set<ISensor> sensors, Set<IController> controllers, SimpleRouteFinder routeFinder)
-
-
Method Details
-
tickRunningBehaviors
运行并刷新正在运行的行为- Specified by:
tickRunningBehaviors
in interfaceIBehaviorGroup
- Parameters:
entity
- 目标实体对象
-
tickRunningCoreBehaviors
Description copied from interface:IBehaviorGroup
调用行为组内部所有被激活的核心行为IBehavior
的执行器IBehaviorExecutor
- Specified by:
tickRunningCoreBehaviors
in interfaceIBehaviorGroup
- Parameters:
entity
- 目标实体对象
-
collectSensorData
Description copied from interface:IBehaviorGroup
调用行为组内部的所有传感器ISensor
,并将传感器返回的记忆数据写入到记忆存储器中IMemoryStorage
- Specified by:
collectSensorData
in interfaceIBehaviorGroup
- Parameters:
entity
- 目标实体对象
-
evaluateCoreBehaviors
Description copied from interface:IBehaviorGroup
调用行为组内部的所有核心行为IBehavior
的评估器IBehaviorEvaluator
- Specified by:
evaluateCoreBehaviors
in interfaceIBehaviorGroup
- Parameters:
entity
- 目标实体对象
-
evaluateBehaviors
评估所有行为- Specified by:
evaluateBehaviors
in interfaceIBehaviorGroup
- Parameters:
entity
- 评估的实体对象
-
applyController
Description copied from interface:IBehaviorGroup
应用行为内部所有的控制器IController
- Specified by:
applyController
in interfaceIBehaviorGroup
- Parameters:
entity
- 目标实体对象
-
updateRoute
Description copied from interface:IBehaviorGroup
通过行为组使用的寻路器更新当前位置到目标位置路径- Specified by:
updateRoute
in interfaceIBehaviorGroup
- Parameters:
entity
- 目标实体
-
debugTick
Description copied from interface:IBehaviorGroup
当EntityAI
.DEBUG == true 时此方法每1gt调用一次,用于debug模式相关内容的刷新- Specified by:
debugTick
in interfaceIBehaviorGroup
-
calcActiveDelay
计算活跃实体延迟- Parameters:
entity
- 实体originalDelay
- 原始延迟- Returns:
- 如果实体是非活跃的,则延迟*4,否则返回原始延迟
-
initPeriodTimer
protected void initPeriodTimer() -
updateMoveDirection
-
addToRunningBehaviors
添加评估成功后的行为到runningBehaviors
- Parameters:
entity
- 评估的实体behaviors
- 要添加的行为
-
interruptAllRunningBehaviors
中断所有正在运行的行为 -
getCoreBehaviors
不会被其他行为覆盖的"核心“行为- Specified by:
getCoreBehaviors
in interfaceIBehaviorGroup
- Returns:
- 行为组包含的核心行为
IBehavior
-
getBehaviors
全部行为- Specified by:
getBehaviors
in interfaceIBehaviorGroup
- Returns:
- 行为组包含的行为
IBehavior
-
getSensors
传感器- Specified by:
getSensors
in interfaceIBehaviorGroup
- Returns:
- 行为组包含的传感器
ISensor
-
getControllers
控制器- Specified by:
getControllers
in interfaceIBehaviorGroup
- Returns:
- 行为组包含的控制器
IController
-
getRunningCoreBehaviors
正在运行的”核心“行为- Specified by:
getRunningCoreBehaviors
in interfaceIBehaviorGroup
- Returns:
- 被激活的核心行为
IBehavior
-
getRunningBehaviors
正在运行的行为- Specified by:
getRunningBehaviors
in interfaceIBehaviorGroup
- Returns:
- 被激活的行为
IBehavior
-
getCoreBehaviorPeriodTimer
用于存储核心行为距离上次评估逝去的gt数 -
getBehaviorPeriodTimer
用于存储行为距离上次评估逝去的gt数 -
getSensorPeriodTimer
用于存储传感器距离上次刷新逝去的gt数 -
getMemoryStorage
记忆存储器- Specified by:
getMemoryStorage
in interfaceIBehaviorGroup
- Returns:
- 行为组的记忆存储器
IMemoryStorage
-
getRouteFinder
寻路器(非异步,因为没必要,生物AI本身就是并行的)- Specified by:
getRouteFinder
in interfaceIBehaviorGroup
- Returns:
- 行为组使用的寻路器
IRouteFinder
-
getRouteFindingTask
寻路任务 -
getCurrentRouteUpdateTick
public int getCurrentRouteUpdateTick()记录距离上次路径更新过去的gt数 -
isForceUpdateRoute
public boolean isForceUpdateRoute()- Specified by:
isForceUpdateRoute
in interfaceIBehaviorGroup
- Returns:
- 下一gt是否强制更新路径
-
setRouteFindingTask
寻路任务 -
setCurrentRouteUpdateTick
public void setCurrentRouteUpdateTick(int currentRouteUpdateTick) 记录距离上次路径更新过去的gt数 -
setForceUpdateRoute
public void setForceUpdateRoute(boolean forceUpdateRoute) Description copied from interface:IBehaviorGroup
要求下一gt立即更新路径- Specified by:
setForceUpdateRoute
in interfaceIBehaviorGroup
- Parameters:
forceUpdateRoute
- 立即更新路径
-