summaryrefslogtreecommitdiff
path: root/src/dungeon/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/dungeon/mod.rs')
-rw-r--r--src/dungeon/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/dungeon/mod.rs b/src/dungeon/mod.rs
index d3227a5..baeb0fe 100644
--- a/src/dungeon/mod.rs
+++ b/src/dungeon/mod.rs
@@ -1,11 +1,15 @@
//! Turn-based dungeons: the map, field of view, derelict-ship generation,
//! and the rules of a crawl. Drawing lives in `scenes::derelict`.
+pub mod armour;
+pub mod arms;
pub mod crawl;
pub mod fov;
pub mod ship;
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Pos {
pub x: i32,
pub y: i32,
@@ -111,6 +115,14 @@ impl Map {
self.tiles[i] = tile;
}
+ /// Which room `p` is in, to tell when you've gone into another.
+ pub fn room_index(&self, p: Pos) -> Option<u16> {
+ if !self.contains(p) {
+ return None;
+ }
+ self.room_of[self.index(p)]
+ }
+
pub fn room_at(&self, p: Pos) -> Option<&Room> {
if !self.contains(p) {
return None;