fix: Default gravity parameters

This commit is contained in:
Rendo 2026-08-07 20:26:00 +05:00
commit 12eb4b59b9
2 changed files with 15 additions and 2 deletions

View file

@ -2,7 +2,7 @@ use bevy::prelude::*;
use crate::grid::{Grid,GridElement}; use crate::grid::{Grid,GridElement};
use crate::MAX_FLUID_AMOUNT; use crate::MAX_FLUID_AMOUNT;
const FLUID_FULLNES_STAGES: usize = 7; const FLUID_FULLNES_STAGES: usize = 15;
pub struct GameViewPlugin; pub struct GameViewPlugin;

View file

@ -14,7 +14,8 @@ impl Plugin for UIPlugin {
app.add_plugins(FeathersPlugins) app.add_plugins(FeathersPlugins)
.insert_resource(UiTheme(create_dark_theme())) .insert_resource(UiTheme(create_dark_theme()))
.add_systems(Startup, ui.spawn()) .add_systems(Startup, ui.spawn())
.add_systems(Update, count_water_amount); .add_systems(Update, count_water_amount)
.add_systems(PostStartup, |mut commands: Commands, query: Query<Entity>| query.iter().for_each(|entity| commands.trigger(ReadyPlaceholder(entity)) ));
} }
} }
@ -27,6 +28,9 @@ struct SpeedLabel;
#[derive(Component, Clone, Default)] #[derive(Component, Clone, Default)]
struct ToolLabel; struct ToolLabel;
#[derive(EntityEvent,Clone)]
struct ReadyPlaceholder(Entity);
const MAX_FREQUENCY: u32 = 512; const MAX_FREQUENCY: u32 = 512;
const MIN_FREQUENCY: u32 = 1; const MIN_FREQUENCY: u32 = 1;
@ -245,18 +249,27 @@ fn gravity_control() -> impl Scene {
} }
on(|change: On<ValueChange<f32>>, mut gravity: ResMut<SimulationOptions>| { on(|change: On<ValueChange<f32>>, mut gravity: ResMut<SimulationOptions>| {
gravity.gravity.x = change.value; gravity.gravity.x = change.value;
})
on(|change: On<ReadyPlaceholder>, mut commands: Commands, gravity: Res<SimulationOptions>| {
commands.trigger(UpdateNumberInput { entity: change.0, value: NumberInputValue::F32(gravity.gravity.x) });
}), }),
@FeathersNumberInput { @FeathersNumberInput {
@label_text: "Y" @label_text: "Y"
} }
on(|change: On<ValueChange<f32>>, mut gravity: ResMut<SimulationOptions>| { on(|change: On<ValueChange<f32>>, mut gravity: ResMut<SimulationOptions>| {
gravity.gravity.y = change.value; gravity.gravity.y = change.value;
})
on(|change: On<ReadyPlaceholder>, mut commands: Commands, gravity: Res<SimulationOptions>| {
commands.trigger(UpdateNumberInput { entity: change.0, value: NumberInputValue::F32(gravity.gravity.y) });
}), }),
@FeathersNumberInput { @FeathersNumberInput {
@label_text: "Z" @label_text: "Z"
} }
on(|change: On<ValueChange<f32>>, mut gravity: ResMut<SimulationOptions>| { on(|change: On<ValueChange<f32>>, mut gravity: ResMut<SimulationOptions>| {
gravity.gravity.z = change.value; gravity.gravity.z = change.value;
})
on(|change: On<ReadyPlaceholder>, mut commands: Commands, gravity: Res<SimulationOptions>| {
commands.trigger(UpdateNumberInput { entity: change.0, value: NumberInputValue::F32(gravity.gravity.z) });
}), }),
] ]
} }