silphius/app/server/create/homestead.js

188 lines
4.0 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
{
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-22 04:19:29 -05:00
offset: {x: 0, y: -48},
origin: 'track',
position: 'track',
2024-07-12 02:10:22 -05:00
})
`,
},
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>',
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-22 07:55:05 -05:00
for (let i = 0; i < 30; ++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: `
ecs.switchEcs(
other,
2024-07-23 17:04:17 -05:00
'town',
2024-07-23 15:06:32 -05:00
{
Position: {
2024-07-23 17:04:17 -05:00
x: 940,
y: 480,
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
}