From 931bc21d8ed9365ee86f2159f90278e311527f07 Mon Sep 17 00:00:00 2001 From: Carlo Supina Date: Sat, 5 Oct 2024 12:35:01 -0500 Subject: [PATCH] Cleanup (#197) * remove unwrap from sprite_animation_system * remove * import and exports from assets module * add comment to change_bg_music_system * remove unused star explode system * rename screen shake systems add comments * remove star imports and collision module, limit visibility of collision systems * remove * imports from run module * remove * imports and some warnings from spawnable module * remove * export of mob module from spawnable * remove * imports from arena module, limit visibility of exports * comment assets module * limit visibility of exports from modules --- src/animation/mod.rs | 70 ++++++++++++----------- src/arena/barrier.rs | 4 +- src/arena/gate.rs | 14 ++++- src/arena/mod.rs | 9 ++- src/assets/audio.rs | 17 ++++-- src/assets/consumable.rs | 9 ++- src/assets/effect.rs | 11 +++- src/assets/item.rs | 12 +++- src/assets/mob.rs | 26 ++++++--- src/assets/mod.rs | 5 +- src/assets/player.rs | 9 ++- src/assets/projectile.rs | 9 ++- src/assets/ui.rs | 11 +++- src/audio/mod.rs | 14 +++++ src/background/mod.rs | 41 +------------ src/camera/mod.rs | 12 +++- src/camera/screen_shake.rs | 8 ++- src/collision/contact.rs | 7 ++- src/collision/intersection.rs | 2 +- src/collision/mod.rs | 9 ++- src/game/mod.rs | 2 +- src/game/resources.rs | 2 +- src/loot/mod.rs | 3 +- src/run/formation.rs | 6 +- src/run/level.rs | 7 ++- src/run/mod.rs | 8 ++- src/spawnable/behavior_sequence.rs | 14 +++-- src/spawnable/consumable/behavior.rs | 8 ++- src/spawnable/consumable/mod.rs | 6 +- src/spawnable/effect/behavior.rs | 4 +- src/spawnable/effect/spawn.rs | 3 +- src/spawnable/item/mod.rs | 6 +- src/spawnable/item/spawn.rs | 2 +- src/spawnable/mob/behavior.rs | 9 ++- src/spawnable/mob/mob_segment/behavior.rs | 10 +++- src/spawnable/mob/mob_segment/mod.rs | 25 +++++--- src/spawnable/mob/mod.rs | 32 ++++++++--- src/spawnable/mod.rs | 29 ++++++---- src/spawnable/projectile/behavior.rs | 30 ++++------ src/spawnable/projectile/mod.rs | 10 ++-- 40 files changed, 324 insertions(+), 191 deletions(-) diff --git a/src/animation/mod.rs b/src/animation/mod.rs index daefb6d0..569706c6 100644 --- a/src/animation/mod.rs +++ b/src/animation/mod.rs @@ -10,6 +10,7 @@ use bevy::{ schedule::IntoSystemConfigs, system::{Query, Res}, }, + prelude::error, sprite::{TextureAtlas, TextureAtlasLayout}, state::condition::in_state, time::{Time, Timer}, @@ -84,43 +85,48 @@ fn animate_sprite_system( // check if frame has completed if animation.timer.finished() { // get the texture atlas - let texture_atlas_layout = texture_atlas_layouts - .get(texture_atlas.layout.id()) - .unwrap(); - - // update animation based on the animation direction - match &animation.direction { - AnimationDirection::None => {} - AnimationDirection::Forward => { - let new_idx = (texture_atlas.index + 1) % texture_atlas_layout.textures.len(); - if new_idx == 0 { - animation_complete_event_writer.send(AnimationCompletedEvent(entity)); - } - texture_atlas.index = new_idx; - } - AnimationDirection::PingPong(direction) => match direction { - PingPongDirection::Forward => { - if texture_atlas.index < (texture_atlas_layout.textures.len() - 1) { - texture_atlas.index += 1; - } - - if texture_atlas.index == (texture_atlas_layout.textures.len() - 1) { - animation.direction = - AnimationDirection::PingPong(PingPongDirection::Backward) + if let Some(texture_atlas_layout) = texture_atlas_layouts.get(texture_atlas.layout.id()) + { + // update animation based on the animation direction + match &animation.direction { + AnimationDirection::None => {} + AnimationDirection::Forward => { + let new_idx = + (texture_atlas.index + 1) % texture_atlas_layout.textures.len(); + if new_idx == 0 { + animation_complete_event_writer.send(AnimationCompletedEvent(entity)); } + texture_atlas.index = new_idx; } - PingPongDirection::Backward => { - if texture_atlas.index > 0 { - texture_atlas.index -= 1; + AnimationDirection::PingPong(direction) => match direction { + PingPongDirection::Forward => { + if texture_atlas.index < (texture_atlas_layout.textures.len() - 1) { + texture_atlas.index += 1; + } + + if texture_atlas.index == (texture_atlas_layout.textures.len() - 1) { + animation.direction = + AnimationDirection::PingPong(PingPongDirection::Backward) + } } + PingPongDirection::Backward => { + if texture_atlas.index > 0 { + texture_atlas.index -= 1; + } - if texture_atlas.index == 0 { - animation.direction = - AnimationDirection::PingPong(PingPongDirection::Forward) + if texture_atlas.index == 0 { + animation.direction = + AnimationDirection::PingPong(PingPongDirection::Forward) + } } - } - }, - }; + }, + }; + } else { + error!( + "Could not get texture atlas layout for id: {}.", + texture_atlas.layout.id() + ); + } } } } diff --git a/src/arena/barrier.rs b/src/arena/barrier.rs index ae85284e..f85a11cf 100644 --- a/src/arena/barrier.rs +++ b/src/arena/barrier.rs @@ -3,7 +3,9 @@ use crate::{game::GameParametersResource, spawnable::SpawnEffectEvent}; use bevy::prelude::{ Commands, Component, EventWriter, Name, Quat, Res, Transform, TransformBundle, Vec2, Vec3, }; -use bevy_rapier2d::prelude::*; +use bevy_rapier2d::prelude::{ + ActiveEvents, Collider, CollisionGroups, Friction, Group, Restitution, RigidBody, +}; use std::f32::consts::FRAC_PI_2; use thetawave_interface::{spawnable::EffectType, states::GameCleanup}; diff --git a/src/arena/gate.rs b/src/arena/gate.rs index 10c9c5a1..fd7ea2bb 100644 --- a/src/arena/gate.rs +++ b/src/arena/gate.rs @@ -1,6 +1,16 @@ use crate::spawnable::{MobComponent, MobSegmentComponent, SpawnableComponent}; -use bevy::prelude::*; -use bevy_rapier2d::{prelude::*, rapier::prelude::CollisionEventFlags}; +use bevy::{ + core::Name, + math::Vec2, + prelude::{ + Commands, Component, DespawnRecursiveExt, Entity, EventReader, EventWriter, Query, + Transform, TransformBundle, With, + }, +}; +use bevy_rapier2d::{ + prelude::{Collider, CollisionEvent, Sensor}, + rapier::prelude::CollisionEventFlags, +}; use thetawave_interface::{objective::MobReachedBottomGateEvent, states::GameCleanup}; /// Tag for the gate that triggers mobs to respawn (and cause something bad to happen to the diff --git a/src/arena/mod.rs b/src/arena/mod.rs index aabc562c..e23a7ed0 100644 --- a/src/arena/mod.rs +++ b/src/arena/mod.rs @@ -1,16 +1,21 @@ //! Exposes a plugin that renders a rectangular boundary that the player cannot cross, but mobs //! can. Also handles sending events when mobs reach the botton of the screen. -use bevy::prelude::*; +use barrier::spawn_barriers_system; +use bevy::{ + app::{App, Plugin, Update}, + prelude::{in_state, IntoSystemConfigs, OnEnter}, +}; use thetawave_interface::{objective::MobReachedBottomGateEvent, states}; mod barrier; mod gate; use crate::GameEnterSet; -pub use self::barrier::*; use self::gate::{despawn_gates_system, spawn_despawn_gates_system}; +pub(crate) use self::barrier::ArenaBarrierComponent; + /// Plugin that spawns a rectangular boundary for the main game play area and fires off /// `MobReachedBottomGateEvent` at the right times pub(super) struct ArenaPlugin; diff --git a/src/assets/audio.rs b/src/assets/audio.rs index 97bf7d97..fc21aa67 100644 --- a/src/assets/audio.rs +++ b/src/assets/audio.rs @@ -1,11 +1,15 @@ -use bevy::prelude::*; -use bevy_asset_loader::prelude::*; +use bevy::{ + asset::Handle, + prelude::{Res, Resource}, +}; +use bevy_asset_loader::asset_collection::AssetCollection; use bevy_kira_audio::AudioSource; use rand::Rng; use thetawave_interface::audio::{BGMusicType, CollisionSoundType, SoundEffectType}; +/// Collection of all audio assets in the game including sound effects and background music #[derive(AssetCollection, Resource)] -pub struct GameAudioAssets { +pub(crate) struct GameAudioAssets { #[asset(key = "sounds.main_music")] pub main_music: Handle, #[asset(key = "sounds.game_music")] @@ -69,7 +73,8 @@ pub struct GameAudioAssets { } impl GameAudioAssets { - pub fn get_bg_music_asset(&self, bg_music_type: &BGMusicType) -> Handle { + /// Use a BGMusicType enum to access a handle for a track of music + pub(crate) fn get_bg_music_asset(&self, bg_music_type: &BGMusicType) -> Handle { match bg_music_type { BGMusicType::Game => self.game_music.clone(), BGMusicType::Boss => self.boss_music.clone(), @@ -78,7 +83,9 @@ impl GameAudioAssets { } } - pub fn get_sound_effect(&self, sound_type: &SoundEffectType) -> Handle { + /// Use a SoundEffectType enum to access a handle for a sound effect + /// Sound effects that produced a randomized sound will we return a random effect from a subset + pub(crate) fn get_sound_effect(&self, sound_type: &SoundEffectType) -> Handle { match sound_type { SoundEffectType::Collision(collsion_type) => match collsion_type { CollisionSoundType::Squishy => self.squishy_collision.clone(), diff --git a/src/assets/consumable.rs b/src/assets/consumable.rs index 6a33f021..0cfc16e5 100644 --- a/src/assets/consumable.rs +++ b/src/assets/consumable.rs @@ -6,8 +6,9 @@ use bevy_asset_loader::prelude::AssetCollection; use thetawave_interface::spawnable::ConsumableType; +/// Collection of texture atlases and images for consumable sprites #[derive(AssetCollection, Resource)] -pub struct ConsumableAssets { +pub(crate) struct ConsumableAssets { #[asset(key = "health_wrench.layout")] pub health_wrench_layout: Handle, #[asset(key = "health_wrench.image")] @@ -31,7 +32,8 @@ pub struct ConsumableAssets { } impl ConsumableAssets { - pub fn get_texture_atlas_layout( + /// Use a ConsumableType enum to access a texture atlas layout + pub(crate) fn get_texture_atlas_layout( &self, consumable_type: &ConsumableType, ) -> Handle { @@ -44,7 +46,8 @@ impl ConsumableAssets { } } - pub fn get_image(&self, consumable_type: &ConsumableType) -> Handle { + /// Use a ConsumableType enum to access an image handle + pub(crate) fn get_image(&self, consumable_type: &ConsumableType) -> Handle { match consumable_type { ConsumableType::Money1 => self.money1_image.clone(), ConsumableType::Money3 => self.money3_image.clone(), diff --git a/src/assets/effect.rs b/src/assets/effect.rs index 31ccb887..09a8a667 100644 --- a/src/assets/effect.rs +++ b/src/assets/effect.rs @@ -3,8 +3,9 @@ use bevy_asset_loader::prelude::AssetCollection; use thetawave_interface::spawnable::EffectType; +/// Collection of texture atlases and images for effect sprites #[derive(AssetCollection, Resource)] -pub struct EffectAssets { +pub(crate) struct EffectAssets { #[asset(key = "ally_blast_explosion.layout")] pub ally_blast_explosion_layout: Handle, #[asset(key = "ally_blast_explosion.image")] @@ -52,7 +53,9 @@ pub struct EffectAssets { } impl EffectAssets { - pub fn get_texture_atlas_layout( + /// Use a EffectType enum to access a texture atlas layout + /// Option because a Text effect doesn't have a texture atlas + pub(crate) fn get_texture_atlas_layout( &self, effect_type: &EffectType, ) -> Option> { @@ -72,7 +75,9 @@ impl EffectAssets { } } - pub fn get_image(&self, effect_type: &EffectType) -> Option> { + /// Use a EffectType enum to access an image handle + /// Option because a Text effect doesn't have an image + pub(crate) fn get_image(&self, effect_type: &EffectType) -> Option> { match effect_type { EffectType::AllyBlastExplosion => Some(self.ally_blast_explosion_image.clone()), EffectType::AllyBlastDespawn => Some(self.ally_blast_despawn_image.clone()), diff --git a/src/assets/item.rs b/src/assets/item.rs index 88ad57ce..65727ecd 100644 --- a/src/assets/item.rs +++ b/src/assets/item.rs @@ -6,8 +6,9 @@ use bevy_asset_loader::prelude::AssetCollection; use thetawave_interface::spawnable::ItemType; +/// Collection of texture atlases and images for item sprites #[derive(AssetCollection, Resource)] -pub struct ItemAssets { +pub(crate) struct ItemAssets { #[asset(key = "item_placeholder.layout")] pub item_placeholder_layout: Handle, #[asset(key = "item_placeholder.image")] @@ -15,7 +16,11 @@ pub struct ItemAssets { } impl ItemAssets { - pub fn get_texture_atlas_layout(&self, item_type: &ItemType) -> Handle { + /// Use a ItemType enum to access a texture atlas layout + pub(crate) fn get_texture_atlas_layout( + &self, + item_type: &ItemType, + ) -> Handle { match item_type { ItemType::EnhancedPlating => self.item_placeholder_layout.clone(), /* @@ -37,7 +42,8 @@ impl ItemAssets { } } - pub fn get_image(&self, item_type: &ItemType) -> Handle { + /// Use a ItemType enum to access an item image handle + pub(crate) fn get_image(&self, item_type: &ItemType) -> Handle { match item_type { ItemType::EnhancedPlating => self.item_placeholder_image.clone(), } diff --git a/src/assets/mob.rs b/src/assets/mob.rs index 5c7a7bdd..3c6ea364 100644 --- a/src/assets/mob.rs +++ b/src/assets/mob.rs @@ -8,8 +8,9 @@ use thetawave_interface::spawnable::{ NeutralMobType, }; +/// Collection of texture atlases and images for mob and mob segment sprites #[derive(AssetCollection, Resource)] -pub struct MobAssets { +pub(crate) struct MobAssets { #[asset(key = "tutorial_drone.layout")] pub tutorial_drone_layout: Handle, #[asset(key = "tutorial_drone.image")] @@ -193,7 +194,11 @@ pub struct MobAssets { } impl MobAssets { - pub fn get_mob_texture_atlas_layout(&self, mob_type: &MobType) -> Handle { + /// Use a MobType enum to access a texture atlas layout + pub(crate) fn get_mob_texture_atlas_layout( + &self, + mob_type: &MobType, + ) -> Handle { match mob_type { MobType::Enemy(enemy_type) => match enemy_type { EnemyMobType::Pawn => self.pawn_layout.clone(), @@ -223,7 +228,8 @@ impl MobAssets { } } - pub fn get_mob_image(&self, mob_type: &MobType) -> Handle { + /// Use a MobType enum to access an image handle + pub(crate) fn get_mob_image(&self, mob_type: &MobType) -> Handle { match mob_type { MobType::Enemy(enemy_type) => match enemy_type { EnemyMobType::Pawn => self.pawn_image.clone(), @@ -253,7 +259,8 @@ impl MobAssets { } } - pub fn get_mob_segment_texture_atlas_layout( + /// Use a MobSegmentType enum to access a texture atlas layout + pub(crate) fn get_mob_segment_texture_atlas_layout( &self, mob_segment_type: &MobSegmentType, ) -> Handle { @@ -324,7 +331,8 @@ impl MobAssets { } } - pub fn get_mob_segment_image(&self, mob_segment_type: &MobSegmentType) -> Handle { + /// Use a MobSegmentType enum to access an image handle + pub(crate) fn get_mob_segment_image(&self, mob_segment_type: &MobSegmentType) -> Handle { match mob_segment_type { MobSegmentType::Neutral(neutral_type) => match neutral_type { NeutralMobSegmentType::HaulerBack => self.hauler_back_image.clone(), @@ -390,7 +398,9 @@ impl MobAssets { } } - pub fn get_thruster_texture_atlas_layout( + /// Use a MobType enum to access its associated thruster's texture atlas layout + /// Returns an option due to some mobs not having an thruster + pub(crate) fn get_thruster_texture_atlas_layout( &self, mob_type: &MobType, ) -> Option> { @@ -423,7 +433,9 @@ impl MobAssets { } } - pub fn get_thruster_image(&self, mob_type: &MobType) -> Option> { + /// Use a MobType enum to access its associated thruster's image + /// Returns an option due to some mobs not having an thruster + pub(crate) fn get_thruster_image(&self, mob_type: &MobType) -> Option> { match mob_type { MobType::Enemy(enemy_type) => match enemy_type { EnemyMobType::Pawn => Some(self.pawn_thruster_image.clone()), diff --git a/src/assets/mod.rs b/src/assets/mod.rs index fd1cbd89..c138c965 100644 --- a/src/assets/mod.rs +++ b/src/assets/mod.rs @@ -9,6 +9,7 @@ mod player; mod projectile; mod ui; -pub use self::{ - audio::*, consumable::*, effect::*, item::*, mob::*, player::*, projectile::*, ui::*, +pub(crate) use self::{ + audio::GameAudioAssets, consumable::ConsumableAssets, effect::EffectAssets, item::ItemAssets, + mob::MobAssets, player::PlayerAssets, projectile::ProjectileAssets, ui::UiAssets, }; diff --git a/src/assets/player.rs b/src/assets/player.rs index f316ec5c..883b62db 100644 --- a/src/assets/player.rs +++ b/src/assets/player.rs @@ -2,8 +2,9 @@ use bevy::prelude::{Handle, Image, Res, Resource}; use bevy_asset_loader::prelude::AssetCollection; use thetawave_interface::character::CharacterType; +/// Collection of images for player characters #[derive(AssetCollection, Resource)] -pub struct PlayerAssets { +pub(crate) struct PlayerAssets { #[asset(key = "captain")] pub captain: Handle, #[asset(key = "juggernaut")] @@ -15,14 +16,16 @@ pub struct PlayerAssets { } impl PlayerAssets { - pub fn get_asset(&self, character_type: &CharacterType) -> Handle { + /// Use a CharacterType enum to access an image handle + pub(crate) fn get_asset(&self, character_type: &CharacterType) -> Handle { match character_type { CharacterType::Captain => self.captain.clone(), CharacterType::Juggernaut => self.juggernaut.clone(), } } - pub fn get_outline_asset(&self, character_type: &CharacterType) -> Handle { + /// Use a CharacterType enum to access a character's associated outline image handle + pub(crate) fn get_outline_asset(&self, character_type: &CharacterType) -> Handle { match character_type { CharacterType::Captain => self.captain_outline.clone(), CharacterType::Juggernaut => self.juggernaut_outline.clone(), diff --git a/src/assets/projectile.rs b/src/assets/projectile.rs index de0456b2..8a5add8a 100644 --- a/src/assets/projectile.rs +++ b/src/assets/projectile.rs @@ -5,8 +5,9 @@ use bevy::{ use bevy_asset_loader::prelude::AssetCollection; use thetawave_interface::spawnable::{Faction, ProjectileType}; +/// Collection of texture atlases and images for projectile sprites #[derive(AssetCollection, Resource)] -pub struct ProjectileAssets { +pub(crate) struct ProjectileAssets { #[asset(key = "ally_blast.layout")] pub ally_blast_layout: Handle, #[asset(key = "ally_blast.image")] @@ -30,7 +31,8 @@ pub struct ProjectileAssets { } impl ProjectileAssets { - pub fn get_texture_atlas_layout( + /// Use a ProjectileType enum to access a texture atlas layout + pub(crate) fn get_texture_atlas_layout( &self, projectile_type: &ProjectileType, ) -> Handle { @@ -48,7 +50,8 @@ impl ProjectileAssets { } } - pub fn get_image(&self, projectile_type: &ProjectileType) -> Handle { + /// Use a ProjectileType enum to access an image handle + pub(crate) fn get_image(&self, projectile_type: &ProjectileType) -> Handle { match projectile_type { ProjectileType::Blast(faction) => match faction { Faction::Ally => self.ally_blast_image.clone(), diff --git a/src/assets/ui.rs b/src/assets/ui.rs index 289210d4..702836e6 100644 --- a/src/assets/ui.rs +++ b/src/assets/ui.rs @@ -9,8 +9,9 @@ use thetawave_interface::{ character::CharacterStatType, }; +/// Collection of texture atlases and images for ui #[derive(AssetCollection, Resource)] -pub struct UiAssets { +pub(crate) struct UiAssets { #[asset(key = "font.lunchds")] pub lunchds_font: Handle, #[asset(key = "thetawave_logo.layout")] @@ -72,6 +73,8 @@ pub struct UiAssets { } impl UiAssets { + /// Use a SlotOneAbilityType enum to access an image handle + /// Used in the game to indicate the available slot one ability to the player pub fn get_slot_1_ability_image(&self, ability_type: &SlotOneAbilityType) -> Handle { match ability_type { SlotOneAbilityType::StandardBlast => self.standard_blast_ability.clone(), @@ -79,6 +82,8 @@ impl UiAssets { } } + /// Use a SlotTwoAbilityType enum to access an image handle + /// Used in the game to indicate the available slot two ability to the player pub fn get_slot_2_ability_image(&self, ability_type: &SlotTwoAbilityType) -> Handle { match ability_type { SlotTwoAbilityType::MegaBlast => self.mega_blast_ability.clone(), @@ -86,6 +91,8 @@ impl UiAssets { } } + /// Takes in a boolean to indicate if a slot image should be flipped, then returns the correct image handle + /// Ability slots on opposite sides of the window are mirrored pub fn get_ability_slot_image(&self, is_flipped: bool) -> Handle { if is_flipped { self.right_ability_slot.clone() @@ -94,6 +101,8 @@ impl UiAssets { } } + /// Use a CharacterStatType enum to access an image handle + /// Character stat images are used on the character selection screen to symbolize relative attributes of characters pub fn get_stat_icon(&self, stat: &CharacterStatType) -> Handle { match stat { CharacterStatType::Damage => self.damage_icon.clone(), diff --git a/src/audio/mod.rs b/src/audio/mod.rs index d471a73a..de0459c8 100644 --- a/src/audio/mod.rs +++ b/src/audio/mod.rs @@ -64,6 +64,20 @@ fn play_sound_effect_system( } } +/// System to handle background music changes based on events. +/// +/// This system listens for `ChangeBackgroundMusicEvent` events and updates +/// the background music accordingly. It can stop the current music, start new +/// music, handle looping, and apply fade-in and fade-out effects if specified in the event. +/// +/// - If an event specifies a fade-out duration, the current track will fade out before stopping. +/// - If a new background music type is provided, it will play the corresponding track from the `GameAudioAssets`. +/// - The system supports looping the new track from a specified point and applying a fade-in effect if specified. +/// +/// Parameters: +/// - `EventReader`: Reads events that dictate when and how to change background music. +/// - `AudioChannel`: Controls the background music audio channel, allowing for stop, play, and fade effects. +/// - `GameAudioAssets`: A resource that holds all available audio assets. fn change_bg_music_system( mut change_bg_music_event_reader: EventReader, audio_channel: Res>, diff --git a/src/background/mod.rs b/src/background/mod.rs index 8469730d..49685006 100644 --- a/src/background/mod.rs +++ b/src/background/mod.rs @@ -7,8 +7,6 @@ use bevy::{ core::Name, ecs::{ component::Component, - event::EventReader, - query::With, reflect::ReflectComponent, schedule::{Condition, IntoSystemConfigs}, system::{Commands, Query, Res, ResMut, Resource}, @@ -39,7 +37,6 @@ use std::fs; use std::ops::Range; use thetawave_interface::{ game::options::GameOptions, - run::{RunDefeatType, RunEndEvent, RunOutcomeType}, states::{self, CharacterSelectionCleanup, GameCleanup}, }; use thiserror::Error; @@ -52,7 +49,6 @@ pub(super) struct BackgroundPlugin; impl Plugin for BackgroundPlugin { fn build(&self, app: &mut App) { - app.insert_resource(StarExplodeResource::default()); app.insert_resource( from_bytes::(include_bytes!("../../assets/data/backgrounds.ron")) .unwrap(), @@ -78,7 +74,7 @@ impl Plugin for BackgroundPlugin { app.add_systems( Update, - (rotate_planet_system, on_defeat_star_explode_system) + (rotate_planet_system) .run_if(in_state(states::AppStates::Game)) .run_if(in_state(states::GameStates::Playing)), ); @@ -88,8 +84,6 @@ impl Plugin for BackgroundPlugin { /// Parameters for procedurally generated 3D level backgrounds #[derive(Resource, Deserialize)] struct BackgroundsResource { - /// Intensity increase rate for star explosion effect - pub star_explode_intensity: f32, /// Position of the quad with the background image pub background_transation: Vec3, /// Range of x coordinates of star position @@ -122,12 +116,6 @@ struct BackgroundsResource { pub star_bloom_brightness: f32, } -/// Resource to track if star explosion is happening -#[derive(Resource, Default)] -struct StarExplodeResource { - pub started: bool, -} - /// Component to manage movement of planets #[derive(Reflect, Default, Component)] #[reflect(Component)] @@ -147,29 +135,6 @@ fn rotate_planet_system(mut query: Query<(&mut Transform, &PlanetComponent)>, ti } } -/// Execute the exploding star effect if the game is lost through defense being destroyed -fn on_defeat_star_explode_system( - mut run_end_event_reader: EventReader, - mut point_light_query: Query<&mut PointLight, With>, - mut star_explode_res: ResMut, - time: Res