diff --git a/src/fighter_state.rs b/src/fighter_state.rs index 834ff848..0f9a77a6 100644 --- a/src/fighter_state.rs +++ b/src/fighter_state.rs @@ -1447,7 +1447,9 @@ fn bomb_throw( attack_enemy: false, }) .insert(ItemBundle { - item: Item, + item: Item { + spawn_sprite: false, + }, item_meta_handle: attack.item_handle.clone(), name: Name::new("Bomb Item"), }); diff --git a/src/item.rs b/src/item.rs index cfec62cf..6a292170 100644 --- a/src/item.rs +++ b/src/item.rs @@ -38,7 +38,10 @@ pub struct ScriptItemGrabEvent { } #[derive(Component)] -pub struct Item; +pub struct Item { + /// Prevent the spawning of a Sprite component by load_items by setting this to false + pub spawn_sprite: bool, +} #[derive(Bundle)] pub struct ItemBundle { @@ -50,7 +53,7 @@ pub struct ItemBundle { impl ItemBundle { pub fn new(item_spawn_meta: &ItemSpawnMeta) -> Self { Self { - item: Item, + item: Item { spawn_sprite: true }, item_meta_handle: item_spawn_meta.item_handle.clone(), // TODO: Actually include the item's name at some point name: Name::new("Map Item"), diff --git a/src/loading.rs b/src/loading.rs index b349c52b..74cf9086 100644 --- a/src/loading.rs +++ b/src/loading.rs @@ -12,7 +12,7 @@ use crate::{ enemy::{Boss, Enemy, EnemyBundle}, fighter::ActiveFighterBundle, input::MenuAction, - item::ItemBundle, + item::{Item, ItemBundle}, metadata::{ BorderImageMeta, FighterMeta, GameHandle, GameMeta, ItemMeta, LevelHandle, LevelMeta, Settings, @@ -427,10 +427,16 @@ fn hot_reload_level( fn load_items( mut commands: Commands, - item_spawns: Query<(Entity, &Transform, &Handle), Without>, + item_spawns: Query<(Entity, &Transform, &Handle, Option<&Item>), Without>, item_assets: Res>, ) { - for (entity, transform, item_handle) in item_spawns.iter() { + for (entity, transform, item_handle, item) in item_spawns.iter() { + if let Some(item) = item { + if !item.spawn_sprite { + continue; + } + } + if let Some(item_meta) = item_assets.get(item_handle) { commands.entity(entity).insert(SpriteBundle { texture: item_meta.image.image_handle.clone(),