2024-07-20 04:19:39 -05:00
|
|
|
import createEcs from './ecs.js';
|
2024-07-02 22:42:56 -05:00
|
|
|
|
2024-07-09 15:05:23 -05:00
|
|
|
export default async function createHouse(Ecs, id) {
|
2024-07-02 22:42:56 -05:00
|
|
|
const ecs = createEcs(Ecs);
|
|
|
|
const area = {x: 20, y: 20};
|
|
|
|
await ecs.create({
|
|
|
|
AreaSize: {x: area.x * 16, y: area.y * 16},
|
|
|
|
Ticking: {},
|
|
|
|
TileLayers: {
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
area,
|
|
|
|
data: Array(area.x * area.y).fill(0).map(() => 5 + Math.floor(Math.random() * 2)),
|
|
|
|
source: '/assets/tileset.json',
|
|
|
|
tileSize: {x: 16, y: 16},
|
|
|
|
}
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
2024-07-03 11:17:36 -05:00
|
|
|
await ecs.create({
|
|
|
|
Collider: {
|
|
|
|
bodies: [
|
2024-07-03 16:13:14 -05:00
|
|
|
{
|
|
|
|
points: [
|
|
|
|
{x: -8, y: -8},
|
|
|
|
{x: 7, y: -8},
|
|
|
|
{x: 7, y: 7},
|
|
|
|
{x: -8, y: 7},
|
|
|
|
],
|
|
|
|
},
|
2024-07-03 11:17:36 -05:00
|
|
|
],
|
2024-07-26 02:20:12 -05:00
|
|
|
collisionStartScript: `
|
|
|
|
if (other.Player) {
|
|
|
|
ecs.switchEcs(
|
|
|
|
other,
|
|
|
|
'homesteads/${id}',
|
|
|
|
{
|
|
|
|
Position: {
|
|
|
|
x: 74,
|
|
|
|
y: 128,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
`,
|
2024-07-09 15:05:23 -05:00
|
|
|
},
|
2024-07-03 11:17:36 -05:00
|
|
|
Position: {
|
|
|
|
x: 72,
|
|
|
|
y: 320,
|
|
|
|
},
|
2024-07-04 15:17:33 -05:00
|
|
|
Ticking: {},
|
2024-07-03 11:17:36 -05:00
|
|
|
});
|
2024-07-02 22:42:56 -05:00
|
|
|
return ecs;
|
|
|
|
}
|