diff --git a/src/upgrade.rs b/src/upgrade.rs index ed32841..1822349 100644 --- a/src/upgrade.rs +++ b/src/upgrade.rs @@ -8,6 +8,8 @@ use bevy_kira_audio::prelude::*; use rand::seq::SliceRandom; use rand::thread_rng; use strum::EnumCount; +use strum::EnumIter; +use strum::IntoEnumIterator; use crate::audio::AudioAssets; #[cfg(not(feature = "web"))] @@ -229,7 +231,7 @@ fn install_upgrades(world: &mut World, mut reader: Local()[kind].update { world.run_system(update).unwrap(); } @@ -291,8 +293,7 @@ impl UpgradeSequence { // Filter the list of all upgrade kinds into just the ones that are unlocked // Then, (weighted) randomly choose from those upgrades for the available slots - let mut upgrades = ALL_UPGRADE_KINDS - .into_iter() + let mut upgrades = UpgradeKind::iter() .filter(|&kind| { let upgrade = &upgrade_list[kind]; // This prevents the tutorial upgrades from being offered when @@ -364,15 +365,11 @@ fn load_upgrade_sequence(mut commands: Commands) { macro_rules! generate_upgrade_list { (|$world:ident| $($enumname:ident: $upgrade:expr),+ $(,)?) => { /// Enum containing all upgrade types. - #[derive(Reflect, Clone, Copy, PartialEq, Eq, Hash, EnumCount, Debug, PartialOrd, Ord)] + #[derive(Reflect, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, EnumCount, EnumIter)] pub enum UpgradeKind { $($enumname),+ } - pub const ALL_UPGRADE_KINDS: [UpgradeKind; UpgradeKind::COUNT] = [ - $(UpgradeKind::$enumname),+ - ]; - #[derive(Resource)] pub struct UpgradeList(pub [Upgrade; UpgradeKind::COUNT]);