Documentation
use super::*;

/// Velocity component.
///
/// Use to move and rotate entities (without physics).

pub struct Velocity {
    id: Entity,
}

impl std::fmt::Debug for Velocity {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("Velocity")
            .field("entity", &self.id.name())
            .field("velocity", &self.velocity().get())
            .field("angular_velocity", &self.angular_velocity().get())
            .finish()
    }
}

impl Velocity {
    impl_world_accessor!(
        /// Returns a `ValueAccessor` for the world-space linear velocity of the entity.
        ///
        /// Used to set/get/animate the velocity. This only works if physics has not been enabled
        /// for the entity.
        Velocity,
        Velocity,
        Vec3,
        velocity,
        ValueAccessorReadWriteAnimate
    );

    impl_world_accessor!(
        /// Returns a `ValueAccessor` for the world-space angular velocity of the entity
        ///
        /// This is an angular velocity as a pseudovector, with its magnitude measuring
        /// the rate at which an object rotates or revolves (in radians per seconds), and
        /// its direction pointing perpendicular to the instantaneous plane of rotation or
        /// angular displacement.
        ///
        /// Used to set/get/animate the velocity. This only works if physics has not been enabled
        /// for the entity.
        Velocity,
        AngularVelocity,
        Vec3,
        angular_velocity,
        ValueAccessorReadWriteAnimate
    );
}

impl_world_component!(Velocity);