import data from '../../../public/assets/dev/homestead.json'; export default async function createHomestead(id) { const area = {x: 100, y: 60}; const entities = []; entities.push({ AreaSize: {x: area.x * 16, y: area.y * 16}, Ticking: {}, TileLayers: { layers: [ { area, data, source: '/assets/tileset.json', tileSize: {x: 16, y: 16}, }, { area, data: Array(area.x * area.y).fill(0), source: '/assets/tileset.json', tileSize: {x: 16, y: 16}, }, ], }, Time: {}, Water: {water: {}}, }); entities.push({ Collider: { bodies: [ { impassable: 1, points: [ {x: -52, y: -16}, {x: 44, y: -16}, {x: -52, y: 15}, {x: 44, y: 15}, ], }, ], }, Ecs: { path: ['houses', `${id}`].join('/'), }, Position: {x: 100, y: 100}, Sprite: { anchorX: 0.5, anchorY: 0.8, source: '/assets/shit-shack/shit-shack.json', }, Ticking: {}, VisibleAabb: {}, }); entities.push({ Collider: { bodies: [ { points: [ {x: -8, y: -5}, {x: 8, y: -5}, {x: 8, y: 5}, {x: -8, y: 5}, ], }, ], collisionStartScript: ` if (other.Player) { ecs.switchEcs( other, 'houses/${id}', { Position: { x: 72, y: 304, }, }, ); } `, }, Position: {x: 71, y: 113}, Ticking: {}, }); entities.push({ Collider: { bodies: [ { impassable: 1, points: [ {x: -11, y: -7}, {x: 10, y: -7}, {x: 10, y: 5}, {x: -11, y: 5}, ], }, ], }, Interactive: { interacting: 1, interactScript: ` initiator.Player.openInventory = subject.Inventory; // subject.Interlocutor.dialogue({ // body: "Sure, I'm a treasure chest. Probably. Do you really think that means you're about to get some treasure? Hah!", // monopolizer: true, // offset: {x: 0, y: -48}, // origin: 'track', // position: 'track', // }) `, }, Interlocutor: {}, Inventory: { slots: { 2: { qty: 1, source: '/assets/watering-can/watering-can.json', }, 3: { qty: 1, source: '/assets/tomato-seeds/tomato-seeds.json', }, 4: { qty: 1, source: '/assets/hoe/hoe.json', }, 5: { qty: 1, source: '/assets/brush/brush.json', }, }, }, Position: {x: 200, y: 200}, Sprite: { anchorX: 0.5, anchorY: 0.7, source: '/assets/chest/chest.json', }, Ticking: {}, VisibleAabb: {}, }); const kitty = { Alive: {health: 100}, Behaving: { routines: { initial: '/assets/kitty/initial.js', }, }, Collider: { bodies: [ { points: [ {x: -3.5, y: -3.5}, {x: 3.5, y: -3.5}, {x: 3.5, y: 3.5}, {x: -3.5, y: 3.5}, ], }, ], }, Controlled: {}, Direction: {}, Emitter: {}, Forces: {}, Interactive: { interacting: 1, interactScript: ` const lines = [ 'mrowwr', 'prrrowwwww', 'mew mew!', 'mewwwww', '\\\\*purrrrr\\\\*', ]; const line = lines[Math.floor(Math.random() * lines.length)]; subject.Interlocutor.dialogue({ body: line, linger: 2, offset: {x: 0, y: -32}, origin: 'track', position: 'track', }) `, }, Interlocutor: {}, Position: {x: 250, y: 250}, Speed: {speed: 20}, Sprite: { anchorX: 0.5, anchorY: 0.7, source: '/assets/kitty/kitty.json', speed: 0.115, }, Tags: {tags: ['kittan']}, Ticking: {}, VisibleAabb: {}, Vulnerable: {}, }; for (let i = 0; i < 10; ++i) { entities.push(kitty); } entities.push({ Collider: { bodies: [ { points: [ {x: -8, y: -16}, {x: 7, y: -16}, {x: 7, y: 15}, {x: -8, y: 15}, ], }, ], collisionStartScript: ` if (other.Player) { ecs.switchEcs( other, 'town', { Position: { x: 940, y: 480, }, }, ); } `, }, Position: {x: 8, y: 432}, Ticking: {}, }); return entities; }