Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boss bomb throw always has another static bomb sprite behind the animated explosion #299

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/fighter_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
});
Expand Down
7 changes: 5 additions & 2 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"),
Expand Down
12 changes: 9 additions & 3 deletions src/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -427,10 +427,16 @@ fn hot_reload_level(

fn load_items(
mut commands: Commands,
item_spawns: Query<(Entity, &Transform, &Handle<ItemMeta>), Without<Sprite>>,
item_spawns: Query<(Entity, &Transform, &Handle<ItemMeta>, Option<&Item>), Without<Sprite>>,
item_assets: Res<Assets<ItemMeta>>,
) {
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(),
Expand Down