Skip to content

Commit

Permalink
rename SimState to FrameState
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffomatic committed May 17, 2021
1 parent 7ef44f8 commit a6e2d5c
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"codemirror": "^5.59.1",
"file-saver": "^2.0.2",
"gl-matrix": "^3.3.0",
"hash-wasm": "^4.6.0",
"l1-path-finder": "^1.0.0",
"ndarray": "^1.0.19",
"rc-slider": "^9.7.2",
Expand Down
4 changes: 2 additions & 2 deletions src/simulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function simulationPhaseDebugColor(
}
}

export type SimState = {
export type FrameState = {
entityManager: EntityManager
messages: ClientMessage[]
frameEvents: FrameEvent[]
Expand All @@ -46,7 +46,7 @@ export type SimState = {
}

export const simulate = (
simState: SimState,
simState: FrameState,
gameState: GameState,
dt: number,
): void => {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BUILDER_SPEED } from '~/constants'
// import { TILE_SIZE } from '~/constants'
// import { make } from '~/entities/builder'
// import { Entity } from '~/entities/Entity'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'
// import { makeTurret } from '~/entities/turret'
// import { makeWall } from '~/entities/wall'
// import { pathfind } from '~/map/PathFinder'
Expand Down Expand Up @@ -51,7 +51,7 @@ const tilePos = vec2.create()
const destTilePos = vec2.create()
const nextTilePos = vec2.create()

export const update = (simState: SimState, dt: number): void => {
export const update = (simState: FrameState, dt: number): void => {
for (const [id, builder] of simState.entityManager.builders) {
const pos = simState.entityManager.transforms.get(id)!.position
tileCoords(tilePos, pos)
Expand Down
4 changes: 2 additions & 2 deletions src/systems/damageable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { vec2 } from 'gl-matrix'
import { FrameEventType } from './FrameEvent'

import { PickupConstructors } from '~/entities/pickups'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'

export const update = (simState: SimState): void => {
export const update = (simState: FrameState): void => {
for (const [id, damageable] of simState.entityManager.damageables) {
const transform = simState.entityManager.transforms.get(id)!

Expand Down
4 changes: 2 additions & 2 deletions src/systems/damager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DebugDrawObject } from '~/DebugDraw'
import { EntityId } from '~/entities/EntityId'
import { UnlitObjectType } from '~/renderer/Renderer3d'
import {
SimState,
FrameState,
SimulationPhase,
simulationPhaseDebugColor,
} from '~/simulate'
Expand Down Expand Up @@ -135,7 +135,7 @@ export function clone(d: Immutable<Damager>): Damager {
}
}

export const update = (simState: SimState): void => {
export const update = (simState: FrameState): void => {
simState.debugDraw.draw3d(() => {
const objects: DebugDrawObject[] = []

Expand Down
4 changes: 2 additions & 2 deletions src/systems/explosion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
EntityComponents,
makeDefaultEntity,
} from '~/entities/EntityComponents'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'
import { Immutable } from '~/types/immutable'

export const makeExplosion = (pos: Immutable<vec2>): EntityComponents => {
Expand All @@ -32,7 +32,7 @@ export const makeExplosion = (pos: Immutable<vec2>): EntityComponents => {
return e
}

export function update(simState: SimState): void {
export function update(simState: FrameState): void {
for (const id of simState.entityManager.explosions) {
simState.frameEvents.push({
type: FrameEventType.MortarExplosion,
Expand Down
4 changes: 2 additions & 2 deletions src/systems/shooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BulletConfig } from '~/components/Bullet'
import { TILE_SIZE } from '~/constants'
import { makeBuilder } from '~/entities/builder'
import { makeBullet } from '~/entities/bullet'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'
import * as emitter from '~/systems/emitter'
import { FrameEventType } from '~/systems/FrameEvent'
import { WEAPON_TYPE_LENGTH, WeaponType } from '~/systems/WeaponType'
Expand Down Expand Up @@ -53,7 +53,7 @@ export function clone(s: ShooterComponent): ShooterComponent {
}
}

export const update = (simState: SimState): void => {
export const update = (simState: FrameState): void => {
simState.messages.forEach((message) => {
const id = simState.entityManager.getPlayerId(message.playerNumber)!
const shooter = simState.entityManager.shooters.get(id)!
Expand Down
4 changes: 2 additions & 2 deletions src/systems/tankMover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '~/constants'
import { DirectionMove } from '~/input/interfaces'
import { ClientMoveUpdate } from '~/network/ClientMessage'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'
import { FrameEventType } from '~/systems/FrameEvent'
import { WeaponType } from '~/systems/WeaponType'
import { North2, Zero2, radialTranslate2, rotateUntil } from '~/util/math'
Expand All @@ -38,7 +38,7 @@ export function clone(t: TankMoverComponent): TankMoverComponent {
}
}

export const update = (simState: SimState, dt: number): void => {
export const update = (simState: FrameState, dt: number): void => {
const messages = new Map<number, ClientMoveUpdate>()
simState.messages.forEach((m) => {
if (m.move !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/transformInit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { vec2 } from 'gl-matrix'

import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'

export const update = (simState: Pick<SimState, 'entityManager'>): void => {
export const update = (simState: Pick<FrameState, 'entityManager'>): void => {
for (const id of simState.entityManager.moveables) {
const transform = simState.entityManager.transforms.get(id)!
if (!vec2.equals(transform.position, transform.previousPosition)) {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/turret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Transform } from '~/components/Transform'
import { TILE_SIZE } from '~/constants'
import { makeBullet } from '~/entities/bullet'
import { EntityId } from '~/entities/EntityId'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'
import { FrameEventType } from '~/systems/FrameEvent'
import { Immutable } from '~/types/immutable'
import { Aabb2 } from '~/util/aabb2'
Expand All @@ -35,7 +35,7 @@ export function clone(t: TurretComponent): TurretComponent {
return { cooldownTtl: t.cooldownTtl, orientation: t.orientation }
}

export const update = (simState: SimState, dt: number): void => {
export const update = (simState: FrameState, dt: number): void => {
const { entityManager } = simState

const turretIds = new SortedSet<EntityId>()
Expand Down
4 changes: 2 additions & 2 deletions src/systems/wallCollider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { vec2 } from 'gl-matrix'

import { Transform } from '~/components/Transform'
import { TILE_SIZE } from '~/constants'
import { SimState } from '~/simulate'
import { FrameState } from '~/simulate'
import { Immutable } from '~/types/immutable'
import * as aabb2 from '~/util/aabb2'
import { Aabb2 } from '~/util/aabb2'
Expand All @@ -15,7 +15,7 @@ enum DirectionCollision {
West = 'W',
}

export const update = (simState: Pick<SimState, 'entityManager'>): void => {
export const update = (simState: Pick<FrameState, 'entityManager'>): void => {
for (const [id] of simState.entityManager.playerNumbers) {
const transform = simState.entityManager.transforms.get(id)!
const position = transform.position
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3409,6 +3409,11 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"

hash-wasm@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/hash-wasm/-/hash-wasm-4.6.0.tgz#6944a0dd33696d9ab1245e407af22a3a459a0773"
integrity sha512-Wi96tJDftxUQciCUi2Vs/Nw8al3psRATe/FhyezrajJKCXKRHvpiFARTZuUgdlGB7825LiN+FluH7SFoGdiGRA==

hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
Expand Down

0 comments on commit a6e2d5c

Please sign in to comment.