add bbox checks for pathfinding

This commit is contained in:
2025-01-21 10:02:54 +09:00
parent 6b8a220f39
commit 8ce1a2266f
7 changed files with 90 additions and 69 deletions
+2 -7
View File
@@ -36,10 +36,6 @@ export default class Game {
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()
}
action(id, options) {
const entity = this.entities.find((it) => it.id == id)
if (entity == null) {
@@ -104,7 +100,7 @@ export default class Game {
if (this.gameLoopIntervalId != null) { return }
this.startTimestamp = performance.now() + (this.currentTick * this.tickBudget)
console.log(`Started game ${this.id} with ${this.tickRate} tps. Starting on tick ${this.currentTick}.`)
console.info(`Started game ${this.id} with ${this.tickRate} tps. Starting on tick ${this.currentTick}.`)
this.gameLoopIntervalId = setInterval(this.#gameLoopCall.bind(this), this.tickBudget / 5)
}
@@ -113,7 +109,7 @@ export default class Game {
clearInterval(this.gameLoopIntervalId)
this.gameLoopIntervalId = null
console.log(`Stopped game ${this.id}. Stopped on tick ${this.currentTick}.`)
console.info(`Stopped game ${this.id}. Stopped on tick ${this.currentTick}.`)
}
subscription(websocket, id) {
@@ -158,7 +154,6 @@ export default class Game {
return entityVisionSources.concat(projectileVisionSources)
}
// TODO: castingVision should not reveal casting in non-lanes (= only spawn castingVision if slightly outside regular vision [or obstructeed])
visionByTeam(team) {
const visionSources = this.visionSources(team)
const visibleEntities = new Set(visionSources.map((it) => it.entitiesInVision()).flat())