save
This commit is contained in:
parent
4a401182fb
commit
2552d0dcdd
@ -1,4 +1,3 @@
|
|||||||
#![feature(duration_constructors)]
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
@ -20,8 +20,8 @@ impl CellKind {
|
|||||||
pub fn regen_full_growth_duration(&self) -> Duration {
|
pub fn regen_full_growth_duration(&self) -> Duration {
|
||||||
match self {
|
match self {
|
||||||
CellKind::Sea | CellKind::Beach | CellKind::Dirt | CellKind::Stone => unreachable!(),
|
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::Forest => Duration::from_secs(100 * 365 * 24 * 60 * 60), // 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::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 {
|
pub fn can_place_animal(&self, kind: AnimalKind) -> bool {
|
||||||
|
14
src/ui.rs
14
src/ui.rs
@ -65,7 +65,7 @@ fn setup(mut world: Commands, asset_server: Res<AssetServer>) {
|
|||||||
.observe(|
|
.observe(|
|
||||||
trigger: Trigger<Pointer<Drag>>,
|
trigger: Trigger<Pointer<Drag>>,
|
||||||
mut ptrs: Query<&mut PointersDragging>,
|
mut ptrs: Query<&mut PointersDragging>,
|
||||||
mut cam: Query<(&mut Transform, &PerspectiveProjection), With<CameraMarker>>,
|
mut cam: Query<&mut Transform, With<CameraMarker>>,
|
||||||
| {
|
| {
|
||||||
if trigger.button == PointerButton::Primary {
|
if trigger.button == PointerButton::Primary {
|
||||||
let mut ptrs = ptrs.single_mut();
|
let mut ptrs = ptrs.single_mut();
|
||||||
@ -81,12 +81,14 @@ fn setup(mut world: Commands, asset_server: Res<AssetServer>) {
|
|||||||
let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
||||||
|
|
||||||
// move camera
|
// move camera
|
||||||
cam.0.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.1.fov*0.001;
|
cam.translation.x -= (new_midpoint.x - old_midpoint.x)*cam.translation.z*0.001;
|
||||||
cam.0.translation.y += (new_midpoint.y - old_midpoint.y)*cam.1.fov*0.001;
|
cam.translation.y += (new_midpoint.y - old_midpoint.y)*cam.translation.z*0.001;
|
||||||
|
|
||||||
// if ptrs.0.len() > 1 {
|
if ptrs.0.len() > 1 {
|
||||||
// cam.scale *= old_d_to_midpoint/new_d_to_midpoint;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user