Move elements to new module

This commit is contained in:
Jarrod Doyle 2024-02-01 11:33:30 +00:00
parent fe503f51de
commit 020260a2f3
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 23 additions and 20 deletions

View File

@ -0,0 +1,18 @@
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Element {
None,
Air,
Sand,
Water,
}
impl From<u32> for Element {
fn from(value: u32) -> Self {
match value {
x if x == Element::Air as u32 => Element::Air,
x if x == Element::Sand as u32 => Element::Sand,
x if x == Element::Water as u32 => Element::Water,
_ => Element::None,
}
}
}

View File

@ -1,3 +1,4 @@
mod element;
mod rules; mod rules;
use bevy::{ use bevy::{
@ -17,7 +18,10 @@ use rand::Rng;
use crate::util::DirtyRect; use crate::util::DirtyRect;
use self::rules::{to_rule_state, FallingSandRules}; use self::{
element::Element,
rules::{to_rule_state, FallingSandRules},
};
pub struct FallingSandPlugin; pub struct FallingSandPlugin;
@ -222,22 +226,3 @@ pub fn update_chunk_texture_system(
chunk.dirty_rect.reset(); chunk.dirty_rect.reset();
} }
} }
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Element {
None,
Air,
Sand,
Water,
}
impl From<u32> for Element {
fn from(value: u32) -> Self {
match value {
x if x == Element::Air as u32 => Element::Air,
x if x == Element::Sand as u32 => Element::Sand,
x if x == Element::Water as u32 => Element::Water,
_ => Element::None,
}
}
}