mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 10:22:12 +00:00
use tiles to improve perf
This commit is contained in:
@@ -56,12 +56,12 @@ class Client {
|
||||
this.lobbiesContainer.appendChild(button);
|
||||
});
|
||||
|
||||
// Join first lobby
|
||||
if (!this.hasJoined && lobbies.length > 0) {
|
||||
this.hasJoined = true
|
||||
console.log(`joining lobby ${lobbies[0].id}`)
|
||||
this.joinLobby(lobbies[0].id)
|
||||
}
|
||||
// // Join first lobby
|
||||
// if (!this.hasJoined && lobbies.length > 0) {
|
||||
// this.hasJoined = true
|
||||
// console.log(`joining lobby ${lobbies[0].id}`)
|
||||
// this.joinLobby(lobbies[0].id)
|
||||
// }
|
||||
}
|
||||
|
||||
async fetchLobbies() {
|
||||
|
||||
@@ -95,7 +95,7 @@ export class ClientGame {
|
||||
|
||||
this.renderer.initialize()
|
||||
this.input.initialize()
|
||||
this.executor.spawnBots(500)
|
||||
this.executor.spawnBots(1000)
|
||||
|
||||
|
||||
setInterval(() => this.tick(), 10);
|
||||
@@ -148,7 +148,7 @@ export class ClientGame {
|
||||
const owner = tile.owner()
|
||||
const targetID = owner.isPlayer() ? owner.id() : null
|
||||
if (tile.owner() != this.myPlayer) {
|
||||
if (this.myPlayer.sharesBorderWith(tile.owner())) {
|
||||
if (this.myPlayer.sharesBorderWith(tile.owner())) {
|
||||
this.sendAttackIntent(targetID, cell)
|
||||
} else {
|
||||
// TODO verify on ocean
|
||||
|
||||
@@ -193,15 +193,15 @@ export class GameRenderer {
|
||||
|
||||
tileUpdate(event: TileEvent) {
|
||||
this.paintTile(event.tile)
|
||||
this.gs.neighbors(event.tile.cell()).forEach(c => this.paintTile(this.gs.tile(c)))
|
||||
event.tile.neighbors().forEach(t => this.paintTile(t))
|
||||
}
|
||||
|
||||
playerEvent(event: PlayerEvent) {
|
||||
}
|
||||
|
||||
boatEvent(event: BoatEvent) {
|
||||
this.paintCell(event.boat.cell(), new Colord({r: 255, g: 255, b: 255}))
|
||||
this.gs.neighbors(event.boat.cell()).map(c => this.gs.tile(c)).forEach(t => this.paintTile(t))
|
||||
this.paintCell(event.boat.tile().cell(), new Colord({r: 255, g: 255, b: 255}))
|
||||
this.gs.neighbors(event.boat.tile()).forEach(t => this.paintTile(t))
|
||||
}
|
||||
|
||||
resize(width: number, height: number): void {
|
||||
|
||||
Reference in New Issue
Block a user