aboutsummaryrefslogtreecommitdiff
path: root/src/map_data.rs
blob: d958736c5252b42b20162344bc19ec1fc9b61087 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::math::{Rect, Vec2};
use serde::{Deserialize, Serialize};
use std::io;
use std::path::Path;

/// All the data of the currently opened map. This does not include things that are currently being
/// drawn, but not finished. It also does not contain Metadata, like the current position of the
/// transform, or the zoom-level
#[derive(Serialize, Deserialize)]
pub struct MapData {
    rooms: Vec<Rect<f32>>,
    walls: Vec<(Vec2<f32>, Vec2<f32>)>,
}

impl MapData {
    pub fn new() -> Self {
        Self {
            rooms: Vec::new(),
            walls: Vec::new(),
        }
    }

    pub fn load_file<P: AsRef<Path>>(&mut self, path: P) -> io::Result<MapData> {
        todo!()
    }

    pub fn write_file<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
        todo!()
    }

    pub fn rooms(&self) -> &Vec<Rect<f32>> {
        &self.rooms
    }
    pub fn rooms_mut(&mut self) -> &mut Vec<Rect<f32>> {
        &mut self.rooms
    }

    pub fn walls(&self) -> &Vec<(Vec2<f32>, Vec2<f32>)> {
        &self.walls
    }
    pub fn walls_mut(&mut self) -> &mut Vec<(Vec2<f32>, Vec2<f32>)> {
        &mut self.walls
    }
}