Skip to main content

VehicleEntity

Trait VehicleEntity 

Source
pub trait VehicleEntity: Entity {
    // Required methods
    fn hurt_time(&self) -> i32;
    fn set_hurt_time(&self, value: i32);
    fn hurt_dir(&self) -> i32;
    fn set_hurt_dir(&self, value: i32);
    fn damage(&self) -> f32;
    fn set_damage(&self, value: f32);
    fn vehicle_drop_item(&self) -> ItemRef;

    // Provided methods
    fn should_source_destroy(&self, _source: &DamageSource) -> bool { ... }
    fn vehicle_hurt(
        &self,
        world: &World,
        source: &DamageSource,
        damage: f32,
    ) -> bool { ... }
    fn vehicle_destroy(&self, world: &World, _source: &DamageSource) { ... }
    fn vehicle_destroy_with_item(&self, world: &World, drop_item: ItemRef) { ... }
}
Expand description

Implemented by vehicle entities (minecarts, boats) for vanilla VehicleEntity damage handling.

Required Methods§

Source

fn hurt_time(&self) -> i32

Returns the vehicle’s remaining hurt time.

Source

fn set_hurt_time(&self, value: i32)

Sets the vehicle’s remaining hurt time.

Source

fn hurt_dir(&self) -> i32

Returns the vehicle’s hurt direction animation.

Source

fn set_hurt_dir(&self, value: i32)

Sets the vehicle’s hurt direction animation.

Source

fn damage(&self) -> f32

Returns the accumulated vehicle damage.

Source

fn set_damage(&self, value: f32)

Sets the accumulated vehicle damage.

Source

fn vehicle_drop_item(&self) -> ItemRef

Returns the item dropped when this vehicle is destroyed.

Provided Methods§

Source

fn should_source_destroy(&self, _source: &DamageSource) -> bool

Returns whether the source should destroy this vehicle.

Source

fn vehicle_hurt( &self, world: &World, source: &DamageSource, damage: f32, ) -> bool

Applies vehicle damage, updates the hurt animation, and handles destruction.

Source

fn vehicle_destroy(&self, world: &World, _source: &DamageSource)

Destroys the vehicle using its default drop item.

Source

fn vehicle_destroy_with_item(&self, world: &World, drop_item: ItemRef)

Destroys the vehicle and drops the given item, when entity drops are enabled.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§