use data::tables::{self, 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| {
                tmpl.create_type == 0
                    && !tmpl.create_position.contains("Test")
                    && !tmpl.default_interact_ids.is_empty()
            })
            .map(|tmpl| SceneUnit::new(tmpl.tag_id))
            .collect();

        Self { unit_vec }
    }
}
