summaryrefslogtreecommitdiff
path: root/dungeon/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dungeon/src/lib.rs')
-rw-r--r--dungeon/src/lib.rs42
1 files changed, 10 insertions, 32 deletions
diff --git a/dungeon/src/lib.rs b/dungeon/src/lib.rs
index cc15455..0a04ca7 100644
--- a/dungeon/src/lib.rs
+++ b/dungeon/src/lib.rs
@@ -1,9 +1,11 @@
//! The `dungon` crate contains the core functionality for
//! interacting with a `Dungeon` and its components.
+mod entity;
mod map;
mod pos;
+pub use entity::*;
pub use map::*;
pub use pos::*;
@@ -11,8 +13,8 @@ pub use pos::*;
/// dungeon crawler.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Dungeon {
- player: Entity,
- floor: Floor,
+ pub floor: Floor,
+ pub player: Player,
}
impl Dungeon {
/// Creates a new `Dungeon`.
@@ -27,9 +29,9 @@ impl Dungeon {
#[must_use]
pub fn new() -> Self {
let floor = Floor::generate();
- let player = Entity::player(floor.player_start());
+ let player = Player::new(floor.player_start());
- Self { player, floor }
+ Self { floor, player }
}
/// Creates a new `Dungeon` with a provided seed.
@@ -45,41 +47,17 @@ impl Dungeon {
#[must_use]
pub fn new_seeded(seed: u64) -> Self {
let floor = Floor::generate_seeded(seed);
- let player = Entity::player(floor.player_start());
+ let player = Player::new(floor.player_start());
- Self { player, floor }
- }
-
- /// Returns a reference to the player
- #[must_use]
- pub fn player(&self) -> &Entity {
- &self.player
- }
-
- /// Returns a mutable reference to the player
- #[must_use]
- pub fn player_mut(&mut self) -> &mut Entity {
- &mut self.player
- }
-
- /// Returns a reference to the current floor
- #[must_use]
- pub fn floor(&self) -> &Floor {
- &self.floor
- }
-
- /// Returns a mutable reference to the current floor
- #[must_use]
- pub fn floor_mut(&mut self) -> &mut Floor {
- &mut self.floor
+ Self { floor, player }
}
}
impl Default for Dungeon {
fn default() -> Self {
let floor = Floor::default();
- let player = Entity::player(floor.player_start());
+ let player = Player::default();
- Self { player, floor }
+ Self { floor, player }
}
}