only calculate name placement when territory changes

This commit is contained in:
evanpelle
2024-12-10 16:57:54 -08:00
committed by Evan
parent b97ef32adb
commit d5f6a9c1e4
2 changed files with 24 additions and 5 deletions
+11 -1
View File
@@ -227,8 +227,9 @@
* you should get a notification and a reward (some money) for eliminating an enemy DONE 12/9/2024
* alert on attack DONE 12/20/2024
* alert on unit captured or destroyed 12/20/2024
* only check islands/clusters when being attacked DONE 12/10/2024
* only calculate name if tile changes DONE 12/10/2024
* allow longer names and allow them to be displayed in the Rank UI not be cut
* only check islands/clusters when being attacked
* store in BigQuery
* make boats work on lakes (& oceania)
* record game winner
@@ -276,3 +277,12 @@ FEB 1st
* REFACTOR: give terranullius an ID, game.player() returns terranullius
* REFACTOR: ocean is considered TerraNullius ?
Error: cannot delete [object Object] not active
Stack: Error: cannot delete [object Object] not active
at UnitImpl.delete (webpack://openfront-client/./src/core/game/UnitImpl.ts?:54:19)
at ShellExecution.tick (webpack://openfront-client/./src/core/execution/ShellExecution.ts?:36:38)
at eval (webpack://openfront-client/./src/core/game/GameImpl.ts?:133:19)
at Array.forEach (<anonymous>)
at GameImpl.executeNextTick (webpack://openfront-client/./src/core/game/GameImpl.ts?:131:20)
at GameRunner.tick (webpack://openfront-client/./src/client/GameRunner.ts?:153:21)
at eval (webpack://openfront-client/./src/client/GameRunner.ts?:110:50)
+13 -4
View File
@@ -87,15 +87,25 @@ export class NameLayer implements Layer {
}
}
}
const tickRefreshRate = Math.floor(this.refreshRate / 100) // 10 ticks
for (const render of this.renders) {
const shouldRecalc = render.boundingBox == null || this.game.ticks() - render.player.lastTileChange() < tickRefreshRate
const now = Date.now()
if (now - render.lastBoundingCalculated > this.refreshRate) {
render.boundingBox = calculateBoundingBox(render.player.borderTiles());
render.lastBoundingCalculated = now
if (shouldRecalc) {
render.boundingBox = calculateBoundingBox(render.player.borderTiles());
} else {
console.log('skipping box calculation')
}
}
if (render.isVisible && now - render.lastRenderCalc > this.refreshRate) {
this.calculateRenderInfo(render)
render.lastRenderCalc = now + this.rand.nextInt(-50, 50)
render.lastRenderCalc = Date.now() + this.rand.nextInt(0, 100)
if (shouldRecalc) {
this.calculateRenderInfo(render)
} else {
console.log('skipping name render')
}
}
}
}
@@ -132,7 +142,6 @@ export class NameLayer implements Layer {
render.fontSize = 0
return
}
render.lastRenderCalc = Date.now() + this.rand.nextInt(0, 100)
const [cell, size] = placeName(this.game, render.player)
render.location = cell
render.fontSize = Math.max(1, Math.floor(size))