Skip to content

Home > @esengine/ecs-framework-monorepo > EntityList

EntityList class

高性能实体列表管理器 管理场景中的所有实体,支持快速查找和批量操作

Signature:

typescript
export declare class EntityList

Constructors

Constructor

Modifiers

Description

(constructor)(scene)

Constructs a new instance of the EntityList class

Properties

Property

Modifiers

Type

Description

buffer

Entity[]

count

readonly

number

Methods

Method

Modifiers

Description

add(entity)

添加实体(立即添加或延迟添加)

findEntitiesByName(name)

根据名称查找所有实体

findEntitiesByTag(tag)

根据标签查找实体

findEntitiesWithComponent(componentType)

根据组件类型查找实体

findEntity(name)

根据名称查找实体(使用索引,O(1)复杂度)

findEntityById(id)

根据ID查找实体(使用索引,O(1)复杂度)

forEach(action)

批量操作:对所有实体执行指定操作

forEachWhere(predicate, action)

批量操作:对符合条件的实体执行指定操作

getStats()

获取实体列表的统计信息

remove(entity)

移除实体(立即移除或延迟移除)

removeAllEntities()

移除所有实体

update()

更新所有实体

updateLists()

更新实体列表,处理延迟操作

基于 MIT 许可证发布