warnings cleanup and MasterDungeonMap class
This commit is contained in:
parent
75e17f235d
commit
557b7095b9
4 changed files with 35 additions and 0 deletions
29
src/map/dungeon.rs
Normal file
29
src/map/dungeon.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
use super::Map;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct MasterDungeonMap {
|
||||||
|
maps: HashMap<i32, Map>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MasterDungeonMap {
|
||||||
|
/// Initialises a blank MasterDungeonMap
|
||||||
|
pub fn new() -> MasterDungeonMap {
|
||||||
|
return MasterDungeonMap { maps: HashMap::new() };
|
||||||
|
}
|
||||||
|
/// Stores the given map in the MasterDungeonMap
|
||||||
|
pub fn store_map(&mut self, map: &Map) {
|
||||||
|
self.maps.insert(map.id, map.clone());
|
||||||
|
}
|
||||||
|
/// Gets a map by ID from the MasterDungeonMap
|
||||||
|
pub fn get_map(&self, id: i32) -> Option<Map> {
|
||||||
|
if self.maps.contains_key(&id) {
|
||||||
|
let mut result = self.maps[&id].clone();
|
||||||
|
result.tile_content = vec![Vec::new(); (result.width * result.height) as usize];
|
||||||
|
return Some(result);
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// DEFAULT THEME
|
// DEFAULT THEME
|
||||||
|
#[allow(dead_code)]
|
||||||
pub const WALL_GLYPH: char = '#';
|
pub const WALL_GLYPH: char = '#';
|
||||||
pub const FLOOR_GLYPH: char = '.';
|
pub const FLOOR_GLYPH: char = '.';
|
||||||
pub const DOWN_STAIR_GLYPH: char = '>';
|
pub const DOWN_STAIR_GLYPH: char = '>';
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ mod tiletype;
|
||||||
pub use tiletype::{tile_cost, tile_opaque, tile_walkable, TileType};
|
pub use tiletype::{tile_cost, tile_opaque, tile_walkable, TileType};
|
||||||
mod interval_spawning_system;
|
mod interval_spawning_system;
|
||||||
pub use interval_spawning_system::try_spawn_interval;
|
pub use interval_spawning_system::try_spawn_interval;
|
||||||
|
pub mod dungeon;
|
||||||
pub mod themes;
|
pub mod themes;
|
||||||
|
|
||||||
// FIXME: If the map size gets too small, entities stop being rendered starting from the right.
|
// FIXME: If the map size gets too small, entities stop being rendered starting from the right.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,9 @@ pub fn get_tile_renderables_for_id(idx: usize, map: &Map) -> (rltk::FontCharType
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub fn get_default_theme_renderables(idx: usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
|
pub fn get_default_theme_renderables(idx: usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
|
||||||
let glyph: rltk::FontCharType;
|
let glyph: rltk::FontCharType;
|
||||||
|
#[allow(unused_assignments)]
|
||||||
let mut fg: RGB = RGB::new();
|
let mut fg: RGB = RGB::new();
|
||||||
|
#[allow(unused_assignments)]
|
||||||
let mut bg: RGB = RGB::new();
|
let mut bg: RGB = RGB::new();
|
||||||
|
|
||||||
match map.tiles[idx] {
|
match map.tiles[idx] {
|
||||||
|
|
@ -52,7 +54,9 @@ pub fn get_default_theme_renderables(idx: usize, map: &Map) -> (rltk::FontCharTy
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn get_forest_theme_renderables(idx:usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
|
fn get_forest_theme_renderables(idx:usize, map: &Map) -> (rltk::FontCharType, RGB, RGB) {
|
||||||
let glyph;
|
let glyph;
|
||||||
|
#[allow(unused_assignments)]
|
||||||
let mut fg = RGB::new();
|
let mut fg = RGB::new();
|
||||||
|
#[allow(unused_assignments)]
|
||||||
let mut bg = RGB::new();
|
let mut bg = RGB::new();
|
||||||
|
|
||||||
match map.tiles[idx] {
|
match map.tiles[idx] {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue