From e50abdb4a0e71df2300ca1d76f424b85d002128f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 10 Jan 2022 10:28:04 -0500 Subject: [PATCH] Add lighting to some mob types --- src/raws/mob_structs.rs | 7 +++++++ src/raws/rawmaster.rs | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/raws/mob_structs.rs b/src/raws/mob_structs.rs index b73a16a..0ede0a0 100644 --- a/src/raws/mob_structs.rs +++ b/src/raws/mob_structs.rs @@ -20,6 +20,13 @@ pub struct Mob { pub equipped: Option>, pub natural: Option, pub loot_table: Option, + pub light: Option, +} + +#[derive(Deserialize, Debug)] +pub struct MobLight { + pub range: i32, + pub color: String, } #[derive(Deserialize, Debug)] diff --git a/src/raws/rawmaster.rs b/src/raws/rawmaster.rs index 840b90f..0ba884d 100644 --- a/src/raws/rawmaster.rs +++ b/src/raws/rawmaster.rs @@ -1,9 +1,9 @@ use std::collections::{HashMap, HashSet}; use ::regex::Regex; +use ::rltk::{RandomNumberGenerator, RGB}; use ::specs::prelude::*; use ::specs::saveload::{MarkedBuilder, SimpleMarker}; -use rltk::RandomNumberGenerator; use crate::components::*; use crate::gamesystem::{mana_at_level, npc_hp}; @@ -420,6 +420,13 @@ pub fn spawn_named_mob( }); } + if let Some(light) = &mob_template.light { + eb = eb.with(LightSource { + range: light.range, + color: RGB::from_hex(&light.color).expect("Bad color"), + }); + } + let new_mob = eb.build(); // Are they weilding anything?