JaneDoe-ZS/nap_gameserver/src/logic/scene/unit_mgr.rs

21 lines
697 B
Rust

use data::tables::{self, MainCityDefaultObjectID, SectionConfigID};
use super::SceneUnit;
pub struct SceneUnitManager {
pub unit_vec: Vec<SceneUnit>,
}
impl SceneUnitManager {
pub fn new(section_id: SectionConfigID) -> Self {
let section_template = section_id.template();
let unit_vec = tables::main_city_object_template_tb::iter()
.filter(|tmpl| tmpl.get_section_name() == section_template.section_name)
.filter(|tmpl| MainCityDefaultObjectID::new(tmpl.tag_id.value()).is_some()) // check if npc tag present in default object table
.map(|tmpl| SceneUnit::new(tmpl.tag_id))
.collect();
Self { unit_vec }
}
}