mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor: don'r store events globally
This commit is contained in:
parent
37826f1c2d
commit
0d1b52e538
5 changed files with 8 additions and 7 deletions
|
|
@ -5,7 +5,6 @@ let grid = {}; // initial graph based on jittered square grid and data
|
||||||
let pack = {}; // packed graph and data
|
let pack = {}; // packed graph and data
|
||||||
|
|
||||||
let notes = [];
|
let notes = [];
|
||||||
let events = {};
|
|
||||||
|
|
||||||
let seed;
|
let seed;
|
||||||
let mapId;
|
let mapId;
|
||||||
|
|
|
||||||
|
|
@ -53,14 +53,13 @@ async function generate(options?: IGenerationOptions) {
|
||||||
window.mapCoordinates = calculateMapCoordinates();
|
window.mapCoordinates = calculateMapCoordinates();
|
||||||
|
|
||||||
const newGrid = await createGrid(grid, precreatedGraph);
|
const newGrid = await createGrid(grid, precreatedGraph);
|
||||||
const {pack: newPack, conflicts} = createPack(newGrid);
|
const newPack = createPack(newGrid);
|
||||||
|
|
||||||
// TODO: draw default ruler
|
// TODO: draw default ruler
|
||||||
|
|
||||||
// redefine global grid and pack
|
// redefine global grid and pack
|
||||||
grid = newGrid;
|
grid = newGrid;
|
||||||
pack = newPack;
|
pack = newPack;
|
||||||
events = {conflicts};
|
|
||||||
|
|
||||||
// temp rendering for debug
|
// temp rendering for debug
|
||||||
// renderLayer("cells");
|
// renderLayer("cells");
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {generateReligions} from "./religions/generateReligions";
|
||||||
const {LAND_COAST, WATER_COAST, DEEPER_WATER} = DISTANCE_FIELD;
|
const {LAND_COAST, WATER_COAST, DEEPER_WATER} = DISTANCE_FIELD;
|
||||||
const {Biomes} = window;
|
const {Biomes} = window;
|
||||||
|
|
||||||
export function createPack(grid: IGrid): {pack: IPack; conflicts: IConflict[]} {
|
export function createPack(grid: IGrid): IPack {
|
||||||
const {temp, prec} = grid.cells;
|
const {temp, prec} = grid.cells;
|
||||||
const {vertices, cells} = repackGrid(grid);
|
const {vertices, cells} = repackGrid(grid);
|
||||||
|
|
||||||
|
|
@ -168,6 +168,8 @@ export function createPack(grid: IGrid): {pack: IPack; conflicts: IConflict[]} {
|
||||||
// drawScaleBar(window.scale);
|
// drawScaleBar(window.scale);
|
||||||
// Names.getMapName();
|
// Names.getMapName();
|
||||||
|
|
||||||
|
const events: IEvents = {conflicts};
|
||||||
|
|
||||||
const pack: IPack = {
|
const pack: IPack = {
|
||||||
vertices,
|
vertices,
|
||||||
cells: {
|
cells: {
|
||||||
|
|
@ -196,10 +198,11 @@ export function createPack(grid: IGrid): {pack: IPack; conflicts: IConflict[]} {
|
||||||
states,
|
states,
|
||||||
burgs,
|
burgs,
|
||||||
routes,
|
routes,
|
||||||
religions
|
religions,
|
||||||
|
events
|
||||||
};
|
};
|
||||||
|
|
||||||
return {pack, conflicts};
|
return pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
// repack grid cells: discart deep water cells, add land cells along the coast
|
// repack grid cells: discart deep water cells, add land cells along the coast
|
||||||
|
|
|
||||||
1
src/types/globals.d.ts
vendored
1
src/types/globals.d.ts
vendored
|
|
@ -2,7 +2,6 @@ declare let grid: IGrid;
|
||||||
declare let pack: IPack;
|
declare let pack: IPack;
|
||||||
|
|
||||||
declare let notes: INote[];
|
declare let notes: INote[];
|
||||||
declare let events: IEvents;
|
|
||||||
|
|
||||||
declare let seed: string;
|
declare let seed: string;
|
||||||
declare let mapId: number;
|
declare let mapId: number;
|
||||||
|
|
|
||||||
1
src/types/pack/pack.d.ts
vendored
1
src/types/pack/pack.d.ts
vendored
|
|
@ -8,6 +8,7 @@ interface IPack extends IGraph {
|
||||||
rivers: TRivers;
|
rivers: TRivers;
|
||||||
religions: TReligions;
|
religions: TReligions;
|
||||||
routes: TRoutes;
|
routes: TRoutes;
|
||||||
|
events: IEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IPackCells {
|
interface IPackCells {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue