From 2552d0dcdda67e2261c549f8004365843242f76e Mon Sep 17 00:00:00 2001 From: Arkitu <85173315+Arkitu@users.noreply.github.com> Date: Sun, 25 May 2025 08:41:05 +0200 Subject: [PATCH] save --- rust-toolchain.toml | 2 +- src/lib.rs | 1 - src/map/cells.rs | 4 ++-- src/ui.rs | 14 ++++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d56faf..271800c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" +channel = "nightly" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 5396c20..bed4ac6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(duration_constructors)] use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, prelude::*, diff --git a/src/map/cells.rs b/src/map/cells.rs index e896ecf..a90739f 100644 --- a/src/map/cells.rs +++ b/src/map/cells.rs @@ -20,8 +20,8 @@ impl CellKind { pub fn regen_full_growth_duration(&self) -> Duration { match self { CellKind::Sea | CellKind::Beach | CellKind::Dirt | CellKind::Stone => unreachable!(), - CellKind::Forest => Duration::from_days(365 * 100), // Let's say that a forest takes 100 years to mature - CellKind::Grass => Duration::from_weeks(7), // Let's say that grass takes 7 weeks to reach its max + CellKind::Forest => Duration::from_secs(100 * 365 * 24 * 60 * 60), // Let's say that a forest takes 100 years to mature + CellKind::Grass => Duration::from_secs(7 * 7 * 24 * 60 * 60), // Let's say that grass takes 7 weeks to reach its max } } pub fn can_place_animal(&self, kind: AnimalKind) -> bool { diff --git a/src/ui.rs b/src/ui.rs index faefc74..31cc640 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -65,7 +65,7 @@ fn setup(mut world: Commands, asset_server: Res) { .observe(| trigger: Trigger>, mut ptrs: Query<&mut PointersDragging>, - mut cam: Query<(&mut Transform, &PerspectiveProjection), With>, + mut cam: Query<&mut Transform, With>, | { if trigger.button == PointerButton::Primary { let mut ptrs = ptrs.single_mut(); @@ -81,12 +81,14 @@ fn setup(mut world: Commands, asset_server: Res) { let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm()); // move camera - cam.0.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.1.fov*0.001; - cam.0.translation.y += (new_midpoint.y - old_midpoint.y)*cam.1.fov*0.001; + cam.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.translation.z*0.001; + cam.translation.y += (new_midpoint.y - old_midpoint.y)*cam.translation.z*0.001; - // if ptrs.0.len() > 1 { - // cam.scale *= old_d_to_midpoint/new_d_to_midpoint; - // } + if ptrs.0.len() > 1 { + let forward = cam.forward(); + cam.translation += forward * (old_d_to_midpoint/new_d_to_midpoint * 0.1); + // cam.scale *= old_d_to_midpoint/new_d_to_midpoint; + } } } );