diff --git a/src/main.rs b/src/main.rs index 4e5a7d3..f4cd607 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,6 @@ mod visibility_system; use ::specs::prelude::*; use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator}; use components::*; -pub use game_log::GameLog; pub use map::*; pub use rect::Rect; pub use state::*; @@ -69,17 +68,7 @@ macro_rules! register { } } -/// 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(); - +fn register_components(state: &mut State) { register!( state <- AlwaysTargetsSelf, @@ -164,6 +153,20 @@ fn init_state() -> State { Weapon, 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 .ecs @@ -180,7 +183,6 @@ fn init_state() -> State { state.ecs.insert(player_entity); state.ecs.insert(RunState::MapGeneration {}); - state.ecs.insert(GameLog::new("Welcome to Rusty Roguelike")); state.ecs.insert(particle_system::ParticleBuilder::new()); state.ecs.insert(rex_assets::RexAssets::new()); diff --git a/src/state.rs b/src/state.rs index 2e0e143..e49c050 100644 --- a/src/state.rs +++ b/src/state.rs @@ -3,7 +3,6 @@ use ::rltk::{GameState, Point, Rltk}; use ::specs::prelude::*; use crate::components::*; -use crate::game_log::GameLog; use crate::gui::{self, show_cheat_mode, CheatMenuResult, MainMenuSelection}; use crate::hunger_system::HungerSystem; use crate::inventory_system::{ @@ -21,7 +20,7 @@ use crate::ranged_combat_system::RangedCombatSystem; use crate::raws::*; use crate::trigger_system::TriggerSystem; 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 pub const SHOW_MAPGEN_VISUALIZER: bool = false; @@ -163,6 +162,12 @@ impl State { } else { 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(); } }