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 abilities in a general context.
//!
use crate::ffi;

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

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

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

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