//! The world is made up of components. Every component must implement this //! general trait that makes it possible to argue about certain characteristics //! and may make it possible to transform some items. use crate::math::Rect; use crate::transformable::NonRigidTransformable; /// Anything that can be added to the map or world must implement this trait. pub trait Component { /// Get the rectangle that contains the component in its entirety without excess. fn bounding_rect(&self) -> Rect; /// If this component can be transformed in a non-rigid way, a dynamic /// reference is returned, otherwise none. fn as_non_rigid(&self) -> Option<&dyn NonRigidTransformable> { None } /// The same as `as_non_rigid`, but mutably. fn as_non_rigid_mut(&mut self) -> Option<&mut dyn NonRigidTransformable> { None } }