@@ 1655,10 1655,8 @@ fn save_eligibility(
let player = player_query.get(player_entity).unwrap();
if !player.save_eligibility {
if player_eligibilities.contains_key(&player_entity) {
- println!("here");
player_eligibilities.remove(&player_entity);
}
- println!("heretrue");
player_eligibilities.insert(player_entity, true);
}
} else {
@@ 1673,7 1671,6 @@ fn save_eligibility(
&& !(player_eligibilities.contains_key(&other)
&& *player_eligibilities.get(&other).unwrap())
{
- println!("herefalse");
player.save_eligibility = false;
player_eligibilities.insert(other, false);
}
@@ 71,11 71,15 @@ export async function hub_connect(
};
global.client = client;
+ let save = window.localStorage.getItem("save");
+ if (save !== null) {
+ save = save.trim();
+ }
let packet: Packet = {
t: PacketType.ClientLogin,
c: {
username,
- save: window.localStorage.getItem("save"),
+ save,
jwt: window.localStorage.getItem("stk-token"),
},
};
@@ 263,17 263,19 @@
available: existing_part_count.available + 1,
});
+ let x_dir = Math.round(Math.cos((rotation+1)*Math.PI/2));
+ let y_dir = Math.round(Math.sin((rotation+1)*Math.PI/2));
if (children[0] !== null) {
- place(x, y + 1, children[0], (rotation + 2) % 4);
+ place(x, y + y_dir, children[0], (rotation + 2) % 4);
}
if (children[1] !== null) {
- place(x + 1, y, children[1], (rotation + 1) % 4);
+ place(x + x_dir, y, children[1], (rotation + 1) % 4);
}
if (children[2] !== null) {
- place(x, y - 1, children[2], rotation);
+ place(x, y - y_dir, children[2], rotation);
}
if (children[3] !== null) {
- place(x - 1, y, children[3], (rotation + 3) % 4);
+ place(x - x_dir, y, children[3], (rotation + 3) % 4);
}
}
@@ 296,31 298,58 @@
}, 5000);
}
- function save_recursive(x: number, y: number) {
+ function save_recursive(x: number, y: number/*, a_rotation: number*/) {
let [part_type, rotation] = grid.get(x)!.get(y)!;
let children = [null, null, null, null];
+ let x_dir = Math.round(Math.cos((rotation+1)*Math.PI/2));
+ let y_dir = Math.round(Math.sin((rotation+1)*Math.PI/2));
+ console.log(x_dir + ", " + y_dir + "(" + rotation + ")");
+ console.log(grid.get(x)?.get(y + y_dir));
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) {}
+ if (grid.get(x + 1)?.get(y)?.[1] == 1) {
+ // right
+ children[1] = save_recursive(x + 1, y, 1);
+ }
+ if (grid.get(x - 1)?.get(y)?.[1] == 3) {
+ // left
+ children[3] = save_recursive(x - 1, y, 3);
+ }
+ if (grid.get(x)?.get(y - 1)?.[1] == 0) {
+ // up
+ children[2] = save_recursive(x, y - 1, 0);
+ }
+ if (grid.get(x)?.get(y + 1)?.[1] == 2) {
+ // down
+ children[0] = save_recursive(x, y + 1, 2);
+ }
+ return { part_type: part_type, children: children };
+ } else if (part_type == PartType.Cargo || part_type == PartType.LandingThruster) {
+ return { part_type: part_type, children: children };
+ }
+ if (grid.get(x + x_dir)?.get(y)?.[1] == (rotation+3)%4) {
+ // left
+ children[3] = save_recursive(x + x_dir, y, rotation+3);
+ }
+ if (grid.get(x - x_dir)?.get(y)?.[1] == (rotation+1)%4) {
+ // right
+ children[1] = save_recursive(x - x_dir, y, rotation+1);
+ }
+ /*if (grid.get(x)?.get(y - y_dir)?.[1] == rotation) {
+ // down
+ children[2] = save_recursive(x, y - y_dir);
+ }*/
+ if (grid.get(x)?.get(y - y_dir)?.[1] == rotation) {
+ // up
+ children[0] = save_recursive(x, y - y_dir, rotation);
+ }
- return {part_type: part_type, children: children};
+ 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
- let children = save_recursive(0, 0).children;
+ let children = save_recursive(0, 0, 0).children;
let unused_modules = [];
for (let [part_type, value] of part_counts) {
let unused = value.available - value.used;