Skip to main content

IPhysicsDirectBodyState2DExtension

Trait IPhysicsDirectBodyState2DExtension 

pub trait IPhysicsDirectBodyState2DExtension: GodotClass<Base = PhysicsDirectBodyState2DExtension> + You_forgot_the_attribute__godot_api {
Show 56 methods // Required methods fn get_total_gravity(&self) -> Vector2; fn get_total_linear_damp(&self) -> f32; fn get_total_angular_damp(&self) -> f32; fn get_center_of_mass(&self) -> Vector2; fn get_center_of_mass_local(&self) -> Vector2; fn get_inverse_mass(&self) -> f32; fn get_inverse_inertia(&self) -> f32; fn set_linear_velocity(&mut self, velocity: Vector2); fn get_linear_velocity(&self) -> Vector2; fn set_angular_velocity(&mut self, velocity: f32); fn get_angular_velocity(&self) -> f32; fn set_transform(&mut self, transform: Transform2D); fn get_transform(&self) -> Transform2D; fn get_velocity_at_local_position(&self, local_position: Vector2) -> Vector2; fn apply_central_impulse(&mut self, impulse: Vector2); fn apply_impulse(&mut self, impulse: Vector2, position: Vector2); fn apply_torque_impulse(&mut self, impulse: f32); fn apply_central_force(&mut self, force: Vector2); fn apply_force(&mut self, force: Vector2, position: Vector2); fn apply_torque(&mut self, torque: f32); fn add_constant_central_force(&mut self, force: Vector2); fn add_constant_force(&mut self, force: Vector2, position: Vector2); fn add_constant_torque(&mut self, torque: f32); fn set_constant_force(&mut self, force: Vector2); fn get_constant_force(&self) -> Vector2; fn set_constant_torque(&mut self, torque: f32); fn get_constant_torque(&self) -> f32; fn set_sleep_state(&mut self, enabled: bool); fn is_sleeping(&self) -> bool; fn set_collision_layer(&mut self, layer: u32); fn get_collision_layer(&self) -> u32; fn set_collision_mask(&mut self, mask: u32); fn get_collision_mask(&self) -> u32; fn get_contact_count(&self) -> i32; fn get_contact_local_position(&self, contact_idx: i32) -> Vector2; fn get_contact_local_normal(&self, contact_idx: i32) -> Vector2; fn get_contact_local_shape(&self, contact_idx: i32) -> i32; fn get_contact_local_velocity_at_position( &self, contact_idx: i32, ) -> Vector2; fn get_contact_collider(&self, contact_idx: i32) -> Rid; fn get_contact_collider_position(&self, contact_idx: i32) -> Vector2; fn get_contact_collider_id(&self, contact_idx: i32) -> u64; fn get_contact_collider_object( &self, contact_idx: i32, ) -> Option<Gd<Object>>; fn get_contact_collider_shape(&self, contact_idx: i32) -> i32; fn get_contact_collider_velocity_at_position( &self, contact_idx: i32, ) -> Vector2; fn get_contact_impulse(&self, contact_idx: i32) -> Vector2; fn get_step(&self) -> f32; fn integrate_forces(&mut self); fn get_space_state(&mut self) -> Gd<PhysicsDirectSpaceState2D>; // Provided methods fn init(base: Base<Self::Base>) -> Self { ... } fn on_notification(&mut self, what: ObjectNotification) { ... } fn on_get(&self, property: StringName) -> Option<Variant> { ... } fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... } fn on_validate_property(&self, property: &mut PropertyInfo) { ... } fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... } fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... } fn to_string(&self) -> GString { ... }
}
Expand description

§Interface trait for class PhysicsDirectBodyState2DExtension.

Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.

Base interfaces: IPhysicsDirectBodyState2D > IObject.
(Strike-through means some intermediate Godot classes are marked final, and can thus not be inherited by GDExtension.)

See also Godot docs for PhysicsDirectBodyState2DExtension methods.

Required Methods§

fn get_total_gravity(&self) -> Vector2

Implement to override the behavior of [member PhysicsDirectBodyState2D.total_gravity] and its respective getter.

fn get_total_linear_damp(&self) -> f32

Implement to override the behavior of [member PhysicsDirectBodyState2D.total_linear_damp] and its respective getter.

fn get_total_angular_damp(&self) -> f32

Implement to override the behavior of [member PhysicsDirectBodyState2D.total_angular_damp] and its respective getter.

fn get_center_of_mass(&self) -> Vector2

Implement to override the behavior of [member PhysicsDirectBodyState2D.center_of_mass] and its respective getter.

fn get_center_of_mass_local(&self) -> Vector2

Implement to override the behavior of [member PhysicsDirectBodyState2D.center_of_mass_local] and its respective getter.

fn get_inverse_mass(&self) -> f32

Implement to override the behavior of [member PhysicsDirectBodyState2D.inverse_mass] and its respective getter.

fn get_inverse_inertia(&self) -> f32

Implement to override the behavior of [member PhysicsDirectBodyState2D.inverse_inertia] and its respective getter.

fn set_linear_velocity(&mut self, velocity: Vector2)

Implement to override the behavior of [member PhysicsDirectBodyState2D.linear_velocity] and its respective setter.

fn get_linear_velocity(&self) -> Vector2

Implement to override the behavior of [member PhysicsDirectBodyState2D.linear_velocity] and its respective getter.

fn set_angular_velocity(&mut self, velocity: f32)

Implement to override the behavior of [member PhysicsDirectBodyState2D.angular_velocity] and its respective setter.

fn get_angular_velocity(&self) -> f32

Implement to override the behavior of [member PhysicsDirectBodyState2D.angular_velocity] and its respective getter.

