refactor: resources

This commit is contained in:
cha0s 2024-09-17 01:25:39 -05:00
parent b137b91ced
commit c24adc47a8
100 changed files with 110 additions and 105 deletions

View File

@ -71,7 +71,6 @@ module.exports = {
'.eslintrc.cjs',
'server.js',
'vite.config.js',
'public/assets/tileset.js',
],
env: {
node: true,
@ -81,7 +80,7 @@ module.exports = {
// Assets
{
files: [
'public/assets/**/*.js',
'resources/**/*.js',
],
rules: {
'no-undef': 0,

View File

@ -44,7 +44,7 @@ export default class Alive extends Component {
}
static properties = {
deathScript: {
defaultValue: '/assets/misc/death-default.js',
defaultValue: '/resources/misc/death-default.js',
type: 'string',
},
health: {type: 'uint32'},

View File

@ -18,7 +18,7 @@ const TileLayerInternal = PixiComponent('TileLayer', {
},
applyProps: (container, {tileLayer: oldTileLayer}, props) => {
const {asset, group, renderer, tileLayer} = props;
const extless = tileLayer.source.slice('/assets/'.length, -'.json'.length);
const extless = tileLayer.source.slice('/resources/'.length, -'.json'.length);
const {textures} = asset;
if (tileLayer === oldTileLayer) {
return;

View File

@ -29,10 +29,10 @@ body {
@font-face {
font-family: "Cookbook";
src: url("/assets/fonts/Cookbook.woff");
src: url("/fonts/Cookbook.woff");
}
@font-face {
font-family: "Joystix";
src: url("/assets/fonts/Joystix.woff");
src: url("/fonts/Joystix.woff");
}

View File

@ -122,7 +122,7 @@ export default function PlaySpecific() {
// let source = true;
// async function play() {
// const ctx = new AudioContext();
// const response = await fetch(new URL('/assets/yuff.wav', window.location.origin));
// const response = await fetch(new URL('/resources/yuff.wav', window.location.origin));
// const buffer = await ctx.decodeAudioData(await response.arrayBuffer());
// if (!source) {
// return;

View File

@ -78,7 +78,7 @@ function Gen() {
),
compute: (x, y) => ({
anchor:{x: 0.5, y: 0.875},
image: '/assets/ambient/tree.png',
image: '/resources/ambient/tree.png',
x: x * 16,
y: y * 16,
}),
@ -91,7 +91,7 @@ function Gen() {
),
compute: (x, y, noise) => ({
anchor:{x: 0.5, y: 0.7},
image: '/assets/ambient/flower.png',
image: '/resources/ambient/flower.png',
x: x * 16 + (noise(x, y) * 8 - 4),
y: y * 16 + (noise(y, x) * 8 - 4),
}),
@ -104,7 +104,7 @@ function Gen() {
),
compute: (x, y, noise) => ({
anchor:{x: 0.5, y: 0.7},
image: '/assets/ambient/shrub.png',
image: '/resources/ambient/shrub.png',
x: x * 16 + (noise(x, y) * 8 - 4),
y: y * 16 + (noise(y, x) * 8 - 4),
}),
@ -117,7 +117,7 @@ function Gen() {
Math.ceil(area.x / CHUNK_SIZE) * Math.ceil(area.y / CHUNK_SIZE)
).fill(0).map(() => ({})),
data: Array(area.x * area.y).fill(1),
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
};
const tileGenerator = new Generator({

View File

@ -63,13 +63,13 @@ export default async function createForest() {
{
area,
data: Array(w * h).fill(0),
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
},
{
area,
data: Array(w * h).fill(0),
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
},
],
@ -113,7 +113,7 @@ export default async function createForest() {
Position: entityPosition(x, y),
Sprite: {
anchorY: 0.7,
source: '/assets/ambient/shrub.json',
source: '/resources/ambient/shrub.json',
},
VisibleAabb: {},
});
@ -123,7 +123,7 @@ export default async function createForest() {
Position: entityPosition(x, y),
Sprite: {
anchorY: 0.875,
source: '/assets/ambient/tree.json',
source: '/resources/ambient/tree.json',
},
VisibleAabb: {},
});
@ -134,7 +134,7 @@ export default async function createForest() {
Position: entityPosition(x, y),
Sprite: {
anchorY: 0.7,
source: '/assets/ambient/flower.json',
source: '/resources/ambient/flower.json',
},
VisibleAabb: {},
});

View File

@ -33,13 +33,13 @@ export default async function createHomestead(id) {
{
area,
data,
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
},
{
area,
data: Array(area.x * area.y).fill(0),
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
},
],
@ -68,7 +68,7 @@ export default async function createHomestead(id) {
Sprite: {
anchorX: 0.5,
anchorY: 0.8,
source: '/assets/shit-shack/shit-shack.json',
source: '/resources/shit-shack/shit-shack.json',
},
Ticking: {},
VisibleAabb: {},
@ -135,19 +135,19 @@ export default async function createHomestead(id) {
slots: {
2: {
qty: 1,
source: '/assets/watering-can/watering-can.json',
source: '/resources/watering-can/watering-can.json',
},
3: {
qty: 1,
source: '/assets/tomato-seeds/tomato-seeds.json',
source: '/resources/tomato-seeds/tomato-seeds.json',
},
4: {
qty: 1,
source: '/assets/hoe/hoe.json',
source: '/resources/hoe/hoe.json',
},
5: {
qty: 1,
source: '/assets/brush/brush.json',
source: '/resources/brush/brush.json',
},
},
},
@ -155,7 +155,7 @@ export default async function createHomestead(id) {
Sprite: {
anchorX: 0.5,
anchorY: 0.7,
source: '/assets/chest/chest.json',
source: '/resources/chest/chest.json',
},
Ticking: {},
VisibleAabb: {},
@ -166,7 +166,7 @@ export default async function createHomestead(id) {
...animalJson,
Behaving: {
routines: {
initial: '/assets/kitty/initial.js',
initial: '/resources/kitty/initial.js',
},
},
Collider: {
@ -209,7 +209,7 @@ export default async function createHomestead(id) {
...animalJson.Sprite,
anchorX: 0.5,
anchorY: 0.7,
source: '/assets/kitty/kitty.json',
source: '/resources/kitty/kitty.json',
speed: 0.115,
},
Tags: {tags: ['kittan']},
@ -220,7 +220,7 @@ export default async function createHomestead(id) {
...animalJson,
Behaving: {
routines: {
initial: '/assets/farm/animals/cow-adult/initial.js',
initial: '/resources/farm/animals/cow-adult/initial.js',
},
},
Collider: {
@ -260,7 +260,7 @@ export default async function createHomestead(id) {
...animalJson.Sprite,
anchorX: 0.5,
anchorY: 0.8,
source: '/assets/farm/animals/cow-adult/cow-adult.json',
source: '/resources/farm/animals/cow-adult/cow-adult.json',
speed: 0.25,
},
});
@ -270,7 +270,7 @@ export default async function createHomestead(id) {
...animalJson,
Behaving: {
routines: {
initial: '/assets/farm/animals/goat-white/initial.js',
initial: '/resources/farm/animals/goat-white/initial.js',
},
},
Collider: {
@ -309,7 +309,7 @@ export default async function createHomestead(id) {
...animalJson.Sprite,
anchorX: 0.5,
anchorY: 0.8,
source: '/assets/farm/animals/goat-white/goat-white.json',
source: '/resources/farm/animals/goat-white/goat-white.json',
speed: 0.25,
},
});

View File

@ -11,7 +11,7 @@ export default async function createHouse(Ecs, id) {
{
area,
data: Array(area.x * area.y).fill(0).map(() => 5 + Math.floor(Math.random() * 2)),
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
}
],

View File

@ -24,11 +24,11 @@ export default async function createPlayer(id) {
slots: {
1: {
qty: 100,
source: '/assets/potion/potion.json',
source: '/resources/potion/potion.json',
},
2: {
qty: 1,
source: '/assets/magic-swords/magic-swords.json',
source: '/resources/magic-swords/magic-swords.json',
},
},
},
@ -44,7 +44,7 @@ export default async function createPlayer(id) {
anchorY: 0.9,
animation: 'moving:down',
frame: 0,
source: '/assets/dude/dude.json',
source: '/resources/dude/dude.json',
speed: 0.115,
},
Ticking: {},

View File

@ -11,13 +11,13 @@ export default async function createTown() {
{
area,
data,
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
},
{
area,
data: Array(area.x * area.y).fill(0),
source: '/assets/tileset.json',
source: '/resources/tileset.json',
tileSize: {x: 16, y: 16},
},
],

View File

@ -1,5 +0,0 @@
{
"icon": "/assets/brush/brush.png",
"label": "Brush",
"start": "/assets/brush/start.js"
}

View File

@ -1,4 +0,0 @@
{
"icon": "/assets/furball/furball.png",
"label": "Fur Ball"
}

View File

@ -1,5 +0,0 @@
{
"icon": "/assets/magic-swords/icon.png",
"label": "Magic swords",
"start": "/assets/magic-swords/start.js"
}

View File

@ -1,5 +0,0 @@
{
"icon": "/assets/potion/icon.png",
"label": "Potion",
"start": "/assets/potion/start.js"
}

View File

@ -1,14 +0,0 @@
{
"icon": "/assets/tomato-seeds/icon.png",
"label": "Tomato Seeds",
"projection": {
"distance": [1, -1],
"grid": [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
},
"projectionCheck": "/assets/tomato-seeds/projection-check.js",
"start": "/assets/tomato-seeds/start.js"
}

View File

@ -1,3 +0,0 @@
{
"icon": "/assets/tomato/tomato.png"
}

View File

@ -1,14 +0,0 @@
{
"icon": "/assets/watering-can/icon.png",
"label": "Watering Can",
"projectionCheck": "/assets/watering-can/projection-check.js",
"projection": {
"distance": [3, -1],
"grid": [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
},
"start": "/assets/watering-can/start.js"
}

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,5 @@
{
"icon": "/resources/brush/brush.png",
"label": "Brush",
"start": "/resources/brush/start.js"
}

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -6,7 +6,7 @@ for (const entity of entities) {
Controlled.locked = 1
const [, direction] = Sprite.animation.split(':')
for (let i = 0; i < 2; ++i) {
Sound.play('/assets/brush/brush.wav');
Sound.play('/resources/brush/brush.wav');
Sprite.animation = ['moving', direction].join(':');
await wait(0.3)
Sprite.animation = ['idle', direction].join(':');
@ -14,7 +14,7 @@ for (const entity of entities) {
}
Inventory.give({
qty: 1,
source: '/assets/furball/furball.json',
source: '/resources/furball/furball.json',
});
Controlled.locked = 0;
@ -69,7 +69,7 @@ for (const entity of entities) {
{
type: 'textureSingle',
config: {
texture: '/assets/heart/heart.png',
texture: '/resources/heart/heart.png',
}
},
],

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,4 @@
{
"icon": "/resources/furball/furball.png",
"label": "Fur Ball"
}

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 570 B

View File

@ -1,7 +1,7 @@
{
"icon": "/assets/hoe/icon.png",
"icon": "/resources/hoe/icon.png",
"label": "Hoe",
"projectionCheck": "/assets/hoe/projection-check.js",
"projectionCheck": "/resources/hoe/projection-check.js",
"projection": {
"distance": [3, -1],
"grid": [
@ -10,5 +10,5 @@
[1, 1, 1]
]
},
"start": "/assets/hoe/start.js"
"start": "/resources/hoe/start.js"
}

View File

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

View File

@ -10,7 +10,7 @@ if (projected?.length > 0) {
const [, direction] = Sprite.animation.split(':')
for (let i = 0; i < 2; ++i) {
Sound.play('/assets/hoe/dig.wav');
Sound.play('/resources/hoe/dig.wav');
for (const {x, y} of projected) {
Emitter.emit({
entity: {

View File

Before

Width:  |  Height:  |  Size: 884 B

After

Width:  |  Height:  |  Size: 884 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,5 @@
{
"icon": "/resources/magic-swords/icon.png",
"label": "Magic swords",
"start": "/resources/magic-swords/start.js"
}

View File

@ -24,7 +24,7 @@ for (let i = 0; i < N; ++i) {
unstoppable: 1,
},
],
collisionStartScript: '/assets/magic-swords/collision-start.js',
collisionStartScript: '/resources/magic-swords/collision-start.js',
},
Controlled: {},
Direction: {direction: Math.TAU * (i / N)},
@ -35,7 +35,7 @@ for (let i = 0; i < N; ++i) {
Speed: {},
Sprite: {
alpha: 0,
source: '/assets/magic-swords/magic-sword-shot.json',
source: '/resources/magic-swords/magic-sword-shot.json',
},
Ticking: {},
VisibleAabb: {},

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,5 @@
{
"icon": "/resources/potion/icon.png",
"label": "Potion",
"start": "/resources/potion/start.js"
}

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 195 KiB

After

Width:  |  Height:  |  Size: 195 KiB

View File

@ -21,7 +21,7 @@ for (let i = 0; i < 10; ++i) {
'if (other.Inventory) {',
' other.Inventory.give({',
' qty: 1,',
" source: '/assets/tomato/tomato.json',",
" source: '/resources/tomato/tomato.json',",
' })',
' ecs.destroy(entity.id)',
'}',
@ -35,7 +35,7 @@ for (let i = 0; i < 10; ++i) {
anchorY: 0.5,
scaleX: 0.333,
scaleY: 0.333,
source: '/assets/tomato/tomato-sprite.json',
source: '/resources/tomato/tomato-sprite.json',
},
Ticking: {},
VisibleAabb: {},

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -22,17 +22,17 @@ if (projected?.length > 0) {
],
},
Interactive: {
interactScript: '/assets/tomato-plant/interact.js',
interactScript: '/resources/tomato-plant/interact.js',
},
Plant: {
growScript: '/assets/tomato-plant/grow.js',
mayGrowScript: '/assets/tomato-plant/may-grow.js',
growScript: '/resources/tomato-plant/grow.js',
mayGrowScript: '/resources/tomato-plant/may-grow.js',
stages: [0.5, 0.5, 0.5, 0.5, 0.5],
},
Sprite: {
anchorY: 0.75,
animation: 'stage/0',
source: '/assets/tomato-plant/tomato-plant.json',
source: '/resources/tomato-plant/tomato-plant.json',
},
Ticking: {},
VisibleAabb: {},
@ -60,7 +60,7 @@ if (projected?.length > 0) {
}
});
Sound.play('/assets/sow.wav');
Sound.play('/resources/sow.wav');
Sprite.animation = ['moving', direction].join(':');
const directionMap = {0: 'right', 1: 'down', 2: 'left', 3: 'up'};

View File

@ -0,0 +1,14 @@
{
"icon": "/resources/tomato-seeds/icon.png",
"label": "Tomato Seeds",
"projection": {
"distance": [1, -1],
"grid": [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
},
"projectionCheck": "/resources/tomato-seeds/projection-check.js",
"start": "/resources/tomato-seeds/start.js"
}

View File

@ -0,0 +1,3 @@
{
"icon": "/resources/tomato/tomato.png"
}

View File

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 570 B

View File

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 683 B

View File

@ -10,7 +10,7 @@ if (projected?.length > 0) {
const [, direction] = Sprite.animation.split(':')
Sprite.animation = ['idle', direction].join(':');
Sound.play('/assets/watering-can/water.wav');
Sound.play('/resources/watering-can/water.wav');
for (const {x, y} of projected) {
Emitter.emit({

View File

@ -0,0 +1,14 @@
{
"icon": "/resources/watering-can/icon.png",
"label": "Watering Can",
"projectionCheck": "/resources/watering-can/projection-check.js",
"projection": {
"distance": [3, -1],
"grid": [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
]
},
"start": "/resources/watering-can/start.js"
}

View File

@ -85,6 +85,12 @@ else {
);
}
// silphius resources
app.use(
'/resources',
express.static('resources', { maxAge: '1h' }),
);
// Everything else (like favicon.ico) is cached for an hour. You may want to be
// more aggressive with this caching.
app.use(express.static('build/client', { maxAge: '1h' }));

View File

@ -6,7 +6,7 @@ import Hotbar from '@/react/components/hotbar.jsx';
import DomDecorator from './dom-decorator.jsx';
const slots = Array(10).fill({});
slots[2] = {qty: 24, icon: '/assets/potion/icon.png'};
slots[2] = {qty: 24, icon: '/resources/potion/icon.png'};
export default {
title: 'Dom/Inventory/Hotbar',

View File

@ -31,7 +31,7 @@ export default {
},
},
args: {
icon: '/assets/potion/icon.png',
icon: '/resources/potion/icon.png',
},
};