add unoptimized pathfinding

This commit is contained in:
2024-12-25 00:32:33 +09:00
parent 47aade7b3f
commit 05360208b0
8 changed files with 353 additions and 37 deletions
+11 -2
View File
@@ -3,8 +3,8 @@ import { EventEmitter } from 'node:events'
export default class Game {
tickRate = 30
currentTick = 0
width = 4000
height = 4000
width = 2000
height = 2000
#entities = []
#eventEmitter = new EventEmitter()
@@ -16,11 +16,20 @@ export default class Game {
get terrains() { return this.#terrains }
get tickBudget() { return this.#tickBudget }
get unadjustedWaypoints() {
return this.terrains.map((t) => t.unadjustedWaypoints).concat(this.entities.map((e) => e.unadjustedWaypoints)).flat()
}
spawn_entity(entity) {
this.#entities.push(entity)
entity.game = this
}
despawn(entity) {
this.#entities = this.#entities.filter((e) => e.id != entity.id)
entity.game = null
}
add_terrain(terrain) {
this.#terrains.push(terrain)
}