starting on config files
This commit is contained in:
parent
98a4422b15
commit
281396f9ce
11 changed files with 23 additions and 22 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
|
use crate::config::entity::*;
|
||||||
use crate::{Burden, BurdenLevel, Clock, Energy, Name, Position, RunState, TakingTurn, LOG_TICKS};
|
use crate::{Burden, BurdenLevel, Clock, Energy, Name, Position, RunState, TakingTurn, LOG_TICKS};
|
||||||
use rltk::prelude::*;
|
use rltk::prelude::*;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
||||||
pub struct EnergySystem {}
|
pub struct EnergySystem {}
|
||||||
|
|
||||||
pub const NORMAL_SPEED: i32 = 12;
|
const TURN_COST: i32 = NORMAL_SPEED * TURN_COST_MULTIPLIER;
|
||||||
const TURN_COST: i32 = NORMAL_SPEED * 4;
|
|
||||||
|
|
||||||
impl<'a> System<'a> for EnergySystem {
|
impl<'a> System<'a> for EnergySystem {
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
mod energy_system;
|
mod energy_system;
|
||||||
pub use energy_system::{EnergySystem, NORMAL_SPEED};
|
pub use energy_system::EnergySystem;
|
||||||
mod turn_status_system;
|
mod turn_status_system;
|
||||||
pub use turn_status_system::TurnStatusSystem;
|
pub use turn_status_system::TurnStatusSystem;
|
||||||
mod quip_system;
|
mod quip_system;
|
||||||
|
|
|
||||||
4
src/config/entity.rs
Normal file
4
src/config/entity.rs
Normal file
|
|
@ -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.
|
||||||
1
src/config/mod.rs
Normal file
1
src/config/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod entity;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{gamesystem::attr_bonus, gamesystem::get_attribute_rolls, Attributes, Pools, Renderable, RunState, State};
|
use super::{gamesystem::attr_bonus, gamesystem::get_attribute_rolls, Attributes, Pools, Renderable, RunState, State};
|
||||||
|
use crate::config::entity::NORMAL_SPEED;
|
||||||
use crate::{
|
use crate::{
|
||||||
ai::NORMAL_SPEED, raws, Attribute, Energy, HasAncestry, HasClass, KnownSpell, KnownSpells, Pool, Skill, Skills,
|
raws, Attribute, Energy, HasAncestry, HasClass, KnownSpell, KnownSpells, Pool, Skill, Skills, Telepath, BUC,
|
||||||
Telepath, BUC,
|
|
||||||
};
|
};
|
||||||
use rltk::prelude::*;
|
use rltk::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ mod inventory;
|
||||||
mod particle_system;
|
mod particle_system;
|
||||||
use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME};
|
use particle_system::{ParticleBuilder, DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME};
|
||||||
mod ai;
|
mod ai;
|
||||||
|
mod config;
|
||||||
mod effects;
|
mod effects;
|
||||||
mod gamesystem;
|
mod gamesystem;
|
||||||
mod random_table;
|
mod random_table;
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
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 distance = DistanceAlg::Pythagoras.distance2d(pos, other_pos) as f32; // Get distance in tiles.
|
||||||
let interp_factor = (distance - START_DARKEN_AT_N_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]
|
let interp_factor = interp_factor.max(0.0).min(1.0); // Clamp [0-1]
|
||||||
return 1.0 - interp_factor * (1.0 - MAX_DARKENING);
|
return 1.0 - interp_factor * (1.0 - MAX_DARKENING);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use super::{Raws, Reaction};
|
use super::{Raws, Reaction};
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
|
use crate::config::entity;
|
||||||
use crate::gamesystem::*;
|
use crate::gamesystem::*;
|
||||||
use crate::gui::Ancestry;
|
use crate::gui::Ancestry;
|
||||||
use crate::random_table::RandomTable;
|
use crate::random_table::RandomTable;
|
||||||
use crate::spawner;
|
|
||||||
use crate::LOG_SPAWNING;
|
use crate::LOG_SPAWNING;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rltk::prelude::*;
|
use rltk::prelude::*;
|
||||||
|
|
@ -381,11 +381,7 @@ pub fn spawn_named_mob(
|
||||||
eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
||||||
eb = spawn_position(pos, eb, key, raws);
|
eb = spawn_position(pos, eb, key, raws);
|
||||||
eb = eb.with(Name { name: mob_template.name.clone(), plural: mob_template.name.clone() });
|
eb = eb.with(Name { name: mob_template.name.clone(), plural: mob_template.name.clone() });
|
||||||
eb = eb.with(Viewshed {
|
eb = eb.with(Viewshed { visible_tiles: Vec::new(), range: mob_template.vision_range as i32, dirty: true });
|
||||||
visible_tiles: Vec::new(),
|
|
||||||
range: (mob_template.vision_range as f32 * spawner::VIEWSHED_MOD) as i32,
|
|
||||||
dirty: true,
|
|
||||||
});
|
|
||||||
if let Some(telepath) = &mob_template.telepathy_range {
|
if let Some(telepath) = &mob_template.telepathy_range {
|
||||||
eb = eb.with(Telepath { telepath_tiles: Vec::new(), range: *telepath, dirty: true });
|
eb = eb.with(Telepath { telepath_tiles: Vec::new(), range: *telepath, dirty: true });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
use super::{
|
use super::{
|
||||||
ai::NORMAL_SPEED, random_table::RandomTable, raws, Attribute, Attributes, Clock, Energy, EquipmentChanged, Faction,
|
random_table::RandomTable, raws, Attribute, Attributes, Clock, Energy, EquipmentChanged, Faction, HungerClock,
|
||||||
HungerClock, HungerState, Map, Mind, Name, Player, Pool, Pools, Position, Rect, Renderable, SerializeMe, Skill,
|
HungerState, Map, Mind, Name, Player, Pool, Pools, Position, Rect, Renderable, SerializeMe, Skill, Skills,
|
||||||
Skills, TileType, Viewshed,
|
TileType, Viewshed,
|
||||||
};
|
};
|
||||||
|
use crate::config::entity;
|
||||||
use crate::gamesystem::*;
|
use crate::gamesystem::*;
|
||||||
use rltk::{RandomNumberGenerator, RGB};
|
use rltk::{RandomNumberGenerator, RGB};
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
use specs::saveload::{MarkedBuilder, SimpleMarker};
|
use specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub const VIEWSHED_MOD: f32 = 1.25;
|
|
||||||
|
|
||||||
/// Spawns the player and returns his/her entity object.
|
/// Spawns the player and returns his/her entity object.
|
||||||
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||||
let mut skills = Skills { skills: HashMap::new() };
|
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);
|
skills.skills.insert(Skill::Magic, 0);
|
||||||
let (int, con) = (10, 10);
|
let (int, con) = (10, 10);
|
||||||
// We only create the player once, so create the Clock here for counting turns too.
|
// 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
|
let player = ecs
|
||||||
.create_entity()
|
.create_entity()
|
||||||
.with(Position { x: player_x, y: player_y })
|
.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(Player {})
|
||||||
.with(Mind {})
|
.with(Mind {})
|
||||||
.with(Faction { name: "player".to_string() })
|
.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(Name { name: "you".to_string(), plural: "you".to_string() })
|
||||||
.with(HungerClock { state: HungerState::Satiated, duration: 1200 })
|
.with(HungerClock { state: HungerState::Satiated, duration: 1200 })
|
||||||
.with(Attributes {
|
.with(Attributes {
|
||||||
|
|
@ -56,7 +55,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||||
})
|
})
|
||||||
.with(EquipmentChanged {})
|
.with(EquipmentChanged {})
|
||||||
.with(skills)
|
.with(skills)
|
||||||
.with(Energy { current: 0, speed: NORMAL_SPEED })
|
.with(Energy { current: 0, speed: entity::NORMAL_SPEED })
|
||||||
.marked::<SimpleMarker<SerializeMe>>()
|
.marked::<SimpleMarker<SerializeMe>>()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -805,11 +805,11 @@ function __wbg_get_imports() {
|
||||||
const ret = makeMutClosure(arg0, arg1, 124, __wbg_adapter_20);
|
const ret = makeMutClosure(arg0, arg1, 124, __wbg_adapter_20);
|
||||||
return addHeapObject(ret);
|
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);
|
const ret = makeMutClosure(arg0, arg1, 518, __wbg_adapter_23);
|
||||||
return addHeapObject(ret);
|
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);
|
const ret = makeMutClosure(arg0, arg1, 518, __wbg_adapter_23);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue