From a89f7cc8826335b5d3696260ffa120e3149c6824 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Sat, 6 Apr 2024 15:35:15 -0500 Subject: [PATCH] something happened --- server/src/component.rs | 2 +- server/src/main.rs | 24 +++++++------- .../src/pages/ShipEditor.svelte | 32 ++++++++++++------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/server/src/component.rs b/server/src/component.rs index 3afed02d96a7087164299d13d0f2fc039087e912..f11684f3909095ab68e15976d67cdbe44b4f87a6 100644 --- a/server/src/component.rs +++ b/server/src/component.rs @@ -92,7 +92,7 @@ pub struct Player { pub save_eligibility: bool, pub energy_capacity: u32, pub energy: u32, - pub save_amount: HashMap // PartType, amount of each module type + pub save_amount: HashMap, // PartType, amount of each module type } #[derive(Bundle)] diff --git a/server/src/main.rs b/server/src/main.rs index 873ccbd759a3541c5dc2a048408f7dbf2f1ed095..75536175390a27a15d238d5e4041ec732cb9ee56 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -36,9 +36,7 @@ use component::*; use hmac::{Hmac, Mac}; use jwt::VerifyWithKey; use packet::*; -use part::{ - HEARTY_THRUST_ENERGY, LANDING_THRUSTER_ENERGY, -}; +use part::{HEARTY_THRUST_ENERGY, LANDING_THRUSTER_ENERGY}; use rand::Rng; use serde::{Deserialize, Serialize}; use sha2::Sha256; @@ -320,7 +318,7 @@ fn on_message( } => { // auth // plz no remove - if let Some(token) = jwt { + /*if let Some(token) = jwt { let key: Hmac = Hmac::new_from_slice(&app_keys.app_key).unwrap(); let claims: UserToken = match token.verify_with_key(&key) { Ok(c) => c, @@ -354,7 +352,7 @@ fn on_message( }); event_queue.push(WsEvent::Close { addr: *from }); continue; - } + }*/ let angle: f32 = { let mut rng = rand::thread_rng(); @@ -373,13 +371,11 @@ fn on_message( energy: part::HEARTY_CAPACITY, save_amount: HashMap::new(), }; - let mut entity_id = commands.spawn( - PartBundle { - part_type: PartType::Hearty, - transform: TransformBundle::from(transform), - flags: PartFlags { attached: false }, - }, - ); + let mut entity_id = commands.spawn(PartBundle { + part_type: PartType::Hearty, + transform: TransformBundle::from(transform), + flags: PartFlags { attached: false }, + }); entity_id .insert(Collider::cuboid(0.5, 0.5)) .insert(AdditionalMassProperties::MassProperties(MassProperties { @@ -748,7 +744,9 @@ fn on_message( // THANKS! let unused_modules = if let Some(ref old_save) = old_save { - if let Ok(old_savedata) = unpack_savefile(&app_keys.app_key, old_save.to_string()) { + if let Ok(old_savedata) = + unpack_savefile(&app_keys.app_key, old_save.to_string()) + { old_savedata.unused_modules } else { Vec::new() diff --git a/starkingdoms-client/src/pages/ShipEditor.svelte b/starkingdoms-client/src/pages/ShipEditor.svelte index 8995c7a6293f20e456855d808e27135a63455608..959005f3b227ecffd858fc7ca62e5eeebe87eb90 100644 --- a/starkingdoms-client/src/pages/ShipEditor.svelte +++ b/starkingdoms-client/src/pages/ShipEditor.svelte @@ -161,10 +161,16 @@ let img = textures.get(selected!)!; ctx.save(); - ctx.translate(canvas_x + grid_size/2, canvas_y + grid_size/2); - ctx.rotate(rotation*Math.PI/2); + ctx.translate(canvas_x + grid_size / 2, canvas_y + grid_size / 2); + ctx.rotate((rotation * Math.PI) / 2); ctx.globalAlpha = 0.2; - ctx.drawImage(img, -grid_size/2, -grid_size/2, grid_size, grid_size); + ctx.drawImage( + img, + -grid_size / 2, + -grid_size / 2, + grid_size, + grid_size, + ); ctx.globalCompositeOperation = "source-atop"; if (selected === null) { ctx.fillStyle = "rgb(24, 24, 37)"; @@ -174,7 +180,7 @@ ctx.fillStyle = "rgb(243, 139, 169)"; } ctx.globalAlpha = 0.5; - ctx.fillRect(-grid_size/2, -grid_size/2, grid_size, grid_size); + ctx.fillRect(-grid_size / 2, -grid_size / 2, grid_size, grid_size); ctx.restore(); } })(); @@ -200,7 +206,11 @@ let canvas_x = x_coord * grid_size + x; let canvas_y = y_coord * grid_size + y; - ctx.drawImage(img, canvas_x, canvas_y, grid_size, grid_size); + ctx.save(); + ctx.translate(canvas_x + grid_size / 2, canvas_y + grid_size / 2); + ctx.rotate((rotation * Math.PI) / 2); + ctx.drawImage(img, -grid_size/2, -grid_size/2, grid_size, grid_size); + ctx.restore(); }); }); } @@ -251,13 +261,13 @@ place(x, y + 1, children[0], rotation); } if (children[1] !== null) { - place(x + 1, y, children[1], (rotation+1)%4); + 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 + 2) % 4); } if (children[3] !== null) { - place(x - 1, y, children[3], (rotation+3)%4); + place(x - 1, y, children[3], (rotation + 3) % 4); } } @@ -348,16 +358,16 @@ grid = grid; } } - canvas.focus() + canvas.focus(); } function keydown(e: KeyboardEvent) { console.log("here"); if (e.code == "KeyQ") { - rotation = (rotation - 1) % 4; + rotation = (rotation - 1) % 4; } if (e.code == "KeyE") { - rotation = (rotation + 1) % 4; + rotation = (rotation + 1) % 4; } }