* 将实体添加到各种索引中
(entity: Entity)
| 254 | * 将实体添加到各种索引中 |
| 255 | */ |
| 256 | private addEntityToIndexes(entity: Entity): void { |
| 257 | // 标签索引 |
| 258 | const tag = entity.tag; |
| 259 | if (tag !== undefined) { |
| 260 | const tagSet = this._entityIndex.byTag.get(tag) || this.createAndSetTagIndex(tag); |
| 261 | tagSet.add(entity); |
| 262 | } |
| 263 | |
| 264 | // 名称索引 |
| 265 | const name = entity.name; |
| 266 | if (name) { |
| 267 | const nameSet = this._entityIndex.byName.get(name) || this.createAndSetNameIndex(name); |
| 268 | nameSet.add(entity); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | private createAndSetTagIndex(tag: number): Set<Entity> { |
| 273 | const set = new Set<Entity>(); |
no test coverage detected