mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Add Dir group consts
This commit is contained in:
parent
25ff4c2b78
commit
ac626acab5
2 changed files with 5 additions and 1 deletions
|
|
@ -20,6 +20,10 @@ pub enum Dir {
|
|||
}
|
||||
|
||||
impl Dir {
|
||||
pub const CARDINALS: &'static [Dir] = &[Dir::North, Dir::South, Dir::East, Dir::West];
|
||||
pub const DIAGONALS: &'static [Dir] = &[Dir::Northeast, Dir::Northwest, Dir::Southeast, Dir::Southwest];
|
||||
pub const ALL: &'static [Dir] = &[Dir::North, Dir::South, Dir::East, Dir::West, Dir::Northeast, Dir::Northwest, Dir::Southeast, Dir::Southwest];
|
||||
|
||||
/// Attempt to build a direction from its integer representation.
|
||||
pub fn from_int(int: i32) -> Option<Dir> {
|
||||
Some(match int {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ fn calculate_adjacencies(objtree: &ObjectTree, neighborhood: &Neighborhood, atom
|
|||
}
|
||||
};
|
||||
|
||||
for &dir in &[Dir::South, Dir::North, Dir::East, Dir::West] {
|
||||
for &dir in Dir::CARDINALS {
|
||||
adjacencies |= check_one(dir, 1 << dir.to_int());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue