refactor: creators manage teleport id
This commit is contained in:
parent
af571e25af
commit
3f580c47c1
|
@ -1,6 +1,6 @@
|
||||||
import createEcs from './create-ecs.js';
|
import createEcs from './create-ecs.js';
|
||||||
|
|
||||||
export default async function createHomestead(Ecs) {
|
export default async function createHomestead(Ecs, id) {
|
||||||
const ecs = createEcs(Ecs);
|
const ecs = createEcs(Ecs);
|
||||||
const area = {x: 100, y: 60};
|
const area = {x: 100, y: 60};
|
||||||
await ecs.create({
|
await ecs.create({
|
||||||
|
@ -49,7 +49,9 @@ export default async function createHomestead(Ecs) {
|
||||||
],
|
],
|
||||||
collisionStartScript: '/assets/shit-shack/collision-start.js',
|
collisionStartScript: '/assets/shit-shack/collision-start.js',
|
||||||
},
|
},
|
||||||
Ecs: {},
|
Ecs: {
|
||||||
|
path: ['houses', `${id}`].join('/'),
|
||||||
|
},
|
||||||
Position: {x: 100, y: 100},
|
Position: {x: 100, y: 100},
|
||||||
Sprite: {
|
Sprite: {
|
||||||
anchorX: 0.5,
|
anchorX: 0.5,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import createEcs from './create-ecs.js';
|
import createEcs from './create-ecs.js';
|
||||||
|
|
||||||
export default async function createHouse(Ecs) {
|
export default async function createHouse(Ecs, id) {
|
||||||
const ecs = createEcs(Ecs);
|
const ecs = createEcs(Ecs);
|
||||||
const area = {x: 20, y: 20};
|
const area = {x: 20, y: 20};
|
||||||
await ecs.create({
|
await ecs.create({
|
||||||
|
@ -31,7 +31,9 @@ export default async function createHouse(Ecs) {
|
||||||
],
|
],
|
||||||
collisionStartScript: '/assets/house/collision-start.js',
|
collisionStartScript: '/assets/house/collision-start.js',
|
||||||
},
|
},
|
||||||
Ecs: {},
|
Ecs: {
|
||||||
|
path: ['homesteads', `${id}`].join('/'),
|
||||||
|
},
|
||||||
Position: {
|
Position: {
|
||||||
x: 72,
|
x: 72,
|
||||||
y: 320,
|
y: 320,
|
||||||
|
|
|
@ -215,14 +215,12 @@ export default class Engine {
|
||||||
if ('ENOENT' !== error.code) {
|
if ('ENOENT' !== error.code) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
const homestead = await createHomestead(this.Ecs);
|
const homestead = await createHomestead(this.Ecs, id);
|
||||||
homestead.get(2).Ecs.path = ['houses', `${id}`].join('/');
|
|
||||||
await this.saveEcs(
|
await this.saveEcs(
|
||||||
['homesteads', `${id}`].join('/'),
|
['homesteads', `${id}`].join('/'),
|
||||||
homestead,
|
homestead,
|
||||||
);
|
);
|
||||||
const house = await createHouse(this.Ecs);
|
const house = await createHouse(this.Ecs, id);
|
||||||
house.get(2).Ecs.path = ['homesteads', `${id}`].join('/');
|
|
||||||
await this.saveEcs(
|
await this.saveEcs(
|
||||||
['houses', `${id}`].join('/'),
|
['houses', `${id}`].join('/'),
|
||||||
house,
|
house,
|
||||||
|
|
|
@ -98,7 +98,7 @@ if (import.meta.hot) {
|
||||||
await beforeResolver;
|
await beforeResolver;
|
||||||
// delete engine.ecses['homesteads/0'];
|
// delete engine.ecses['homesteads/0'];
|
||||||
// await engine.server.removeData('homesteads/0');
|
// await engine.server.removeData('homesteads/0');
|
||||||
// const homestead = await createHomestead(engine.Ecs);
|
// const homestead = await createHomestead(engine.Ecs, '0');
|
||||||
// homestead.get(2).Ecs.path = 'houses/0';
|
// homestead.get(2).Ecs.path = 'houses/0';
|
||||||
// await engine.saveEcs('homesteads/0', homestead);
|
// await engine.saveEcs('homesteads/0', homestead);
|
||||||
resolver.resolve();
|
resolver.resolve();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user