refactor: consolidate
This commit is contained in:
parent
14add7e8bb
commit
917465a35f
|
@ -48,8 +48,7 @@ export default function Entities({monopolizers, particleWorker}) {
|
|||
entities.current[id].setMainEntity();
|
||||
}
|
||||
}
|
||||
entities.current[id].update(payload[id]);
|
||||
entities.current[id].addToContainer(containerRef.current);
|
||||
entities.current[id].update(payload[id], containerRef.current);
|
||||
}
|
||||
}, [debug, ecs, mainEntity])
|
||||
useEffect(() => {
|
||||
|
|
|
@ -28,14 +28,6 @@ export default class Entity {
|
|||
this.debug.addChild(this.colliderAabb);
|
||||
this.debug.addChild(this.visibleAabb);
|
||||
}
|
||||
addToContainer(container) {
|
||||
if (this.attached || !container) {
|
||||
return;
|
||||
}
|
||||
container.addChild(this.container);
|
||||
container.addChild(this.debug);
|
||||
this.attached = true;
|
||||
}
|
||||
static async loadAsset(source = '') {
|
||||
if (!this.assets['']) {
|
||||
const {Texture} = await import('@pixi/core');
|
||||
|
@ -98,7 +90,7 @@ export default class Entity {
|
|||
}
|
||||
return texture;
|
||||
}
|
||||
update({Direction, Light, Position, Sprite, VisibleAabb}) {
|
||||
update({Direction, Light, Position, Sprite, VisibleAabb}, container) {
|
||||
if (Light) {
|
||||
if (!this.light) {
|
||||
this.light = new PointLight(
|
||||
|
@ -190,5 +182,11 @@ export default class Entity {
|
|||
if (this.isMainEntity) {
|
||||
this.interactionAabb.redraw(this.entity.Interacts.aabb());
|
||||
}
|
||||
if (this.attached || !container) {
|
||||
return;
|
||||
}
|
||||
container.addChild(this.container);
|
||||
container.addChild(this.debug);
|
||||
this.attached = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user