Compare commits

..

No commits in common. "91166359e2e7b45a7028e853f6d2aa4b7713338c" and "be8a7634438a45a5018d63ab1cf47a4715def045" have entirely different histories.

10 changed files with 99 additions and 91 deletions

View File

@ -13,24 +13,24 @@ speech_dispatcher_0_10 = ["bevy_tts/speech_dispatcher_0_10"]
speech_dispatcher_0_11 = ["bevy_tts/speech_dispatcher_0_11"] speech_dispatcher_0_11 = ["bevy_tts/speech_dispatcher_0_11"]
[dependencies.bevy] [dependencies.bevy]
version = "0.13" version = "0.11"
default-features = false default-features = false
features = [ features = [
"bevy_gilrs", "bevy_gilrs",
"bevy_winit", "bevy_winit",
"x11", "x11",
"wayland", "wayland",
"multi-threaded",
"serialize", "serialize",
] ]
[dependencies] [dependencies]
bevy_rapier2d = "0.25" bevy_rapier2d = "0.22"
bevy_synthizer = "0.6" bevy_synthizer = "0.4"
bevy_tts = { version = "0.8", default-features = false, features = ["tolk"] } bevy_tts = { version = "0.6", default-features = false, features = ["tolk"] }
coord_2d = "0.3" coord_2d = "0.3"
futures-lite = "1"
here_be_dragons = { version = "0.3", features = ["serde"] } here_be_dragons = { version = "0.3", features = ["serde"] }
leafwing-input-manager = "0.13" leafwing-input-manager = "0.10"
maze_generator = "2" maze_generator = "2"
once_cell = "1" once_cell = "1"
pathfinding = "4" pathfinding = "4"

View File

