mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
Urquhart routes (#1072)
* feat: routes generation * feat: routes rendering * feat: searoutes fix, changing reGraph * feat: searoute - change pathfinding algo * feat: routes - cleanup code * feat: routes - change data format * feat: routes - add routes to json export * feat: edit routes - start * feat: edit routes - main * feat: edit routes - EP * feat: edit routes - remove route * feat: route - generate names * feat: route - continue * Refactor route merging logic for improved performance * feat: routes - show name in tooltip * feat: routes - create route dialog * feat: update data on control point remove * feat: routes editor - split route * feat: add join route functionality to routes editor * feat: Add join route functionality to routes editor * feat: Update join route tooltip in routes editor * feat: routes overview - sort by length * feat: routes overview - fix distanceScale value * feat: routes overview - create route * Refactor getMiddlePoint function to getCloseToEdgePoint * feat: routes - change data format, fix issues * feat: routes - regenerateRoutes * feat: routes - add route on burg creation * chore - remove merge conflict markers * chore - remove merge conflict markers * feat: routes name - no unnamed burg names * feat: routes - lock routes * fix: routes - split routes * feat: routes - tip correction * feat: routes - auto-update part 1 * feat: routes - return old rePacj logic to not break auto-update * feat: routes - auto-update - add connections --------- Co-authored-by: Azgaar <azgaar.fmg@yandex.com>
This commit is contained in:
parent
c6dd331eb6
commit
f19b891421
47 changed files with 2462 additions and 1032 deletions
32
main.js
32
main.js
|
|
@ -647,6 +647,7 @@ async function generate(options) {
|
|||
Cultures.generate();
|
||||
Cultures.expand();
|
||||
BurgsAndStates.generate();
|
||||
Routes.generate();
|
||||
Religions.generate();
|
||||
BurgsAndStates.defineStateForms();
|
||||
BurgsAndStates.generateProvinces();
|
||||
|
|
@ -1175,10 +1176,11 @@ function reGraph() {
|
|||
for (const i of gridCells.i) {
|
||||
const height = gridCells.h[i];
|
||||
const type = gridCells.t[i];
|
||||
|
||||
if (height < 20 && type !== -1 && type !== -2) continue; // exclude all deep ocean points
|
||||
if (type === -2 && (i % 4 === 0 || features[gridCells.f[i]].type === "lake")) continue; // exclude non-coastal lake points
|
||||
const [x, y] = points[i];
|
||||
|
||||
const [x, y] = points[i];
|
||||
addNewPoint(i, x, y, height);
|
||||
|
||||
// add additional points for cells along coast
|
||||
|
|
@ -1406,8 +1408,8 @@ function reMarkFeatures() {
|
|||
queue[0] = cells.f.findIndex(f => !f); // find unmarked cell
|
||||
}
|
||||
|
||||
// markupPackLand
|
||||
markup(pack.cells, 3, 1, 0);
|
||||
markup(pack.cells, 3, 1, 0); // markupPackLand
|
||||
markup(pack.cells, -2, -1, -10); // markupPackWater
|
||||
|
||||
function defineHaven(i) {
|
||||
const water = cells.c[i].filter(c => cells.h[c] < 20);
|
||||
|
|
@ -1645,9 +1647,10 @@ function addZones(number = 1) {
|
|||
const burg = ra(burgs.filter(b => !used[b.cell] && b.i && !b.removed)); // random burg
|
||||
if (!burg) return;
|
||||
|
||||
const cellsArray = [],
|
||||
cost = [],
|
||||
power = rand(20, 37);
|
||||
const cellsArray = [];
|
||||
const cost = [];
|
||||
const power = rand(20, 37);
|
||||
|
||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||
queue.queue({e: burg.cell, p: 0});
|
||||
|
||||
|
|
@ -1656,15 +1659,14 @@ function addZones(number = 1) {
|
|||
if (cells.burg[next.e] || cells.pop[next.e]) cellsArray.push(next.e);
|
||||
used[next.e] = 1;
|
||||
|
||||
cells.c[next.e].forEach(function (e) {
|
||||
const r = cells.road[next.e];
|
||||
const c = r ? Math.max(10 - r, 1) : 100;
|
||||
cells.c[next.e].forEach(nextCellId => {
|
||||
const c = Routes.getRoute(next.e, nextCellId) ? 5 : 100;
|
||||
const p = next.p + c;
|
||||
if (p > power) return;
|
||||
|
||||
if (!cost[e] || p < cost[e]) {
|
||||
cost[e] = p;
|
||||
queue.queue({e, p});
|
||||
if (!cost[nextCellId] || p < cost[nextCellId]) {
|
||||
cost[nextCellId] = p;
|
||||
queue.queue({e: nextCellId, p});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1785,10 +1787,10 @@ function addZones(number = 1) {
|
|||
}
|
||||
|
||||
function addAvalanche() {
|
||||
const roads = cells.i.filter(i => !used[i] && cells.road[i] && cells.h[i] >= 70);
|
||||
if (!roads.length) return;
|
||||
const routes = cells.i.filter(i => !used[i] && Routes.isConnected(i) && cells.h[i] >= 70);
|
||||
if (!routes.length) return;
|
||||
|
||||
const cell = +ra(roads);
|
||||
const cell = +ra(routes);
|
||||
const cellsArray = [],
|
||||
queue = [cell],
|
||||
power = rand(3, 15);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue