1
0
Fork 0

Add lighting to some mob types

This commit is contained in:
Timothy Warren 2022-01-10 10:28:04 -05:00
parent 6f9aa54896
commit e50abdb4a0
2 changed files with 15 additions and 1 deletions

View File

@ -20,6 +20,13 @@ pub struct Mob {
pub equipped: Option<Vec<String>>,
pub natural: Option<MobNatural>,
pub loot_table: Option<String>,
pub light: Option<MobLight>,
}
#[derive(Deserialize, Debug)]
pub struct MobLight {
pub range: i32,
pub color: String,
}
#[derive(Deserialize, Debug)]

View File

@ -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?