From f92e9f6f07b1e3834c2ca58ce3510734819d08e4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Wed, 27 Jan 2021 14:01:50 +0100 Subject: Rework graf karto to fit the client/server structure --- src/world/component.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/world/component.rs (limited to 'src/world/component.rs') diff --git a/src/world/component.rs b/src/world/component.rs new file mode 100644 index 0000000..e8a8df9 --- /dev/null +++ b/src/world/component.rs @@ -0,0 +1,23 @@ +//! 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 + } +} -- cgit v1.2.3-70-g09d2