blob: 2664721a45a758dd65a7ecb5e3386a34ebb8e844 (
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
35
36
37
38
39
40
41
42
43
|
use crate::sim::cell::materials::MaterialId;
#[derive(Clone, Copy)]
pub struct Cell {
pub material: MaterialId,
pub flags: u8,
pub data: u16,
}
impl Cell {
const FLAG_PARITY: u8 = 0b0000_0001;
#[inline]
pub fn parity(self) -> u8 {
self.flags & Self::FLAG_PARITY
}
#[inline]
pub fn flip_parity(&mut self) {
self.flags ^= Self::FLAG_PARITY;
}
#[inline]
pub fn match_parity(&mut self, seqno: u64) {
// TODO this will break with more flags
self.flags = (seqno as u8) & 0b1;
}
}
impl Cell {
pub fn void() -> Cell {
Cell {
material: MaterialId::Void,
flags: 0,
data: 0,
}
}
pub fn from_material(material: MaterialId) -> Cell {
Cell {
material,
flags: 0,
data: 0,
}
}
}
|