@@ 264,13 264,13 @@
});
if (children[0] !== null) {
- place(x, y + 1, children[0], rotation);
+ place(x, y + 1, children[0], (rotation + 2) % 4);
}
if (children[1] !== null) {
place(x + 1, y, children[1], (rotation + 1) % 4);
}
if (children[2] !== null) {
- place(x, y - 1, children[2], (rotation + 2) % 4);
+ place(x, y - 1, children[2], rotation);
}
if (children[3] !== null) {
place(x - 1, y, children[3], (rotation + 3) % 4);
@@ 296,10 296,41 @@
}, 5000);
}
+ function save_recursive(x: number, y: number) {
+ let [part_type, rotation] = grid.get(x)!.get(y)!;
+ let children = [null, null, null, null];
+ if (part_type == PartType.Hearty) {
+ if (grid.get(x+1)?.get(y)?.[1] == 1) { // right
+ children[1] = save_recursive(x+1, y);
+ }
+ if (grid.get(x-1)?.get(y)?.[1] == 3) { // left
+ children[3] = save_recursive(x-1, y);
+ }
+ if (grid.get(x)?.get(y-1)?.[1] == 0) { // up
+ children[2] = save_recursive(x, y-1);
+ }
+ if (grid.get(x)?.get(y+1)?.[1] == 2) { // down
+ children[0] = save_recursive(x, y+1);
+ }
+ } else if (part_type == PartType.Cargo) {}
+
+ return {part_type: part_type, children: children};
+ }
+
function save_btn() {
if (confirm_save) {
// todo: @ghostly you need to turn this back into a savefile and then call pack_partial on it
- window.location.href = "/";
+ let children = save_recursive(0, 0).children;
+ let unused_modules = [];
+ for (let [part_type, value] of part_counts) {
+ let unused = value.available - value.used;
+ if (unused != 0 && part_type != PartType.Hearty) {
+ unused_modules.push([part_type, unused]);
+ }
+ }
+ let save_data = { children: children, unused_modules: unused_modules };
+ console.log(save_data);
+ //window.location.href = "/";
}
confirm_save = !confirm_save;
setTimeout(() => {
@@ 368,7 399,6 @@
}
function keydown(e: KeyboardEvent) {
- console.log("here");
if (e.code == "KeyQ") {
rotation = (rotation - 1) % 4;
}