AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

manager

manager是Yuka js库中Trigger的管理器。它可以注册、删除、触发Trigger,以及检索与entity相关的Trigger

注册Trigger

可以通过调用registerTrigger()方法注册Trigger。该方法接收两个参数,第一个参数为entity,第二个参数为Trigger实例。

以下是一个例子:

import { Entity, Trigger, manager } from 'yuka';

const entity = new Entity();
const trigger = new Trigger();

manager.registerTrigger( entity, trigger );

删除Trigger

可以通过调用unregisterTrigger()方法删除已注册的Trigger。该方法接收一个参数,即要删除的Trigger实例。

以下是一个例子:

manager.unregisterTrigger( trigger );

触发Trigger

可以通过调用trigger()方法触发Trigger。该方法接收一个参数,即TriggerEvent实例。

以下是一个例子:

import { TriggerEvent, manager } from 'yuka';

const triggerEvent = new TriggerEvent( entity );
manager.trigger( triggerEvent );

检索相关的Trigger

可以通过调用getTriggersByEntity()方法检索与entity相关的Trigger。该方法接收一个参数,即entity实例。

以下是一个例子:

const triggers = manager.getTriggersByEntity( entity );