Use :: prefix on external crates

This commit is contained in:
Timothy Warren 2021-12-24 10:38:44 -05:00
parent 2dc420bef9
commit b115f43d5d
54 changed files with 93 additions and 91 deletions

View File

@ -1,9 +1,9 @@
use rltk::{Point, RGB};
use serde::{Deserialize, Serialize};
use specs::error::NoError;
use specs::prelude::*;
use specs::saveload::{ConvertSaveload, Marker};
use specs_derive::*;
use ::rltk::{Point, RGB};
use ::serde::{Deserialize, Serialize};
use ::specs::error::NoError;
use ::specs::prelude::*;
use ::specs::saveload::{ConvertSaveload, Marker};
use ::specs_derive::*;
#[derive(Component, ConvertSaveload, Default, Copy, Clone)]
pub struct Position {

View File

@ -1,4 +1,4 @@
use specs::prelude::*;
use ::specs::prelude::*;
use crate::components::{CombatStats, Name, Player, SufferDamage};
use crate::game_log::GameLog;

View File

@ -1,5 +1,5 @@
use rltk::{Point, Rltk, VirtualKeyCode, RGB};
use specs::prelude::*;
use ::rltk::{Point, Rltk, VirtualKeyCode, RGB};
use ::specs::prelude::*;
use crate::components::{
CombatStats, HungerClock, HungerState, InBackpack, Name, Player, Position, Viewshed,

View File

@ -1,4 +1,4 @@
use specs::prelude::*;
use ::specs::prelude::*;
use crate::components::{HungerClock, HungerState, SufferDamage};
use crate::game_log::GameLog;

View File

@ -1,5 +1,5 @@
use rltk::RGB;
use specs::prelude::*;
use ::rltk::RGB;
use ::specs::prelude::*;
use crate::components::*;
use crate::game_log::GameLog;

View File

@ -50,7 +50,7 @@ macro_rules! register {
}
}
const SHOW_MAPGEN_VISUALIZER: bool = false;
const SHOW_MAPGEN_VISUALIZER: bool = true;
#[derive(PartialEq, Copy, Clone)]
pub enum RunState {
@ -485,10 +485,8 @@ impl State {
}
}
fn main() -> rltk::BError {
use rltk::RltkBuilder;
let context = RltkBuilder::simple80x50()
fn main() -> ::rltk::BError {
let context = ::rltk::RltkBuilder::simple80x50()
.with_title("Roguelike Tutorial")
.build()?;
@ -542,7 +540,7 @@ fn main() -> rltk::BError {
gs.ecs.insert(Map::new(1, 64, 64));
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);
gs.ecs.insert(player_entity);

View File

@ -1,4 +1,4 @@
use serde::{Deserialize, Serialize};
use ::serde::{Deserialize, Serialize};
#[derive(PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
pub enum TileType {

View File

@ -29,6 +29,7 @@ mod voronoi_spawning;
mod waveform_collapse;
use ::rltk::RandomNumberGenerator;
use ::specs::prelude::*;
use area_starting_points::{AreaStartingPosition, XStart, YStart};
use bsp_dungeon::BspDungeonBuilder;
use bsp_interior::BspInteriorBuilder;
@ -53,7 +54,6 @@ use rooms_corridors_dogleg::DoglegCorridors;
use rooms_corridors_lines::StraightLineCorridors;
use rooms_corridors_nearest::NearestCorridors;
use simple_map::SimpleMapBuilder;
use specs::prelude::*;
use town::town_builder;
use voronoi::VoronoiCellBuilder;
use voronoi_spawning::VoronoiSpawning;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::{map, Position};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, InitialMapBuilder};
use crate::{Rect, TileType};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::common::draw_corridor;
use crate::map_builders::{BuilderMap, InitialMapBuilder};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
use crate::TileType;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::TileType;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::TileType;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::common::{paint, Symmetry};
use crate::components::Position;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::{BuilderMap, MetaMapBuilder};
use crate::TileType;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::common::{paint, Symmetry};
use crate::components::Position;

View File

@ -1,6 +1,6 @@
use std::cmp::{max, min};
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, InitialMapBuilder};
use crate::{Map, TileType};

View File

@ -4,7 +4,7 @@ pub mod prefab_sections;
use std::collections::HashSet;
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
use crate::{Position, TileType};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{spawner, BuilderMap, MetaMapBuilder};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::TileType;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::Position;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::{Rect, TileType};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::{BuilderMap, MetaMapBuilder};
use crate::spawner;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::{BuilderMap, MetaMapBuilder};
use crate::{Rect, TileType};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::common::{paint, Symmetry};
use crate::map_builders::{BuilderMap, MetaMapBuilder};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::{BuilderMap, MetaMapBuilder};
use crate::Rect;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::common::draw_corridor;
use super::{BuilderMap, MetaMapBuilder};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::common::{apply_horizontal_tunnel, apply_vertical_tunnel};
use crate::map_builders::{BuilderMap, MetaMapBuilder};

View File

@ -1,6 +1,6 @@
use std::collections::HashSet;
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::{BuilderMap, MetaMapBuilder};
use crate::{Rect, TileType};

View File

@ -1,6 +1,6 @@
use std::collections::HashSet;
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::common::draw_corridor;
use super::{BuilderMap, MetaMapBuilder};

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, InitialMapBuilder};
use crate::Rect;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use super::{BuilderChain, BuilderMap, InitialMapBuilder};
use crate::map_builders::area_starting_points::AreaStartingPosition;

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, InitialMapBuilder};
use crate::TileType;

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
use crate::map_builders::{BuilderMap, MetaMapBuilder};
use crate::{spawner, TileType};

