diff --git a/RELEASES.md b/RELEASES.md index f57681c..aefddda 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -15,6 +15,7 @@ - to better support working with multiple resource pools for a single `Abilitylike`: - `ready_no_cost` and `trigger_no_cost` have been added to `Abilitylike` - when working with multiple resource pools, you should pass in `NullPool` as the type argument for `AbilityState` +- `Default` is now implemented for `Charges` and `Cooldown` ## Bugs (0.9) diff --git a/src/ability_state.rs b/src/ability_state.rs index 8c9fe55..c4434a4 100644 --- a/src/ability_state.rs +++ b/src/ability_state.rs @@ -233,7 +233,7 @@ mod tests { /// Used in [`AbilityState`] to get the type system to play nice when no resource pool type is needed. /// /// Values of this type should never be constructed. -#[derive(Component)] +#[derive(Component, Debug, Default)] pub struct NullPool; impl Pool for NullPool { diff --git a/src/charges.rs b/src/charges.rs index 8bde7d5..994a237 100644 --- a/src/charges.rs +++ b/src/charges.rs @@ -104,7 +104,7 @@ impl Default for ChargeState { /// /// Charges refresh when [`Charges::refresh`] is called manually, /// or when the corresponding cooldown expires (if the [`InputManagerPlugin`](crate::plugin::InputManagerPlugin) is added). -#[derive(Clone, PartialEq, Eq, Debug, Reflect)] +#[derive(Clone, Default, PartialEq, Eq, Debug, Reflect)] pub struct Charges { current: u8, max: u8, @@ -115,11 +115,12 @@ pub struct Charges { } /// What happens when [`Charges`] are replenished? -#[derive(Debug, Clone, Copy, PartialEq, Eq, Reflect)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Reflect)] pub enum ReplenishStrategy { /// A single charge will be recovered. /// /// Usually paired with [`CooldownStrategy::ConstantlyRefresh`]. + #[default] OneAtATime, /// All charges will be recovered. /// @@ -128,13 +129,14 @@ pub enum ReplenishStrategy { } /// How do these charges replenish when cooldowns are refreshed? -#[derive(Debug, Clone, Copy, PartialEq, Eq, Reflect)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Reflect)] pub enum CooldownStrategy { /// Cooldowns refresh will have no effect on the charges. Ignore, /// Cooldowns will replenish charges whenever the current charges are less than the max. /// /// Usually paired with [`ReplenishStrategy::OneAtATime`]. + #[default] ConstantlyRefresh, /// Cooldowns will only replenish charges when 0 charges are available. /// diff --git a/src/cooldown.rs b/src/cooldown.rs index fb8d8f7..fee1a4b 100644 --- a/src/cooldown.rs +++ b/src/cooldown.rs @@ -255,7 +255,7 @@ impl CooldownState { /// cooldown.refresh(); /// assert!(cooldown.ready().is_ok()); /// ``` -#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)] +#[derive(Clone, Default, PartialEq, Eq, Debug, Serialize, Deserialize, Reflect)] pub struct Cooldown { max_time: Duration, /// The amount of time that has elapsed since all [`Charges`](crate::charges::Charges) were fully replenished.