refactor: normalize createMany
This commit is contained in:
parent
bbf11c0b63
commit
ee566e7c70
|
@ -25,14 +25,7 @@ export default class ArbitraryComponent extends BaseComponent {
|
|||
if (entries.length > 0) {
|
||||
const allocated = this.allocateMany(entries.length);
|
||||
for (let i = 0; i < entries.length; ++i) {
|
||||
let entity;
|
||||
let values = {};
|
||||
if (Array.isArray(entries[i])) {
|
||||
[entity, values] = entries[i];
|
||||
}
|
||||
else {
|
||||
entity = entries[i];
|
||||
}
|
||||
const [entity, values = {}] = entries[i];
|
||||
this.map[entity] = allocated[i];
|
||||
this.data[allocated[i]].entity = entity;
|
||||
for (const j in values) {
|
||||
|
|
|
@ -47,14 +47,7 @@ export default class FlatComponent extends BaseComponent {
|
|||
const window = new this.Window(this.data, this);
|
||||
const {defaultValues} = this.schema;
|
||||
for (let i = 0; i < entries.length; ++i) {
|
||||
let entity;
|
||||
let values = {};
|
||||
if (Array.isArray(entries[i])) {
|
||||
[entity, values] = entries[i];
|
||||
}
|
||||
else {
|
||||
entity = entries[i];
|
||||
}
|
||||
const [entity, values = {}] = entries[i];
|
||||
this.map[entity] = allocated[i];
|
||||
window.cursor = allocated[i] * this.constructor.width;
|
||||
window.entity = entity;
|
||||
|
|
|
@ -96,7 +96,7 @@ export default class Ecs {
|
|||
if (!creating[component]) {
|
||||
creating[component] = [];
|
||||
}
|
||||
creating[component].push(components[component] ? [entity, components[component]] : entity);
|
||||
creating[component].push([entity, components[component]]);
|
||||
}
|
||||
}
|
||||
for (const i in creating) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user