use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct MaterialId {
    pub index: u32,
    pub generation: u32,
}

impl MaterialId {
    pub const INVALID: Self = Self {
        index: u32::MAX,
        generation: 0,
    };

    pub fn is_valid(self) -> bool {
        self.index != u32::MAX
    }
}

impl Default for MaterialId {
    fn default() -> Self {
        Self::INVALID
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct MeshId {
    pub index: u32,
    pub generation: u32,
}

impl MeshId {
    pub const INVALID: Self = Self {
        index: u32::MAX,
        generation: 0,
    };

    pub fn is_valid(self) -> bool {
        self.index != u32::MAX
    }
}

impl Default for MeshId {
    fn default() -> Self {
        Self::INVALID
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TextureId {
    pub index: u32,
    pub generation: u32,
}

impl TextureId {
    pub const INVALID: Self = Self {
        index: u32::MAX,
        generation: 0,
    };

    pub fn is_valid(self) -> bool {
        self.index != u32::MAX
    }
}

impl Default for TextureId {
    fn default() -> Self {
        Self::INVALID
    }
}
