silphius/app/server/create/homestead.js

155 lines
3.5 KiB
JavaScript
Raw Normal View History

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,
data: Array(area.x * area.y).fill(0).map(() => 1 + Math.floor(Math.random() * 4)),
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
{
points: [
{x: -36, y: 8},
{x: -21, y: 8},
{x: -36, y: 17},
{x: -21, y: 17},
],
tags: ['door'],
},
{
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
],
collisionStartScript: '/assets/shit-shack/collision-start.js',
},
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-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: `
subject.Interlocutor.dialogue({
2024-07-14 02:26:43 -05:00
body: "Sure, I'm a treasure chest. Probably. Do you really think that means you're about to get some treasure? Hah!",
2024-07-13 17:08:23 -05:00
monopolizer: true,
2024-07-12 02:10:22 -05:00
origin: subject.Position.toJSON(),
position: {x: subject.Position.x, y: subject.Position.y - 32},
})
`,
},
Interlocutor: {},
Position: {x: 200, y: 200},
Sprite: {
anchorX: 0.5,
anchorY: 0.7,
source: '/assets/chest.json',
},
Ticking: {},
VisibleAabb: {},
});
2024-07-21 11:14:51 -05:00
const kitty = {
Behaving: {
routines: {
initial: '/assets/kitty/initial.js',
},
},
Collider: {
bodies: [
{
points: [
{x: -4, y: -4},
{x: 3, y: -4},
{x: 3, y: 3},
{x: -4, y: 3},
],
},
],
},
Controlled: {},
Direction: {direction: 2},
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>',
'pu<shake>rrrrr</shake>',
];
const line = lines[Math.floor(Math.random() * lines.length)];
subject.Interlocutor.dialogue({
body: line,
linger: 2,
origin: 'track',
position: {x: subject.Position.x, y: subject.Position.y - 32},
})
`,
},
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: {},
};
for (let i = 0; i < 10; ++i) {
entities.push(kitty);
}
2024-07-11 16:01:16 -05:00
return entities;
2024-07-02 20:43:55 -05:00
}