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

在SteeringBehavior对象之间建立引用关系。

语法

SteeringBehavior.resolveReferences(entity, world)

参数

  • entity:一个实体(具有SteeringBehavior对象的)。
  • world:一个世界(包含entity)。

描述

resolveReferences函数将遍历SteeringBehavior对象的属性,检查其中是否有对其他实体的引用。如果有,它将在world中查找该实体并将其设置为引用。如果实体不存在,则将创建一个新实体并将其添加到世界中。

示例

//创建实体和SteeringBehavior
var entity = new Entity();
var steeringBehavior = new SteeringBehavior();

//设置SteeringBehavior的属性
steeringBehavior.target = "player"; //目标实体的名称

//将SteeringBehavior附加到实体上
entity.steeringBehavior = steeringBehavior;

//创建一个新的世界并添加实体
var world = new World();
world.addEntity(entity);

//解析实体和SteeringBehavior之间的引用,并将任何新实体添加到世界中
SteeringBehavior.resolveReferences(entity, world);

备注

resolveReferences函数将只处理直接引用其他实体的属性。如果属性引用了一个嵌套对象,它将不会被处理。