fn set_transform(&mut self, transform: Transform2D)

Implement to override the behavior of [member PhysicsDirectBodyState2D.transform] and its respective setter.

fn get_transform(&self) -> Transform2D

Implement to override the behavior of [member PhysicsDirectBodyState2D.transform] and its respective getter.

fn get_velocity_at_local_position(&self, local_position: Vector2) -> Vector2

Overridable version of get_velocity_at_local_position.

fn apply_central_impulse(&mut self, impulse: Vector2)

Overridable version of apply_central_impulse.

fn apply_impulse(&mut self, impulse: Vector2, position: Vector2)

Overridable version of apply_impulse.

fn apply_torque_impulse(&mut self, impulse: f32)

Overridable version of apply_torque_impulse.

fn apply_central_force(&mut self, force: Vector2)

Overridable version of apply_central_force.

fn apply_force(&mut self, force: Vector2, position: Vector2)

Overridable version of apply_force.

fn apply_torque(&mut self, torque: f32)

Overridable version of apply_torque.

fn add_constant_central_force(&mut self, force: Vector2)

Overridable version of add_constant_central_force.

fn add_constant_force(&mut self, force: Vector2, position: Vector2)

Overridable version of add_constant_force.

fn add_constant_torque(&mut self, torque: f32)

Overridable version of add_constant_torque.

fn set_constant_force(&mut self, force: Vector2)

Overridable version of set_constant_force.

fn get_constant_force(&self) -> Vector2

Overridable version of get_constant_force.

fn set_constant_torque(&mut self, torque: f32)

Overridable version of set_constant_torque.

fn get_constant_torque(&self) -> f32

Overridable version of get_constant_torque.

fn set_sleep_state(&mut self, enabled: bool)

Implement to override the behavior of [member PhysicsDirectBodyState2D.sleeping] and its respective setter.

fn is_sleeping(&self) -> bool

Implement to override the behavior of [member PhysicsDirectBodyState2D.sleeping] and its respective getter.

fn set_collision_layer(&mut self, layer: u32)

fn get_collision_layer(&self) -> u32

fn set_collision_mask(&mut self, mask: u32)

fn get_collision_mask(&self) -> u32

fn get_contact_count(&self) -> i32

Overridable version of get_contact_count.

fn get_contact_local_position(&self, contact_idx: i32) -> Vector2

Overridable version of get_contact_local_position.

fn get_contact_local_normal(&self, contact_idx: i32) -> Vector2

Overridable version of get_contact_local_normal.

fn get_contact_local_shape(&self, contact_idx: i32) -> i32

Overridable version of get_contact_local_shape.

fn get_contact_local_velocity_at_position(&self, contact_idx: i32) -> Vector2

fn get_contact_collider(&self, contact_idx: i32) -> Rid

Overridable version of get_contact_collider.

fn get_contact_collider_position(&self, contact_idx: i32) -> Vector2

Overridable version of get_contact_collider_position.

fn get_contact_collider_id(&self, contact_idx: i32) -> u64

Overridable version of get_contact_collider_id.

fn get_contact_collider_object(&self, contact_idx: i32) -> Option<Gd<Object>>

Overridable version of get_contact_collider_object.

fn get_contact_collider_shape(&self, contact_idx: i32) -> i32

Overridable version of get_contact_collider_shape.

fn get_contact_collider_velocity_at_position(&self, contact_idx: i32) -> Vector2

fn get_contact_impulse(&self, contact_idx: i32) -> Vector2

Overridable version of get_contact_impulse.

fn get_step(&self) -> f32

Implement to override the behavior of [member PhysicsDirectBodyState2D.step] and its respective getter.

fn integrate_forces(&mut self)

Overridable version of integrate_forces.

fn get_space_state(&mut self) -> Gd<PhysicsDirectSpaceState2D>

Overridable version of get_space_state.

Provided Methods§

fn init(base: Base<Self::Base>) -> Self

Godot constructor, accepting an injected base object.

base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded. This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.

If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.

fn on_notification(&mut self, what: ObjectNotification)

Called when the object receives a Godot notification.

The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_* constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists to represent integers out of known constants (mistakes or future additions).

This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the Object::notify method.

See also in Godot docs:

fn on_get(&self, property: StringName) -> Option<Variant>

Called whenever get() is called or Godot gets the value of a property.

Should return the given property’s value as Some(value), or None if the property should be handled normally.

See also in Godot docs:

fn on_set(&mut self, property: StringName, value: Variant) -> bool

Called whenever Godot set() is called or Godot sets the value of a property.

Should set property to the given value and return true, or return false to indicate the property should be handled normally.

See also in Godot docs:

fn on_validate_property(&self, property: &mut PropertyInfo)

Called whenever Godot retrieves value of property. Allows to customize existing properties. Every property info goes through this method, except properties added with on_get_property_list().

Exposed property here is a shared mutable reference obtained (and returned to) from Godot.

See also in the Godot docs:

fn on_get_property_list(&mut self) -> Vec<PropertyInfo>

Available on since_api=4.3 only.

Called whenever Godot get_property_list() is called, the returned vector here is appended to the existing list of properties.

This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.

See also in Godot docs:

fn on_property_get_revert(&self, property: StringName) -> Option<Variant>

Called by Godot to tell if a property has a custom revert or not.

Return None for no custom revert, and return Some(value) to specify the custom revert.

This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this function will usually be called twice by Godot to find the revert.

Note that this should be a pure function. That is, it should always return the same value for a property as long as self remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.

fn to_string(&self) -> GString

String representation of the Godot instance.

Override this method to define how the instance is represented as a string. Used by impl Display for Gd<T>, as well as str() and print() in GDScript.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§