### Pool Trait Resource Management Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Introduction of the Pool trait for managing resource pools like life, mana, or energy. Pools have a zero value, max, and regeneration rate. The trait includes a Quantity associated type for tracking amounts, costs, or rates. Example usage involves adding `PoolBundle` to an entity. ```Rust Introduced Pool trait for resource management Pools have zero value, max, and regeneration rate Pool::Quantity associated type for tracking amounts Example: PoolBundle ``` -------------------------------- ### Build and Open Local Documentation Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/CONTRIBUTING.md Generates Rust documentation from doc strings within the codebase and opens it in the default web browser, allowing developers to preview and review the documentation locally. ```Rust cargo doc --open ``` -------------------------------- ### Managing Action Cooldowns and Charges in Leafwing Abilities Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Demonstrates how to manage cooldowns and action charges for individual actions within Leafwing Abilities. It covers setting cooldowns, checking readiness, triggering actions, and advancing cooldown timers. ```Rust CooldownState::set(action, cooldown) CooldownState::new() Actionlike::ready(action) Actionlike::trigger(action) CooldownState::tick() ``` -------------------------------- ### Run CI Locally Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/CONTRIBUTING.md Executes the project's Continuous Integration checks locally to verify code formatting, compilation, clippy lints, and test execution on various platforms before pushing changes. ```Rust cargo run -p ci ``` ```Rust cargo test --workspace ``` -------------------------------- ### Run All Tests with Cargo Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/CONTRIBUTING.md This command executes all tests within the project, including doc tests, unit tests, and integration tests, ensuring code correctness across different environments. ```Rust cargo test ``` -------------------------------- ### Abilitylike ready_no_cost and trigger_no_cost Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Addition of `ready_no_cost` and `trigger_no_cost` methods to the `Abilitylike` trait. These methods facilitate working with multiple resource pools for a single ability, offering more flexibility in managing costs. ```Rust Added ready_no_cost to Abilitylike Added trigger_no_cost to Abilitylike ``` -------------------------------- ### Renamed trigger_action and action_ready Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md The functions `trigger_action` and `action_ready` have been renamed to `trigger_ability` and `ability_ready` respectively. This change aligns the naming convention with the library's focus on abilities. ```Rust Renamed trigger_action to trigger_ability Renamed action_ready to ability_ready ``` -------------------------------- ### Life and Mana Pool Add/Sub Implementations Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Addition of Add, Sub, AddAssign, and SubAssign implementations for the premade Life and Mana types and their corresponding pools. This allows for direct arithmetic operations on these resource types. ```Rust Added Add, Sub, AddAssign, SubAssign to Life and Mana pools ``` -------------------------------- ### Format Code with Cargo Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/CONTRIBUTING.md Ensures the codebase adheres to standard formatting conventions, improving readability and maintainability. This is a crucial step in the Continuous Integration (CI) process. ```Rust cargo fmt ``` -------------------------------- ### Result<(), CannotUseAbility> Return Type Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Methods and functions that previously returned a bool now return a `Result<(), CannotUseAbility>`. This provides more informative error handling by explaining why an ability could not be used. ```Rust Changed bool return types to Result<(), CannotUseAbility> ``` -------------------------------- ### Life and Mana Display Implementations Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Display trait implementations have been added for Life, Mana, LifePool, and ManaPool. This enables easy string representation of these resource types and their pools. ```Rust Added Display to Life Added Display to Mana Added Display to LifePool Added Display to ManaPool ``` -------------------------------- ### Define and Manage Champion Abilities in Rust Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/README.md This Rust code defines a ZyraAbility enum for a champion's abilities, implementing methods to manage cooldowns, charges, and mana costs. It integrates with Bevy Engine and Leafwing Input Manager to create a champion bundle with associated pools and ability states. ```rust use bevy::prelude::*; use bevy::reflect::Reflect; use leafwing_abilities::prelude::*; use leafwing_abilities::premade_pools::mana::{ManaPool, Mana}; use leafwing_abilities::premade_pools::life::{LifePool, Life}; use leafwing_input_manager::prelude::*; // We're modelling https://leagueoflegends.fandom.com/wiki/Zyra/LoL // to show off this crate's features! #[derive(Actionlike, Abilitylike, Debug, Clone, Copy, Hash, PartialEq, Eq, Reflect)] pub enum ZyraAbility { GardenOfThorns, DeadlySpines, RampantGrowth, GraspingRoots, Stranglethorns, } impl ZyraAbility { /// You could use the `strum` crate to derive this automatically! fn variants() -> Vec { use ZyraAbility::*; vec![GardenOfThorns, DeadlySpines, RampantGrowth, GraspingRoots, Stranglethorns] } fn input_map() -> InputMap { use ZyraAbility::*; // We can use this `new` idiom, which accepts an iterator of pairs InputMap::new([ (DeadlySpines, KeyCode::KeyQ), (RampantGrowth, KeyCode::KeyW), (GraspingRoots, KeyCode::KeyE), (Stranglethorns, KeyCode::KeyR), ]) } // This match pattern is super useful to be sure you've defined an attribute for every variant fn cooldown(&self) -> Cooldown { use ZyraAbility::*; let seconds: f32 = match *self { GardenOfThorns => 13.0, DeadlySpines => 7.0, RampantGrowth => 18.0, GraspingRoots => 12.0, Stranglethorns => 110.0, }; Cooldown::from_secs(seconds) } fn cooldowns() -> CooldownState { let mut cooldowns = CooldownState::default(); // Now, we can loop over all the variants to populate our struct for ability in ZyraAbility::variants() { cooldowns.set(ability, ability.cooldown()); } cooldowns } fn charges() -> ChargeState { // The builder API can be very convenient when you only need to set a couple of values ChargeState::default() .set(ZyraAbility::RampantGrowth, Charges::replenish_one(2)) .build() } fn mana_costs() -> AbilityCosts { use ZyraAbility::*; AbilityCosts::new([ (DeadlySpines, Mana(70.)), (GraspingRoots, Mana(70.)), (Stranglethorns, Mana(100.)), ]) } } /// Marker component for this champion #[derive(Component)] struct Zyra; #[derive(Bundle)] struct ZyraBundle { champion: Zyra, life_pool: LifePool, input_manager_bundle: InputManagerBundle, abilities_bundle: AbilitiesBundle, mana_bundle: PoolBundle, } impl Default for ZyraBundle { fn default() -> Self { ZyraBundle { champion: Zyra, // Max life, then regen life_pool: LifePool::new(Life(574.), Life(574.), (Life(5.5))), input_manager_bundle: InputManagerBundle:: { input_map: ZyraAbility::input_map(), ..default() }, abilities_bundle: AbilitiesBundle:: { cooldowns: ZyraAbility::cooldowns(), charges: ZyraAbility::charges(), }, mana_bundle: PoolBundle:: { pool: ManaPool::new(Mana(418.), Mana(418.), Mana(13.0)), ability_costs: ZyraAbility::mana_costs(), } } } } ``` -------------------------------- ### Pool Trait Splitting and Helper Methods Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md The Pool trait has been split into Pool and RegeratingPool to better support non-regenerating pools. Helper methods `is_empty` and `is_full` have been added to the Pool trait for convenience. ```Rust Pool trait split into Pool and RegeratingPool Added Pool::is_empty Added Pool::is_full ``` -------------------------------- ### Actionlike::trigger Resource Cost Expenditure Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Fix for Actionlike::trigger and related functions to correctly expend resource costs. Users who previously worked around this bug should remove their workarounds to prevent double-spending resources. ```Rust Actionlike::trigger and friends now expend resource costs correctly ``` -------------------------------- ### AbilityState, CooldownState, ChargeState with AbilityLike Reference Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Updates to AbilityState, CooldownState, and ChargeState to accept a reference to an AbilityLike. This change aims to improve how these states interact with abilities, potentially simplifying trait bounds and improving flexibility. It's part of usability enhancements in version 0.11. ```Rust AbilityState takes &AbilityLike CooldownState takes &AbilityLike ChargeState takes &AbilityLike ``` -------------------------------- ### OnGlobalCooldown Error Variant Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md Introduction of the OnGlobalCooldown error variant for CooldownState. This variant clarifies whether a failure in CooldownState::ready or CooldownState::trigger was due to the global cooldown or the ability's specific cooldown, enhancing error reporting. ```Rust Added OnGlobalCooldown error variant to CooldownState ``` -------------------------------- ### Pool Trait Component Bound Source: https://github.com/leafwing-studios/leafwing_abilities/blob/main/RELEASES.md The Pool trait now requires the Component trait. This change simplifies trait bounds, especially with the introduction of immutable components, making it easier to integrate the Pool trait into Bevy entities and systems. ```Rust Pool trait now requires Component trait ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.