refactor: structure
This commit is contained in:
parent
ede9614e2d
commit
a27f79dc33
|
@ -1,4 +1,4 @@
|
|||
import Client from './client.js';
|
||||
import Client from '@/net/client.js';
|
||||
|
||||
export default class LocalClient extends Client {
|
||||
async connect() {
|
|
@ -1,8 +1,7 @@
|
|||
import Client from '@/net/client.js';
|
||||
import {encode} from '@/net/packets/index.js';
|
||||
import {CLIENT_PREDICTION} from '@/util/constants.js';
|
||||
|
||||
import Client from './client.js';
|
||||
|
||||
export default class RemoteClient extends Client {
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -16,7 +15,7 @@ export default class RemoteClient extends Client {
|
|||
async connect(host) {
|
||||
if (CLIENT_PREDICTION) {
|
||||
this.worker = new Worker(
|
||||
new URL('../client/prediction.js', import.meta.url),
|
||||
new URL('./prediction.js', import.meta.url),
|
||||
{type: 'module'},
|
||||
);
|
||||
this.worker.postMessage({host});
|
|
@ -17,10 +17,10 @@ export async function websocket(server, viteDevServer) {
|
|||
if (viteDevServer) {
|
||||
const {createViteRuntime} = await import('vite');
|
||||
const runtime = await createViteRuntime(viteDevServer);
|
||||
(await runtime.executeEntrypoint('/app/websocket.js')).default(server);
|
||||
(await runtime.executeEntrypoint('/app/server/websocket.js')).default(server);
|
||||
}
|
||||
else {
|
||||
(await import('./websocket.js')).default(server);
|
||||
(await import('./server/websocket.js')).default(server);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import DebugContext from '@/react/context/debug.js';
|
|||
import EcsContext from '@/react/context/ecs.js';
|
||||
import MainEntityContext from '@/react/context/main-entity.js';
|
||||
import RadiansContext from '@/react/context/radians.js';
|
||||
import {juggleSession} from '@/server/session.server.js';
|
||||
import {TAU} from '@/util/math.js';
|
||||
import {juggleSession} from '@/util/session.server';
|
||||
|
||||
export async function loader({request}) {
|
||||
await juggleSession(request);
|
||||
|
|
|
@ -14,10 +14,10 @@ export default function Play() {
|
|||
let Client;
|
||||
switch (type) {
|
||||
case 'local':
|
||||
({default: Client} = await import('@/net/client/local.js'));
|
||||
({default: Client} = await import('@/client/local.js'));
|
||||
break;
|
||||
case 'remote':
|
||||
({default: Client} = await import('@/net/client/remote.js'));
|
||||
({default: Client} = await import('@/client/remote.js'));
|
||||
break;
|
||||
}
|
||||
class SilphiusClient extends Client {
|
||||
|
|
|
@ -3,8 +3,8 @@ import {dirname, join} from 'node:path';
|
|||
|
||||
import {WebSocketServer} from 'ws';
|
||||
|
||||
import Server from '@/net/server/server.js';
|
||||
import {getSession} from '@/util/session.server.js';
|
||||
import Server from '@/net/server.js';
|
||||
import {getSession} from '@/server/session.server.js';
|
||||
|
||||
import Engine from './engine.js';
|
||||
|
||||
|
@ -48,7 +48,7 @@ class SocketServer extends Server {
|
|||
await mkdir(path, {recursive: true});
|
||||
}
|
||||
static qualify(path) {
|
||||
return join(import.meta.dirname, '..', 'data', 'remote', 'UNIVERSE', path);
|
||||
return join(import.meta.dirname, '..', '..', 'data', 'remote', 'UNIVERSE', path);
|
||||
}
|
||||
async readAsset(path) {
|
||||
const url = new URL(path, 'https://localhost:3000')
|
|
@ -1,14 +1,14 @@
|
|||
import {del, get, set} from 'idb-keyval';
|
||||
|
||||
import {encode} from '@/net/packets/index.js';
|
||||
import Server from '@/net/server.js';
|
||||
|
||||
import createEcs from '../../create/ecs.js';
|
||||
import '../../create/forest.js';
|
||||
import '../../create/homestead.js';
|
||||
import '../../create/player.js';
|
||||
import createEcs from './create/ecs.js';
|
||||
import './create/forest.js';
|
||||
import './create/homestead.js';
|
||||
import './create/player.js';
|
||||
|
||||
import Engine from '../../engine.js';
|
||||
import Server from './server.js';
|
||||
import Engine from './engine.js';
|
||||
|
||||
class WorkerServer extends Server {
|
||||
constructor() {
|
||||
|
@ -78,8 +78,8 @@ if (import.meta.hot) {
|
|||
await engine.saveEcses();
|
||||
beforeResolver.resolve();
|
||||
});
|
||||
import.meta.hot.accept('../../engine.js');
|
||||
import.meta.hot.accept('../../create-player.js', async ({default: createPlayer}) => {
|
||||
import.meta.hot.accept('./engine.js');
|
||||
import.meta.hot.accept('./create/player.js', async ({default: createPlayer}) => {
|
||||
const resolver = createResolver();
|
||||
resolvers.push(resolver);
|
||||
await beforeResolver;
|
||||
|
@ -93,7 +93,7 @@ if (import.meta.hot) {
|
|||
await engine.server.writeData('players/0', (new TextEncoder()).encode(JSON.stringify(player)));
|
||||
resolver.resolve();
|
||||
});
|
||||
import.meta.hot.accept('../../create-forest.js', async ({default: createForest}) => {
|
||||
import.meta.hot.accept('./create/forest.js', async ({default: createForest}) => {
|
||||
const resolver = createResolver();
|
||||
resolvers.push(resolver);
|
||||
await beforeResolver;
|
||||
|
@ -106,7 +106,7 @@ if (import.meta.hot) {
|
|||
await engine.saveEcs('forests/0', forest);
|
||||
resolver.resolve();
|
||||
});
|
||||
import.meta.hot.accept('../../create-homestead.js', async ({default: createHomestead}) => {
|
||||
import.meta.hot.accept('./create/homestead.js', async ({default: createHomestead}) => {
|
||||
const resolver = createResolver();
|
||||
resolvers.push(resolver);
|
||||
await beforeResolver;
|
Loading…
Reference in New Issue
Block a user