pub struct Entity { /* private fields */ }Implementations§
Source§impl Entity
impl Entity
pub fn index(&self) -> u32
pub fn serial(&self) -> u32
pub fn handle(&self) -> u32
pub fn class(&self) -> &Class
Sourcepub fn get_property_by_name(
&self,
name: &str,
) -> Result<&FieldValue, EntityError>
pub fn get_property_by_name( &self, name: &str, ) -> Result<&FieldValue, EntityError>
Returns FieldValue for given property name. You can also use
property! and try_property! macros.
§Examples
use d2_stampede::prelude::*;
#[derive(Default)]
struct MyObs;
impl Observer for MyObs {
fn on_entity(
&mut self,
ctx: &Context,
event: EntityEvents,
entity: &Entity,
) -> ObserverResult {
let x: u8 = entity
.get_property_by_name("CBodyComponent.m_cellX")?
.try_into()?;
let y: u8 = property!(entity, "CBodyComponent.m_cellY");
let z = property!(entity, u8, "CBodyComponent.m_cellY");
Ok(())
}
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Entity
impl !RefUnwindSafe for Entity
impl !Send for Entity
impl !Sync for Entity
impl Unpin for Entity
impl !UnwindSafe for Entity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more