@ -521,6 +521,7 @@ impl GlobalTransformExt for GlobalTransform {
other: &GlobalTransform, other: &GlobalTransform,
other_collider: &Collider, other_collider: &Collider,
) -> ClosestPoints { ) -> ClosestPoints {
use bevy::math::Vec3Swizzles;
let scale = PHYSICS_SCALE.read().unwrap(); let scale = PHYSICS_SCALE.read().unwrap();
let pos1 = Isometry::new( let pos1 = Isometry::new(
(self.translation() / *scale).xy().into(), (self.translation() / *scale).xy().into(),
@ -539,6 +540,7 @@ impl GlobalTransformExt for GlobalTransform {
other: &GlobalTransform, other: &GlobalTransform,
other_collider: &Collider, other_collider: &Collider,
) -> String { ) -> String {
use bevy::math::Vec3Swizzles;
let scale = PHYSICS_SCALE.read().unwrap(); let scale = PHYSICS_SCALE.read().unwrap();
let pos1 = Isometry::new( let pos1 = Isometry::new(
(self.translation() / *scale).xy().into(), (self.translation() / *scale).xy().into(),
@ -630,7 +632,7 @@ where
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let mut rng = thread_rng(); let mut rng = thread_rng();
self.0.shuffle(&mut rng); self.0.shuffle(&mut rng);
self.0.first().cloned() self.0.get(0).cloned()
} }
} }

View File

@ -72,7 +72,7 @@ where
types.dedup(); types.dedup();
if types.is_empty() { if types.is_empty() {
tts.speak("Nothing visible.", true)?; tts.speak("Nothing visible.", true)?;
} else if actions.just_pressed(&ExplorationAction::SelectPrevType) { } else if actions.just_pressed(ExplorationAction::SelectPrevType) {
if let Some(t) = &focused.0 { if let Some(t) = &focused.0 {
if let Some(i) = types.iter().position(|v| *v == *t) { if let Some(i) = types.iter().position(|v| *v == *t) {
if i == 0 { if i == 0 {
@ -89,7 +89,7 @@ where
let t = types.last().unwrap(); let t = types.last().unwrap();
focused.0 = Some(*t); focused.0 = Some(*t);
} }
} else if actions.just_pressed(&ExplorationAction::SelectNextType) { } else if actions.just_pressed(ExplorationAction::SelectNextType) {
if let Some(t) = &focused.0 { if let Some(t) = &focused.0 {
if let Some(i) = types.iter().position(|v| *v == *t) { if let Some(i) = types.iter().position(|v| *v == *t) {
if i == types.len() - 1 { if i == types.len() - 1 {
@ -141,7 +141,7 @@ where
features.retain(|(_, t)| **t == *focused); features.retain(|(_, t)| **t == *focused);
} }
let mut target: Option<&((f32, f32), &ExplorationType)> = None; let mut target: Option<&((f32, f32), &ExplorationType)> = None;
if actions.just_pressed(&ExplorationAction::FocusNext) { if actions.just_pressed(ExplorationAction::FocusNext) {
if let Some(exploring) = exploring { if let Some(exploring) = exploring {
target = features.iter().find(|(c, _)| *c > **exploring); target = features.iter().find(|(c, _)| *c > **exploring);
if target.is_none() { if target.is_none() {
@ -150,7 +150,7 @@ where
} else { } else {
target = features.first(); target = features.first();
} }
} else if actions.just_pressed(&ExplorationAction::FocusPrev) { } else if actions.just_pressed(ExplorationAction::FocusPrev) {
if let Some(exploring) = exploring { if let Some(exploring) = exploring {
features.reverse(); features.reverse();
target = features.iter().find(|(c, _)| *c < **exploring); target = features.iter().find(|(c, _)| *c < **exploring);
@ -224,13 +224,13 @@ fn exploration_focus<MapData>(
(floor.x, floor.y) (floor.x, floor.y)
}; };
let orig = exploring; let orig = exploring;
if actions.just_pressed(&ExplorationAction::Forward) { if actions.just_pressed(ExplorationAction::Forward) {
exploring.1 += 1.; exploring.1 += 1.;
} else if actions.just_pressed(&ExplorationAction::Backward) { } else if actions.just_pressed(ExplorationAction::Backward) {
exploring.1 -= 1.; exploring.1 -= 1.;
} else if actions.just_pressed(&ExplorationAction::Left) { } else if actions.just_pressed(ExplorationAction::Left) {
exploring.0 -= 1.; exploring.0 -= 1.;
} else if actions.just_pressed(&ExplorationAction::Right) { } else if actions.just_pressed(ExplorationAction::Right) {
exploring.0 += 1.; exploring.0 += 1.;
} }
let dimensions = if let Ok(map) = map.get_single() { let dimensions = if let Ok(map) = map.get_single() {
@ -261,7 +261,7 @@ fn navigate_to_explored<MapData>(
let point = **exploring; let point = **exploring;
let idx = point.to_index(map.width); let idx = point.to_index(map.width);
let known = revealed_tiles[idx]; let known = revealed_tiles[idx];
if actions.just_pressed(&ExplorationAction::NavigateTo) && known { if actions.just_pressed(ExplorationAction::NavigateTo) && known {
commands commands
.entity(entity) .entity(entity)
.insert(Destination((point.x_i32(), point.y_i32()))); .insert(Destination((point.x_i32(), point.y_i32())));
@ -421,7 +421,7 @@ where
if !config.states.is_empty() { if !config.states.is_empty() {
let states = config.states; let states = config.states;
for state in states { for state in states {
app.configure_sets(Update, Exploration.run_if(in_state(state.clone()))) app.configure_set(Update, Exploration.run_if(in_state(state.clone())))
.add_systems(OnExit(state), cleanup); .add_systems(OnExit(state), cleanup);
} }
} }

View File

@ -11,6 +11,7 @@ pub use coord_2d;
pub mod core; pub mod core;
pub mod error; pub mod error;
pub mod exploration; pub mod exploration;
pub use futures_lite;
pub use here_be_dragons as mapgen; pub use here_be_dragons as mapgen;
pub use leafwing_input_manager; pub use leafwing_input_manager;
pub mod log; pub mod log;

View File

@ -98,7 +98,7 @@ fn snap(
for (entity, actions, mut transform, direction) in &mut query { for (entity, actions, mut transform, direction) in &mut query {
if snap_timers.contains_key(&entity) { if snap_timers.contains_key(&entity) {
continue; continue;
} else if actions.just_pressed(&NavigationAction::SnapLeft) { } else if actions.just_pressed(NavigationAction::SnapLeft) {
snap_timers.insert(entity, SnapTimer::default()); snap_timers.insert(entity, SnapTimer::default());
transform.rotation = Quat::from_rotation_z(match direction { transform.rotation = Quat::from_rotation_z(match direction {
CardinalDirection::North => PI, CardinalDirection::North => PI,
@ -106,7 +106,7 @@ fn snap(
CardinalDirection::South => 0., CardinalDirection::South => 0.,
CardinalDirection::West => -PI / 2., CardinalDirection::West => -PI / 2.,
}); });
} else if actions.just_pressed(&NavigationAction::SnapRight) { } else if actions.just_pressed(NavigationAction::SnapRight) {
snap_timers.insert(entity, SnapTimer::default()); snap_timers.insert(entity, SnapTimer::default());
transform.rotation = Quat::from_rotation_z(match direction { transform.rotation = Quat::from_rotation_z(match direction {
CardinalDirection::North => 0., CardinalDirection::North => 0.,
@ -114,10 +114,10 @@ fn snap(
CardinalDirection::South => PI, CardinalDirection::South => PI,
CardinalDirection::West => PI / 2., CardinalDirection::West => PI / 2.,
}); });
} else if actions.just_pressed(&NavigationAction::SnapReverse) { } else if actions.just_pressed(NavigationAction::SnapReverse) {
snap_timers.insert(entity, SnapTimer::default()); snap_timers.insert(entity, SnapTimer::default());
transform.rotate(Quat::from_rotation_z(PI)); transform.rotate(Quat::from_rotation_z(PI));
} else if actions.just_pressed(&NavigationAction::SnapCardinal) { } else if actions.just_pressed(NavigationAction::SnapCardinal) {
let yaw: Angle = direction.into(); let yaw: Angle = direction.into();
let yaw = yaw.radians(); let yaw = yaw.radians();
transform.rotation = Quat::from_rotation_z(yaw); transform.rotation = Quat::from_rotation_z(yaw);
@ -147,7 +147,7 @@ fn controls(
Option<&BackwardMovementFactor>, Option<&BackwardMovementFactor>,
Option<&ForwardMovementFactor>, Option<&ForwardMovementFactor>,
Option<&StrafeMovementFactor>, Option<&StrafeMovementFactor>,
&mut Transform, &Transform,
Option<&mut KinematicCharacterController>, Option<&mut KinematicCharacterController>,
)>, )>,
exploration_focused: Query<Entity, With<ExplorationFocused>>, exploration_focused: Query<Entity, With<ExplorationFocused>>,
@ -161,13 +161,13 @@ fn controls(
backward_movement_factor, backward_movement_factor,
forward_movement_factor, forward_movement_factor,
strafe_movement_factor, strafe_movement_factor,
mut transform, transform,
character_controller, character_controller,
) in &mut query ) in &mut query
{ {
let mut cleanup = false; let mut cleanup = false;
if actions.pressed(&NavigationAction::Move) { if actions.pressed(NavigationAction::Move) {
if let Some(pair) = actions.clamped_axis_pair(&NavigationAction::Move) { if let Some(pair) = actions.clamped_axis_pair(NavigationAction::Move) {
cleanup = true; cleanup = true;
let mut direction = pair.xy(); let mut direction = pair.xy();
let forward_movement_factor = let forward_movement_factor =
@ -201,83 +201,76 @@ fn controls(
let velocity = direction * speed; let velocity = direction * speed;
if character_controller.is_some() { if character_controller.is_some() {
let translation = velocity * time.delta_seconds(); let translation = velocity * time.delta_seconds();
actions.press(&NavigationAction::Translate); actions.press(NavigationAction::Translate);
actions actions
.action_data_mut_or_default(&NavigationAction::Translate) .action_data_mut(NavigationAction::Translate)
.axis_pair = Some(DualAxisData::from_xy(translation)); .axis_pair = Some(DualAxisData::from_xy(translation));
} else { } else {
// println!("{entity:?}: SetLinearVelocity: {velocity:?}"); // println!("{entity:?}: SetLinearVelocity: {velocity:?}");
actions.press(&NavigationAction::SetLinearVelocity); actions.press(NavigationAction::SetLinearVelocity);
actions actions
.action_data_mut_or_default(&NavigationAction::SetLinearVelocity) .action_data_mut(NavigationAction::SetLinearVelocity)
.axis_pair = Some(DualAxisData::from_xy(velocity)); .axis_pair = Some(DualAxisData::from_xy(velocity));
} }
} }
} else if actions.just_released(&NavigationAction::Move) { } else if actions.just_released(NavigationAction::Move) {
trace!("{entity:?}: Stopped moving"); trace!("{entity:?}: Stopped moving");
actions.release(&NavigationAction::SetLinearVelocity); actions.release(NavigationAction::SetLinearVelocity);
actions.release(&NavigationAction::Translate); actions.release(NavigationAction::Translate);
actions actions.action_data_mut(NavigationAction::Move).axis_pair =
.action_data_mut_or_default(&NavigationAction::Move) Some(DualAxisData::from_xy(Vec2::ZERO));
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
} }
if actions.pressed(&NavigationAction::SetLinearVelocity) { if actions.pressed(NavigationAction::SetLinearVelocity) {
if let Some(pair) = actions.axis_pair(&NavigationAction::SetLinearVelocity) { if let Some(pair) = actions.axis_pair(NavigationAction::SetLinearVelocity) {
// println!("{entity:?}: SetLinearVelocity: {pair:?}"); // println!("{entity:?}: SetLinearVelocity: {pair:?}");
velocity.linvel = pair.into(); velocity.linvel = pair.into();
} else { } else {
// println!("{entity:?}: SetLinearVelocity: 0"); // println!("{entity:?}: SetLinearVelocity: 0");
velocity.linvel = Vec2::ZERO; velocity.linvel = Vec2::ZERO;
} }
} else if actions.just_released(&NavigationAction::SetLinearVelocity) { } else if actions.just_released(NavigationAction::SetLinearVelocity) {
// println!("{entity:?}: Released velocity"); // println!("{entity:?}: Released velocity");
velocity.linvel = Vec2::ZERO; velocity.linvel = Vec2::ZERO;
actions actions
.action_data_mut_or_default(&NavigationAction::SetLinearVelocity) .action_data_mut(NavigationAction::SetLinearVelocity)
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO)); .axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
} }
if actions.pressed(&NavigationAction::Translate) { if actions.pressed(NavigationAction::Translate) {
if let Some(pair) = actions.axis_pair(&NavigationAction::Translate) { if let Some(pair) = actions.axis_pair(NavigationAction::Translate) {
if let Some(mut character_controller) = character_controller { if let Some(mut character_controller) = character_controller {
character_controller.translation = Some(pair.xy()); character_controller.translation = Some(pair.xy());
} }
} }
} else if actions.just_released(&NavigationAction::Translate) { } else if actions.just_released(NavigationAction::Translate) {
if let Some(mut character_controller) = character_controller { if let Some(mut character_controller) = character_controller {
character_controller.translation = None; character_controller.translation = None;
} }
actions actions
.action_data_mut_or_default(&NavigationAction::Translate) .action_data_mut(NavigationAction::Translate)
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO)); .axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
} }
if !snap_timers.contains_key(&entity) { if !snap_timers.contains_key(&entity) {
if let Some(rotation_speed) = rotation_speed { if let Some(rotation_speed) = rotation_speed {
if actions.pressed(&NavigationAction::Rotate) { if actions.pressed(NavigationAction::Rotate) {
cleanup = true; cleanup = true;
let delta = -rotation_speed.radians() let delta =
* actions.clamped_value(&NavigationAction::Rotate); -rotation_speed.radians() * actions.clamped_value(NavigationAction::Rotate);
actions.press(&NavigationAction::SetAngularVelocity); actions.press(NavigationAction::SetAngularVelocity);
actions actions
.action_data_mut_or_default(&NavigationAction::SetAngularVelocity) .action_data_mut(NavigationAction::SetAngularVelocity)
.value = delta; .value = delta;
} }
} }
} }
if actions.just_released(&NavigationAction::Rotate) { if actions.just_released(NavigationAction::Rotate) {
actions.release(&NavigationAction::SetAngularVelocity); actions.release(NavigationAction::SetAngularVelocity);
actions actions.action_data_mut(NavigationAction::Rotate).value = 0.;
.action_data_mut_or_default(&NavigationAction::Rotate)
.value = 0.;
} }
if actions.pressed(&NavigationAction::SetAngularVelocity) { if actions.pressed(NavigationAction::SetAngularVelocity) {
// velocity.angvel = velocity.angvel = actions.value(NavigationAction::SetAngularVelocity);
// actions.value(&NavigationAction::SetAngularVelocity); } else if actions.just_released(NavigationAction::SetAngularVelocity) {
transform.rotation *= Quat::from_rotation_z(
actions.value(&NavigationAction::SetAngularVelocity) * time.delta_seconds(),
);
} else if actions.just_released(&NavigationAction::SetAngularVelocity) {
actions actions
.action_data_mut_or_default(&NavigationAction::SetAngularVelocity) .action_data_mut(NavigationAction::SetAngularVelocity)
.value = 0.; .value = 0.;
velocity.angvel = 0.; velocity.angvel = 0.;
} }
@ -315,7 +308,7 @@ fn remove_direction(
mut removed: RemovedComponents<Transform>, mut removed: RemovedComponents<Transform>,
directions: Query<&CardinalDirection>, directions: Query<&CardinalDirection>,
) { ) {
for entity in removed.read() { for entity in &mut removed {
if directions.contains(entity) { if directions.contains(entity) {
commands.entity(entity).remove::<CardinalDirection>(); commands.entity(entity).remove::<CardinalDirection>();
} }
@ -359,7 +352,7 @@ fn log_area_descriptions<State>(
if !config.log_area_descriptions { if !config.log_area_descriptions {
return; return;
} }
for event in events.read() { for event in events.iter() {
let (entity1, entity2, started) = match event { let (entity1, entity2, started) = match event {
CollisionEvent::Started(collider1, collider2, _) => (collider1, collider2, true), CollisionEvent::Started(collider1, collider2, _) => (collider1, collider2, true),
CollisionEvent::Stopped(collider1, collider2, _) => (collider1, collider2, false), CollisionEvent::Stopped(collider1, collider2, _) => (collider1, collider2, false),

View File

@ -1,7 +1,7 @@
use bevy::{ use bevy::{
ecs::entity::Entities, ecs::entity::Entities,
prelude::*, prelude::*,
tasks::{futures_lite::future, prelude::*, Task}, tasks::{prelude::*, Task},
utils::HashMap, utils::HashMap,
}; };
use bevy_rapier2d::{ use bevy_rapier2d::{
@ -9,6 +9,7 @@ use bevy_rapier2d::{
prelude::*, prelude::*,
rapier::prelude::{ColliderHandle, ColliderSet, QueryPipeline, RigidBodySet}, rapier::prelude::{ColliderHandle, ColliderSet, QueryPipeline, RigidBodySet},
}; };
use futures_lite::future;
use leafwing_input_manager::{axislike::DualAxisData, plugin::InputManagerSystem, prelude::*}; use leafwing_input_manager::{axislike::DualAxisData, plugin::InputManagerSystem, prelude::*};
use pathfinding::prelude::*; use pathfinding::prelude::*;
@ -21,7 +22,23 @@ use crate::{
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)] #[derive(PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)]
pub struct NegotiatePathAction; pub struct NegotiatePathAction;
impl Actionlike for NegotiatePathAction {} impl Actionlike for NegotiatePathAction {
fn n_variants() -> usize {
1
}
fn get_at(index: usize) -> Option<Self> {
if index == 0 {
Some(Self)
} else {
None
}
}
fn index(&self) -> usize {
0
}
}
#[derive(Component, Debug, Deref, DerefMut)] #[derive(Component, Debug, Deref, DerefMut)]
struct Calculating(Task<Option<Path>>); struct Calculating(Task<Option<Path>>);
@ -245,7 +262,7 @@ fn remove_destination(
entities: &Entities, entities: &Entities,
mut removed: RemovedComponents<Destination>, mut removed: RemovedComponents<Destination>,
) { ) {
for entity in removed.read() { for entity in &mut removed {
if entities.contains(entity) { if entities.contains(entity) {
commands.entity(entity).remove::<Calculating>(); commands.entity(entity).remove::<Calculating>();
} }
@ -309,7 +326,6 @@ fn negotiate_path(
direction, direction,
collider, collider,
rapier_context.integration_parameters.dt, rapier_context.integration_parameters.dt,
true,
QueryFilter::new() QueryFilter::new()
.predicate(&|entity| obstructions.get(entity).is_ok()) .predicate(&|entity| obstructions.get(entity).is_ok())
.exclude_sensors() .exclude_sensors()
@ -321,10 +337,9 @@ fn negotiate_path(
continue; continue;
} }
trace!("{entity:?}: path: direction: {direction:?}"); trace!("{entity:?}: path: direction: {direction:?}");
actions.press(&NavigationAction::Move); actions.press(NavigationAction::Move);
actions actions.action_data_mut(NavigationAction::Move).axis_pair =
.action_data_mut_or_default(&NavigationAction::Move) Some(DualAxisData::from_xy(Vec2::new(-direction.y, direction.x)));
.axis_pair = Some(DualAxisData::from_xy(Vec2::new(-direction.y, direction.x)));
if rotation_speed.is_some() { if rotation_speed.is_some() {
let angle = direction.y.atan2(direction.x); let angle = direction.y.atan2(direction.x);
transform.rotation = Quat::from_rotation_z(angle); transform.rotation = Quat::from_rotation_z(angle);
@ -336,7 +351,7 @@ fn negotiate_path(
.remove::<Path>() .remove::<Path>()
.remove::<NoPath>() .remove::<NoPath>()
.remove::<Destination>(); .remove::<Destination>();
actions.release(&NavigationAction::Move); actions.release(NavigationAction::Move);
trace!("{entity:?}: pathfinding: cleaned up"); trace!("{entity:?}: pathfinding: cleaned up");
} }
} }
@ -352,25 +367,24 @@ fn actions(
)>, )>,
) { ) {
for (entity, mut actions, mut navigation_action, destination) in &mut query { for (entity, mut actions, mut navigation_action, destination) in &mut query {
if actions.pressed(&NegotiatePathAction) { if actions.pressed(NegotiatePathAction) {
if let Some(pair) = actions.axis_pair(&NegotiatePathAction) { if let Some(pair) = actions.axis_pair(NegotiatePathAction) {
trace!("Negotiating path to {pair:?}"); trace!("Negotiating path to {pair:?}");
let dest = Destination((pair.x() as i32, pair.y() as i32)); let dest = Destination((pair.x() as i32, pair.y() as i32));
if let Some(mut current_dest) = destination { if let Some(mut current_dest) = destination {
if *current_dest != dest { if *current_dest != dest {
trace!("{entity:?}: New destination, zeroing velocity"); trace!("{entity:?}: New destination, zeroing velocity");
navigation_action.press(&NavigationAction::SetLinearVelocity); navigation_action.press(NavigationAction::SetLinearVelocity);
navigation_action navigation_action
.action_data_mut_or_default(&NavigationAction::SetLinearVelocity) .action_data_mut(NavigationAction::SetLinearVelocity)
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO)); .axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
*current_dest = dest; *current_dest = dest;
} }
} else { } else {
trace!("{entity:?}: Adding destination, zeroing velocity"); trace!("{entity:?}: Adding destination, zeroing velocity");
navigation_action.press(&NavigationAction::SetLinearVelocity); navigation_action.press(NavigationAction::SetLinearVelocity);
navigation_action navigation_action
.action_data_mut_or_default(&NavigationAction::SetLinearVelocity) .action_data_mut(NavigationAction::SetLinearVelocity)
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO)); .axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
commands.entity(entity).insert(dest); commands.entity(entity).insert(dest);
} }
@ -380,10 +394,8 @@ fn actions(
.remove::<Destination>() .remove::<Destination>()
.remove::<NoPath>(); .remove::<NoPath>();
} }
actions.release(&NegotiatePathAction); actions.release(NegotiatePathAction);
actions actions.action_data_mut(NegotiatePathAction).axis_pair = None;
.action_data_mut_or_default(&NegotiatePathAction)
.axis_pair = None;
} }
} }
} }

View File

@ -79,7 +79,7 @@ fn update<S>(
if interval.finished() { if interval.finished() {
interval.reset(); interval.reset();
continue; continue;
} else if interval.fraction() == 0. { } else if interval.percent() == 0. {
sound.generator = None; sound.generator = None;
} }
interval.tick(time.delta()); interval.tick(time.delta());
@ -139,7 +139,7 @@ fn exploration_focus_removed(
children: Query<&Children>, children: Query<&Children>,
) { ) {
const ICON_GAIN: f64 = 3.; const ICON_GAIN: f64 = 3.;
for entity in removed.read() { for entity in &mut removed {
if let Ok(mut icon) = query.get_mut(entity) { if let Ok(mut icon) = query.get_mut(entity) {
icon.gain /= ICON_GAIN; icon.gain /= ICON_GAIN;
} }

View File

@ -74,7 +74,7 @@ fn behind_removed(
mut sounds: Query<&mut Sound>, mut sounds: Query<&mut Sound>,
) { ) {
let downshift = 1. / config.downshift; let downshift = 1. / config.downshift;
for entity in removed.read() { for entity in &mut removed {
if let Ok(mut icon) = icons.get_mut(entity) { if let Ok(mut icon) = icons.get_mut(entity) {
icon.pitch *= downshift; icon.pitch *= downshift;
last_icon_pitch.remove(&entity); last_icon_pitch.remove(&entity);

View File

@ -44,7 +44,7 @@ fn removed(
mut removed: RemovedComponents<Volumetric>, mut removed: RemovedComponents<Volumetric>,
transforms: Query<Entity, (With<Transform>, With<GlobalTransform>)>, transforms: Query<Entity, (With<Transform>, With<GlobalTransform>)>,
) { ) {
for entity in removed.read() { for entity in &mut removed {
if transforms.get(entity).is_ok() { if transforms.get(entity).is_ok() {
commands.entity(entity).insert(TransformBundle::default()); commands.entity(entity).insert(TransformBundle::default());
} }

View File

@ -267,13 +267,13 @@ fn viewshed_removed(
visible_entities: Query<&VisibleEntities>, visible_entities: Query<&VisibleEntities>,
mut events: EventWriter<VisibilityChanged>, mut events: EventWriter<VisibilityChanged>,
) { ) {
for entity in query.read() { for entity in &mut query {
if let Ok(visible) = visible_entities.get(entity) { if let Ok(visible) = visible_entities.get(entity) {
for e in visible.iter() { for e in visible.iter() {
events.send(VisibilityChanged::Lost { events.send(VisibilityChanged::Lost {
viewer: entity, viewer: entity,
viewed: *e, viewed: *e,
}); })
} }
} }
} }
@ -344,7 +344,7 @@ fn remove_visible(
) { ) {
if !removed.is_empty() { if !removed.is_empty() {
let mut cache = HashMap::new(); let mut cache = HashMap::new();
for removed in removed.read() { for removed in &mut removed {
for (viewer_entity, mut viewshed, mut visible_entities, start) in &mut viewers { for (viewer_entity, mut viewshed, mut visible_entities, start) in &mut viewers {
if !visible_entities.contains(&removed) { if !visible_entities.contains(&removed) {
continue; continue;
@ -394,7 +394,7 @@ fn log_visible(
timer.tick(time.delta()); timer.tick(time.delta());
} }
recently_lost.retain(|_entity, timer| !timer.finished()); recently_lost.retain(|_entity, timer| !timer.finished());
for event in events.read() { for event in events.iter() {
let viewer = match event { let viewer = match event {
VisibilityChanged::Gained { viewer, .. } => viewer, VisibilityChanged::Gained { viewer, .. } => viewer,
VisibilityChanged::Lost { viewer, .. } => viewer, VisibilityChanged::Lost { viewer, .. } => viewer,