Galactica/crates/gameobject/src/handles.rs

34 lines
704 B
Rust
Raw Normal View History

2024-01-09 11:34:54 -08:00
use std::hash::Hash;
use galactica_content::ShipHandle;
2024-01-08 23:05:07 -08:00
/// A lightweight representation of a ship in the galaxy
2024-01-09 11:34:54 -08:00
#[derive(Debug, Clone, Copy)]
2024-01-08 23:05:07 -08:00
pub struct GameShipHandle {
2024-01-09 11:34:54 -08:00
/// This ship's unique index
2024-01-08 23:05:07 -08:00
pub(crate) index: u64,
2024-01-09 11:34:54 -08:00
/// This ship's content handle
/// (technically redundant, but this greatly simplifies code)
pub(crate) content: ShipHandle,
}
impl GameShipHandle {
pub fn content_handle(&self) -> ShipHandle {
self.content
}
}
impl Hash for GameShipHandle {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.index.hash(state)
}
}
impl Eq for GameShipHandle {}
impl PartialEq for GameShipHandle {
fn eq(&self, other: &Self) -> bool {
self.index.eq(&other.index)
}
2024-01-08 23:05:07 -08:00
}