Reorder use statements

This commit is contained in:
Timothy Warren 2021-12-10 20:16:48 -05:00
parent ce3d92bfe2
commit 9ff645066b
30 changed files with 140 additions and 78 deletions

View File

@ -14,7 +14,7 @@ lint:
cargo clippy
fmt:
cargo fmt
cargo +nightly fmt
fix: fmt
cargo fix --allow-dirty --allow-staged

7
rustfmt.toml Normal file
View File

@ -0,0 +1,7 @@
unstable_features = true
format_code_in_doc_comments = true
format_macro_matchers = true
format_strings = true
imports_granularity = "Module"
group_imports = "StdExternalCrate"
use_field_init_shorthand = true

View File

@ -1,7 +1,9 @@
use crate::components::{CombatStats, Name, Player, SufferDamage};
use crate::{game_log::GameLog, Map, Position, RunState};
use specs::prelude::*;
use crate::components::{CombatStats, Name, Player, SufferDamage};
use crate::game_log::GameLog;
use crate::{Map, Position, RunState};
pub struct DamageSystem {}
impl<'a> System<'a> for DamageSystem {

View File

@ -1,9 +1,12 @@
use rltk::{Point, Rltk, VirtualKeyCode, RGB};
use specs::prelude::*;
use crate::components::{
CombatStats, HungerClock, HungerState, InBackpack, Name, Player, Position, Viewshed,
};
use crate::{game_log::GameLog, rex_assets::RexAssets, Equipped, Hidden, Map, RunState, State};
use rltk::{Point, Rltk, VirtualKeyCode, RGB};
use specs::prelude::*;
use crate::game_log::GameLog;
use crate::rex_assets::RexAssets;
use crate::{Equipped, Hidden, Map, RunState, State};
pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
ctx.draw_box(

View File

@ -1,7 +1,9 @@
use crate::components::{HungerClock, HungerState, SufferDamage};
use crate::{game_log::GameLog, RunState};
use specs::prelude::*;
use crate::components::{HungerClock, HungerState, SufferDamage};
use crate::game_log::GameLog;
use crate::RunState;
pub struct HungerSystem {}
impl<'a> System<'a> for HungerSystem {

View File

@ -1,8 +1,11 @@
use crate::components::*;
use crate::{game_log::GameLog, particle_system::ParticleBuilder, Map, RunState};
use rltk::RGB;
use specs::prelude::*;
use crate::components::*;
use crate::game_log::GameLog;
use crate::particle_system::ParticleBuilder;
use crate::{Map, RunState};
pub struct ItemCollectionSystem {}
impl<'a> System<'a> for ItemCollectionSystem {

View File

@ -1,7 +1,8 @@
use std::collections::HashSet;
use rltk::{Algorithm2D, BaseMap, Point, Rltk, SmallVec, RGB};
use serde::{Deserialize, Serialize};
use specs::prelude::*;
use std::collections::HashSet;
pub const MAP_WIDTH: usize = 80;
pub const MAP_HEIGHT: usize = 43;

View File

@ -10,7 +10,6 @@ mod simple_map;
mod voronoi;
mod waveform_collapse;
use crate::{spawner, Map, Position};
use bsp_dungeon::BspDungeonBuilder;
use bsp_interior::BspInteriorBuilder;
use cellular_automata::CellularAutomataBuilder;
@ -24,6 +23,8 @@ use specs::prelude::*;
use voronoi::VoronoiCellBuilder;
use waveform_collapse::WaveformCollapseBuilder;
use crate::{spawner, Map, Position};
pub trait MapBuilder {
fn get_map(&self) -> Map;
fn get_starting_position(&self) -> Position;

View File

@ -1,10 +1,11 @@
use super::MapBuilder;
use crate::map_builders::common::apply_room_to_map;
use crate::spawner;
use crate::{components::Position, Map, Rect, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::MapBuilder;
use crate::components::Position;
use crate::map_builders::common::apply_room_to_map;
use crate::{spawner, Map, Rect, TileType, SHOW_MAPGEN_VISUALIZER};
pub struct BspDungeonBuilder {
map: Map,
starting_position: Position,

View File

@ -1,9 +1,10 @@
use super::MapBuilder;
use crate::spawner;
use crate::{components::Position, Map, Rect, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::MapBuilder;
use crate::components::Position;
use crate::{spawner, Map, Rect, TileType, SHOW_MAPGEN_VISUALIZER};
const MIN_ROOM_SIZE: i32 = 8;
pub struct BspInteriorBuilder {

View File

@ -1,11 +1,14 @@
use std::collections::HashMap;
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::common::{
generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant,
};
use super::MapBuilder;
use crate::{components::Position, spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::collections::HashMap;
use crate::components::Position;
use crate::{spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
pub struct CellularAutomataBuilder {
map: Map,

View File

@ -1,7 +1,8 @@
use crate::{Map, Rect, TileType};
use std::cmp::{max, min};
use std::collections::HashMap;
use crate::{Map, Rect, TileType};
#[derive(PartialEq, Copy, Clone)]
#[allow(dead_code)]
pub enum Symmetry {

View File

@ -1,12 +1,15 @@
use std::collections::HashMap;
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::common::{
generate_voronoi_spawn_regions, paint, remove_unreachable_areas_returning_most_distant,
Symmetry,
};
use super::MapBuilder;
use crate::{components::Position, spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::collections::HashMap;
use crate::components::Position;
use crate::{spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
#[derive(PartialEq, Copy, Clone)]
pub enum DLAAlgorithm {

View File

@ -1,12 +1,15 @@
use std::collections::HashMap;
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::common::{
generate_voronoi_spawn_regions, paint, remove_unreachable_areas_returning_most_distant,
Symmetry,
};
use super::MapBuilder;
use crate::{components::Position, spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::collections::HashMap;
use crate::components::Position;
use crate::{spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
#[derive(PartialEq, Copy, Clone)]
pub enum DrunkSpawnMode {

View File

@ -1,11 +1,14 @@
use super::MapBuilder;
use super::{generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant};
use crate::{spawner, Map, Position, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::cmp::{max, min};
use std::collections::HashMap;
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::{
generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant, MapBuilder,
};
use crate::{spawner, Map, Position, TileType, SHOW_MAPGEN_VISUALIZER};
pub struct MazeBuilder {
map: Map,
starting_position: Position,

View File

@ -1,11 +1,12 @@
mod prefab_levels;
mod prefab_sections;
use super::{remove_unreachable_areas_returning_most_distant, MapBuilder};
use crate::{spawner, Map, Position, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::{remove_unreachable_areas_returning_most_distant, MapBuilder};
use crate::{spawner, Map, Position, TileType, SHOW_MAPGEN_VISUALIZER};
#[derive(PartialEq, Clone)]
#[allow(dead_code)]
pub enum PrefabMode {

View File

@ -1,9 +1,9 @@
use super::{apply_horizontal_tunnel, apply_room_to_map, apply_vertical_tunnel, MapBuilder};
use crate::{spawner, SHOW_MAPGEN_VISUALIZER};
use crate::{Map, Position, Rect, TileType};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::{apply_horizontal_tunnel, apply_room_to_map, apply_vertical_tunnel, MapBuilder};
use crate::{spawner, Map, Position, Rect, TileType, SHOW_MAPGEN_VISUALIZER};
pub struct SimpleMapBuilder {
map: Map,
starting_position: Position,

View File

@ -1,11 +1,14 @@
use std::collections::HashMap;
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use super::common::{
generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant,
};
use super::MapBuilder;
use crate::{components::Position, spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::collections::HashMap;
use crate::components::Position;
use crate::{spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
#[derive(PartialEq, Copy, Clone)]
#[allow(dead_code)]

View File

@ -2,17 +2,19 @@ mod common;
mod constraints;
mod solver;
use std::collections::HashMap;
use common::*;
use constraints::*;
use rltk::RandomNumberGenerator;
use solver::*;
use specs::prelude::*;
use super::common::{
generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant,
};
use super::MapBuilder;
use crate::{spawner, Map, Position, TileType, SHOW_MAPGEN_VISUALIZER};
use common::*;
use constraints::*;
use rltk::RandomNumberGenerator;
use solver::*;
use specs::prelude::*;
use std::collections::HashMap;
pub struct WaveformCollapseBuilder {
map: Map,

View File

@ -1,7 +1,8 @@
use std::collections::HashSet;
use super::MapChunk;
use crate::map_builders::waveform_collapse::common::tile_idx_in_chunk;
use crate::{Map, TileType};
use std::collections::HashSet;
pub fn build_patterns(
map: &Map,

View File

@ -1,6 +1,7 @@
use std::collections::HashSet;
use super::common::MapChunk;
use crate::Map;
use std::collections::HashSet;
pub struct Solver {
constraints: Vec<MapChunk>,

View File

@ -1,6 +1,7 @@
use crate::{BlocksTile, Map, Position};
use specs::prelude::*;
use crate::{BlocksTile, Map, Position};
pub struct MapIndexingSystem {}
impl<'a> System<'a> for MapIndexingSystem {

View File

@ -1,10 +1,13 @@
use rltk::RGB;
use specs::prelude::*;
use crate::components::{
CombatStats, DefenseBonus, Equipped, HungerClock, HungerState, MeleePowerBonus, Name,
SufferDamage, WantsToMelee,
};
use crate::{game_log::GameLog, particle_system::ParticleBuilder, Position};
use rltk::RGB;
use specs::prelude::*;
use crate::game_log::GameLog;
use crate::particle_system::ParticleBuilder;
use crate::Position;
pub struct MeleeCombatSystem {}

View File

@ -1,8 +1,10 @@
use crate::components::{Confusion, Monster, Position, Viewshed, WantsToMelee};
use crate::{particle_system::ParticleBuilder, EntityMoved, Map, RunState};
use rltk::{Point, RGB};
use specs::prelude::*;
use crate::components::{Confusion, Monster, Position, Viewshed, WantsToMelee};
use crate::particle_system::ParticleBuilder;
use crate::{EntityMoved, Map, RunState};
pub struct MonsterAI {}
impl<'a> System<'a> for MonsterAI {

View File

@ -1,8 +1,9 @@
use crate::components::{ParticleLifetime, Renderable};
use crate::Position;
use rltk::{Rltk, RGB};
use specs::prelude::*;
use crate::components::{ParticleLifetime, Renderable};
use crate::Position;
pub fn cull_dead_particles(ecs: &mut World, ctx: &Rltk) {
let mut dead_particles: Vec<Entity> = Vec::new();
{

View File

@ -1,11 +1,14 @@
use std::cmp::{max, min};
use rltk::{Point, Rltk, VirtualKeyCode};
use specs::prelude::*;
use crate::components::{
CombatStats, EntityMoved, HungerClock, HungerState, Item, Monster, Player, Position, Viewshed,
WantsToMelee, WantsToPickupItem,
};
use crate::{game_log::GameLog, Map, RunState, State, TileType};
use rltk::{Point, Rltk, VirtualKeyCode};
use specs::prelude::*;
use std::cmp::{max, min};
use crate::game_log::GameLog;
use crate::{Map, RunState, State, TileType};
pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
let mut positions = ecs.write_storage::<Position>();

View File

@ -1,12 +1,14 @@
use crate::components::*;
use std::fs;
use std::fs::File;
use std::path::Path;
use specs::error::NoError;
use specs::prelude::*;
use specs::saveload::{
DeserializeComponents, MarkedBuilder, SerializeComponents, SimpleMarker, SimpleMarkerAllocator,
};
use std::fs;
use std::fs::File;
use std::path::Path;
use crate::components::*;
macro_rules! serialize_individually {
($ecs:expr, $ser:expr, $data:expr, $( $type:ty),*,) => {

View File

@ -1,9 +1,13 @@
use crate::components::*;
use crate::{map::MAP_WIDTH, random_table::RandomTable, Map, Rect, TileType};
use std::collections::HashMap;
use rltk::{RandomNumberGenerator, RGB};
use specs::prelude::*;
use specs::saveload::{MarkedBuilder, SimpleMarker};
use std::collections::HashMap;
use crate::components::*;
use crate::map::MAP_WIDTH;
use crate::random_table::RandomTable;
use crate::{Map, Rect, TileType};
/// Spawns the player and returns their entity object
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {

View File

@ -1,9 +1,12 @@
use specs::prelude::*;
use crate::components::{
EntityMoved, EntryTrigger, Hidden, InflictsDamage, Name, Position, SingleActivation,
SufferDamage,
};
use crate::{game_log::GameLog, particle_system::ParticleBuilder, Map};
use specs::prelude::*;
use crate::game_log::GameLog;
use crate::particle_system::ParticleBuilder;
use crate::Map;
pub struct TriggerSystem {}

View File

@ -1,9 +1,10 @@
use crate::{
components::Hidden, components::Name, game_log::GameLog, Map, Player, Position, Viewshed,
};
use rltk::{field_of_view, Point};
use specs::prelude::*;
use crate::components::{Hidden, Name};
use crate::game_log::GameLog;
use crate::{Map, Player, Position, Viewshed};
pub struct VisibilitySystem {}
impl<'a> System<'a> for VisibilitySystem {