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

resolveReferences

介绍

resolveReferences是Yuka js库的MemorySystem中负责解析引用的函数。在实体之间存在引用关系时,需要使用该函数解析出引用实体的实际对象。

函数定义

resolveReferences(referenceMap: Map<string, Entity>): void

参数说明

  • referenceMap: Map类型,包含所有引用实体的键值对,键为引用实体的ID,值为引用实体的名称。

使用示例

const memorySystem = new MemorySystem();
const entityA = new Entity();
const entityB = new Entity();
const entityIdA = 'entityA';
const entityIdB = 'entityB';
entityA.name = 'A';
entityB.name = 'B';
memorySystem.entities.set(entityIdA, entityA);
memorySystem.entities.set(entityIdB, entityB);
entityA.add(entityB);
entityB.add(entityA);
const referenceMap = new Map();
referenceMap.set(entityIdA, 'entityA');
referenceMap.set(entityIdB, 'entityB');
memorySystem.resolveReferences(referenceMap);

通过以上代码,memorySystem会正确解析出entityA和entityB的引用关系。