use std::sync::atomic::{AtomicI32, Ordering};
use crate::protocol::types::{Rotation, Vector3};
use crate::registry::EntityKind;
use uuid::Uuid;
pub struct EntityId(AtomicI32);
impl EntityId {
pub fn negative() -> Self {
Self(AtomicI32::new(-1))
}
pub fn get(&self) -> i32 {
self.0.load(Ordering::SeqCst)
}
pub fn set(&self, entity_id: i32) {
self.0.store(entity_id, Ordering::SeqCst);
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Entity {
pub kind: EntityKind,
pub uuid: Uuid,
pub position: Vector3,
pub rotation: Rotation,
pub velocity: Vector3,
pub on_ground: bool,
}
impl Default for Entity {
fn default() -> Self {
Self {
kind: EntityKind::Null,
uuid: Uuid::nil(),
position: Vector3::zero(),
rotation: Rotation::zero(),
velocity: Vector3::zero(),
on_ground: false,
}
}
}