Skip to main content

Entity

Struct Entity 

Source
pub struct Entity {
    pub index: i32,
    pub serial: u32,
    pub class_id: i32,
    pub class_name: String,
    pub fields: FxHashMap<u64, FieldValue>,
}
Expand description

A single entity with its class, fields, and current state.

Fields§

§index: i32

Slot index in the entity array (0–16383).

§serial: u32

Serial number for this slot (increments on reuse).

§class_id: i32

Numeric class ID (indexes into ClassInfo).

§class_name: String

Network class name (e.g. "CCitadelPlayerController").

§fields: FxHashMap<u64, FieldValue>

Current field values, keyed by packed field path keys.

Implementations§

Source§

impl Entity

Source

pub fn get_by_name( &self, path: &str, serializer: &Serializer, ) -> Option<&FieldValue>

Look up a field by its dotted name string using the serializer to resolve the key.

Source

pub fn get_i64(&self, key: Option<u64>) -> i64

Read a field as i64, returning 0 when absent or non-integer.

Source

pub fn get_u32(&self, key: Option<u64>) -> u32

Read a field as u32, returning 0 when absent or non-integer.

Source

pub fn get_f32(&self, key: Option<u64>) -> f32

Read a field as f32, returning 0.0 when absent or non-float.

Source

pub fn get_bool(&self, key: Option<u64>) -> bool

Read a field as bool, returning false when absent or non-bool.

Source

pub fn get_qangle(&self, key: Option<u64>) -> [f32; 3]

Read a field as a QAngle, returning [0.0; 3] when absent or non-angle.

Source

pub fn world_position( &self, cell_keys: [Option<u64>; 3], offset_keys: [Option<u64>; 3], ) -> [f32; 3]

Combine cell + in-cell offset fields into a world-coordinate [x, y, z].

Source 2 splits each axis of an entity’s position across two networked fields — an integer cell index (e.g. m_cellX) and a quantized offset inside that cell (e.g. m_vecOrigin.m_vecX). Pass the resolved keys for both halves and this returns the full world position in Hammer units via cell_to_world. Reading the offset alone gives a sawtooth that resets every cell boundary, not a usable coordinate.

Cell keys with no resolved field decode as cell 0, which means the result is shifted into a single cell-grid quadrant rather than returning a sentinel — verify the keys before relying on it.

Source

pub fn get_handle(&self, key: Option<u64>) -> Option<u32>

Read a raw CHandle field as u32, if present.

Pass the result to EntityContainer::get_by_handle to follow the handle to its entity; that helper owns the index mask so callers never decode it by hand.

Trait Implementations§

Source§

impl Clone for Entity

Source§

fn clone(&self) -> Entity

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.