refactor: silphius app structure
This commit is contained in:
parent
4eef129c53
commit
9494e0b901
|
@ -1,3 +0,0 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
|
||||
export default class Grabber extends Component {}
|
|
@ -1,3 +0,0 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
|
||||
export default class Shop extends Component {}
|
|
@ -14,7 +14,7 @@ import { renderToPipeableStream } from "react-dom/server";
|
|||
const ABORT_DELAY = 5_000;
|
||||
|
||||
export async function handleUpgrade(request, socket, head) {
|
||||
const {handleUpgrade} = await import('./server/websocket.js');
|
||||
const {handleUpgrade} = await import('./silphius/server/websocket.js');
|
||||
handleUpgrade(request, socket, head);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {expect, test} from 'vitest';
|
||||
|
||||
import Components from '@/ecs/components/index.js';
|
||||
import Ecs from '@/ecs/ecs.js';
|
||||
import Components from '@/silphius/ecs/components/index.js';
|
||||
import Ecs from '@/silphius/ecs/ecs.js';
|
||||
|
||||
import {Emitter} from './particles.js';
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import Packet from '@/net/packet.js';
|
||||
|
||||
export default class Tick extends Packet {}
|
|
@ -1,4 +1,4 @@
|
|||
import Ecs from '@/ecs/ecs.js';
|
||||
import Ecs from '@/silphius/ecs/ecs.js';
|
||||
import {readAsset} from '@/lib/resources.js';
|
||||
|
||||
export default class ClientEcs extends Ecs {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {memo, useCallback, useRef} from 'react';
|
||||
|
||||
import {DamageTypes} from '@/ecs/components/vulnerable.js';
|
||||
import {DamageTypes} from '@/silphius/ecs/components/vulnerable.js';
|
||||
import {useEcsTick} from '@/react/context/ecs.js';
|
||||
import useAnimationFrame from '@/react/hooks/use-animation-frame.js';
|
||||
import {easeInOutExpo, easeInQuint, easeOutQuad, linear} from '@/lib/easing.js';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Emitter} from '@/lib/particles.js';
|
||||
import createEcs from '@/server/create/ecs.js';
|
||||
import createEcs from '@/silphius/server/create/ecs.js';
|
||||
|
||||
import ClientEcs from './client-ecs.js';
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ export default function PlaySpecific() {
|
|||
}, [ecsRef, Components, Systems]);
|
||||
useEffect(() => {
|
||||
async function setEcsStuff() {
|
||||
const {default: Components} = await import('@/ecs/components/index.js');
|
||||
const {default: Systems} = await import('@/ecs/systems/index.js');
|
||||
const {default: Components} = await import('@/silphius/ecs/components/index.js');
|
||||
const {default: Systems} = await import('@/silphius/ecs/systems/index.js');
|
||||
setComponents(Components);
|
||||
setSystems(Systems);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ settings.ADAPTER.fetch = async (path) => {
|
|||
};
|
||||
|
||||
export async function loader({request}) {
|
||||
const {juggleSession} = await import('@/server/session.server.js');
|
||||
const {juggleSession} = await import('@/silphius/server/session.server.js');
|
||||
const {loadManifest} = await import('@/lib/resources.server.js');
|
||||
await juggleSession(request);
|
||||
return json({
|
||||
|
@ -43,10 +43,10 @@ export default function Play() {
|
|||
let Client;
|
||||
switch (type) {
|
||||
case 'local':
|
||||
({default: Client} = await import('@/client/local.js'));
|
||||
({default: Client} = await import('@/silphius/client/local.js'));
|
||||
break;
|
||||
case 'remote':
|
||||
({default: Client} = await import('@/client/remote.js'));
|
||||
({default: Client} = await import('@/silphius/client/remote.js'));
|
||||
break;
|
||||
}
|
||||
setClient(() => Client);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import {Form, json, redirect, useLoaderData} from '@remix-run/react';
|
||||
import {useState} from 'react';
|
||||
|
||||
import {commitSession, getSession, juggleSession} from '@/server/session.server.js';
|
||||
import {commitSession, getSession, juggleSession} from '@/silphius/server/session.server.js';
|
||||
|
||||
import NoiseField from './noise-field.jsx';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Client from '@/net/client.js';
|
||||
import {decode, encode} from '@/net/packets/index.js';
|
||||
import Client from '@/silphius/net/client.js';
|
||||
import {decode, encode} from '@/silphius/net/packets/index.js';
|
||||
import {CLIENT_INTERPOLATION, CLIENT_PREDICTION} from '@/lib/constants.js';
|
||||
|
||||
export default class LocalClient extends Client {
|
|
@ -1,6 +1,6 @@
|
|||
import Components from '@/ecs/components/index.js';
|
||||
import Ecs from '@/ecs/ecs.js';
|
||||
import Systems from '@/ecs/systems/index.js';
|
||||
import Components from '@/silphius/ecs/components/index.js';
|
||||
import Ecs from '@/silphius/ecs/ecs.js';
|
||||
import Systems from '@/silphius/ecs/systems/index.js';
|
||||
import {get, loadResources, readAsset} from '@/lib/resources.js';
|
||||
|
||||
class PredictionEcs extends Ecs {
|
|
@ -1,5 +1,5 @@
|
|||
import Client from '@/net/client.js';
|
||||
import {decode, encode} from '@/net/packets/index.js';
|
||||
import Client from '@/silphius/net/client.js';
|
||||
import {decode, encode} from '@/silphius/net/packets/index.js';
|
||||
import {CLIENT_INTERPOLATION, CLIENT_PREDICTION} from '@/lib/constants.js';
|
||||
|
||||
export default class RemoteClient extends Client {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Alive extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Animation extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Arbitrary extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class AreaSize extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Behaving extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Camera extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import {distance, intersects, transform} from '@/lib/math.js';
|
||||
|
||||
import vector2d from './helpers/vector-2d';
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Controlled extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import {HALF_PI, TAU} from '@/lib/math.js';
|
||||
|
||||
export default class Direction extends Component {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Ecs extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
import {Emitter} from '@/lib/particles.js';
|
||||
import Ticker from '@/lib/ticker.js';
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Forces extends Component {
|
||||
instanceFromSchema() {
|
3
app/silphius/ecs/components/grabber.js
Normal file
3
app/silphius/ecs/components/grabber.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Grabber extends Component {}
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Harmful extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Health extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Interactive extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Interacts extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Interlocutor extends Component {
|
||||
mergeDiff(original, update) {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
import {distribute} from '@/lib/inventory.js';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class ItemStack extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Light extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Magnet extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Magnetic extends Component {
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class MainEntity extends Component {}
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Owned extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Plant extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
const State = {
|
||||
CLOSED: 0,
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Position extends Component {
|
||||
instanceFromSchema() {
|
3
app/silphius/ecs/components/shop.js
Normal file
3
app/silphius/ecs/components/shop.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Shop extends Component {}
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Sound extends Component {
|
||||
mergeDiff(original, update) {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Speed extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import {hexToHsl, hslToHex} from '@/lib/color.js';
|
||||
|
||||
export default class Sprite extends Component {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Tags extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import {withResolvers} from '@/lib/promise.js';
|
||||
|
||||
export default class Ticking extends Component {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import {CHUNK_SIZE} from '@/lib/constants.js';
|
||||
import {floodwalk2D, ortho, removeCollinear} from '@/lib/math.js';
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import {expect, test} from 'vitest';
|
||||
|
||||
import Ecs from '@/ecs/ecs.js';
|
||||
import Ecs from '@/silphius/ecs/ecs.js';
|
||||
|
||||
import TileLayers from './tile-layers.js';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import {IRL_MINUTES_PER_GAME_DAY} from '@/lib/constants';
|
||||
|
||||
const realSecondsPerGameDay = 60 * IRL_MINUTES_PER_GAME_DAY;
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Ttl extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class VisibleAabb extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
import * as Math from '@/lib/math.js';
|
||||
import Ticker from '@/lib/ticker.js';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Wallet extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Water extends Component {
|
||||
static properties = {
|
|
@ -1,4 +1,4 @@
|
|||
import Component from '@/ecs/component.js';
|
||||
import Component from '@/silphius/ecs/component.js';
|
||||
|
||||
export default class Wielder extends Component {
|
||||
instanceFromSchema() {
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
import {normalizeVector} from '@/lib/math.js';
|
||||
|
||||
export default class ApplyControlMovement extends System {
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
import {distance, normalizeVector} from '@/lib/math.js';
|
||||
|
||||
export default class Attract extends System {
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class Behave extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class ClampPositions extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class Colliders extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
import {TAU} from '@/lib/math.js';
|
||||
|
||||
export default class ControlDirection extends System {
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
// import {RESOLUTION} from '@/lib/constants.js'
|
||||
|
||||
// const [hx, hy] = [RESOLUTION.x / 2, RESOLUTION.y / 2];
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class Harm extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import System from '@/ecs/system.js';
|
||||
import System from '@/silphius/ecs/system.js';
|
||||
import gather from '@/lib/gather.js';
|
||||
|
||||
const gathered = gather(import.meta.glob('./*.js', {eager: true, import: 'default'}));
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class IntegratePhysics extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class Interactions extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
import {distance} from '@/lib/math.js';
|
||||
|
||||
export default class InventoryCloser extends System {
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
|
||||
export default class KillPerishable extends System {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import {System} from '@/ecs/index.js';
|
||||
import {System} from '@/silphius/ecs/index.js';
|
||||
import SpatialHash from '@/lib/spatial-hash.js';
|
||||
|
||||
export default class MaintainColliderHash extends System {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user