Use :: prefix on external crates
This commit is contained in:
parent
2dc420bef9
commit
b115f43d5d
@ -1,9 +1,9 @@
|
|||||||
use rltk::{Point, RGB};
|
use ::rltk::{Point, RGB};
|
||||||
use serde::{Deserialize, Serialize};
|
use ::serde::{Deserialize, Serialize};
|
||||||
use specs::error::NoError;
|
use ::specs::error::NoError;
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use specs::saveload::{ConvertSaveload, Marker};
|
use ::specs::saveload::{ConvertSaveload, Marker};
|
||||||
use specs_derive::*;
|
use ::specs_derive::*;
|
||||||
|
|
||||||
#[derive(Component, ConvertSaveload, Default, Copy, Clone)]
|
#[derive(Component, ConvertSaveload, Default, Copy, Clone)]
|
||||||
pub struct Position {
|
pub struct Position {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{CombatStats, Name, Player, SufferDamage};
|
use crate::components::{CombatStats, Name, Player, SufferDamage};
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rltk::{Point, Rltk, VirtualKeyCode, RGB};
|
use ::rltk::{Point, Rltk, VirtualKeyCode, RGB};
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
CombatStats, HungerClock, HungerState, InBackpack, Name, Player, Position, Viewshed,
|
CombatStats, HungerClock, HungerState, InBackpack, Name, Player, Position, Viewshed,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{HungerClock, HungerState, SufferDamage};
|
use crate::components::{HungerClock, HungerState, SufferDamage};
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rltk::RGB;
|
use ::rltk::RGB;
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -50,7 +50,7 @@ macro_rules! register {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SHOW_MAPGEN_VISUALIZER: bool = false;
|
const SHOW_MAPGEN_VISUALIZER: bool = true;
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
pub enum RunState {
|
pub enum RunState {
|
||||||
@ -485,10 +485,8 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> rltk::BError {
|
fn main() -> ::rltk::BError {
|
||||||
use rltk::RltkBuilder;
|
let context = ::rltk::RltkBuilder::simple80x50()
|
||||||
|
|
||||||
let context = RltkBuilder::simple80x50()
|
|
||||||
.with_title("Roguelike Tutorial")
|
.with_title("Roguelike Tutorial")
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
@ -542,7 +540,7 @@ fn main() -> rltk::BError {
|
|||||||
|
|
||||||
gs.ecs.insert(Map::new(1, 64, 64));
|
gs.ecs.insert(Map::new(1, 64, 64));
|
||||||
gs.ecs.insert(Point::zero());
|
gs.ecs.insert(Point::zero());
|
||||||
gs.ecs.insert(rltk::RandomNumberGenerator::new());
|
gs.ecs.insert(RandomNumberGenerator::new());
|
||||||
|
|
||||||
let player_entity = spawner::player(&mut gs.ecs, 0, 0);
|
let player_entity = spawner::player(&mut gs.ecs, 0, 0);
|
||||||
gs.ecs.insert(player_entity);
|
gs.ecs.insert(player_entity);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use ::serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
|
||||||
pub enum TileType {
|
pub enum TileType {
|
||||||
|
@ -29,6 +29,7 @@ mod voronoi_spawning;
|
|||||||
mod waveform_collapse;
|
mod waveform_collapse;
|
||||||
|
|
||||||
use ::rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
use ::specs::prelude::*;
|
||||||
use area_starting_points::{AreaStartingPosition, XStart, YStart};
|
use area_starting_points::{AreaStartingPosition, XStart, YStart};
|
||||||
use bsp_dungeon::BspDungeonBuilder;
|
use bsp_dungeon::BspDungeonBuilder;
|
||||||
use bsp_interior::BspInteriorBuilder;
|
use bsp_interior::BspInteriorBuilder;
|
||||||
@ -53,7 +54,6 @@ use rooms_corridors_dogleg::DoglegCorridors;
|
|||||||
use rooms_corridors_lines::StraightLineCorridors;
|
use rooms_corridors_lines::StraightLineCorridors;
|
||||||
use rooms_corridors_nearest::NearestCorridors;
|
use rooms_corridors_nearest::NearestCorridors;
|
||||||
use simple_map::SimpleMapBuilder;
|
use simple_map::SimpleMapBuilder;
|
||||||
use specs::prelude::*;
|
|
||||||
use town::town_builder;
|
use town::town_builder;
|
||||||
use voronoi::VoronoiCellBuilder;
|
use voronoi::VoronoiCellBuilder;
|
||||||
use voronoi_spawning::VoronoiSpawning;
|
use voronoi_spawning::VoronoiSpawning;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::{map, Position};
|
use crate::{map, Position};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
||||||
use crate::{Rect, TileType};
|
use crate::{Rect, TileType};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::common::draw_corridor;
|
use crate::map_builders::common::draw_corridor;
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
|
||||||
use crate::TileType;
|
use crate::TileType;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::TileType;
|
use crate::TileType;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::TileType;
|
use crate::TileType;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::common::{paint, Symmetry};
|
use super::common::{paint, Symmetry};
|
||||||
use crate::components::Position;
|
use crate::components::Position;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::TileType;
|
use crate::TileType;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::common::{paint, Symmetry};
|
use super::common::{paint, Symmetry};
|
||||||
use crate::components::Position;
|
use crate::components::Position;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
||||||
use crate::{Map, TileType};
|
use crate::{Map, TileType};
|
||||||
|
@ -4,7 +4,7 @@ pub mod prefab_sections;
|
|||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
|
||||||
use crate::{Position, TileType};
|
use crate::{Position, TileType};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{spawner, BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{spawner, BuilderMap, MetaMapBuilder};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::TileType;
|
use crate::TileType;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::Position;
|
use crate::Position;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::{Rect, TileType};
|
use crate::{Rect, TileType};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::spawner;
|
use crate::spawner;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::{Rect, TileType};
|
use crate::{Rect, TileType};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::common::{paint, Symmetry};
|
use crate::map_builders::common::{paint, Symmetry};
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::Rect;
|
use crate::Rect;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::common::draw_corridor;
|
use super::common::draw_corridor;
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::common::{apply_horizontal_tunnel, apply_vertical_tunnel};
|
use super::common::{apply_horizontal_tunnel, apply_vertical_tunnel};
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::{Rect, TileType};
|
use crate::{Rect, TileType};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::common::draw_corridor;
|
use super::common::draw_corridor;
|
||||||
use super::{BuilderMap, MetaMapBuilder};
|
use super::{BuilderMap, MetaMapBuilder};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
||||||
use crate::Rect;
|
use crate::Rect;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use super::{BuilderChain, BuilderMap, InitialMapBuilder};
|
use super::{BuilderChain, BuilderMap, InitialMapBuilder};
|
||||||
use crate::map_builders::area_starting_points::AreaStartingPosition;
|
use crate::map_builders::area_starting_points::AreaStartingPosition;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
use crate::map_builders::{BuilderMap, InitialMapBuilder};
|
||||||
use crate::TileType;
|
use crate::TileType;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
use crate::{spawner, TileType};
|
use crate::{spawner, TileType};
|
||||||
|
@ -2,9 +2,9 @@ mod common;
|
|||||||
mod constraints;
|
mod constraints;
|
||||||
mod solver;
|
mod solver;
|
||||||
|
|
||||||
|
use ::rltk::RandomNumberGenerator;
|
||||||
use common::*;
|
use common::*;
|
||||||
use constraints::*;
|
use constraints::*;
|
||||||
use rltk::RandomNumberGenerator;
|
|
||||||
use solver::*;
|
use solver::*;
|
||||||
|
|
||||||
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
use crate::map_builders::{BuilderMap, MetaMapBuilder};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::{BlocksTile, Map, Position};
|
use crate::{BlocksTile, Map, Position};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rltk::RGB;
|
use ::rltk::RGB;
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
CombatStats, DefenseBonus, Equipped, HungerClock, HungerState, MeleePowerBonus, Name,
|
CombatStats, DefenseBonus, Equipped, HungerClock, HungerState, MeleePowerBonus, Name,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rltk::{Point, RGB};
|
use ::rltk::{Point, RGB};
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{Confusion, Monster, Position, Viewshed, WantsToMelee};
|
use crate::components::{Confusion, Monster, Position, Viewshed, WantsToMelee};
|
||||||
use crate::particle_system::ParticleBuilder;
|
use crate::particle_system::ParticleBuilder;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rltk::{Rltk, RGB};
|
use ::rltk::{Rltk, RGB};
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{ParticleLifetime, Renderable};
|
use crate::components::{ParticleLifetime, Renderable};
|
||||||
use crate::Position;
|
use crate::Position;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
use rltk::{Point, Rltk, VirtualKeyCode};
|
use ::rltk::{Point, Rltk, VirtualKeyCode};
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
BlocksTile, BlocksVisibility, CombatStats, Door, EntityMoved, HungerClock, HungerState, Item,
|
BlocksTile, BlocksVisibility, CombatStats, Door, EntityMoved, HungerClock, HungerState, Item,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
pub struct RandomEntry {
|
pub struct RandomEntry {
|
||||||
name: String,
|
name: String,
|
||||||
|
11
src/raws.rs
11
src/raws.rs
@ -6,11 +6,12 @@ mod spawn_table_structs;
|
|||||||
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
use ::rltk::{embedded_resource, link_resource};
|
||||||
|
use ::serde::Deserialize;
|
||||||
use item_structs::*;
|
use item_structs::*;
|
||||||
use mob_structs::*;
|
use mob_structs::*;
|
||||||
use prop_structs::*;
|
use prop_structs::*;
|
||||||
pub use rawmaster::*;
|
pub use rawmaster::*;
|
||||||
use serde::Deserialize;
|
|
||||||
use spawn_table_structs::*;
|
use spawn_table_structs::*;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
@ -21,23 +22,23 @@ pub struct Raws {
|
|||||||
pub spawn_table: Vec<SpawnTableEntry>,
|
pub spawn_table: Vec<SpawnTableEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
rltk::embedded_resource!(RAW_FILE, "../raws/spawns.json");
|
embedded_resource!(RAW_FILE, "../raws/spawns.json");
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref RAWS: Mutex<RawMaster> = Mutex::new(RawMaster::empty());
|
pub static ref RAWS: Mutex<RawMaster> = Mutex::new(RawMaster::empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_raws() {
|
pub fn load_raws() {
|
||||||
rltk::link_resource!(RAW_FILE, "../raws/spawns.json");
|
link_resource!(RAW_FILE, "../raws/spawns.json");
|
||||||
|
|
||||||
let raw_data = rltk::embedding::EMBED
|
let raw_data = ::rltk::embedding::EMBED
|
||||||
.lock()
|
.lock()
|
||||||
.get_resource("../raws/spawns.json".to_string())
|
.get_resource("../raws/spawns.json".to_string())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let raw_string =
|
let raw_string =
|
||||||
std::str::from_utf8(raw_data).expect("Unable to convert to a valid UTF-8 string.");
|
std::str::from_utf8(raw_data).expect("Unable to convert to a valid UTF-8 string.");
|
||||||
let decoder: Raws = serde_json::from_str(raw_string).expect("Unable to parse JSON");
|
let decoder: Raws = ::serde_json::from_str(raw_string).expect("Unable to parse JSON");
|
||||||
|
|
||||||
RAWS.lock().unwrap().load(decoder);
|
RAWS.lock().unwrap().load(decoder);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use ::serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use serde::Deserialize;
|
use ::serde::Deserialize;
|
||||||
|
|
||||||
use super::item_structs::Renderable;
|
use super::item_structs::Renderable;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use ::serde::Deserialize;
|
||||||
|
|
||||||
use super::Renderable;
|
use super::Renderable;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
use crate::random_table::RandomTable;
|
use crate::random_table::RandomTable;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use serde::Deserialize;
|
use ::serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct SpawnTableEntry {
|
pub struct SpawnTableEntry {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use ::serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
|
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
|
||||||
pub struct Rect {
|
pub struct Rect {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use rltk::rex::XpFile;
|
use ::rltk::rex::XpFile;
|
||||||
|
use ::rltk::{embedded_resource, link_resource};
|
||||||
|
|
||||||
rltk::embedded_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
|
embedded_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
|
||||||
rltk::embedded_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
|
embedded_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
|
||||||
rltk::embedded_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
|
embedded_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
|
||||||
|
|
||||||
pub struct RexAssets {
|
pub struct RexAssets {
|
||||||
pub menu: XpFile,
|
pub menu: XpFile,
|
||||||
@ -10,9 +11,9 @@ pub struct RexAssets {
|
|||||||
|
|
||||||
impl RexAssets {
|
impl RexAssets {
|
||||||
pub fn new() -> RexAssets {
|
pub fn new() -> RexAssets {
|
||||||
rltk::link_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
|
link_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
|
||||||
rltk::link_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
|
link_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
|
||||||
rltk::link_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
|
link_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
|
||||||
|
|
||||||
RexAssets {
|
RexAssets {
|
||||||
menu: XpFile::from_resource("../resources/SmallDungeon_80x50.xp").unwrap(),
|
menu: XpFile::from_resource("../resources/SmallDungeon_80x50.xp").unwrap(),
|
||||||
|
@ -2,13 +2,15 @@ use std::fs;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use specs::error::NoError;
|
use ::rltk::Point;
|
||||||
use specs::prelude::*;
|
use ::specs::error::NoError;
|
||||||
use specs::saveload::{
|
use ::specs::prelude::*;
|
||||||
|
use ::specs::saveload::{
|
||||||
DeserializeComponents, MarkedBuilder, SerializeComponents, SimpleMarker, SimpleMarkerAllocator,
|
DeserializeComponents, MarkedBuilder, SerializeComponents, SimpleMarker, SimpleMarkerAllocator,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
|
use crate::map::Map;
|
||||||
|
|
||||||
macro_rules! serialize_individually {
|
macro_rules! serialize_individually {
|
||||||
($ecs:expr, $ser:expr, $data:expr, $( $type:ty),*,) => {
|
($ecs:expr, $ser:expr, $data:expr, $( $type:ty),*,) => {
|
||||||
@ -30,7 +32,7 @@ pub fn save_game(_ecs: &mut World) {}
|
|||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn save_game(ecs: &mut World) {
|
pub fn save_game(ecs: &mut World) {
|
||||||
// Create helper
|
// Create helper
|
||||||
let mapcopy = ecs.get_mut::<crate::map::Map>().unwrap().clone();
|
let mapcopy = ecs.get_mut::<Map>().unwrap().clone();
|
||||||
let savehelper = ecs
|
let savehelper = ecs
|
||||||
.create_entity()
|
.create_entity()
|
||||||
.with(SerializationHelper { map: mapcopy })
|
.with(SerializationHelper { map: mapcopy })
|
||||||
@ -45,7 +47,7 @@ pub fn save_game(ecs: &mut World) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let writer = File::create("./savegame.json").unwrap();
|
let writer = File::create("./savegame.json").unwrap();
|
||||||
let mut serializer = serde_json::Serializer::new(writer);
|
let mut serializer = ::serde_json::Serializer::new(writer);
|
||||||
serialize_individually!(
|
serialize_individually!(
|
||||||
ecs,
|
ecs,
|
||||||
serializer,
|
serializer,
|
||||||
@ -128,7 +130,7 @@ pub fn load_game(ecs: &mut World) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let data = fs::read_to_string("./savegame.json").unwrap();
|
let data = fs::read_to_string("./savegame.json").unwrap();
|
||||||
let mut de = serde_json::Deserializer::from_str(&data);
|
let mut de = ::serde_json::Deserializer::from_str(&data);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut d = (
|
let mut d = (
|
||||||
@ -189,15 +191,15 @@ pub fn load_game(ecs: &mut World) {
|
|||||||
let position = ecs.read_storage::<Position>();
|
let position = ecs.read_storage::<Position>();
|
||||||
|
|
||||||
for (e, h) in (&entities, &helper).join() {
|
for (e, h) in (&entities, &helper).join() {
|
||||||
let mut worldmap = ecs.write_resource::<crate::map::Map>();
|
let mut worldmap = ecs.write_resource::<Map>();
|
||||||
*worldmap = h.map.clone();
|
*worldmap = h.map.clone();
|
||||||
worldmap.tile_content = vec![Vec::new(); (worldmap.height * worldmap.width) as usize];
|
worldmap.tile_content = vec![Vec::new(); (worldmap.height * worldmap.width) as usize];
|
||||||
deleteme = Some(e);
|
deleteme = Some(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (e, _p, pos) in (&entities, &player, &position).join() {
|
for (e, _p, pos) in (&entities, &player, &position).join() {
|
||||||
let mut ppos = ecs.write_resource::<rltk::Point>();
|
let mut ppos = ecs.write_resource::<Point>();
|
||||||
*ppos = rltk::Point::new(pos.x, pos.y);
|
*ppos = Point::new(pos.x, pos.y);
|
||||||
|
|
||||||
let mut player_resource = ecs.write_resource::<Entity>();
|
let mut player_resource = ecs.write_resource::<Entity>();
|
||||||
*player_resource = e;
|
*player_resource = e;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use rltk::{RandomNumberGenerator, RGB};
|
use ::rltk::{RandomNumberGenerator, RGB};
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use specs::saveload::{MarkedBuilder, SimpleMarker};
|
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||||
|
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
use crate::random_table::RandomTable;
|
use crate::random_table::RandomTable;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
EntityMoved, EntryTrigger, Hidden, InflictsDamage, Name, Position, SingleActivation,
|
EntityMoved, EntryTrigger, Hidden, InflictsDamage, Name, Position, SingleActivation,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rltk::{field_of_view, Point, RandomNumberGenerator};
|
use ::rltk::{field_of_view, Point, RandomNumberGenerator};
|
||||||
use specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use crate::components::{BlocksVisibility, Hidden, Name};
|
use crate::components::{BlocksVisibility, Hidden, Name};
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
|
Loading…
Reference in New Issue
Block a user