From 020260a2f36f4320bb34c7800723a2f6866df0c7 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Thu, 1 Feb 2024 11:33:30 +0000 Subject: [PATCH] Move elements to new module --- src/falling_sand/element.rs | 18 ++++++++++++++++++ src/falling_sand/mod.rs | 25 +++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 src/falling_sand/element.rs diff --git a/src/falling_sand/element.rs b/src/falling_sand/element.rs new file mode 100644 index 0000000..5207b5d --- /dev/null +++ b/src/falling_sand/element.rs @@ -0,0 +1,18 @@ +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Element { + None, + Air, + Sand, + Water, +} + +impl From 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, + } + } +} diff --git a/src/falling_sand/mod.rs b/src/falling_sand/mod.rs index 3eabbaf..2642600 100644 --- a/src/falling_sand/mod.rs +++ b/src/falling_sand/mod.rs @@ -1,3 +1,4 @@ +mod element; mod rules; use bevy::{ @@ -17,7 +18,10 @@ use rand::Rng; use crate::util::DirtyRect; -use self::rules::{to_rule_state, FallingSandRules}; +use self::{ + element::Element, + rules::{to_rule_state, FallingSandRules}, +}; pub struct FallingSandPlugin; @@ -222,22 +226,3 @@ pub fn update_chunk_texture_system( chunk.dirty_rect.reset(); } } - -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum Element { - None, - Air, - Sand, - Water, -} - -impl From 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, - } - } -}