refactor: entity $$extends
This commit is contained in:
parent
34247e00db
commit
739a3e4f95
|
@ -204,8 +204,23 @@ export default class Ecs {
|
|||
return entityIds;
|
||||
}
|
||||
const creating = {};
|
||||
const extendedSpecificsList = [];
|
||||
for (let i = 0; i < specificsList.length; i++) {
|
||||
const [entityId, components] = specificsList[i];
|
||||
const [entityId, rawComponents] = specificsList[i];
|
||||
let {
|
||||
$$extends,
|
||||
...components
|
||||
} = rawComponents;
|
||||
if ($$extends) {
|
||||
components = {
|
||||
...this.readJson($$extends),
|
||||
...components,
|
||||
};
|
||||
}
|
||||
extendedSpecificsList.push([entityId, components]);
|
||||
}
|
||||
for (let i = 0; i < extendedSpecificsList.length; i++) {
|
||||
const [entityId, components] = extendedSpecificsList[i];
|
||||
if (!this.$$detached.has(entityId)) {
|
||||
this.deferredChanges[entityId] = [];
|
||||
}
|
||||
|
@ -227,8 +242,8 @@ export default class Ecs {
|
|||
for (const i in creating) {
|
||||
this.Components[i].createMany(creating[i])
|
||||
}
|
||||
for (let i = 0; i < specificsList.length; i++) {
|
||||
const [entityId, components] = specificsList[i];
|
||||
for (let i = 0; i < extendedSpecificsList.length; i++) {
|
||||
const [entityId, components] = extendedSpecificsList[i];
|
||||
this.rebuild(entityId, () => Object.keys(components));
|
||||
if (this.$$detached.has(entityId)) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue
Block a user