1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! Structs and functions to interact with the data of monster types in a general context.

use crate::ffi;

/// A monster type ID with associated methods to get metadata.
///
/// Use the associated constants or the [`Self::new`] method to get instances of this.
pub type MonsterTypeId = ffi::type_id;
impl Copy for MonsterTypeId {}

/// This impl provides general metadata about monster types in the game.
impl MonsterTypeId {
    /// Returns the ID struct for the type with the given ID.
    ///
    /// # Safety
    /// The caller must make sure the ID is valid (refers to an existing type),
    /// otherwise this is UB.
    pub const unsafe fn new(id: u32) -> Self {
        Self(id)
    }

    /// Returns the ID of this type.
    pub const fn id(&self) -> u32 {
        self.0
    }
}

impl From<MonsterTypeId> for u32 {
    fn from(v: MonsterTypeId) -> Self {
        v.0
    }
}