Skip to content

Commit

Permalink
rename Client to ClientSim
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffomatic committed Dec 25, 2020
1 parent e8ef2b7 commit 6a52db2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Client.ts → src/ClientSim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import * as math from '~/util/math'
import { RunningAverage } from '~/util/RunningAverage'
import * as time from '~/util/time'

export class Client {
export class ClientSim {
entityManager: EntityManager
localMessageHistory: ClientMessage[]
playerInputState: {
Expand Down
8 changes: 4 additions & 4 deletions src/clientMain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vec2 } from 'gl-matrix'

import { Client } from '~/Client'
import * as clientHotReload from '~/clientHotReload'
import { ClientSim } from '~/ClientSim'
import { ClientView } from '~/ClientView'
import { DebugDraw } from '~/DebugDraw'
import { GameState } from '~/Game'
Expand All @@ -13,7 +13,7 @@ import { createServerConnectionWs } from '~/network/ServerConnection'
declare global {
interface Window {
debug: {
client: Client
client: ClientSim
restartServer: () => Promise<void>
}
}
Expand Down Expand Up @@ -43,7 +43,7 @@ document.body.appendChild(canvas2d)
// TODO: refactor this whole thing into a class...the way this currently works
// is gross
function makeClientObjects(): [
Client,
ClientSim,
ClientView,
IKeyboard,
IMouse,
Expand All @@ -59,7 +59,7 @@ function makeClientObjects(): [
debugDraw,
})

const client = new Client({
const client = new ClientSim({
keyboard,
mouse,
modelLoader: clientView.getModelLoader(),
Expand Down
8 changes: 4 additions & 4 deletions src/systems/client/playerInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { vec2 } from 'gl-matrix'
import { vec4 } from 'gl-matrix'
import { vec3 } from 'gl-matrix'

import { Client } from '~/Client'
import { ClientSim } from '~/ClientSim'
import { DirectionMove } from '~/input/interfaces'
import { MouseButton } from '~/input/interfaces'
import { ClientMessageType } from '~/network/ClientMessage'
Expand All @@ -26,7 +26,7 @@ export enum CursorMode {
BUILD_WALL,
}

export const update = (client: Client, frame: number): void => {
export const update = (client: ClientSim, frame: number): void => {
// handleCursorMode(game)
handleMoveInput(client, frame)
handleAttackInput(client, frame)
Expand All @@ -47,7 +47,7 @@ export const update = (client: Client, frame: number): void => {
// }
// }

const handleMoveInput = (client: Client, frame: number): void => {
const handleMoveInput = (client: ClientSim, frame: number): void => {
let direction
if (client.keyboard.downKeys.has(keyMap.moveUp)) {
if (client.keyboard.downKeys.has(keyMap.moveLeft)) {
Expand Down Expand Up @@ -81,7 +81,7 @@ const handleMoveInput = (client: Client, frame: number): void => {
}
}

const handleAttackInput = (client: Client, frame: number): void => {
const handleAttackInput = (client: ClientSim, frame: number): void => {
const mousePos = client.mouse.getPos()
if (mousePos === undefined) {
return
Expand Down
4 changes: 2 additions & 2 deletions src/systems/client/syncServerState.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Client } from '~/Client'
import { ClientSim } from '~/ClientSim'
import { mockDebugDraw } from '~/DebugDraw'
import { simulate } from '~/simulate'

export const update = (c: Client, dt: number, frame: number): void => {
export const update = (c: ClientSim, dt: number, frame: number): void => {
c.serverFrameUpdates = c.serverFrameUpdates
.filter((m) => m.frame > c.committedFrame)
.sort((a, b) => a.frame - b.frame)
Expand Down
4 changes: 2 additions & 2 deletions src/systems/hud/crosshair.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client } from '~/Client'
import { ClientSim } from '~/ClientSim'
import { CursorMode } from '~/systems/client/playerInput'

export const update = (c: Client): void => {
export const update = (c: ClientSim): void => {
const mousePos = c.mouse!.getPos()
if (mousePos) {
// crosshair (TODO: this could probably be moved to HUD rendering, which
Expand Down

0 comments on commit 6a52db2

Please sign in to comment.