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.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/dungeon/src/lib.rs b/dungeon/src/lib.rs
index 76a2bda..4e48b68 100644
--- a/dungeon/src/lib.rs
+++ b/dungeon/src/lib.rs
@@ -8,11 +8,9 @@ pub mod map;
pub mod msg;
pub mod player_input;
pub mod pos;
+pub mod rng;
-use rand::{
- Rng, SeedableRng, TryRngCore,
- rngs::{OsRng, SmallRng},
-};
+use rand::{Rng, SeedableRng, TryRngCore, rngs::OsRng};
use crate::{
entity::{Entity, Player},
@@ -20,6 +18,7 @@ use crate::{
msg::Message,
player_input::PlayerInput,
pos::FPos,
+ rng::DungeonRng,
};
/// Lets the caller know what has
@@ -45,8 +44,8 @@ pub struct Dungeon {
pub enemies: Vec<Entity>,
pub msg: Message,
seed: u64,
- level_rng: SmallRng,
- game_rng: SmallRng,
+ level_rng: DungeonRng,
+ game_rng: DungeonRng,
}
impl Dungeon {
/// Creates a new `Dungeon` with a provided seed.
@@ -61,8 +60,8 @@ impl Dungeon {
/// ```
#[must_use]
pub fn new(seed: u64) -> Self {
- let mut game_rng = SmallRng::seed_from_u64(seed);
- let mut level_rng = SmallRng::seed_from_u64(game_rng.random());
+ let mut game_rng = DungeonRng::seed_from_u64(seed);
+ let mut level_rng = DungeonRng::seed_from_u64(game_rng.random());
let floor = bsp::generate(&mut level_rng);
let player = Player::new(floor.player_start());
let enemies = vec![];
@@ -110,7 +109,7 @@ impl Dungeon {
/// Returns the runtime random number gen for the `Floor`
#[must_use]
- pub const fn rng(&mut self) -> &mut SmallRng {
+ pub const fn rng(&mut self) -> &mut DungeonRng {
&mut self.game_rng
}