aboutsummaryrefslogtreecommitdiff
path: root/client/src/world/mod.rs
blob: 7b25a53d2e94f89577a624efd0ffa1a734d3ca27 (plain)
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
use self::{map::Map, tee::Tees};
use crate::client::{helper::get_map_path, ClientMesgOut};
use std::fs::File;

pub mod helper;
pub mod map;
pub mod tee;

pub use gamenet::enums;

pub struct World {
    pub map: Map,
    pub tees: Tees,
}

impl World {
    pub fn new() -> Self {
        Self {
            map: Map::empty(),
            tees: Tees::new(),
        }
    }

    pub fn update(&mut self, m: &ClientMesgOut) {
        self.tees.update(m);
        match m {
            ClientMesgOut::MapChange { name, crc } => {
                let file = File::open(get_map_path(name.as_str(), *crc)).unwrap();
                self.map = Map::load(file, name.as_str(), *crc).unwrap();
            }
            _ => (),
        }
    }
}