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§
Sourcefn set_hurt_time(&self, value: i32)
fn set_hurt_time(&self, value: i32)
Sets the vehicle’s remaining hurt time.
Sourcefn set_hurt_dir(&self, value: i32)
fn set_hurt_dir(&self, value: i32)
Sets the vehicle’s hurt direction animation.
Sourcefn set_damage(&self, value: f32)
fn set_damage(&self, value: f32)
Sets the accumulated vehicle damage.
Sourcefn vehicle_drop_item(&self) -> ItemRef
fn vehicle_drop_item(&self) -> ItemRef
Returns the item dropped when this vehicle is destroyed.
Provided Methods§
Sourcefn should_source_destroy(&self, _source: &DamageSource) -> bool
fn should_source_destroy(&self, _source: &DamageSource) -> bool
Returns whether the source should destroy this vehicle.
Sourcefn vehicle_hurt(
&self,
world: &World,
source: &DamageSource,
damage: f32,
) -> bool
fn vehicle_hurt( &self, world: &World, source: &DamageSource, damage: f32, ) -> bool
Applies vehicle damage, updates the hurt animation, and handles destruction.
Sourcefn vehicle_destroy(&self, world: &World, _source: &DamageSource)
fn vehicle_destroy(&self, world: &World, _source: &DamageSource)
Destroys the vehicle using its default drop item.
Sourcefn vehicle_destroy_with_item(&self, world: &World, drop_item: ItemRef)
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".