mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:00:44 +00:00
tile perf improvements
This commit is contained in:
@@ -149,7 +149,13 @@ export class TerritoryLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
paintTerritory(tile: Tile) {
|
||||
paintTerritory(tile: Tile, isBorder: boolean = false, parent: Tile = null) {
|
||||
if (isBorder && !tile.hasOwner()) {
|
||||
return
|
||||
}
|
||||
if (!isBorder) {
|
||||
tile.neighbors().forEach(t => this.paintTerritory(t, true, tile))
|
||||
}
|
||||
if (!tile.hasOwner()) {
|
||||
if (tile.hasFallout()) {
|
||||
this.paintCell(tile.cell(), this.theme.falloutColor(), 150)
|
||||
|
||||
+14
-4
@@ -8,6 +8,8 @@ import { WorkerClient } from './worker/WorkerClient';
|
||||
|
||||
export class TileView {
|
||||
|
||||
private _neighbors: TileView[] = []
|
||||
|
||||
constructor(private game: GameView, public data: TileUpdate, private _terrain: TerrainTile) { }
|
||||
|
||||
type(): TerrainType {
|
||||
@@ -23,7 +25,12 @@ export class TileView {
|
||||
return this.data?.ownerID !== undefined && this.data.ownerID !== 0;
|
||||
}
|
||||
isBorder(): boolean {
|
||||
return this.data?.isBorder
|
||||
for (const n of this.neighbors()) {
|
||||
if (n.data?.ownerID != this.data?.ownerID) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
cell(): Cell {
|
||||
return this._terrain.cell()
|
||||
@@ -35,8 +42,11 @@ export class TileView {
|
||||
return this._terrain
|
||||
}
|
||||
|
||||
neighbors(): Tile[] {
|
||||
return this._terrain.neighbors().map(t => this.game.tile(t.cell()))
|
||||
neighbors(): TileView[] {
|
||||
if (this._neighbors.length == 0) {
|
||||
this._neighbors = this._terrain.neighbors().map(t => this.game.tile(t.cell()))
|
||||
}
|
||||
return this._neighbors
|
||||
}
|
||||
|
||||
hasDefenseBonus(): boolean {
|
||||
@@ -303,7 +313,7 @@ export class GameView {
|
||||
players(): Player[] {
|
||||
return []
|
||||
}
|
||||
tile(cell: Cell): Tile {
|
||||
tile(cell: Cell): TileView {
|
||||
return this.tiles[cell.x][cell.y]
|
||||
}
|
||||
isOnMap(cell: Cell): boolean {
|
||||
|
||||
@@ -399,7 +399,7 @@ export class GameImpl implements MutableGame {
|
||||
(t.owner() as PlayerImpl)._borderTiles.delete(t);
|
||||
t._isBorder = false
|
||||
}
|
||||
this.updates.push(t.toUpdate())
|
||||
// this.updates.push(t.toUpdate())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user