made name rendering more efficient

This commit is contained in:
Evan
2025-01-20 20:58:15 -08:00
parent 70a5b8883e
commit e4f0d76733
5 changed files with 33 additions and 8 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ import { Cell, DisplayMessageUpdate, Game, GameUpdateType, MessageType, MutableG
import { createGame } from "./game/GameImpl";
import { loadTerrainMap as loadGameMap } from "./game/TerrainMapLoader";
import { GameConfig, Turn } from "./Schemas";
import { GameUpdateViewData} from "./GameView";
import { GameUpdateViewData } from "./GameView";
import { andFN, manhattanDistFN, TileRef } from "./game/GameMap";
import { targetTransportTile } from "./Util";
@@ -62,8 +62,8 @@ export class GameRunner {
this.game.addExecution(...this.execManager.createExecs(this.turns[this.currTurn]))
this.currTurn++
const updates = this.game.executeNextTick()
if (this.game.inSpawnPhase() || this.game.ticks() % 20 == 0) {
// TODO: make name rendering more efficient in spawn phase.
if (this.game.inSpawnPhase() || this.game.ticks() % 30 == 0) {
this.game.players().forEach(p => {
this.playerViewData[p.id()] = placeName(this.game, p)
})
+1
View File
@@ -95,6 +95,7 @@ export class PlayerExecution implements Execution {
clusters.sort((a, b) => b.size - a.size);
const main = clusters.shift()
this.player.largestClusterBoundingBox = calculateBoundingBox(this.mg, main)
const surroundedBy = this.surroundedBySamePlayer(main)
if (surroundedBy && !this.player.isAlliedWith(surroundedBy)) {
this.removeCluster(main)
+1
View File
@@ -259,6 +259,7 @@ export interface Player {
}
export interface MutablePlayer extends Player {
largestClusterBoundingBox: { min: Cell, max: Cell } | null
// Targets for this player
targets(): Player[]
// Targets of player and all allies.
+3
View File
@@ -56,6 +56,9 @@ export class PlayerImpl implements MutablePlayer {
this._displayName = this._name // processName(this._name)
}
largestClusterBoundingBox: { min: Cell, max: Cell } | null
toUpdate(): PlayerUpdate {
return {
type: GameUpdateType.Player,