game_manager.rs 485 Bytes
Newer Older
Rahix's avatar
Rahix committed
1
pub struct GameManager {
Rahix's avatar
Rahix committed
2
3
    pub return_timeout: Option<f64>,
    pub return_timestamp: Option<f64>,
Rahix's avatar
Rahix committed
4
5
6
7
8
}

impl GameManager {
    pub fn new() -> GameManager {
        GameManager {
Rahix's avatar
Rahix committed
9
10
            return_timeout: None,
            return_timestamp: None,
Rahix's avatar
Rahix committed
11
12
13
14
        }
    }

    pub fn request_return_to_heaven(&mut self) {
Rahix's avatar
Rahix committed
15
        self.return_timeout.get_or_insert(0.0);
Rahix's avatar
Rahix committed
16
17
18
    }

    pub fn wants_return_to_heaven(&self) -> bool {
Rahix's avatar
Rahix committed
19
        self.return_timeout.map_or(false, |t| t >= 3.0)
Rahix's avatar
Rahix committed
20
21
    }
}