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

updateEntity

该方法用于更新实体对象的属性。

entityManager.updateEntity(entity: Entity, updateObj: UpdateObject): Entity

参数说明

  • entity: Entity类型,欲更新属性的实体对象
  • updateObj: UpdateObject类型,待更新的属性信息,以键值对形式表示

返回值说明

  • 返回值: Entity类型,更新后的实体对象。

方法功能

该方法将实体对象的指定属性更新为给定的值。

使用示例

以下示例演示如何使用updateEntity方法更新实体对象的属性:

// 创建一个实体对象
const entity = new Entity('1', 'person', { name: 'Tom', age: 18, gender: 'male' });

// 调用updateEntity更新实体对象的属性
entityManager.updateEntity(entity, { age: 19, gender: 'female' });

// 输出更新后实体对象的属性
console.log(entity.getProperties());  // { name: 'Tom', age: 19, gender: 'female' }

在上述示例中,我们首先创建了一个实体对象并打印其属性。然后我们调用updateEntity方法更新实体对象的属性,并再次打印属性。可以看到实体对象的年龄和性别属性已被更新。