veloren_world/site/
block_mask.rs

1use common::terrain::Block;
2
3#[derive(Copy, Clone)]
4pub struct BlockMask {
5    block: Option<Block>,
6    priority: i32,
7}
8
9impl BlockMask {
10    pub const fn new(block: Block, priority: i32) -> Self {
11        Self {
12            block: Some(block),
13            priority,
14        }
15    }
16
17    pub const fn nothing() -> Self {
18        Self {
19            block: None,
20            priority: 0,
21        }
22    }
23
24    #[must_use]
25    pub const fn with_priority(mut self, priority: i32) -> Self {
26        self.priority = priority;
27        self
28    }
29
30    #[must_use]
31    pub const fn resolve_with(self, other: Self) -> Self {
32        if self.priority >= other.priority {
33            self
34        } else {
35            other
36        }
37    }
38
39    pub const fn finish(self) -> Option<Block> { self.block }
40}