use strafesnet_common::model::{TextureId,RenderConfigId,RenderConfig};

#[derive(Clone)]
pub enum Texture{
	ImageDDS(Vec<u8>),
}
impl AsRef<[u8]> for Texture{
	fn as_ref(&self)->&[u8]{
		match self{
			Texture::ImageDDS(data)=>data.as_ref(),
		}
	}
}

pub struct RenderConfigs{
	textures:Vec<Option<Texture>>,
	render_configs:Vec<RenderConfig>,
}
impl RenderConfigs{
	pub(crate) const fn new(textures:Vec<Option<Texture>>,render_configs:Vec<RenderConfig>)->Self{
		Self{
			textures,
			render_configs,
		}
	}
	pub fn consume(self)->(
		impl Iterator<Item=(TextureId,Texture)>,
		impl Iterator<Item=(RenderConfigId,RenderConfig)>
	){
		(
			self.textures.into_iter().enumerate().filter_map(|(texture_id,maybe_texture)|
				maybe_texture.map(|texture|(TextureId::new(texture_id as u32),texture))
			),
			self.render_configs.into_iter().enumerate().map(|(render_id,render)|
				(RenderConfigId::new(render_id as u32),render)
			),
		)
	}
}