mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
refactor: lake group detection and features rendering
This commit is contained in:
parent
4a15dc3243
commit
4b874246e3
10 changed files with 52 additions and 60 deletions
|
|
@ -209,7 +209,6 @@ export function resolveVersionConflicts(version) {
|
|||
lakes.selectAll("path").remove();
|
||||
|
||||
reMarkFeatures(pack, newGrid);
|
||||
drawCoastline(pack);
|
||||
}
|
||||
|
||||
if (version < 1.11) {
|
||||
|
|
|
|||
|
|
@ -8,18 +8,6 @@ import {DISTANCE_FIELD, MIN_LAND_HEIGHT} from "config/generation";
|
|||
import {byId} from "utils/shorthands";
|
||||
|
||||
window.Lakes = (function () {
|
||||
const defineGroup = function (pack: IPack) {
|
||||
for (const feature of pack.features) {
|
||||
if (feature && feature.type === "lake") {
|
||||
const lakeEl = lakes.select(`[data-f="${feature.i}"]`).node();
|
||||
if (!lakeEl) continue;
|
||||
|
||||
feature.group = getGroup(feature);
|
||||
byId(feature.group)?.appendChild(lakeEl);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const generateName = function () {
|
||||
Math.random = aleaPRNG(seed);
|
||||
for (const feature of pack.features) {
|
||||
|
|
@ -34,20 +22,6 @@ window.Lakes = (function () {
|
|||
return Names.getCulture(culture);
|
||||
};
|
||||
|
||||
function getGroup(feature) {
|
||||
if (feature.temp < -3) return "frozen";
|
||||
if (feature.height > 60 && feature.cells < 10 && feature.firstCell % 10 === 0) return "lava";
|
||||
|
||||
if (!feature.inlets && !feature.outlet) {
|
||||
if (feature.evaporation > feature.flux * 4) return "dry";
|
||||
if (feature.cells < 3 && feature.firstCell % 10 === 0) return "sinkhole";
|
||||
}
|
||||
|
||||
if (!feature.outlet && feature.evaporation > feature.flux) return "salt";
|
||||
|
||||
return "freshwater";
|
||||
}
|
||||
|
||||
const {LAND_COAST, WATER_COAST} = DISTANCE_FIELD;
|
||||
|
||||
function addLakesInDeepDepressions(grid: IGraph & Partial<IGrid>) {
|
||||
|
|
@ -162,11 +136,5 @@ window.Lakes = (function () {
|
|||
TIME && console.timeEnd("openLakes");
|
||||
}
|
||||
|
||||
return {
|
||||
defineGroup,
|
||||
generateName,
|
||||
getName,
|
||||
addLakesInDeepDepressions,
|
||||
openNearSeaLakes
|
||||
};
|
||||
return {generateName, getName, addLakesInDeepDepressions, openNearSeaLakes};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -132,7 +132,6 @@ window.Submap = (function () {
|
|||
// remove misclassified cells
|
||||
stage("Define coastline.");
|
||||
reMarkFeatures(pack, newGrid);
|
||||
drawCoastline(pack);
|
||||
|
||||
/****************************************************/
|
||||
/* Packed Graph */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue