strafe-client-jed/src/texture.rs

30 lines
649 B
Rust
Raw Normal View History

2024-02-14 03:48:47 +00:00
use strafesnet_common::model::TextureId;
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 Textures{
textures:Vec<Texture>,
}
impl Textures{
pub(crate) const fn new(textures:Vec<Texture>)->Self{
Self{
textures,
}
}
pub fn get_texture(&self,texture_id:TextureId)->Option<&Texture>{
self.textures.get(texture_id.get() as usize)
}
pub fn into_iter(self)->impl Iterator<Item=(TextureId,Texture)>{
self.textures.into_iter().enumerate().map(|(texture_id,texture)|(TextureId::new(texture_id as u32),texture))
}
}