diff options
| author | Arne Dußin | 2021-01-27 14:01:50 +0100 |
|---|---|---|
| committer | Arne Dußin | 2021-02-02 22:16:15 +0100 |
| commit | f92e9f6f07b1e3834c2ca58ce3510734819d08e4 (patch) | |
| tree | 20e3d3afce342a56ae98f6c20491482ccd2b5c6b /src/client/map/mappable.rs | |
| parent | c60a6d07efb120724b308e29e8e70f27c87c952d (diff) | |
| download | graf_karto-f92e9f6f07b1e3834c2ca58ce3510734819d08e4.tar.gz graf_karto-f92e9f6f07b1e3834c2ca58ce3510734819d08e4.zip | |
Rework graf karto to fit the client/server structure
Diffstat (limited to 'src/client/map/mappable.rs')
| -rw-r--r-- | src/client/map/mappable.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/client/map/mappable.rs b/src/client/map/mappable.rs new file mode 100644 index 0000000..39e774b --- /dev/null +++ b/src/client/map/mappable.rs @@ -0,0 +1,23 @@ +//! Something that's mappable can be placed on the map and drawn at a specific position. It has a +//! dimension on the map and may be transformable in various ways. + +use crate::client::transform::Transform; +use crate::world::Component; +use raylib::drawing::RaylibDrawHandle; + +/// Anything that can be added to the map or world must implement this trait. +pub trait Mappable { + /// Draw this to `rld` with the transform. An item that cannot be drawn is not mappable, so + /// this must always be implemented. + fn draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform); + + /// Set the selection status of this item. If it is selected, actions that concern all selected + /// items will be applied to this item as well. + fn set_selected(&mut self, selected: bool); + + /// Get if this item is currently selected. + fn selected(&self) -> bool; + + /// Get this mappable as a world component. + fn as_component(&self) -> &dyn Component; +} |
