revert "disable collision to fix pathfinding phasing through walls"
This reverts commit f48a6bf9aa.
This commit is contained in:
+1
-16
@@ -1,5 +1,4 @@
|
||||
import { EventEmitter } from 'node:events'
|
||||
import Pathfind from './pathfind.js'
|
||||
|
||||
export default class Game {
|
||||
tickRate = 30
|
||||
@@ -11,23 +10,14 @@ export default class Game {
|
||||
#eventEmitter = new EventEmitter()
|
||||
#terrains = []
|
||||
#tickBudget = Math.floor(1000 / this.tickRate)
|
||||
#waypointGraph = []
|
||||
|
||||
get entities() { return this.#entities }
|
||||
get eventEmitter() { return this.#eventEmitter }
|
||||
get terrains() { return this.#terrains }
|
||||
get tickBudget() { return this.#tickBudget }
|
||||
get waypointGraph() { return this.#waypointGraph }
|
||||
|
||||
get unadjustedWaypoints() {
|
||||
// const terrainAndEntities = this.entities.concat(this.terrains)
|
||||
const terrainAndEntities = this.terrains
|
||||
return terrainAndEntities.map((e) => e.unadjustedWaypoints).flat()
|
||||
}
|
||||
|
||||
colliders() {
|
||||
const terrainAndEntities = this.entities.concat(this.terrains)
|
||||
return terrainAndEntities.map((e) => e.colliders).flat()
|
||||
return this.terrains.map((t) => t.unadjustedWaypoints).concat(this.entities.map((e) => e.unadjustedWaypoints)).flat()
|
||||
}
|
||||
|
||||
spawn_entity(entity) {
|
||||
@@ -42,7 +32,6 @@ export default class Game {
|
||||
|
||||
add_terrain(terrain) {
|
||||
this.#terrains.push(terrain)
|
||||
this.#calculateWaypointGraph()
|
||||
}
|
||||
|
||||
state() {
|
||||
@@ -64,8 +53,4 @@ export default class Game {
|
||||
this.currentTick++
|
||||
this.eventEmitter.emit('tick')
|
||||
}
|
||||
|
||||
#calculateWaypointGraph() {
|
||||
this.#waypointGraph = Pathfind.buildGraph(this.unadjustedWaypoints, this.colliders())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user