~starkingdoms/starkingdoms

b7d0fea9993fab1ee921d1b01e3a7609bf7f9275 — ghostlyzsh 1 year, 8 months ago 5365ecc
appease tsc
M starkingdoms-client/src/hub.ts => starkingdoms-client/src/hub.ts +1 -3
@@ 19,7 19,6 @@ import { global } from "./globals.ts";
import { startRender } from "./rendering.ts";
import { ButtonType } from "./protocol.ts";
import type Chatbox from "./components/Chatbox.svelte";
import type Button from "./components/ui/Button.svelte";
import { part_texture_url } from "./textures.js";
import * as PIXI from "pixi.js";



@@ 47,7 46,6 @@ export async function hub_connect(
  x_pos: HTMLSpanElement,
  y_pos: HTMLSpanElement,
  energy: HTMLDivElement,
  beam_out_button: Button,
): Promise<ClientHub | null> {
  logger("connecting to client hub at " + url);



@@ 73,7 71,7 @@ export async function hub_connect(

    let save = window.localStorage.getItem("save");
    if (save !== null) {
        save = save.trim();
      save = save.trim();
    }
    let packet: Packet = {
      t: PacketType.ClientLogin,

M starkingdoms-client/src/pages/Play.svelte => starkingdoms-client/src/pages/Play.svelte +1 -3
@@ 25,7 25,6 @@
  //let antialiasing: boolean = false;

  let chatbox: Chatbox;
  let beam_out_button: Button;

  const logger = createDebug("main");
  logger(


@@ 108,7 107,6 @@
      x_pos,
      y_pos,
      energy,
      beam_out_button,
    );
  });
</script>


@@ 167,7 165,7 @@
      <tbody>
        <tr>
          <td id="leave">
            <Button on:click={beam_out} bind:this={beam_out_button}>
            <Button on:click={beam_out}>
              Beam out
            </Button>
          </td>

M starkingdoms-client/src/pages/ShipEditor.svelte => starkingdoms-client/src/pages/ShipEditor.svelte +31 -28
@@ 263,8 263,8 @@
      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));
    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 + y_dir, children[0], (rotation + 2) % 4);
    }


@@ 298,41 298,44 @@
    }, 5000);
  }

  function save_recursive(x: number, y: number/*, a_rotation: 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));
    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, 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 + 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) {
    if (grid.get(x + x_dir)?.get(y)?.[1] == (rotation + 3) % 4) {
      // left
      children[3] = save_recursive(x + x_dir, y, rotation+3);
      children[3] = save_recursive(x + x_dir, y, rotation + 3);
    }
    if (grid.get(x - x_dir)?.get(y)?.[1] == (rotation+1)%4) {
    if (grid.get(x - x_dir)?.get(y)?.[1] == (rotation + 1) % 4) {
      // right
      children[1] = save_recursive(x - x_dir, y, rotation+1);
      children[1] = save_recursive(x - x_dir, y, rotation + 1);
    }
    /*if (grid.get(x)?.get(y - y_dir)?.[1] == rotation) {
      // down