From 0eeb65e62d24164937de36e6a959292d2703c233 Mon Sep 17 00:00:00 2001 From: Miro Andrin Date: Sun, 22 Aug 2021 20:29:54 +0200 Subject: [PATCH] Small refactor, moving chunk related files into a module. --- .../common/src/{chunk_cache.rs => chunk/cache.rs} | 0 .../src/{chunk_entities.rs => chunk/entities.rs} | 0 .../src/{chunk_loading.rs => chunk/loading.rs} | 2 +- feather/common/src/chunk/mod.rs | 4 ++++ .../common/src/{chunk_worker.rs => chunk/worker.rs} | 0 feather/common/src/game.rs | 2 +- feather/common/src/lib.rs | 12 +++--------- feather/common/src/region_worker.rs | 2 +- feather/common/src/world.rs | 4 ++-- 9 files changed, 12 insertions(+), 14 deletions(-) rename feather/common/src/{chunk_cache.rs => chunk/cache.rs} (100%) rename feather/common/src/{chunk_entities.rs => chunk/entities.rs} (100%) rename feather/common/src/{chunk_loading.rs => chunk/loading.rs} (99%) create mode 100644 feather/common/src/chunk/mod.rs rename feather/common/src/{chunk_worker.rs => chunk/worker.rs} (100%) diff --git a/feather/common/src/chunk_cache.rs b/feather/common/src/chunk/cache.rs similarity index 100% rename from feather/common/src/chunk_cache.rs rename to feather/common/src/chunk/cache.rs diff --git a/feather/common/src/chunk_entities.rs b/feather/common/src/chunk/entities.rs similarity index 100% rename from feather/common/src/chunk_entities.rs rename to feather/common/src/chunk/entities.rs diff --git a/feather/common/src/chunk_loading.rs b/feather/common/src/chunk/loading.rs similarity index 99% rename from feather/common/src/chunk_loading.rs rename to feather/common/src/chunk/loading.rs index 442d077f5..a6bb9971e 100644 --- a/feather/common/src/chunk_loading.rs +++ b/feather/common/src/chunk/loading.rs @@ -12,7 +12,7 @@ use ecs::{Entity, SysResult, SystemExecutor}; use utils::vec_remove_item; use crate::{ - chunk_worker::LoadRequest, + chunk::worker::LoadRequest, events::{EntityRemoveEvent, ViewUpdateEvent}, Game, }; diff --git a/feather/common/src/chunk/mod.rs b/feather/common/src/chunk/mod.rs new file mode 100644 index 000000000..e1c180383 --- /dev/null +++ b/feather/common/src/chunk/mod.rs @@ -0,0 +1,4 @@ +pub mod cache; +pub mod entities; +pub mod loading; +pub mod worker; diff --git a/feather/common/src/chunk_worker.rs b/feather/common/src/chunk/worker.rs similarity index 100% rename from feather/common/src/chunk_worker.rs rename to feather/common/src/chunk/worker.rs diff --git a/feather/common/src/game.rs b/feather/common/src/game.rs index db856e010..3d23442dc 100644 --- a/feather/common/src/game.rs +++ b/feather/common/src/game.rs @@ -9,7 +9,7 @@ use quill_common::{entities::Player, entity_init::EntityInit}; use crate::{ chat::{ChatKind, ChatMessage}, - chunk_entities::ChunkEntities, + chunk::entities::ChunkEntities, events::{BlockChangeEvent, EntityCreateEvent, EntityRemoveEvent, PlayerJoinEvent}, ChatBox, World, }; diff --git a/feather/common/src/lib.rs b/feather/common/src/lib.rs index 94223229d..9f9e7348a 100644 --- a/feather/common/src/lib.rs +++ b/feather/common/src/lib.rs @@ -19,18 +19,12 @@ pub use window::Window; pub mod events; -pub mod chunk_worker; +pub mod chunk; mod region_worker; -pub mod chunk_cache; - pub mod world; pub use world::World; -mod chunk_loading; - -mod chunk_entities; - pub mod chat; pub use chat::ChatBox; @@ -41,8 +35,8 @@ pub mod interactable; /// Registers gameplay systems with the given `Game` and `SystemExecutor`. pub fn register(game: &mut Game, systems: &mut SystemExecutor) { view::register(game, systems); - chunk_loading::register(game, systems); - chunk_entities::register(systems); + chunk::loading::register(game, systems); + chunk::entities::register(systems); interactable::register(game); game.add_entity_spawn_callback(entities::add_entity_components); diff --git a/feather/common/src/region_worker.rs b/feather/common/src/region_worker.rs index 836c252c5..dac33c985 100644 --- a/feather/common/src/region_worker.rs +++ b/feather/common/src/region_worker.rs @@ -11,7 +11,7 @@ use base::anvil::{ }; use flume::{Receiver, Sender}; -use crate::chunk_worker::{ChunkLoadResult, LoadRequest, LoadedChunk, SaveRequest, WorkerRequest}; +use crate::chunk::worker::{ChunkLoadResult, LoadRequest, LoadedChunk, SaveRequest, WorkerRequest}; /// Duration to keep a region file open when not in use. const CACHE_TIME: Duration = Duration::from_secs(60); diff --git a/feather/common/src/world.rs b/feather/common/src/world.rs index d27070755..f06db279f 100644 --- a/feather/common/src/world.rs +++ b/feather/common/src/world.rs @@ -7,8 +7,8 @@ use std::{path::PathBuf, sync::Arc}; use worldgen::{ComposableGenerator, WorldGenerator}; use crate::{ - chunk_cache::ChunkCache, - chunk_worker::{ChunkWorker, LoadRequest, SaveRequest}, + chunk::cache::ChunkCache, + chunk::worker::{ChunkWorker, LoadRequest, SaveRequest}, events::ChunkLoadEvent, };