Skip to content

Commit

Permalink
[alt] Changes to be consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-lua committed Oct 13, 2024
1 parent c9ff5ce commit a8ae06b
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 20 deletions.
7 changes: 3 additions & 4 deletions examples/2d/bloom_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,16 @@ fn setup(

fn update_bloom_settings(
camera: Single<(Entity, Option<&mut Bloom>), With<Camera>>,
text: Single<&mut Text>,
mut text: Single<&mut Text>,
mut commands: Commands,
keycode: Res<ButtonInput<KeyCode>>,
time: Res<Time>,
) {
let bloom = camera.into_inner();
let mut text = text.into_inner();

match bloom {
(entity, Some(mut bloom)) => {
**text = "Bloom (Toggle: Space)\n".to_string();
text.0 = "Bloom (Toggle: Space)\n".to_string();
text.push_str(&format!("(Q/A) Intensity: {}\n", bloom.intensity));
text.push_str(&format!(
"(W/S) Low-frequency boost: {}\n",
Expand Down Expand Up @@ -173,7 +172,7 @@ fn update_bloom_settings(
}

(entity, None) => {
**text = "Bloom: Off (Toggle: Space)".to_string();
text.0 = "Bloom: Off (Toggle: Space)".to_string();

if keycode.just_pressed(KeyCode::Space) {
commands.entity(entity).insert(Bloom::default());
Expand Down
3 changes: 1 addition & 2 deletions examples/2d/bounding_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ fn update_test_state(
state.set(next);
}

fn update_text(text: Single<&mut Text>, cur_state: Res<State<Test>>) {
fn update_text(mut text: Single<&mut Text>, cur_state: Res<State<Test>>) {
if !cur_state.is_changed() {
return;
}

let mut text = text.into_inner();
text.clear();

text.push_str("Intersection test:\n");
Expand Down
3 changes: 1 addition & 2 deletions examples/2d/pixel_grid_snap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ fn rotate(time: Res<Time>, mut transforms: Query<&mut Transform, With<Rotate>>)
/// Scales camera projection to fit the window (integer multiples only).
fn fit_canvas(
mut resize_events: EventReader<WindowResized>,
projections: Single<&mut OrthographicProjection, With<OuterCamera>>,
mut projection: Single<&mut OrthographicProjection, With<OuterCamera>>,
) {
let mut projection = projections.into_inner();
for event in resize_events.read() {
let h_scale = event.width / RES_WIDTH as f32;
let v_scale = event.height / RES_HEIGHT as f32;
Expand Down
6 changes: 2 additions & 4 deletions examples/2d/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ fn player_movement_system(
/// Demonstrates snapping the enemy ship to face the player ship immediately.
fn snap_to_player_system(
mut query: Query<&mut Transform, (With<SnapToPlayer>, Without<Player>)>,
player_query: Single<&Transform, With<Player>>,
player_transform: Single<&Transform, With<Player>>,
) {
let player_transform = player_query.into_inner();
// get the player translation in 2D
let player_translation = player_transform.translation.xy();

Expand Down Expand Up @@ -186,9 +185,8 @@ fn snap_to_player_system(
fn rotate_to_player_system(
time: Res<Time>,
mut query: Query<(&RotateToPlayer, &mut Transform), Without<Player>>,
player_query: Single<&Transform, With<Player>>,
player_transform: Single<&Transform, With<Player>>,
) {
let player_transform = player_query.into_inner();
// get the player translation in 2D
let player_translation = player_transform.translation.xy();

Expand Down
2 changes: 1 addition & 1 deletion examples/3d/3d_viewport_to_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn draw_cursor(
windows: Single<&Window>,
mut gizmos: Gizmos,
) {
let (camera, camera_transform) = camera_query.into_inner();
let (camera, camera_transform) = *camera_query;

let Some(cursor_position) = windows.cursor_position() else {
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/anti_aliasing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn update_ui(
>,
mut ui: Single<&mut Text>,
) {
let (fxaa, smaa, taa, cas, msaa) = camera.into_inner();
let (fxaa, smaa, taa, cas, msaa) = *camera;

let ui = &mut ui.0;
*ui = "Antialias Method\n".to_string();
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/order_independent_transparency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn toggle_oit(
mut text_writer: UiTextWriter,
) {
if keyboard_input.just_pressed(KeyCode::KeyT) {
let (e, has_oit) = q.into_inner();
let (e, has_oit) = *q;
*text_writer.text(*text, 2) = if has_oit {
// Removing the component will completely disable OIT for this camera
commands
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/ssao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn update(
) {
sphere.translation.y = ops::sin(time.elapsed_seconds() / 1.7) * 0.7;

let (camera_entity, ssao, temporal_jitter) = camera.into_inner();
let (camera_entity, ssao, temporal_jitter) = *camera;
let current_ssao = ssao.cloned().unwrap_or_default();

let mut commands = commands.entity(camera_entity);
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/tonemapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ fn update_ui(
return;
}

let (tonemapping, color_grading) = settings.into_inner();
let (tonemapping, color_grading) = *settings;
let tonemapping = *tonemapping;

let mut text = String::with_capacity(text_query.len());
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs/observers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn handle_click(
windows: Single<&Window>,
mut commands: Commands,
) {
let (camera, camera_transform) = camera.into_inner();
let (camera, camera_transform) = *camera;
if let Some(pos) = windows
.cursor_position()
.and_then(|cursor| camera.viewport_to_world(camera_transform, cursor).ok())
Expand Down
2 changes: 1 addition & 1 deletion examples/games/desk_toy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn get_cursor_world_pos(
primary_window: Single<&Window, With<PrimaryWindow>>,
q_camera: Single<(&Camera, &GlobalTransform)>,
) {
let (main_camera, main_camera_transform) = q_camera.into_inner();
let (main_camera, main_camera_transform) = *q_camera;
// Get the cursor position in the world
cursor_world_pos.0 = primary_window.cursor_position().and_then(|cursor_pos| {
main_camera
Expand Down
2 changes: 1 addition & 1 deletion examples/games/stepping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ fn update_ui(
mut writer: UiTextWriter,
) {
// ensure the UI is only visible when stepping is enabled
let (ui, vis) = ui.into_inner();
let (ui, vis) = *ui;
match (vis, stepping.is_enabled()) {
(Visibility::Hidden, true) => {
commands.entity(ui).insert(Visibility::Inherited);
Expand Down

0 comments on commit a8ae06b

Please sign in to comment.