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: i32Slot index in the entity array (0–16383).
serial: u32Serial number for this slot (increments on reuse).
class_id: i32Numeric class ID (indexes into ClassInfo).
class_name: StringNetwork class name (e.g. "CCitadelPlayerController").
fields: FxHashMap<u64, FieldValue>Current field values, keyed by packed field path keys.
Implementations§
Source§impl Entity
impl Entity
Sourcepub fn get_by_name(
&self,
path: &str,
serializer: &Serializer,
) -> Option<&FieldValue>
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.
Sourcepub fn get_i64(&self, key: Option<u64>) -> i64
pub fn get_i64(&self, key: Option<u64>) -> i64
Read a field as i64, returning 0 when absent or non-integer.
Sourcepub fn get_u32(&self, key: Option<u64>) -> u32
pub fn get_u32(&self, key: Option<u64>) -> u32
Read a field as u32, returning 0 when absent or non-integer.
Sourcepub fn get_f32(&self, key: Option<u64>) -> f32
pub fn get_f32(&self, key: Option<u64>) -> f32
Read a field as f32, returning 0.0 when absent or non-float.
Sourcepub fn get_bool(&self, key: Option<u64>) -> bool
pub fn get_bool(&self, key: Option<u64>) -> bool
Read a field as bool, returning false when absent or non-bool.
Sourcepub fn get_qangle(&self, key: Option<u64>) -> [f32; 3]
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.
Sourcepub fn world_position(
&self,
cell_keys: [Option<u64>; 3],
offset_keys: [Option<u64>; 3],
) -> [f32; 3]
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.
Sourcepub fn get_handle(&self, key: Option<u64>) -> Option<u32>
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.