use strafesnet_common::model::MeshId;

#[derive(Clone)]
pub struct RobloxMeshData(Vec<u8>);
impl RobloxMeshData{
	pub(crate) fn new(data:Vec<u8>)->Self{
		Self(data)
	}
	pub fn get(self)->Vec<u8>{
		self.0
	}
}
pub struct Meshes{
	meshes:Vec<Option<RobloxMeshData>>,
}
impl Meshes{
	pub(crate) const fn new(meshes:Vec<Option<RobloxMeshData>>)->Self{
		Self{
			meshes,
		}
	}
	pub fn get_texture(&self,texture_id:MeshId)->Option<&RobloxMeshData>{
		self.meshes.get(texture_id.get() as usize)?.as_ref()
	}
	pub fn into_iter(self)->impl Iterator<Item=(MeshId,RobloxMeshData)>{
		self.meshes.into_iter().enumerate().filter_map(|(mesh_id,maybe_mesh)|
			maybe_mesh.map(|mesh|(MeshId::new(mesh_id as u32),mesh))
		)
	}
}