mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 04:18:29 +00:00
moved TerrainMap
This commit is contained in:
@@ -190,22 +190,6 @@ class TerraNulliusImpl implements TerraNullius {
|
||||
|
||||
}
|
||||
|
||||
export class TerrainMapImpl implements TerrainMap {
|
||||
|
||||
constructor(public readonly tiles: TerrainType[][]) { }
|
||||
|
||||
terrain(cell: Cell): TerrainType {
|
||||
return this.tiles[cell.x][cell.y]
|
||||
}
|
||||
|
||||
width(): number {
|
||||
return this.tiles.length
|
||||
}
|
||||
|
||||
height(): number {
|
||||
return this.tiles[0].length
|
||||
}
|
||||
}
|
||||
|
||||
export class GameImpl implements MutableGame {
|
||||
private ticks = 0
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
import {Jimp as JimpType, JimpConstructors} from '@jimp/core';
|
||||
import 'jimp';
|
||||
import {TerrainMapImpl} from './GameImpl';
|
||||
import {TerrainTile} from '../../generated/protos';
|
||||
import {Cell} from './Game';
|
||||
|
||||
declare const Jimp: JimpType & JimpConstructors;
|
||||
|
||||
|
||||
export class TerrainMap {
|
||||
|
||||
constructor(public readonly tiles: TerrainType[][]) { }
|
||||
|
||||
terrain(cell: Cell): TerrainType {
|
||||
return this.tiles[cell.x][cell.y]
|
||||
}
|
||||
|
||||
width(): number {
|
||||
return this.tiles.length
|
||||
}
|
||||
|
||||
height(): number {
|
||||
return this.tiles[0].length
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: make terrain api better.
|
||||
export class Terrain {
|
||||
constructor(
|
||||
@@ -22,12 +38,6 @@ export const TerrainTypes = {
|
||||
Water: new Terrain(0, 0)
|
||||
}
|
||||
|
||||
export interface TerrainMap {
|
||||
terrain(cell: Cell): Terrain
|
||||
width(): number
|
||||
height(): number
|
||||
}
|
||||
|
||||
export async function loadTerrainMap(): Promise<TerrainMap> {
|
||||
const imageModule = await import(`../../resources/maps/World.png`);
|
||||
const imageUrl = imageModule.default;
|
||||
@@ -45,5 +55,5 @@ export async function loadTerrainMap(): Promise<TerrainMap> {
|
||||
}
|
||||
})
|
||||
|
||||
return new TerrainMapImpl(terrain);
|
||||
return new TerrainMap(terrain);
|
||||
}
|
||||
Reference in New Issue
Block a user