View File

@ -2,9 +2,9 @@ mod common;
mod constraints;
mod solver;
use ::rltk::RandomNumberGenerator;
use common::*;
use constraints::*;
use rltk::RandomNumberGenerator;
use solver::*;
use crate::map_builders::{BuilderMap, MetaMapBuilder};

View File

@ -1,4 +1,4 @@
use specs::prelude::*;
use ::specs::prelude::*;
use crate::{BlocksTile, Map, Position};

View File

@ -1,5 +1,5 @@
use rltk::RGB;
use specs::prelude::*;
use ::rltk::RGB;
use ::specs::prelude::*;
use crate::components::{
CombatStats, DefenseBonus, Equipped, HungerClock, HungerState, MeleePowerBonus, Name,

View File

@ -1,5 +1,5 @@
use rltk::{Point, RGB};
use specs::prelude::*;
use ::rltk::{Point, RGB};
use ::specs::prelude::*;
use crate::components::{Confusion, Monster, Position, Viewshed, WantsToMelee};
use crate::particle_system::ParticleBuilder;

View File

@ -1,5 +1,5 @@
use rltk::{Rltk, RGB};
use specs::prelude::*;
use ::rltk::{Rltk, RGB};
use ::specs::prelude::*;
use crate::components::{ParticleLifetime, Renderable};
use crate::Position;

View File

@ -1,7 +1,7 @@
use std::cmp::{max, min};
use rltk::{Point, Rltk, VirtualKeyCode};
use specs::prelude::*;
use ::rltk::{Point, Rltk, VirtualKeyCode};
use ::specs::prelude::*;
use crate::components::{
BlocksTile, BlocksVisibility, CombatStats, Door, EntityMoved, HungerClock, HungerState, Item,

View File

@ -1,4 +1,4 @@
use rltk::RandomNumberGenerator;
use ::rltk::RandomNumberGenerator;
pub struct RandomEntry {
name: String,

View File

@ -6,11 +6,12 @@ mod spawn_table_structs;
use std::sync::Mutex;
use ::rltk::{embedded_resource, link_resource};
use ::serde::Deserialize;
use item_structs::*;
use mob_structs::*;
use prop_structs::*;
pub use rawmaster::*;
use serde::Deserialize;
use spawn_table_structs::*;
#[derive(Deserialize, Debug)]
@ -21,23 +22,23 @@ pub struct Raws {
pub spawn_table: Vec<SpawnTableEntry>,
}
rltk::embedded_resource!(RAW_FILE, "../raws/spawns.json");
embedded_resource!(RAW_FILE, "../raws/spawns.json");
lazy_static! {
pub static ref RAWS: Mutex<RawMaster> = Mutex::new(RawMaster::empty());
}
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()
.get_resource("../raws/spawns.json".to_string())
.unwrap();
let raw_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);
}

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use serde::Deserialize;
use ::serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Item {

View File

@ -1,4 +1,4 @@
use serde::Deserialize;
use ::serde::Deserialize;
use super::item_structs::Renderable;

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use serde::Deserialize;
use ::serde::Deserialize;
use super::Renderable;

View File

@ -1,6 +1,6 @@
use std::collections::{HashMap, HashSet};
use specs::prelude::*;
use ::specs::prelude::*;
use crate::components::*;
use crate::random_table::RandomTable;

View File

@ -1,4 +1,4 @@
use serde::Deserialize;
use ::serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct SpawnTableEntry {

View File

@ -1,4 +1,4 @@
use serde::{Deserialize, Serialize};
use ::serde::{Deserialize, Serialize};
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize)]
pub struct Rect {

View File

@ -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");
rltk::embedded_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
rltk::embedded_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
embedded_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
embedded_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
embedded_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
pub struct RexAssets {
pub menu: XpFile,
@ -10,9 +11,9 @@ pub struct RexAssets {
impl RexAssets {
pub fn new() -> RexAssets {
rltk::link_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
rltk::link_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
rltk::link_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
link_resource!(SMALL_DUNGEON, "../resources/SmallDungeon_80x50.xp");
link_resource!(WFC_DEMO_IMAGE1, "../resources/wfc-demo1.xp");
link_resource!(WFC_POPULATED, "../resources/wfc-populated.xp");
RexAssets {
menu: XpFile::from_resource("../resources/SmallDungeon_80x50.xp").unwrap(),

View File

@ -2,13 +2,15 @@ use std::fs;
use std::fs::File;
use std::path::Path;
use specs::error::NoError;
use specs::prelude::*;
use specs::saveload::{
use ::rltk::Point;
use ::specs::error::NoError;
use ::specs::prelude::*;
use ::specs::saveload::{
DeserializeComponents, MarkedBuilder, SerializeComponents, SimpleMarker, SimpleMarkerAllocator,
};
use crate::components::*;
use crate::map::Map;
macro_rules! serialize_individually {
($ecs:expr, $ser:expr, $data:expr, $( $type:ty),*,) => {
@ -30,7 +32,7 @@ pub fn save_game(_ecs: &mut World) {}
#[cfg(not(target_arch = "wasm32"))]
pub fn save_game(ecs: &mut World) {
// Create helper
let mapcopy = ecs.get_mut::<crate::map::Map>().unwrap().clone();
let mapcopy = ecs.get_mut::<Map>().unwrap().clone();
let savehelper = ecs
.create_entity()
.with(SerializationHelper { map: mapcopy })
@ -45,7 +47,7 @@ pub fn save_game(ecs: &mut World) {
);
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!(
ecs,
serializer,
@ -128,7 +130,7 @@ pub fn load_game(ecs: &mut World) {
}
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 = (
@ -189,15 +191,15 @@ pub fn load_game(ecs: &mut World) {
let position = ecs.read_storage::<Position>();
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.tile_content = vec![Vec::new(); (worldmap.height * worldmap.width) as usize];
deleteme = Some(e);
}
for (e, _p, pos) in (&entities, &player, &position).join() {
let mut ppos = ecs.write_resource::<rltk::Point>();
*ppos = rltk::Point::new(pos.x, pos.y);
let mut ppos = ecs.write_resource::<Point>();
*ppos = Point::new(pos.x, pos.y);
let mut player_resource = ecs.write_resource::<Entity>();
*player_resource = e;

View File

@ -1,8 +1,8 @@
use std::collections::HashMap;
use rltk::{RandomNumberGenerator, RGB};
use specs::prelude::*;
use specs::saveload::{MarkedBuilder, SimpleMarker};
use ::rltk::{RandomNumberGenerator, RGB};
use ::specs::prelude::*;
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
use crate::components::*;
use crate::random_table::RandomTable;

View File

@ -1,4 +1,4 @@
use specs::prelude::*;
use ::specs::prelude::*;
use crate::components::{
EntityMoved, EntryTrigger, Hidden, InflictsDamage, Name, Position, SingleActivation,

View File

@ -1,5 +1,5 @@
use rltk::{field_of_view, Point, RandomNumberGenerator};
use specs::prelude::*;
use ::rltk::{field_of_view, Point, RandomNumberGenerator};
use ::specs::prelude::*;
use crate::components::{BlocksVisibility, Hidden, Name};
use crate::game_log::GameLog;