feat: findEntity
This commit is contained in:
parent
e42726f1ff
commit
a4d10904af
|
@ -71,12 +71,13 @@ export class EntityList extends decorate(class {}) {
|
|||
}
|
||||
}
|
||||
|
||||
entity(uuid) {
|
||||
return this.entities_PRIVATE[uuid];
|
||||
}
|
||||
|
||||
mappedUuid(uuid) {
|
||||
return this.uuidMap_PRIVATE[uuid];
|
||||
findEntity(uuid) {
|
||||
if (this.uuidMap_PRIVATE[uuid]) {
|
||||
return this.entities_PRIVATE[this.uuidMap_PRIVATE[uuid]];
|
||||
}
|
||||
if (this.entities_PRIVATE[uuid]) {
|
||||
return this.entities_PRIVATE[uuid];
|
||||
}
|
||||
}
|
||||
|
||||
get quadTree() {
|
||||
|
|
|
@ -48,6 +48,10 @@ export class Layer extends decorate(class {}) {
|
|||
this.entityList.off('entityRemoved', this.onEntityRemovedFromLayer);
|
||||
}
|
||||
|
||||
findEntity(uuid) {
|
||||
return this.entityList.findEntity(uuid);
|
||||
}
|
||||
|
||||
fromJSON(json) {
|
||||
if (json.entities) {
|
||||
json.entities.forEach((entityJSON) => {
|
||||
|
|
|
@ -58,6 +58,16 @@ export class Layers extends decorate(class {}) {
|
|||
}
|
||||
}
|
||||
|
||||
findEntity(uuid) {
|
||||
for (const index in this.layers) {
|
||||
const layer = this.layers[index];
|
||||
const foundEntity = layer.findEntity(uuid);
|
||||
if (foundEntity) {
|
||||
return foundEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fromJSON(json) {
|
||||
if (json) {
|
||||
for (const index in json) {
|
||||
|
|
|
@ -44,6 +44,10 @@ export class Room extends decorate(class {}) {
|
|||
this.off('worldChanged', this.onWorldChanged);
|
||||
}
|
||||
|
||||
findEntity(uuid) {
|
||||
return this.layers.findEntity(uuid);
|
||||
}
|
||||
|
||||
fromJSON(json) {
|
||||
if (json.layers) {
|
||||
this.layers.fromJSON(json.layers);
|
||||
|
|
Loading…
Reference in New Issue
Block a user