diff --git a/src/ai/energy_system.rs b/src/ai/energy_system.rs index b4ee5c2..65b4020 100644 --- a/src/ai/energy_system.rs +++ b/src/ai/energy_system.rs @@ -1,11 +1,11 @@ +use crate::config::entity::*; use crate::{Burden, BurdenLevel, Clock, Energy, Name, Position, RunState, TakingTurn, LOG_TICKS}; use rltk::prelude::*; use specs::prelude::*; pub struct EnergySystem {} -pub const NORMAL_SPEED: i32 = 12; -const TURN_COST: i32 = NORMAL_SPEED * 4; +const TURN_COST: i32 = NORMAL_SPEED * TURN_COST_MULTIPLIER; impl<'a> System<'a> for EnergySystem { #[allow(clippy::type_complexity)] diff --git a/src/ai/mod.rs b/src/ai/mod.rs index 8aece35..77a64e8 100644 --- a/src/ai/mod.rs +++ b/src/ai/mod.rs @@ -1,5 +1,5 @@ mod energy_system; -pub use energy_system::{EnergySystem, NORMAL_SPEED}; +pub use energy_system::EnergySystem; mod turn_status_system; pub use turn_status_system::TurnStatusSystem; mod quip_system; diff --git a/src/config/entity.rs b/src/config/entity.rs new file mode 100644 index 0000000..1ce3448 --- /dev/null +++ b/src/config/entity.rs @@ -0,0 +1,4 @@ +pub const DEFAULT_VIEWSHED_STANDARD: i32 = 16; // Standard viewshed radius for almost all entities. + +pub const NORMAL_SPEED: i32 = 12; // Normal speed for almost all entities. +pub const TURN_COST_MULTIPLIER: i32 = 4; // How many ticks per turn for an entity with NORMAL_SPEED. diff --git a/src/config/mod.rs b/src/config/mod.rs new file mode 100644 index 0000000..e8c3d6a --- /dev/null +++ b/src/config/mod.rs @@ -0,0 +1 @@ +pub mod entity; diff --git a/src/gui/character_creation.rs b/src/gui/character_creation.rs index 404f37e..8db2bf0 100644 --- a/src/gui/character_creation.rs +++ b/src/gui/character_creation.rs @@ -1,7 +1,7 @@ use super::{gamesystem::attr_bonus, gamesystem::get_attribute_rolls, Attributes, Pools, Renderable, RunState, State}; +use crate::config::entity::NORMAL_SPEED; use crate::{ - ai::NORMAL_SPEED, raws, Attribute, Energy, HasAncestry, HasClass, KnownSpell, KnownSpells, Pool, Skill, Skills, - Telepath, BUC, + raws, Attribute, Energy, HasAncestry, HasClass, KnownSpell, KnownSpells, Pool, Skill, Skills, Telepath, BUC, }; use rltk::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/src/main.rs b/src/main.rs index 435d4bc..0d61adf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ mod inventory; mod particle_system; use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME}; mod ai; +mod config; mod effects; mod gamesystem; mod random_table; diff --git a/src/map/themes.rs b/src/map/themes.rs index 60ec90c..c6b7046 100644 --- a/src/map/themes.rs +++ b/src/map/themes.rs @@ -252,7 +252,7 @@ pub fn multiply_by_float(rgb: rltk::RGB, offsets: (f32, f32, f32)) -> RGB { fn darken_by_distance(pos: Point, other_pos: Point) -> f32 { let distance = DistanceAlg::Pythagoras.distance2d(pos, other_pos) as f32; // Get distance in tiles. let interp_factor = (distance - START_DARKEN_AT_N_TILES) - / (MAX_DARKEN_AT_N_TILES * crate::spawner::VIEWSHED_MOD - START_DARKEN_AT_N_TILES); + / (MAX_DARKEN_AT_N_TILES * crate::config::entity::DEFAULT_VIEWSHED_STANDARD as f32 - START_DARKEN_AT_N_TILES); let interp_factor = interp_factor.max(0.0).min(1.0); // Clamp [0-1] return 1.0 - interp_factor * (1.0 - MAX_DARKENING); } diff --git a/src/raws/rawmaster.rs b/src/raws/rawmaster.rs index f63467a..fc265ba 100644 --- a/src/raws/rawmaster.rs +++ b/src/raws/rawmaster.rs @@ -1,9 +1,9 @@ use super::{Raws, Reaction}; use crate::components::*; +use crate::config::entity; use crate::gamesystem::*; use crate::gui::Ancestry; use crate::random_table::RandomTable; -use crate::spawner; use crate::LOG_SPAWNING; use regex::Regex; use rltk::prelude::*; @@ -381,11 +381,7 @@ pub fn spawn_named_mob( eb = ecs.create_entity().marked::>(); eb = spawn_position(pos, eb, key, raws); eb = eb.with(Name { name: mob_template.name.clone(), plural: mob_template.name.clone() }); - eb = eb.with(Viewshed { - visible_tiles: Vec::new(), - range: (mob_template.vision_range as f32 * spawner::VIEWSHED_MOD) as i32, - dirty: true, - }); + eb = eb.with(Viewshed { visible_tiles: Vec::new(), range: mob_template.vision_range as i32, dirty: true }); if let Some(telepath) = &mob_template.telepathy_range { eb = eb.with(Telepath { telepath_tiles: Vec::new(), range: *telepath, dirty: true }); } diff --git a/src/spawner.rs b/src/spawner.rs index cfe44fd..62e85ed 100644 --- a/src/spawner.rs +++ b/src/spawner.rs @@ -1,16 +1,15 @@ use super::{ - ai::NORMAL_SPEED, random_table::RandomTable, raws, Attribute, Attributes, Clock, Energy, EquipmentChanged, Faction, - HungerClock, HungerState, Map, Mind, Name, Player, Pool, Pools, Position, Rect, Renderable, SerializeMe, Skill, - Skills, TileType, Viewshed, + random_table::RandomTable, raws, Attribute, Attributes, Clock, Energy, EquipmentChanged, Faction, HungerClock, + HungerState, Map, Mind, Name, Player, Pool, Pools, Position, Rect, Renderable, SerializeMe, Skill, Skills, + TileType, Viewshed, }; +use crate::config::entity; use crate::gamesystem::*; use rltk::{RandomNumberGenerator, RGB}; use specs::prelude::*; use specs::saveload::{MarkedBuilder, SimpleMarker}; use std::collections::HashMap; -pub const VIEWSHED_MOD: f32 = 1.25; - /// Spawns the player and returns his/her entity object. pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { let mut skills = Skills { skills: HashMap::new() }; @@ -19,7 +18,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { skills.skills.insert(Skill::Magic, 0); let (int, con) = (10, 10); // We only create the player once, so create the Clock here for counting turns too. - ecs.create_entity().with(Clock {}).with(Energy { current: 0, speed: NORMAL_SPEED }).build(); + ecs.create_entity().with(Clock {}).with(Energy { current: 0, speed: entity::NORMAL_SPEED }).build(); let player = ecs .create_entity() .with(Position { x: player_x, y: player_y }) @@ -32,7 +31,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { .with(Player {}) .with(Mind {}) .with(Faction { name: "player".to_string() }) - .with(Viewshed { visible_tiles: Vec::new(), range: (12 as f32 * VIEWSHED_MOD) as i32, dirty: true }) + .with(Viewshed { visible_tiles: Vec::new(), range: entity::DEFAULT_VIEWSHED_STANDARD, dirty: true }) .with(Name { name: "you".to_string(), plural: "you".to_string() }) .with(HungerClock { state: HungerState::Satiated, duration: 1200 }) .with(Attributes { @@ -56,7 +55,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { }) .with(EquipmentChanged {}) .with(skills) - .with(Energy { current: 0, speed: NORMAL_SPEED }) + .with(Energy { current: 0, speed: entity::NORMAL_SPEED }) .marked::>() .build(); diff --git a/wasm/rust-llyrl.js b/wasm/rust-llyrl.js index c22d459..c16e6aa 100644 --- a/wasm/rust-llyrl.js +++ b/wasm/rust-llyrl.js @@ -805,11 +805,11 @@ function __wbg_get_imports() { const ret = makeMutClosure(arg0, arg1, 124, __wbg_adapter_20); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper2705 = function(arg0, arg1, arg2) { + imports.wbg.__wbindgen_closure_wrapper2716 = function(arg0, arg1, arg2) { const ret = makeMutClosure(arg0, arg1, 518, __wbg_adapter_23); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper2707 = function(arg0, arg1, arg2) { + imports.wbg.__wbindgen_closure_wrapper2718 = function(arg0, arg1, arg2) { const ret = makeMutClosure(arg0, arg1, 518, __wbg_adapter_23); return addHeapObject(ret); }; diff --git a/wasm/rust-llyrl_bg.wasm b/wasm/rust-llyrl_bg.wasm index eda9896..8233f55 100644 Binary files a/wasm/rust-llyrl_bg.wasm and b/wasm/rust-llyrl_bg.wasm differ