Skip to main content

EntityLevelCallback

Trait EntityLevelCallback 

Source
pub trait EntityLevelCallback: Send + Sync {
    // Required methods
    fn validate_move(
        &self,
        old_pos: DVec3,
        new_pos: DVec3,
    ) -> Result<(), EntityMoveError>;
    fn on_move_committed(
        &self,
        old_pos: DVec3,
        new_pos: DVec3,
    ) -> Result<(), EntityMoveError>;
    fn on_remove(&self, reason: RemovalReason);

    // Provided methods
    fn allows_local_position_update(&self) -> bool { ... }
    fn on_bounding_box_changed(&self, _bounding_box: WorldAabb) { ... }
}
Expand description

Callback interface for entity lifecycle events.

Mirrors vanilla’s EntityInLevelCallback.

Required Methods§

Source

fn validate_move( &self, old_pos: DVec3, new_pos: DVec3, ) -> Result<(), EntityMoveError>

Called before an entity position change is committed.

Source

fn on_move_committed( &self, old_pos: DVec3, new_pos: DVec3, ) -> Result<(), EntityMoveError>

Called after an entity position change has been committed.

Source

fn on_remove(&self, reason: RemovalReason)

Called when entity is removed from the world.

Provided Methods§

Source

fn allows_local_position_update(&self) -> bool

Returns whether direct local position writes may bypass lifecycle callbacks.

Source

fn on_bounding_box_changed(&self, _bounding_box: WorldAabb)

Called after an entity’s collision bounds change without a position change.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§