remove borderOnlyChange

This commit is contained in:
Evan
2025-01-03 19:55:02 -08:00
parent beb00fd637
commit 12e535a21f
3 changed files with 2 additions and 26 deletions
+1 -21
View File
@@ -20,7 +20,6 @@ export async function createGameRunner(gameID: string, gameConfig: GameConfig, c
export class GameRunner {
private updatedTiles: Set<MutableTile> = new Set()
private borderOnlyUpdated: Set<MutableTile> = new Set()
private tickInterval = null
private turns: Turn[] = []
private currTurn = 0
@@ -37,11 +36,6 @@ export class GameRunner {
init() {
this.eventBus.on(TileEvent, (e) => {
this.updatedTiles.add(e.tile as MutableTile)
if (e.borderOnlyChange) {
this.borderOnlyUpdated.add(e.tile as MutableTile)
} else {
this.updatedTiles.add(e.tile as MutableTile)
}
})
this.game.addExecution(...this.execManager.spawnBots(this.game.config().numBots()))
if (this.game.config().spawnNPCs()) {
@@ -64,7 +58,6 @@ export class GameRunner {
}
this.isExecuting = true
this.updatedTiles.clear()
this.borderOnlyUpdated.clear()
this.game.addExecution(...this.execManager.createExecs(this.turns[this.currTurn]))
@@ -72,23 +65,10 @@ export class GameRunner {
this.game.executeNextTick()
this.updatedTiles.forEach(t => this.borderOnlyUpdated.delete(t))
const updatedData = Array.from(this.updatedTiles).map(t => t.toViewData())
updatedData.forEach(t => t.borderOnlyChange = false)
const borderOnlyData = Array.from(this.borderOnlyUpdated).map(t => t.toViewData())
borderOnlyData.forEach(t => t.borderOnlyChange = true)
updatedData.concat(borderOnlyData)
this.callBack({
tick: this.game.ticks(),
units: this.game.units().map(u => u.toViewData()),
packedTileUpdates: updatedData.map(d => packTileData(d)),
packedTileUpdates: Array.from(this.updatedTiles).map(t => packTileData(t.toViewData())),
players: Object.fromEntries(
this.game.allPlayers().map(p => [p.id(), p.toViewData()])
) as Record<PlayerID, PlayerViewData>
+1 -4
View File
@@ -19,7 +19,6 @@ export interface TileViewData extends ViewData<TileViewData> {
hasFallout: boolean
hasDefenseBonus: boolean
isBorder: boolean
borderOnlyChange: boolean
}
export class TileView {
@@ -350,8 +349,7 @@ export function packTileData(tile: TileViewData): Uint16Array {
// Pack booleans into bits
packed[3] = (tile.hasFallout ? 1 : 0) |
(tile.hasDefenseBonus ? 2 : 0) |
(tile.isBorder ? 4 : 0) |
(tile.borderOnlyChange ? 8 : 0)
(tile.isBorder ? 4 : 0)
return packed;
}
@@ -364,6 +362,5 @@ export function unpackTileData(packed: Uint16Array): TileViewData {
hasFallout: !!(packed[3] & 1),
hasDefenseBonus: !!(packed[3] & 2),
isBorder: !!(packed[3] & 4),
borderOnlyChange: !!(packed[4] & 8)
};
}
-1
View File
@@ -31,7 +31,6 @@ export class TileImpl implements MutableTile {
hasFallout: this._hasFallout,
hasDefenseBonus: this.hasDefenseBonus(),
isBorder: this.isBorder(),
borderOnlyChange: false,
}
}