Galactica/crates/gameobject/src/handles.rs

34 lines
704 B
Rust

use std::hash::Hash;
use galactica_content::ShipHandle;
/// A lightweight representation of a ship in the galaxy
#[derive(Debug, Clone, Copy)]
pub struct GameShipHandle {
/// This ship's unique index
pub(crate) index: u64,
/// 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)
}
}