Use new logging system at setup

This commit is contained in:
Timothy Warren 2022-02-01 09:22:23 -05:00
parent c3e51d7b06
commit 88fc0dbcea
2 changed files with 22 additions and 15 deletions

View File

@ -38,7 +38,6 @@ mod visibility_system;
use ::specs::prelude::*; use ::specs::prelude::*;
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator}; use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
use components::*; use components::*;
pub use game_log::GameLog;
pub use map::*; pub use map::*;
pub use rect::Rect; pub use rect::Rect;
pub use state::*; pub use state::*;
@ -69,17 +68,7 @@ macro_rules! register {
} }
} }
/// Sets up the game. fn register_components(state: &mut State) {
///
/// * Creates the [`State`] object
/// * Registers [`components`](register!)
/// * Loads the dynamic game entities using the [`raws`](crate::raws::load_raws) module
/// * Generates the map builder environment
/// * Creates the [`Player`](crate::spawner::player)
/// * Generates the first [`map`](crate::state::State::generate_world_map)
fn init_state() -> State {
let mut state = State::new();
register!( register!(
state <- state <-
AlwaysTargetsSelf, AlwaysTargetsSelf,
@ -164,6 +153,20 @@ fn init_state() -> State {
Weapon, Weapon,
Wearable, Wearable,
); );
}
/// Sets up the game.
///
/// * Creates the [`State`] object
/// * Registers [`components`](register!)
/// * Loads the dynamic game entities using the [`raws`](crate::raws::load_raws) module
/// * Generates the map builder environment
/// * Creates the [`Player`](crate::spawner::player)
/// * Generates the first [`map`](crate::state::State::generate_world_map)
fn init_state() -> State {
let mut state = State::new();
register_components(&mut state);
state state
.ecs .ecs
@ -180,7 +183,6 @@ fn init_state() -> State {
state.ecs.insert(player_entity); state.ecs.insert(player_entity);
state.ecs.insert(RunState::MapGeneration {}); state.ecs.insert(RunState::MapGeneration {});
state.ecs.insert(GameLog::new("Welcome to Rusty Roguelike"));
state.ecs.insert(particle_system::ParticleBuilder::new()); state.ecs.insert(particle_system::ParticleBuilder::new());
state.ecs.insert(rex_assets::RexAssets::new()); state.ecs.insert(rex_assets::RexAssets::new());

View File

@ -3,7 +3,6 @@ use ::rltk::{GameState, Point, Rltk};
use ::specs::prelude::*; use ::specs::prelude::*;
use crate::components::*; use crate::components::*;
use crate::game_log::GameLog;
use crate::gui::{self, show_cheat_mode, CheatMenuResult, MainMenuSelection}; use crate::gui::{self, show_cheat_mode, CheatMenuResult, MainMenuSelection};
use crate::hunger_system::HungerSystem; use crate::hunger_system::HungerSystem;
use crate::inventory_system::{ use crate::inventory_system::{
@ -21,7 +20,7 @@ use crate::ranged_combat_system::RangedCombatSystem;
use crate::raws::*; use crate::raws::*;
use crate::trigger_system::TriggerSystem; use crate::trigger_system::TriggerSystem;
use crate::visibility_system::VisibilitySystem; use crate::visibility_system::VisibilitySystem;
use crate::{ai, camera, damage_system, effects, player, saveload_system, spawner}; use crate::{ai, camera, damage_system, effects, game_log, player, saveload_system, spawner};
/// Whether to show a visual representation of map generation /// Whether to show a visual representation of map generation
pub const SHOW_MAPGEN_VISUALIZER: bool = false; pub const SHOW_MAPGEN_VISUALIZER: bool = false;
@ -163,6 +162,12 @@ impl State {
} else { } else {
map::thaw_level_entities(&mut self.ecs); map::thaw_level_entities(&mut self.ecs);
} }
// Set up the game log
game_log::clear_log();
game_log::line("Welcome to")
.append_color(colors::CYAN, "Rusty Roguelike")
.log();
} }
} }