From a436180ae440a3c70e58588d0cbf81e93eba6a0e Mon Sep 17 00:00:00 2001 From: copygirl Date: Mon, 5 Jan 2026 11:13:29 +0100 Subject: [PATCH] Modify crate visibility --- client/src/assets/block_visuals.rs | 30 +++++++++++++++++++++++----- client/src/assets/mod.rs | 6 +++--- client/src/assets/player.rs | 2 +- client/src/input/client_inputs.rs | 2 +- client/src/input/cursor_grab.rs | 2 +- client/src/input/head_orientation.rs | 2 +- client/src/input/mod.rs | 8 ++++---- client/src/ui/crosshair.rs | 9 ++++----- client/src/ui/loading_screen.rs | 2 +- client/src/ui/mod.rs | 6 +++--- common/src/assets/manifest.rs | 4 ++-- 11 files changed, 46 insertions(+), 27 deletions(-) diff --git a/client/src/assets/block_visuals.rs b/client/src/assets/block_visuals.rs index 461d66b..fd3551b 100644 --- a/client/src/assets/block_visuals.rs +++ b/client/src/assets/block_visuals.rs @@ -5,7 +5,7 @@ use bevy::asset::io::Reader; use bevy::asset::{AssetLoader, LoadContext}; use serde::Deserialize; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { let mesh = Mesh::from(Cuboid::new(1.0, 1.0, 1.0)); let cube = app.world_mut().add_asset(mesh); app.insert_resource(BuiltinBlockMeshes { cube }); @@ -22,10 +22,25 @@ struct BuiltinBlockMeshes { } #[derive(Asset, TypePath)] -struct BlockVisuals { +pub struct BlockVisuals { _id: Identifier, - // mesh: Handle, + color: Color, material: Handle, + // mesh: Handle, +} + +impl BlockVisuals { + // pub fn id(&self) -> &Identifier { + // &self.id + // } + + pub fn color(&self) -> Color { + self.color + } + + // pub fn material(&self) -> &Handle { + // &self.material + // } } impl ManifestEntry for BlockVisuals { @@ -57,14 +72,19 @@ impl AssetLoader for BlockVisualsLoader { let raw = ron::de::from_bytes::(&bytes)?; let (r, g, b) = raw.color; - let material = StandardMaterial::from(Color::srgb_u8(r, g, b)); + let color = Color::srgb_u8(r, g, b); + let material = StandardMaterial::from(color); let material = load_context.add_labeled_asset("material".to_string(), material); // TODO: Figure out how to reference a procedural mesh from here. // let mesh = load_context.load(???); let id = load_context.path().try_into()?; - Ok(BlockVisuals { _id: id, material }) + Ok(BlockVisuals { + _id: id, + color, + material, + }) } fn extensions(&self) -> &[&str] { diff --git a/client/src/assets/mod.rs b/client/src/assets/mod.rs index fb01348..011409d 100644 --- a/client/src/assets/mod.rs +++ b/client/src/assets/mod.rs @@ -6,10 +6,10 @@ use bevy::prelude::*; -mod block_visuals; -mod player; +pub mod block_visuals; +pub mod player; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.add_plugins(block_visuals::plugin); app.add_plugins(player::plugin); } diff --git a/client/src/assets/player.rs b/client/src/assets/player.rs index fb6971e..0f64853 100644 --- a/client/src/assets/player.rs +++ b/client/src/assets/player.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; use common::prelude::*; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.load_resource::(); app.add_observer(insert_player_visuals); } diff --git a/client/src/input/client_inputs.rs b/client/src/input/client_inputs.rs index 3e25314..550c6cc 100644 --- a/client/src/input/client_inputs.rs +++ b/client/src/input/client_inputs.rs @@ -8,7 +8,7 @@ use lightyear::prelude::input::native::*; use bevy::window::{CursorGrabMode, CursorOptions}; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.init_resource::(); app.add_systems( FixedPreUpdate, diff --git a/client/src/input/cursor_grab.rs b/client/src/input/cursor_grab.rs index 052a2b8..37f9daa 100644 --- a/client/src/input/cursor_grab.rs +++ b/client/src/input/cursor_grab.rs @@ -6,7 +6,7 @@ use bevy::window::{CursorGrabMode, CursorOptions}; use crate::Screen; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.add_systems(OnEnter(Screen::Gameplay), add_window_click_observer); app.add_systems(PreUpdate, center_cursor.run_if(is_cursor_grabbed)); app.add_systems( diff --git a/client/src/input/head_orientation.rs b/client/src/input/head_orientation.rs index 605f341..9882736 100644 --- a/client/src/input/head_orientation.rs +++ b/client/src/input/head_orientation.rs @@ -15,7 +15,7 @@ impl Default for MouseSensitivity { } } -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.init_resource::(); app.add_systems(Update, update_head_orientation.run_if(is_cursor_grabbed)); } diff --git a/client/src/input/mod.rs b/client/src/input/mod.rs index 9cf1f65..08d65f9 100644 --- a/client/src/input/mod.rs +++ b/client/src/input/mod.rs @@ -1,12 +1,12 @@ use bevy::prelude::*; -mod client_inputs; -mod cursor_grab; -mod head_orientation; +pub mod client_inputs; +pub mod cursor_grab; +pub mod head_orientation; pub use cursor_grab::is_cursor_grabbed; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.add_plugins(( client_inputs::plugin, cursor_grab::plugin, diff --git a/client/src/ui/crosshair.rs b/client/src/ui/crosshair.rs index 9ba8c53..3c5c875 100644 --- a/client/src/ui/crosshair.rs +++ b/client/src/ui/crosshair.rs @@ -5,7 +5,7 @@ use bevy::window::{CursorGrabMode, CursorOptions}; use crate::Screen; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.load_resource::(); app.add_systems(OnEnter(Screen::Gameplay), setup_crosshair); app.add_systems(Update, update_crosshair_visibility); @@ -13,7 +13,7 @@ pub fn plugin(app: &mut App) { #[derive(Resource, Asset, Reflect, Clone)] #[reflect(Resource)] -pub struct CrosshairAssets { +struct CrosshairAssets { #[dependency] image: Handle, } @@ -21,9 +21,8 @@ pub struct CrosshairAssets { impl FromWorld for CrosshairAssets { fn from_world(world: &mut World) -> Self { let assets = world.resource::(); - Self { - image: assets.load("crosshair.png"), - } + let image = assets.load("crosshair.png"); + Self { image } } } diff --git a/client/src/ui/loading_screen.rs b/client/src/ui/loading_screen.rs index 114f7a6..614c198 100644 --- a/client/src/ui/loading_screen.rs +++ b/client/src/ui/loading_screen.rs @@ -4,7 +4,7 @@ use common::assets::asset_tracking::ResourceHandles; use crate::Screen; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.add_systems( Update, enter_gameplay_screen.run_if(in_state(Screen::Loading).and(all_assets_loaded)), diff --git a/client/src/ui/mod.rs b/client/src/ui/mod.rs index 6ad31ae..6f9b1ff 100644 --- a/client/src/ui/mod.rs +++ b/client/src/ui/mod.rs @@ -1,9 +1,9 @@ use bevy::prelude::*; -mod crosshair; -mod loading_screen; +pub mod crosshair; +pub mod loading_screen; -pub fn plugin(app: &mut App) { +pub(super) fn plugin(app: &mut App) { app.add_plugins((crosshair::plugin, loading_screen::plugin)); // Make entities require the `Pickable` component if diff --git a/common/src/assets/manifest.rs b/common/src/assets/manifest.rs index f715f8d..ced7506 100644 --- a/common/src/assets/manifest.rs +++ b/common/src/assets/manifest.rs @@ -17,13 +17,13 @@ pub trait ManifestEntry: Asset { #[derive(Resource, Asset, Reflect)] #[derive_where(Clone)] -struct ManifestResource { +pub struct ManifestResource { #[dependency] handle: Handle>, } #[derive(Asset, TypePath)] -struct ManifestAsset { +pub struct ManifestAsset { #[dependency] map: IdentifierMap>, }