diff --git a/RELEASES.md b/RELEASES.md index 9e6bef7..f57681c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -16,6 +16,11 @@ - `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` +## Bugs (0.9) + +- `Actionlike::trigger` and friends now expends resource costs correctly + - if you were working around this bug, remember to remove your workaround to avoid double-spending! + ## Version 0.8 - now supports Bevy 0.14 diff --git a/src/lib.rs b/src/lib.rs index a41404c..912e3a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -231,7 +231,7 @@ pub fn trigger_ability( ability_ready( charges.as_deref(), cooldown.as_deref(), - pool.map(|p| &*p), + pool.as_deref(), cost, )?; @@ -241,6 +241,14 @@ pub fn trigger_ability( cooldown.trigger()?; } + if let Some(pool) = pool { + if let Some(cost) = cost { + let _pool_result = pool.expend(cost); + // This is good to check, but panics in release mode are miserable + debug_assert!(_pool_result.is_ok()); + } + } + Ok(()) }