fix pathfinding issues
This commit is contained in:
@@ -11,17 +11,20 @@ export default class Game {
|
||||
running = false
|
||||
nextTick = 0
|
||||
|
||||
#logic = null
|
||||
#entities = []
|
||||
#eventEmitter = new EventEmitter()
|
||||
#projectiles = []
|
||||
#terrains = []
|
||||
#tickBudget = 1000 / this.tickRate
|
||||
|
||||
get logic() { return this.#logic }
|
||||
get entities() { return this.#entities }
|
||||
get eventEmitter() { return this.#eventEmitter }
|
||||
get projectiles() { return this.#projectiles }
|
||||
get terrains() { return this.#terrains }
|
||||
get tickBudget() { return this.#tickBudget }
|
||||
set logic(value) { this.#logic = value }
|
||||
|
||||
get unadjustedWaypoints() {
|
||||
return this.terrains.map((t) => t.unadjustedWaypoints).concat(this.entities.map((e) => e.unadjustedWaypoints)).flat()
|
||||
@@ -104,6 +107,10 @@ export default class Game {
|
||||
update() {
|
||||
this.#entities.forEach((e) => e.update())
|
||||
this.#projectiles.forEach((p) => p.update())
|
||||
if (this.#logic != null) {
|
||||
this.#logic()
|
||||
}
|
||||
|
||||
this.currentTick++
|
||||
this.eventEmitter.emit('tick')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user