mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31: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 notes = [];
|
||||
let events = {};
|
||||
|
||||
let seed;
|
||||
let mapId;
|
||||
|
|
|
|||
|
|
@ -53,14 +53,13 @@ async function generate(options?: IGenerationOptions) {
|
|||
window.mapCoordinates = calculateMapCoordinates();
|
||||
|
||||
const newGrid = await createGrid(grid, precreatedGraph);
|
||||
const {pack: newPack, conflicts} = createPack(newGrid);
|
||||
const newPack = createPack(newGrid);
|
||||
|
||||
// TODO: draw default ruler
|
||||
|
||||
// redefine global grid and pack
|
||||
grid = newGrid;
|
||||
pack = newPack;
|
||||
events = {conflicts};
|
||||
|
||||
// temp rendering for debug
|
||||
// renderLayer("cells");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import {generateReligions} from "./religions/generateReligions";
|
|||
const {LAND_COAST, WATER_COAST, DEEPER_WATER} = DISTANCE_FIELD;
|
||||
const {Biomes} = window;
|
||||
|
||||
export function createPack(grid: IGrid): {pack: IPack; conflicts: IConflict[]} {
|
||||
export function createPack(grid: IGrid): IPack {
|
||||
const {temp, prec} = grid.cells;
|
||||
const {vertices, cells} = repackGrid(grid);
|
||||
|
||||
|
|
@ -168,6 +168,8 @@ export function createPack(grid: IGrid): {pack: IPack; conflicts: IConflict[]} {
|
|||
// drawScaleBar(window.scale);
|
||||
// Names.getMapName();
|
||||
|
||||
const events: IEvents = {conflicts};
|
||||
|
||||
const pack: IPack = {
|
||||
vertices,
|
||||
cells: {
|
||||
|
|
@ -196,10 +198,11 @@ export function createPack(grid: IGrid): {pack: IPack; conflicts: IConflict[]} {
|
|||
states,
|
||||
burgs,
|
||||
routes,
|
||||
religions
|
||||
religions,
|
||||
events
|
||||
};
|
||||
|
||||
return {pack, conflicts};
|
||||
return pack;
|
||||
}
|
||||
|
||||
// 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 notes: INote[];
|
||||
declare let events: IEvents;
|
||||
|
||||
declare let seed: string;
|
||||
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;
|
||||
religions: TReligions;
|
||||
routes: TRoutes;
|
||||
events: IEvents;
|
||||
}
|
||||
|
||||
interface IPackCells {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue