aboutsummaryrefslogtreecommitdiff
path: root/src/map/mappable.rs
blob: f75c990ae8b67ea17ca5c47cc2e0637d2e7a72ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! 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 scaleable

use crate::math::Rect;
use crate::scaleable::Scaleable;
use crate::transform::Transform;
use raylib::drawing::RaylibDrawHandle;

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);

    /// Get the rectangle that contains the mappable object in its entirety without excess.
    fn bounding_rect(&self) -> Rect<f64>;

    fn as_scaleable(&self) -> Option<&dyn Scaleable> {
        None
    }
}