diff --git a/src/lib/client/ecs/scene/entity/component/component-manager.ts b/src/lib/client/ecs/scene/entity/component/component-manager.ts index f40514b..35ebf91 100644 --- a/src/lib/client/ecs/scene/entity/component/component-manager.ts +++ b/src/lib/client/ecs/scene/entity/component/component-manager.ts @@ -15,6 +15,8 @@ export class EntityComponentManager { public readonly entity: SceneEntityHandle; private readonly _store: Writable>>; + private readonly _storageResolvable: string; + static reset() { _storage.set({}); resetSubscriptions(_subscriptions); @@ -24,9 +26,9 @@ export class EntityComponentManager { constructor(entity: SceneEntityHandle, components: Record>) { this.entity = entity; - const storageResolvable = `${this.entity.manager.scene.id}/${this.entity.id}`; + this._storageResolvable = `${this.entity.manager.scene.id}/${this.entity.id}`; - this._store = resolveStore(_storage, storageResolvable, components); + this._store = resolveStore(_storage, this._storageResolvable, components); this._listen(); } @@ -70,10 +72,11 @@ export class EntityComponentManager { }); this._store.set(newComponents); + const fullId = `${this._storageResolvable}/${id}`; const subscriptions = get(_subscriptions); - if (subscriptions[id]) { - subscriptions[id](); - subscriptions[id] = null; + if (subscriptions[fullId]) { + subscriptions[fullId](); + subscriptions[fullId] = null; _subscriptions.set(subscriptions); } } @@ -93,9 +96,10 @@ export class EntityComponentManager { private _subscribe(id: string, handle: EntityComponentHandle) { setTimeout(() => { + const fullId = `${this._storageResolvable}/${id}`; const subscriptions = get(_subscriptions); - if (subscriptions[id]) return; - subscriptions[id] = handle.params.values.subscribe((params) => this._update(id, params)); + if (subscriptions[fullId]) return; + subscriptions[fullId] = handle.params.values.subscribe((params) => this._update(id, params)); _subscriptions.set(subscriptions); }, 0); } diff --git a/src/lib/client/ecs/scene/entity/component/component-param-manager.ts b/src/lib/client/ecs/scene/entity/component/component-param-manager.ts index 47b8adc..89e9fc8 100644 --- a/src/lib/client/ecs/scene/entity/component/component-param-manager.ts +++ b/src/lib/client/ecs/scene/entity/component/component-param-manager.ts @@ -18,6 +18,8 @@ export class ComponentParamManager { private readonly _store: Writable; private readonly _valuesStore: Writable>; + private readonly _storageResolvable: string; + static reset() { _storage.set({}); _valueStorage.set({}); @@ -28,10 +30,10 @@ export class ComponentParamManager { constructor(component: EntityComponentHandle, params: Record) { this.component = component; - const storageResolvable = `${this.component.manager.entity.manager.scene.id}/${this.component.manager.entity.id}/${this.component.id}`; + this._storageResolvable = `${this.component.manager.entity.manager.scene.id}/${this.component.manager.entity.id}/${this.component.id}`; - this._store = resolveStore(_storage, storageResolvable, get(component.store).params); - this._valuesStore = resolveStore(_valueStorage, storageResolvable, params); + this._store = resolveStore(_storage, this._storageResolvable, get(component.store).params); + this._valuesStore = resolveStore(_valueStorage, this._storageResolvable, params); this._listen(); } @@ -62,10 +64,11 @@ export class ComponentParamManager { params.map((param) => (param.name === id ? { ...param, value: undefined } : param)), ); + const fullId = `${this._storageResolvable}/${id}`; const subscriptions = get(_subscriptions); - if (subscriptions[id]) { - subscriptions[id](); - subscriptions[id] = null; + if (subscriptions[fullId]) { + subscriptions[fullId](); + subscriptions[fullId] = null; _subscriptions.set(subscriptions); } } @@ -80,9 +83,10 @@ export class ComponentParamManager { private _subscribe(id: string, handle: ComponentParamHandle) { setTimeout(() => { + const fullId = `${this._storageResolvable}/${id}`; const subscriptions = get(_subscriptions); - if (subscriptions[id]) return; - subscriptions[id] = handle.value.subscribe((param) => this._update(id, param)); + if (subscriptions[fullId]) return; + subscriptions[fullId] = handle.value.subscribe((param) => this._update(id, param)); _subscriptions.set(subscriptions); }, 0); } diff --git a/src/lib/client/ecs/scene/entity/entity-manager.ts b/src/lib/client/ecs/scene/entity/entity-manager.ts index 7c2238d..527f046 100644 --- a/src/lib/client/ecs/scene/entity/entity-manager.ts +++ b/src/lib/client/ecs/scene/entity/entity-manager.ts @@ -69,10 +69,11 @@ export class SceneEntityManager { const entities = get(this._store); this._store.set(entities.filter((entity) => entity.id !== id)); + const fullId = `${this.scene.id}/${id}`; const subscriptions = get(_subscriptions); - if (subscriptions[id]) { - subscriptions[id](); - subscriptions[id] = null; + if (subscriptions[fullId]) { + subscriptions[fullId](); + subscriptions[fullId] = null; _subscriptions.set(subscriptions); } @@ -83,9 +84,10 @@ export class SceneEntityManager { private _subscribe(id: string, handle: SceneEntityHandle) { setTimeout(() => { + const fullId = `${this.scene.id}/${id}`; const subscriptions = get(_subscriptions); - if (subscriptions[id]) return; - subscriptions[id] = handle.store.subscribe((entity) => this._update(id, entity)); + if (subscriptions[fullId]) return; + subscriptions[fullId] = handle.store.subscribe((entity) => this._update(id, entity)); _subscriptions.set(subscriptions); }, 0); } diff --git a/src/lib/components/Widget/content-browser/content-item.svelte b/src/lib/components/Widget/content-browser/content-item.svelte index 56bb25c..eb82f1b 100644 --- a/src/lib/components/Widget/content-browser/content-item.svelte +++ b/src/lib/components/Widget/content-browser/content-item.svelte @@ -1,32 +1,18 @@ { + const [type] = FILE_TYPES.find(([, exts]) => exts.includes(name.split('.').pop()!)) ?? [ + 'unknown', + ]; + return type; +};