make fetchHadler synchronous only

This commit is contained in:
Elizabeth Hunt 2023-08-26 13:54:39 -06:00
parent 2fbe0f0595
commit 594921352c
Signed by: simponic
GPG Key ID: 52B3774857EB24B1
2 changed files with 8 additions and 7 deletions

View File

@ -75,13 +75,17 @@ export class Input extends System {
PhysicsConstants.MAX_JUMP_TIME_MS PhysicsConstants.MAX_JUMP_TIME_MS
) { ) {
const mass = entity.getComponent<Mass>(ComponentNames.Mass).mass; const mass = entity.getComponent<Mass>(ComponentNames.Mass).mass;
entity.getComponent<Forces>(ComponentNames.Forces)?.forces.push({
const jumpForce = {
fCartesian: { fCartesian: {
fy: mass * PhysicsConstants.PLAYER_JUMP_ACC, fy: mass * PhysicsConstants.PLAYER_JUMP_ACC,
fx: 0 fx: 0
}, },
torque: 0 torque: 0
}); };
entity
.getComponent<Forces>(ComponentNames.Forces)
?.forces.push(jumpForce);
} }
} }
} }

View File

@ -65,10 +65,10 @@ export class GameServer {
const { sessionId } = websocket.data; const { sessionId } = websocket.data;
const sessionEntities = this.sessions.get(sessionId)!.controllableEntities; const sessionEntities = this.sessions.get(sessionId)!.controllableEntities;
this.sessions.delete(sessionId); this.sessions.delete(sessionId);
if (!sessionEntities) return; if (!sessionEntities) return;
this.messagePublisher.addMessage({ this.messagePublisher.addMessage({
type: MessageType.REMOVE_ENTITIES, type: MessageType.REMOVE_ENTITIES,
body: Array.from(sessionEntities) body: Array.from(sessionEntities)
@ -103,10 +103,7 @@ export class GameServer {
this.sessions.get(sessionId)!.controllableEntities.add(player.id); this.sessions.get(sessionId)!.controllableEntities.add(player.id);
} }
private fetchHandler( private fetchHandler(req: Request, server: Server): Response {
req: Request,
server: Server
): Promise<Response> | Response {
const url = new URL(req.url); const url = new URL(req.url);
const headers = new Headers(); const headers = new Headers();