Skip to content

Commit 8af5dbd

Browse files
bors[bot]Zac8668
andauthored
Merge #299
299: Boss bomb throw always has another static bomb sprite behind the animated explosion r=odecay a=Zac8668 Closes #298 Co-authored-by: Isaac <78173025+Zac8668@users.noreply.github.com>
2 parents c209b4b + e183bb8 commit 8af5dbd

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/fighter_state.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,9 @@ fn bomb_throw(
14471447
attack_enemy: false,
14481448
})
14491449
.insert(ItemBundle {
1450-
item: Item,
1450+
item: Item {
1451+
spawn_sprite: false,
1452+
},
14511453
item_meta_handle: attack.item_handle.clone(),
14521454
name: Name::new("Bomb Item"),
14531455
});

src/item.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ pub struct ScriptItemGrabEvent {
3838
}
3939

4040
#[derive(Component)]
41-
pub struct Item;
41+
pub struct Item {
42+
/// Prevent the spawning of a Sprite component by load_items by setting this to false
43+
pub spawn_sprite: bool,
44+
}
4245

4346
#[derive(Bundle)]
4447
pub struct ItemBundle {
@@ -50,7 +53,7 @@ pub struct ItemBundle {
5053
impl ItemBundle {
5154
pub fn new(item_spawn_meta: &ItemSpawnMeta) -> Self {
5255
Self {
53-
item: Item,
56+
item: Item { spawn_sprite: true },
5457
item_meta_handle: item_spawn_meta.item_handle.clone(),
5558
// TODO: Actually include the item's name at some point
5659
name: Name::new("Map Item"),

src/loading.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
enemy::{Boss, Enemy, EnemyBundle},
1313
fighter::ActiveFighterBundle,
1414
input::MenuAction,
15-
item::ItemBundle,
15+
item::{Item, ItemBundle},
1616
metadata::{
1717
BorderImageMeta, FighterMeta, GameHandle, GameMeta, ItemMeta, LevelHandle, LevelMeta,
1818
Settings,
@@ -427,10 +427,16 @@ fn hot_reload_level(
427427

428428
fn load_items(
429429
mut commands: Commands,
430-
item_spawns: Query<(Entity, &Transform, &Handle<ItemMeta>), Without<Sprite>>,
430+
item_spawns: Query<(Entity, &Transform, &Handle<ItemMeta>, Option<&Item>), Without<Sprite>>,
431431
item_assets: Res<Assets<ItemMeta>>,
432432
) {
433-
for (entity, transform, item_handle) in item_spawns.iter() {
433+
for (entity, transform, item_handle, item) in item_spawns.iter() {
434+
if let Some(item) = item {
435+
if !item.spawn_sprite {
436+
continue;
437+
}
438+
}
439+
434440
if let Some(item_meta) = item_assets.get(item_handle) {
435441
commands.entity(entity).insert(SpriteBundle {
436442
texture: item_meta.image.image_handle.clone(),

0 commit comments

Comments
 (0)