use std::collections::HashMap;
use fmc::{items::ItemId, prelude::*};
pub mod crafting;
mod ground_items;
mod bread;
mod hoes;
mod seeds;
pub use ground_items::GroundItemBundle;
pub struct ItemPlugin;
impl Plugin for ItemPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(UsableItems::default())
.add_plugins(ground_items::GroundItemPlugin)
.add_plugins(crafting::CraftingPlugin)
.add_plugins(hoes::HoePlugin)
.add_plugins(seeds::SeedPlugin);
}
}
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
pub struct RegisterItemUse;
#[derive(Resource, Deref, DerefMut, Default)]
pub struct UsableItems(HashMap<ItemId, Entity>);
#[derive(Component, Default)]
pub struct ItemUses(Vec<Entity>);
impl ItemUses {
fn read(&mut self) -> impl Iterator<Item = Entity> + '_ {
self.0.drain(..)
}
pub fn push(&mut self, player_entity: Entity) {
self.0.push(player_entity);
}
}