From 52ba77be462afa05af57572aafe81f54fa7b5ec9 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 30 Jun 2021 09:43:26 -0500 Subject: [PATCH] Remove old area system. --- src/core.rs | 19 ------------------- src/error.rs | 3 --- src/map.rs | 37 ++++++++----------------------------- 3 files changed, 8 insertions(+), 51 deletions(-) diff --git a/src/core.rs b/src/core.rs index 23f76d0..f8c0044 100644 --- a/src/core.rs +++ b/src/core.rs @@ -107,25 +107,6 @@ impl From<(usize, usize)> for Coordinates { } } -#[derive(Clone, Debug, PartialEq)] -pub struct Area { - pub rect: mapgen::geometry::Rect, - pub description: Option, -} - -impl Area { - pub fn contains(&self, point: &dyn PointLike) -> bool { - let x = point.x() as usize; - let y = point.y() as usize; - x >= self.rect.x1 && x <= self.rect.x2 && y >= self.rect.y1 && y <= self.rect.y2 - } - - pub fn center(&self) -> (usize, usize) { - let center = self.rect.center(); - (center.x, center.y) - } -} - #[derive(Clone, Copy, Debug, Reflect)] pub enum Angle { Degrees(f32), diff --git a/src/error.rs b/src/error.rs index c7d1f2a..cb723f9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -13,10 +13,8 @@ pub fn error_handler(In(result): In>>) { fn init_panic_handler() { panic::set_hook(Box::new(|info| { let backtrace = Backtrace::default(); - let thread = thread::current(); let thread = thread.name().unwrap_or(""); - let msg = match info.payload().downcast_ref::<&'static str>() { Some(s) => *s, None => match info.payload().downcast_ref::() { @@ -24,7 +22,6 @@ fn init_panic_handler() { None => "Box", }, }; - match info.location() { Some(location) => { error!( diff --git a/src/map.rs b/src/map.rs index b9b4a8d..9be23b0 100644 --- a/src/map.rs +++ b/src/map.rs @@ -9,7 +9,7 @@ use maze_generator::{prelude::*, recursive_backtracking::RbGenerator}; use rand::prelude::StdRng; use crate::{ - core::{Area, Coordinates, Player, PointLike}, + core::{Coordinates, Player, PointLike}, exploration::{ExplorationType, Mappable}, log::Log, utils::target_and_other, @@ -26,9 +26,6 @@ impl From for Coordinates { #[reflect(Component)] pub struct AreaTag; -#[derive(Clone, Debug, Default, Deref, DerefMut)] -pub struct Areas(pub Vec); - #[derive(Clone, Debug, Default, Reflect)] #[reflect(Component)] pub struct MapObstruction; @@ -182,13 +179,10 @@ impl MapFilter for GridBuilder { fn add_map_colliders(mut commands: Commands, maps: Query<(Entity, &Map), Added>) { for (map_entity, map) in maps.iter() { - let rigid_body_entity = commands - .entity(map_entity) - .insert_bundle(RigidBodyBundle { - body_type: RigidBodyType::Static, - ..Default::default() - }) - .id(); + commands.entity(map_entity).insert_bundle(RigidBodyBundle { + body_type: RigidBodyType::Static, + ..Default::default() + }); for x in 0..map.width { for y in 0..map.height { let tile = map.at(x, y); @@ -199,7 +193,7 @@ fn add_map_colliders(mut commands: Commands, maps: Query<(Entity, &Map), Added, Without)>) { - for (entity, map) in query.iter() { - let mut v = vec![]; - for room in &map.rooms { - v.push(Area { - rect: *room, - description: None, - }); - } - commands.entity(entity).insert(Areas(v)); - } -} - pub struct MapPlugin; impl Plugin for MapPlugin { @@ -356,9 +337,7 @@ impl Plugin for MapPlugin { let config = app.world().get_resource::().unwrap().clone(); app.register_type::() .add_system(add_map_colliders.system()) - .add_system(portal_spawner.system()) - .add_system(add_areas.system()) - .add_system_to_stage(CoreStage::PostUpdate, add_areas.system()); + .add_system(portal_spawner.system()); if config.speak_area_descriptions { app.add_system_to_stage(CoreStage::PostUpdate, area_description.system()); }