silphius/app/server/create/homestead.js

234 lines
4.9 KiB
JavaScript
Raw Normal View History

2024-07-23 15:06:32 -05:00
import data from '../../../public/assets/dev/homestead.json';
2024-07-11 16:01:16 -05:00
export default async function createHomestead(id) {
2024-07-02 20:43:55 -05:00
const area = {x: 100, y: 60};
2024-07-11 16:01:16 -05:00
const entities = [];
entities.push({
2024-07-02 20:43:55 -05:00
AreaSize: {x: area.x * 16, y: area.y * 16},
2024-07-02 22:42:56 -05:00
Ticking: {},
2024-07-02 20:43:55 -05:00
TileLayers: {
layers: [
{
area,
2024-07-23 15:06:32 -05:00
data,
2024-07-02 20:43:55 -05:00
source: '/assets/tileset.json',
tileSize: {x: 16, y: 16},
2024-07-07 17:32:54 -05:00
},
{
area,
data: Array(area.x * area.y).fill(0),
source: '/assets/tileset.json',
tileSize: {x: 16, y: 16},
},
2024-07-02 20:43:55 -05:00
],
},
2024-07-04 15:17:33 -05:00
Time: {},
2024-07-02 20:43:55 -05:00
Water: {water: {}},
});
2024-07-11 16:01:16 -05:00
entities.push({
2024-07-02 22:42:56 -05:00
Collider: {
bodies: [
2024-07-03 16:13:14 -05:00
{
impassable: 1,
points: [
{x: -52, y: -16},
2024-07-04 21:47:14 -05:00
{x: 44, y: -16},
2024-07-03 16:13:14 -05:00
{x: -52, y: 15},
2024-07-04 21:47:14 -05:00
{x: 44, y: 15},
2024-07-03 16:13:14 -05:00
],
},
2024-07-02 22:42:56 -05:00
],
},
2024-07-09 15:05:23 -05:00
Ecs: {
path: ['houses', `${id}`].join('/'),
},
2024-07-02 20:43:55 -05:00
Position: {x: 100, y: 100},
Sprite: {
2024-07-03 21:56:55 -05:00
anchorX: 0.5,
anchorY: 0.8,
2024-07-02 20:43:55 -05:00
source: '/assets/shit-shack/shit-shack.json',
},
2024-07-04 15:17:33 -05:00
Ticking: {},
2024-07-02 20:43:55 -05:00
VisibleAabb: {},
});
2024-07-26 02:20:12 -05:00
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: {},
});
2024-07-12 02:10:22 -05:00
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: `
2024-07-28 18:42:28 -05:00
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',
// })
2024-07-12 02:10:22 -05:00
`,
},
Interlocutor: {},
2024-07-25 00:37:50 -05:00
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',
},
},
},
2024-07-12 02:10:22 -05:00
Position: {x: 200, y: 200},
Sprite: {
anchorX: 0.5,
anchorY: 0.7,
2024-07-28 18:42:28 -05:00
source: '/assets/chest/chest.json',
2024-07-12 02:10:22 -05:00
},
Ticking: {},
VisibleAabb: {},
});
2024-07-21 11:14:51 -05:00
const kitty = {
2024-07-27 12:31:52 -05:00
Alive: {health: 100},
2024-07-21 11:14:51 -05:00
Behaving: {
routines: {
initial: '/assets/kitty/initial.js',
},
},
Collider: {
bodies: [
{
points: [
2024-07-25 16:39:05 -05:00
{x: -3.5, y: -3.5},
{x: 3.5, y: -3.5},
{x: 3.5, y: 3.5},
{x: -3.5, y: 3.5},
2024-07-21 11:14:51 -05:00
],
},
],
},
Controlled: {},
2024-07-24 09:28:35 -05:00
Direction: {},
2024-07-24 01:40:10 -05:00
Emitter: {},
2024-07-21 11:14:51 -05:00
Forces: {},
2024-07-22 03:55:49 -05:00
Interactive: {
interacting: 1,
interactScript: `
const lines = [
'mrowwr',
'p<shake>rrr</shake>o<wave>wwwww</wave>',
'mew<rate frequency={0.5}> </rate>mew!',
'me<wave>wwwww</wave>',
2024-07-22 07:55:05 -05:00
'\\\\*pu<shake>rrrrr</shake>\\\\*',
2024-07-22 03:55:49 -05:00
];
const line = lines[Math.floor(Math.random() * lines.length)];
subject.Interlocutor.dialogue({
body: line,
linger: 2,
2024-07-22 04:19:29 -05:00
offset: {x: 0, y: -32},
2024-07-22 03:55:49 -05:00
origin: 'track',
2024-07-22 04:19:29 -05:00
position: 'track',
2024-07-22 03:55:49 -05:00
})
`,
},
Interlocutor: {},
2024-07-21 11:14:51 -05:00
Position: {x: 250, y: 250},
Speed: {speed: 20},
Sprite: {
anchorX: 0.5,
anchorY: 0.7,
source: '/assets/kitty/kitty.json',
speed: 0.115,
},
2024-07-22 03:18:02 -05:00
Tags: {tags: ['kittan']},
2024-07-21 11:14:51 -05:00
Ticking: {},
VisibleAabb: {},
2024-07-26 10:36:59 -05:00
Vulnerable: {},
2024-07-21 11:14:51 -05:00
};
2024-07-26 10:36:59 -05:00
for (let i = 0; i < 10; ++i) {
2024-07-21 11:14:51 -05:00
entities.push(kitty);
}
2024-07-23 15:06:32 -05:00
entities.push({
Collider: {
bodies: [
{
points: [
{x: -8, y: -16},
{x: 7, y: -16},
{x: 7, y: 15},
{x: -8, y: 15},
],
},
],
collisionStartScript: `
2024-07-24 01:50:33 -05:00
if (other.Player) {
ecs.switchEcs(
other,
'town',
{
Position: {
x: 940,
y: 480,
},
2024-07-23 15:06:32 -05:00
},
2024-07-24 01:50:33 -05:00
);
}
2024-07-23 15:06:32 -05:00
`,
},
2024-07-23 17:04:17 -05:00
2024-07-23 15:06:32 -05:00
Position: {x: 8, y: 432},
Ticking: {},
});
2024-07-11 16:01:16 -05:00
return entities;
2024-07-02 20:43:55 -05:00
}