mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
refactor: unify ice data structure and streamline ice element handling
This commit is contained in:
parent
a7d9fb3242
commit
f2d98e5bc7
6 changed files with 105 additions and 113 deletions
|
|
@ -1041,7 +1041,8 @@ export function resolveVersionConflicts(mapVersion) {
|
|||
// v1.110.0 moved ice data from SVG to data model
|
||||
// Migrate old ice SVG elements to new pack.ice structure
|
||||
if (!pack.ice) {
|
||||
pack.ice = { glaciers: [], icebergs: [] };
|
||||
pack.ice = [];
|
||||
let iceId = 0;
|
||||
|
||||
const iceLayer = document.getElementById("ice");
|
||||
if (iceLayer) {
|
||||
|
|
@ -1051,15 +1052,15 @@ export function resolveVersionConflicts(mapVersion) {
|
|||
const points = [...polygon.points].map(svgPoint => [svgPoint.x, svgPoint.y]);
|
||||
|
||||
const transform = polygon.getAttribute("transform");
|
||||
|
||||
if (transform) {
|
||||
pack.ice.glaciers.push({
|
||||
const iceElement = {
|
||||
i: iceId++,
|
||||
points,
|
||||
offset: parseTransform(transform)
|
||||
});
|
||||
} else {
|
||||
pack.ice.glaciers.push({ points });
|
||||
type: "glacier"
|
||||
};
|
||||
if (transform) {
|
||||
iceElement.offset = parseTransform(transform);
|
||||
}
|
||||
pack.ice.push(iceElement);
|
||||
});
|
||||
|
||||
// Migrate icebergs
|
||||
|
|
@ -1074,21 +1075,17 @@ export function resolveVersionConflicts(mapVersion) {
|
|||
const points = [...polygon.points].map(svgPoint => [svgPoint.x, svgPoint.y]);
|
||||
|
||||
const transform = polygon.getAttribute("transform");
|
||||
const iceElement = {
|
||||
i: iceId++,
|
||||
points,
|
||||
type: "iceberg",
|
||||
cellId,
|
||||
size
|
||||
};
|
||||
if (transform) {
|
||||
pack.ice.icebergs.push({
|
||||
cellId,
|
||||
size,
|
||||
points,
|
||||
offset: parseTransform(transform)
|
||||
});
|
||||
} else {
|
||||
pack.ice.icebergs.push({
|
||||
cellId,
|
||||
size,
|
||||
points
|
||||
});
|
||||
iceElement.offset = parseTransform(transform);
|
||||
}
|
||||
|
||||
pack.ice.push(iceElement);
|
||||
});
|
||||
|
||||
// Clear old SVG elements
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue