mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-21 19:41:23 +01:00
Reset burg and state cultures after regeneration
This commit is contained in:
parent
d83e327036
commit
d24f92efab
2 changed files with 28 additions and 2 deletions
|
|
@ -353,6 +353,31 @@
|
|||
console.timeEnd("normalizeStates");
|
||||
}
|
||||
|
||||
// Resets the cultures of all burgs and states to their
|
||||
// cell or center cell's (respectively) culture.
|
||||
const resetCultures = function () {
|
||||
console.time('resetCulturesForBurgsAndStates');
|
||||
// Pull out index 0 nodes so iterators don't touch them.
|
||||
const burgTreeNode = pack.burgs.shift();
|
||||
const neutralsStateNode = pack.states.shift();
|
||||
|
||||
// Assign the culture associated with the burgs cell.
|
||||
pack.burgs = pack.burgs.map( (burg) => {
|
||||
return {...burg, culture: pack.cells.culture[burg.cell]};
|
||||
});
|
||||
|
||||
// Assign the culture associated with the states' center cell.
|
||||
pack.states = pack.states.map( (state) => {
|
||||
return {...state, culture: pack.cells.culture[state.center]};
|
||||
});
|
||||
|
||||
// Prepend the index 0 nodes back onto the packgroups.
|
||||
pack.burgs.unshift(burgTreeNode);
|
||||
pack.states.unshift(neutralsStateNode);
|
||||
|
||||
console.timeEnd('resetCulturesForBurgsAndStates');
|
||||
}
|
||||
|
||||
// calculate and draw curved state labels for a list of states
|
||||
const drawStateLabels = function(list) {
|
||||
console.time("drawStateLabels");
|
||||
|
|
@ -1027,6 +1052,6 @@
|
|||
|
||||
return {generate, expandStates, normalizeStates, assignColors,
|
||||
drawBurgs, specifyBurgs, defineBurgFeatures, drawStateLabels, collectStatistics,
|
||||
generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces};
|
||||
generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, resetCultures};
|
||||
|
||||
})));
|
||||
|
|
|
|||
|
|
@ -248,8 +248,9 @@ function regenerateReligions() {
|
|||
function regenerateCultures() {
|
||||
Cultures.generate();
|
||||
Cultures.expand();
|
||||
BurgsAndStates.resetCultures();
|
||||
if (!layerIsOn("toggleCultures")) toggleCultures(); else drawCultures();
|
||||
if (document.getElementById("culturesEditorRefresh").offsetParent) culturesEditorRefresh.click();
|
||||
refreshAllEditors();
|
||||
}
|
||||
|
||||
function regenerateMilitary() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue