From bc90efbbc4104e70e86c3575d012825aae212e83 Mon Sep 17 00:00:00 2001 From: Franklin Date: Sun, 12 Nov 2023 00:51:15 -0400 Subject: [PATCH] Mild refactor --- src/comps/core/events/loot_container.rs | 2 +- src/comps/core/events/mod.rs | 3 ++- src/comps/core/events/pickup_item.rs | 4 ++++ src/comps/core/{ => inventory}/any_inventory.rs | 4 +++- src/comps/core/{ => inventory}/inventory_item.rs | 2 +- src/comps/core/{ => inventory}/item_inventory.rs | 2 +- src/comps/core/inventory/mod.rs | 4 ++++ src/comps/core/{ => inventory}/player_inventory.rs | 4 +++- src/comps/core/{ => items}/item.rs | 3 ++- src/comps/core/items/mod.rs | 1 + src/comps/core/markers/interactable.rs | 3 +-- src/comps/core/mod.rs | 7 ++----- src/scenes/scene1/obstacles.rs | 2 +- 13 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 src/comps/core/events/pickup_item.rs rename src/comps/core/{ => inventory}/any_inventory.rs (95%) rename src/comps/core/{ => inventory}/inventory_item.rs (94%) rename src/comps/core/{ => inventory}/item_inventory.rs (87%) create mode 100644 src/comps/core/inventory/mod.rs rename src/comps/core/{ => inventory}/player_inventory.rs (90%) rename src/comps/core/{ => items}/item.rs (92%) create mode 100644 src/comps/core/items/mod.rs diff --git a/src/comps/core/events/loot_container.rs b/src/comps/core/events/loot_container.rs index a909c91..24dfdaa 100644 --- a/src/comps/core/events/loot_container.rs +++ b/src/comps/core/events/loot_container.rs @@ -1,6 +1,6 @@ use bevy::prelude::*; -use crate::comps::core::any_inventory::AnyInventory; +use crate::comps::core::inventory::any_inventory::AnyInventory; #[derive(Event)] pub struct LootContainerEvent(pub AnyInventory); \ No newline at end of file diff --git a/src/comps/core/events/mod.rs b/src/comps/core/events/mod.rs index d332458..0f27e70 100644 --- a/src/comps/core/events/mod.rs +++ b/src/comps/core/events/mod.rs @@ -1 +1,2 @@ -pub mod loot_container; \ No newline at end of file +pub mod loot_container; +pub mod pickup_item; \ No newline at end of file diff --git a/src/comps/core/events/pickup_item.rs b/src/comps/core/events/pickup_item.rs new file mode 100644 index 0000000..b296c39 --- /dev/null +++ b/src/comps/core/events/pickup_item.rs @@ -0,0 +1,4 @@ +use bevy::prelude::*; + +#[derive(Event)] +pub struct PickupItemEvent(); \ No newline at end of file diff --git a/src/comps/core/any_inventory.rs b/src/comps/core/inventory/any_inventory.rs similarity index 95% rename from src/comps/core/any_inventory.rs rename to src/comps/core/inventory/any_inventory.rs index 40310a7..39836df 100644 --- a/src/comps/core/any_inventory.rs +++ b/src/comps/core/inventory/any_inventory.rs @@ -1,6 +1,8 @@ use bevy::ecs::component::SparseStorage; -use super::{item::Item, inventory_item::InventoryItem, grid::UGrid}; +use crate::comps::core::{items::item::Item, grid::UGrid}; + +use super::inventory_item::InventoryItem; #[allow(unused)] #[derive(Clone)] diff --git a/src/comps/core/inventory_item.rs b/src/comps/core/inventory/inventory_item.rs similarity index 94% rename from src/comps/core/inventory_item.rs rename to src/comps/core/inventory/inventory_item.rs index 4243945..9082c58 100644 --- a/src/comps/core/inventory_item.rs +++ b/src/comps/core/inventory/inventory_item.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use bevy::ecs::component::SparseStorage; -use super::{item::Item, grid::UGrid}; +use crate::comps::core::{grid::UGrid, items::item::Item}; #[derive(Clone)] diff --git a/src/comps/core/item_inventory.rs b/src/comps/core/inventory/item_inventory.rs similarity index 87% rename from src/comps/core/item_inventory.rs rename to src/comps/core/inventory/item_inventory.rs index a74f26a..db526e3 100644 --- a/src/comps/core/item_inventory.rs +++ b/src/comps/core/inventory/item_inventory.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use bevy::{prelude::*, ecs::component::SparseStorage}; -use super::item::Item; +use crate::comps::core::items::item::Item; /// # ItemInventory /// Specifically made to hold single items such as Guns, Pieces of armor. diff --git a/src/comps/core/inventory/mod.rs b/src/comps/core/inventory/mod.rs new file mode 100644 index 0000000..55ae0af --- /dev/null +++ b/src/comps/core/inventory/mod.rs @@ -0,0 +1,4 @@ +pub mod any_inventory; +pub mod inventory_item; +pub mod item_inventory; +pub mod player_inventory; \ No newline at end of file diff --git a/src/comps/core/player_inventory.rs b/src/comps/core/inventory/player_inventory.rs similarity index 90% rename from src/comps/core/player_inventory.rs rename to src/comps/core/inventory/player_inventory.rs index 4695bcf..5bc1cf9 100644 --- a/src/comps/core/player_inventory.rs +++ b/src/comps/core/inventory/player_inventory.rs @@ -1,6 +1,8 @@ use bevy::prelude::*; -use super::{item_inventory::ItemInventory, any_inventory::AnyInventory, grid::UGrid}; +use crate::comps::core::grid::UGrid; + +use super::{item_inventory::ItemInventory, any_inventory::AnyInventory}; #[derive(Component)] pub struct PlayerInventory { diff --git a/src/comps/core/item.rs b/src/comps/core/items/item.rs similarity index 92% rename from src/comps/core/item.rs rename to src/comps/core/items/item.rs index 2267fbf..c2cf53e 100644 --- a/src/comps/core/item.rs +++ b/src/comps/core/items/item.rs @@ -1,6 +1,7 @@ use bevy::prelude::*; -use super::grid::UGrid; +use crate::comps::core::grid::UGrid; + #[allow(unused)] pub enum ItemType { diff --git a/src/comps/core/items/mod.rs b/src/comps/core/items/mod.rs new file mode 100644 index 0000000..da1b089 --- /dev/null +++ b/src/comps/core/items/mod.rs @@ -0,0 +1 @@ +pub mod item; \ No newline at end of file diff --git a/src/comps/core/markers/interactable.rs b/src/comps/core/markers/interactable.rs index dbeeecf..3b929c5 100644 --- a/src/comps/core/markers/interactable.rs +++ b/src/comps/core/markers/interactable.rs @@ -2,8 +2,7 @@ use std::fmt::Display; use bevy::prelude::Component; -use crate::comps::core::any_inventory::AnyInventory; - +use crate::comps::core::inventory::any_inventory::AnyInventory; #[allow(unused)] #[derive(Component)] diff --git a/src/comps/core/mod.rs b/src/comps/core/mod.rs index ece68b7..f51fe84 100644 --- a/src/comps/core/mod.rs +++ b/src/comps/core/mod.rs @@ -1,9 +1,6 @@ pub mod controller; pub mod markers; -pub mod any_inventory; -pub mod item; pub mod grid; -pub mod inventory_item; pub mod events; -pub mod item_inventory; -pub mod player_inventory; \ No newline at end of file +pub mod inventory; +pub mod items; \ No newline at end of file diff --git a/src/scenes/scene1/obstacles.rs b/src/scenes/scene1/obstacles.rs index 670465f..17b3980 100644 --- a/src/scenes/scene1/obstacles.rs +++ b/src/scenes/scene1/obstacles.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; use bevy_rapier3d::prelude::*; -use crate::comps::core::{any_inventory::AnyInventory, markers::interactable::Interactable, grid::UGrid}; +use crate::comps::core::{markers::interactable::Interactable, grid::UGrid, inventory::any_inventory::AnyInventory}; pub fn spawn_obstacles( mut commands: Commands,