diff --git a/src/core.rs b/src/core.rs index 6c3c803..35e02a6 100644 --- a/src/core.rs +++ b/src/core.rs @@ -646,9 +646,9 @@ fn copy_coordinates_to_transform( ( Changed, Without, - Without, + Without, Without, - Without, + Without, ), >, ) { @@ -686,7 +686,7 @@ fn copy_collider_position_to_coordinates( ( Without, Changed, - With, + With, ), >, ) { @@ -726,7 +726,7 @@ pub struct CorePlugin; impl Plugin for CorePlugin { fn build(&self, app: &mut App) { - if !app.world().contains_resource::() { + if !app.world.contains_resource::() { app.insert_resource(CoreConfig::default()); } app.register_type::() diff --git a/src/error.rs b/src/error.rs index b50606e..7e1f23a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -54,7 +54,7 @@ pub struct ErrorPlugin; impl Plugin for ErrorPlugin { fn build(&self, app: &mut App) { init_panic_handler(); - if let Some(config) = app.world().get_resource::() { + if let Some(config) = app.world.get_resource::() { if let Some(dsn) = &config.sentry_dsn { let guard = sentry::init(dsn.clone()); app.insert_resource(guard); diff --git a/src/exploration.rs b/src/exploration.rs index 148d240..f07a524 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -265,7 +265,7 @@ fn exploration_focus( config.action_explore_right.clone(), ) { for map in map.iter() { - if let Ok((entity, coordinates, exploring)) = explorers.single() { + if let (entity, coordinates, exploring) = explorers.single() { let coordinates = **coordinates; let mut exploring = if let Some(exploring) = exploring { **exploring @@ -334,7 +334,7 @@ fn exploration_changed_announcement( query_pipeline: Res, collider_query: QueryPipelineColliderComponentsQuery, ) -> Result<(), Box> { - if let Ok((coordinates, exploring, viewshed)) = explorer.single() { + if let (coordinates, exploring, viewshed) = explorer.single() { let collider_set = QueryPipelineColliderComponentsSet(&collider_query); let coordinates = coordinates.floor(); for (map, revealed_tiles) in map.iter() { @@ -457,11 +457,11 @@ where 'a: 'static, { fn build(&self, app: &mut App) { - if !app.world().contains_resource::>() { + if !app.world.contains_resource::>() { app.insert_resource(ExplorationConfig::::default()); } let config = app - .world() + .world .get_resource::>() .unwrap() .clone(); diff --git a/src/map.rs b/src/map.rs index 011f520..06a6706 100644 --- a/src/map.rs +++ b/src/map.rs @@ -22,12 +22,10 @@ impl From for Coordinates { } } -#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)] -#[reflect(Component)] +#[derive(Component, Clone, Debug, Deref, DerefMut)] pub struct Area(AABB); -#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)] -#[reflect(Component)] +#[derive(Component, Clone, Default, Deref, DerefMut)] pub struct Map(pub MapgenMap); #[derive(Component, Clone, Debug, Default, Reflect)] @@ -152,7 +150,7 @@ impl GridBuilder { } impl MapFilter for GridBuilder { - fn modify_map(&self, _rng: &mut StdRng, map: &Map) -> Map { + fn modify_map(&self, _rng: &mut StdRng, map: &MapgenMap) -> MapgenMap { let mut map = map.clone(); let mut generator = RbGenerator::new(None); let maze = generator.generate(self.width_in_rooms as i32, self.height_in_rooms as i32); @@ -219,7 +217,7 @@ fn spawn_colliders( .remove::() .remove::() .insert_bundle(RigidBodyBundle { - body_type: RigidBodyType::Static, + body_type: RigidBodyTypeComponent(RigidBodyType::Static), ..Default::default() }); if **spawn_collider_per_tile { @@ -229,7 +227,7 @@ fn spawn_colliders( if tile.blocks_motion() { let id = commands .spawn_bundle(ColliderBundle { - shape: ColliderShape::cuboid(0.5, 0.5), + shape: ColliderShapeComponent(ColliderShape::cuboid(0.5, 0.5)), position: Vec2::new(x as f32 + 0.5, y as f32 + 0.5).into(), ..Default::default() }) @@ -324,7 +322,7 @@ fn spawn_colliders( );*/ let id = commands .spawn_bundle(ColliderBundle { - shape: ColliderShape::cuboid(half_width, half_height), + shape: ColliderShapeComponent(ColliderShape::cuboid(half_width, half_height)), position: Vec2::new(x, y).into(), ..Default::default() }) @@ -343,13 +341,13 @@ fn spawn_colliders( for room in &map.rooms { let shape = ColliderShape::cuboid((room.width() / 2) as f32, (room.height() / 2) as f32); - let position: ColliderPosition = + let position: ColliderPositionComponent = point!(room.center().x(), room.center().y()).into(); let aabb = shape.compute_aabb(&position); let id = commands .spawn_bundle(ColliderBundle { - collider_type: ColliderType::Sensor, - shape: shape.clone(), + collider_type: ColliderTypeComponent(ColliderType::Sensor), + shape: ColliderShapeComponent(shape.clone()), flags: ActiveEvents::INTERSECTION_EVENTS.into(), position, ..Default::default() @@ -429,8 +427,8 @@ fn spawn_portal_colliders( commands .entity(portal_entity) .insert_bundle(ColliderBundle { - collider_type: ColliderType::Sensor, - shape: ColliderShape::cuboid(0.5, 0.5), + collider_type: ColliderTypeComponent(ColliderType::Sensor), + shape: ColliderShapeComponent(ColliderShape::cuboid(0.5, 0.5)), position, flags: ActiveEvents::INTERSECTION_EVENTS.into(), ..Default::default() @@ -456,7 +454,7 @@ fn area_description( }) { if players.get(other).is_ok() { - if let Ok(mut log) = log.single_mut() { + if let mut log = log.single_mut() { if let Ok((aabb, area_name)) = areas.get(area) { let name = if let Some(name) = area_name { Some(name.to_string()) @@ -483,10 +481,10 @@ pub struct MapPlugin; impl Plugin for MapPlugin { fn build(&self, app: &mut App) { - if !app.world().contains_resource::() { + if !app.world.contains_resource::() { app.insert_resource(MapConfig::default()); } - let config = app.world().get_resource::().unwrap().clone(); + let config = app.world.get_resource::().unwrap().clone(); app.register_type::() .add_system(spawn_colliders) .add_system(spawn_portals) diff --git a/src/navigation.rs b/src/navigation.rs index 32c0efc..77a0a35 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -195,14 +195,17 @@ fn speak_direction( mut tts: ResMut, player: Query<&CardinalDirection, (With, Changed)>, ) -> Result<(), Box> { - if let Ok(direction) = player.single() { + if let direction = player.single() { let direction: String = (*direction).into(); tts.speak(direction, true)?; } Ok(()) } -fn remove_speed(removed: RemovedComponents, mut query: Query<&mut RigidBodyVelocityComponent>) { +fn remove_speed( + removed: RemovedComponents, + mut query: Query<&mut RigidBodyVelocityComponent>, +) { for entity in removed.iter() { if let Ok(mut velocity) = query.get_mut(entity) { velocity.linvel = Vec2::ZERO.into(); @@ -260,11 +263,11 @@ where 'a: 'static, { fn build(&self, app: &mut App) { - if !app.world().contains_resource::>() { + if !app.world.contains_resource::>() { app.insert_resource(NavigationConfig::::default()); } let config = app - .world() + .world .get_resource::>() .unwrap() .clone(); diff --git a/src/pathfinding.rs b/src/pathfinding.rs index 934ad92..7112058 100644 --- a/src/pathfinding.rs +++ b/src/pathfinding.rs @@ -92,7 +92,7 @@ impl<'world, 'state> .0 .iter() .filter(|(a, _, _, _)| query.1.get(*a).is_ok()) - .map(|(a, b, c, d)| (a, *b, c.clone(), *d)) + .map(|(a, b, c, d)| (a, **b, (*c).clone(), **d)) .collect::>(); let mut m = HashMap::new(); for (e, a, b, c) in entries { @@ -102,18 +102,18 @@ impl<'world, 'state> } } -impl ComponentSet for StaticColliderComponentsSet { +impl ComponentSet for StaticColliderComponentsSet { fn size_hint(&self) -> usize { self.0.len() } - fn for_each(&self, _f: impl FnMut(Index, &SharedShape)) { + fn for_each(&self, _f: impl FnMut(Index, &ColliderShape)) { unimplemented!() } } -impl ComponentSetOption for StaticColliderComponentsSet { - fn get(&self, index: Index) -> Option<&SharedShape> { +impl ComponentSetOption for StaticColliderComponentsSet { + fn get(&self, index: Index) -> Option<&ColliderShape> { self.0.get(&index.entity()).map(|v| &v.1) } } @@ -158,7 +158,7 @@ fn find_path_for_shape( query_pipeline: &QueryPipeline, map: &Map, collider_set: StaticColliderComponentsSet, - shape: &SharedShape, + shape: &ColliderShape, ) -> Option { let path = astar( &start.i32(), @@ -219,7 +219,7 @@ fn calculate_path( .remove::(); continue; } - for map in map.iter() { + if let map = map.single() { let coordinates_clone = *coordinates; let destination_clone = *destination; let query_pipeline_clone = query_pipeline.clone(); diff --git a/src/sound.rs b/src/sound.rs index 515825b..e15a094 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -285,12 +285,12 @@ where 'a: 'static, { fn build(&self, app: &mut App) { - if !app.world().contains_resource::>() { + if !app.world.contains_resource::>() { app.insert_resource(SoundConfig::::default()); } const SOUND_ICON_AND_EXPLORATION_STAGE: &str = "sound_icon_and_exploration"; - let core_config = *app.world().get_resource::().unwrap(); - if let Some(context) = app.world().get_resource::() { + let core_config = *app.world.get_resource::().unwrap(); + if let Some(context) = app.world.get_resource::() { context .set_meters_per_unit(1. / core_config.pixels_per_unit as f32) .unwrap(); diff --git a/src/visibility.rs b/src/visibility.rs index 984f006..bd33167 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -281,7 +281,7 @@ fn update_viewshed( if let Ok((viewer_entity, mut viewshed, mut visible_entities, viewer_coordinates)) = viewers.get_mut(*entity) { - if let Ok(map) = map.single() { + if let map = map.single() { let mut cache = HashMap::new(); viewshed.update( &viewer_entity, @@ -314,7 +314,7 @@ fn remove_visible( continue; } visible_entities.remove(&removed); - if let Ok(map) = map.single() { + if let map = map.single() { let mut cache = HashMap::new(); viewshed.update( &viewer_entity, @@ -375,7 +375,7 @@ fn log_visible( continue; } if let Ok((name, body_position, collider_position)) = visible.get(*viewed) { - if let Ok(mut log) = log.single_mut() { + if let mut log = log.single_mut() { let viewed_coordinates = if let Some(p) = body_position { (p.position.translation.x, p.position.translation.y) } else if let Some(p) = collider_position {