mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-29 16:54:37 +02:00
wip
This commit is contained in:
@@ -60,7 +60,10 @@ export class WorldRoomMultiplayService {
|
||||
public async heartbeat(userId: MiUser['id'], roomId: MiWorldRoom['id']) {
|
||||
const exists = await this.redisClient.hexists(`worldRoom:${roomId}:players`, userId);
|
||||
if (exists) {
|
||||
await this.redisClient.hexpire(`worldRoom:${roomId}:players`, 30, 'FIELDS', 1, userId);
|
||||
const redisPipeline = this.redisClient.pipeline();
|
||||
redisPipeline.hexpire(`worldRoom:${roomId}:players`, 30, 'FIELDS', 1, userId);
|
||||
redisPipeline.hexpire(`worldRoom:${roomId}:playerStates`, 30, 'FIELDS', 1, userId);
|
||||
await redisPipeline.exec();
|
||||
} else {
|
||||
throw new Error('Not in room.');
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"esbuild": "0.28.0",
|
||||
"execa": "9.6.1",
|
||||
"nodemon": "3.1.14",
|
||||
"throttle-debounce": "5.0.2",
|
||||
"@types/tinycolor2": "1.4.6"
|
||||
},
|
||||
"files": [
|
||||
@@ -24,6 +25,7 @@
|
||||
"@babylonjs/inspector": "9.9.0",
|
||||
"@babylonjs/loaders": "9.9.0",
|
||||
"@babylonjs/materials": "9.9.0",
|
||||
"@types/throttle-debounce": "5.0.2",
|
||||
"eventemitter3": "5.0.4",
|
||||
"seedrandom": "3.0.5",
|
||||
"tinycolor2": "1.6.0",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import * as BABYLON from '@babylonjs/core';
|
||||
import { registerBuiltInLoaders } from '@babylonjs/loaders/dynamic';
|
||||
import { cm, WORLD_SCALE } from 'misskey-world/src/utility.js';
|
||||
import { throttle } from 'throttle-debounce';
|
||||
import { TIME_MAP, getMeshesBoundingBox, Timer, getYRotationDirection, FreeCameraManualInput, remap } from '../utility.js';
|
||||
import { EngineBase } from '../EngineBase.js';
|
||||
import { genId } from '../id.js';
|
||||
@@ -65,7 +66,7 @@ export class RoomEngine extends EngineBase<{
|
||||
'changeSittingState': (ctx: { isSitting: boolean }) => void;
|
||||
'changeGridSnapping': (ctx: { gridSnapping: { enabled: boolean; scale: number } }) => void;
|
||||
'changeRoomState': (ctx: { roomState: RoomState }) => void;
|
||||
'changeMyPlayerState': (ctx: { playerState: PlayerState }) => void;
|
||||
'changeMyPlayerState': (ctx: PlayerState) => void;
|
||||
'playSfxUrl': (ctx: {
|
||||
url: string;
|
||||
options: {
|
||||
@@ -177,7 +178,7 @@ export class RoomEngine extends EngineBase<{
|
||||
this.ev('changeSittingState', { isSitting: v });
|
||||
}
|
||||
|
||||
private playerProfiles: Record<string, PlayerProfiles> = {};
|
||||
private playerProfiles: Record<string, PlayerProfile> = {};
|
||||
private playerStates: Record<string, PlayerState> = {};
|
||||
private playerContainers: PlayerContainer[] = [];
|
||||
|
||||
@@ -499,6 +500,16 @@ export class RoomEngine extends EngineBase<{
|
||||
}
|
||||
});
|
||||
|
||||
this.timer.setInterval(() => {
|
||||
const camera = this.scene.activeCamera!;
|
||||
const myPos = camera.position;
|
||||
const myRotation = camera.rotation;
|
||||
this.ev('changeMyPlayerState', {
|
||||
position: [myPos.x, myPos.y, myPos.z],
|
||||
rotation: [myRotation.x, myRotation.y, myRotation.z],
|
||||
});
|
||||
}, 100);
|
||||
|
||||
this.inited = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ export class RoomController extends EngineControllerBase<RoomEngine> {
|
||||
}
|
||||
});
|
||||
|
||||
engineEvents.on('changeMyPlayerState', ({ playerState }) => {
|
||||
engineEvents.on('changeMyPlayerState', (playerState) => {
|
||||
this.myPlayerState.value = playerState;
|
||||
});
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ export function getConfig(): UserConfig {
|
||||
|
||||
// https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
|
||||
commonjsOptions: {
|
||||
include: [/misskey-js/, /misskey-reversi/, /misskey-bubble-game/, /misskey-world/, /frontend-misskey-world-engine/, /node_modules/],
|
||||
include: [/misskey-js/, /misskey-reversi/, /misskey-bubble-game/, /node_modules/],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user