mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
refactor: refactor greneration routine
This commit is contained in:
parent
d1208b12ec
commit
6b2de4d20e
19 changed files with 401 additions and 292 deletions
4
src/types/globals.d.ts
vendored
4
src/types/globals.d.ts
vendored
|
|
@ -1,5 +1,5 @@
|
|||
declare const grid: IGrid;
|
||||
declare const pack: IPack;
|
||||
declare let grid: IGrid;
|
||||
declare let pack: IPack;
|
||||
|
||||
declare let seed: string;
|
||||
declare let mapId: number;
|
||||
|
|
|
|||
18
src/types/graph.d.ts
vendored
Normal file
18
src/types/graph.d.ts
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// generic part of any graph, simplest verstion of IGrid and IGraph
|
||||
interface IGraph {
|
||||
vertices: IGraphVertices;
|
||||
cells: IGraphCells;
|
||||
}
|
||||
|
||||
interface IGraphVertices {
|
||||
p: TPoints;
|
||||
v: number[][];
|
||||
c: number[][];
|
||||
}
|
||||
|
||||
interface IGraphCells {
|
||||
i: UintArray;
|
||||
b: UintArray;
|
||||
c: number[][];
|
||||
v: number[][];
|
||||
}
|
||||
39
src/types/grid.d.ts
vendored
39
src/types/grid.d.ts
vendored
|
|
@ -1,28 +1,27 @@
|
|||
interface IGrid {
|
||||
interface IGrid extends IGraph {
|
||||
cellsDesired: number;
|
||||
cellsX: number;
|
||||
cellsY: number;
|
||||
spacing: number;
|
||||
boundary: TPoints;
|
||||
points: TPoints;
|
||||
vertices: {
|
||||
p: TPoints;
|
||||
v: number[][];
|
||||
c: number[][];
|
||||
};
|
||||
cells: {
|
||||
i: UintArray;
|
||||
b: UintArray;
|
||||
c: number[][];
|
||||
v: number[][];
|
||||
h: UintArray;
|
||||
t: UintArray;
|
||||
f: UintArray;
|
||||
temp: UintArray;
|
||||
prec: UintArray;
|
||||
};
|
||||
features: IGridFeature[];
|
||||
cells: IGridCells;
|
||||
features: TGridFeatures;
|
||||
}
|
||||
|
||||
interface IGridCells extends IGraphCells {
|
||||
h: UintArray; // heights, [0, 100], see MIN_LAND_HEIGHT constant
|
||||
t: Int8Array; // see DISTANCE_FIELD enum
|
||||
f: Uint16Array; // feature id, see IGridFeature
|
||||
temp: UintArray; // temparature in Celsius
|
||||
prec: UintArray; // precipitation in inner units
|
||||
}
|
||||
|
||||
type TGridFeatures = [0, ...IGridFeature[]];
|
||||
|
||||
interface IGridFeature {
|
||||
i: number;
|
||||
i: number; // starts from 1, not 0
|
||||
land: boolean;
|
||||
border: boolean;
|
||||
border: boolean; // if touches map edge
|
||||
type: "ocean" | "lake" | "island";
|
||||
}
|
||||
|
|
|
|||
6
src/types/overrides.d.ts
vendored
6
src/types/overrides.d.ts
vendored
|
|
@ -6,14 +6,16 @@ interface Navigator {
|
|||
|
||||
interface Window {
|
||||
mapCoordinates: IMapCoordinates;
|
||||
// untyped IIFE modules
|
||||
$: typeof $;
|
||||
d3: typeof d3;
|
||||
// untyped IIFE modules
|
||||
Biomes: typeof Biomes;
|
||||
Names: typeof Names;
|
||||
ThreeD: typeof ThreeD;
|
||||
ReliefIcons: typeof ReliefIcons;
|
||||
Zoom: typeof Zoom;
|
||||
Lakes: typeof Lakes;
|
||||
HeightmapGenerator: typeof HeightmapGenerator;
|
||||
OceanLayers: typeof OceanLayers;
|
||||
}
|
||||
|
||||
interface Node {
|
||||
|
|
|
|||
64
src/types/pack.d.ts
vendored
64
src/types/pack.d.ts
vendored
|
|
@ -1,35 +1,6 @@
|
|||
interface IPack {
|
||||
vertices: {
|
||||
p: TPoints;
|
||||
v: number[][];
|
||||
c: number[][];
|
||||
};
|
||||
features: TPackFeature[];
|
||||
cells: {
|
||||
i: UintArray;
|
||||
p: TPoints;
|
||||
v: number[][];
|
||||
c: number[][];
|
||||
g: UintArray;
|
||||
h: UintArray;
|
||||
t: UintArray;
|
||||
f: UintArray;
|
||||
s: IntArray;
|
||||
pop: Float32Array;
|
||||
fl: UintArray;
|
||||
conf: UintArray;
|
||||
r: UintArray;
|
||||
biome: UintArray;
|
||||
area: UintArray;
|
||||
state: UintArray;
|
||||
culture: UintArray;
|
||||
religion: UintArray;
|
||||
province: UintArray;
|
||||
burg: UintArray;
|
||||
haven: UintArray;
|
||||
harbor: UintArray;
|
||||
q: d3.Quadtree<number[]>;
|
||||
};
|
||||
interface IPack extends IGraph {
|
||||
cells: IPackCells;
|
||||
features: TPackFeatures;
|
||||
states: IState[];
|
||||
cultures: ICulture[];
|
||||
provinces: IProvince[];
|
||||
|
|
@ -38,18 +9,41 @@ interface IPack {
|
|||
religions: IReligion[];
|
||||
}
|
||||
|
||||
interface IPackCells extends IGraphCells {
|
||||
p: TPoints; // cell center points
|
||||
h: UintArray; // heights, [0, 100], see MIN_LAND_HEIGHT constant
|
||||
t: Int8Array; // see DISTANCE_FIELD enum
|
||||
f: Uint16Array; // feature id, see TPackFeature
|
||||
g: UintArray;
|
||||
s: IntArray;
|
||||
pop: Float32Array;
|
||||
fl: UintArray;
|
||||
conf: UintArray;
|
||||
r: UintArray;
|
||||
biome: UintArray;
|
||||
area: UintArray;
|
||||
state: UintArray;
|
||||
culture: UintArray;
|
||||
religion: UintArray;
|
||||
province: UintArray;
|
||||
burg: UintArray;
|
||||
haven: UintArray;
|
||||
harbor: UintArray;
|
||||
q: d3.Quadtree<number[]>;
|
||||
}
|
||||
|
||||
interface IPackFeatureBase {
|
||||
i: number; // feature id starting from 1
|
||||
border: boolean; // if touches map border
|
||||
cells: number; // number of cells
|
||||
firstCell: number; // index of the top left cell
|
||||
vertices: number[]; // indexes of perimetric vertices
|
||||
vertices?: number[]; // indexes of perimetric vertices
|
||||
}
|
||||
|
||||
interface IPackFeatureOcean extends IPackFeatureBase {
|
||||
land: false;
|
||||
type: "ocean";
|
||||
group: "ocean";
|
||||
group: "ocean" | "sea" | "gulf";
|
||||
}
|
||||
|
||||
interface IPackFeatureIsland extends IPackFeatureBase {
|
||||
|
|
@ -67,6 +61,8 @@ interface IPackFeatureLake extends IPackFeatureBase {
|
|||
|
||||
type TPackFeature = IPackFeatureOcean | IPackFeatureIsland | IPackFeatureLake;
|
||||
|
||||
type TPackFeatures = [0, ...TPackFeature[]];
|
||||
|
||||
interface IState {
|
||||
i: number;
|
||||
name: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue