Skip to content

Commit

Permalink
Bump for Bevy 0.14 (#50)
Browse files Browse the repository at this point in the history
Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
alice-i-cecile and Alice Cecile authored Jul 7, 2024
1 parent 932954d commit bf585a7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "leafwing_abilities"
description = "A convenient, well-tested ability management suite. Built for the Bevy game engine."
version = "0.7.0"
version = "0.8.0"
authors = ["Leafwing Studios"]
homepage = "https://leafwing-studios.com/"
repository = "https://github.com/leafwing-studios/leafwing_abilities"
Expand All @@ -23,19 +23,19 @@ default = ["premade_pools"]
premade_pools = []

[dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { version = "0.14", default-features = false, features = [
"serialize",
"bevy_gilrs",
] }
serde = { version = "1.0", features = ["derive"] }
leafwing-input-manager = "0.13"
leafwing-input-manager = "0.14"

leafwing_abilities_macros = { path = "macros", version = "0.3" }
thiserror = "1.0.37"
derive_more = "0.99.17"

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { version = "0.14", default-features = false, features = [
"bevy_asset",
"bevy_sprite",
"bevy_text",
Expand Down
4 changes: 4 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## Version 0.8

- now supports Bevy 0.14

## Version 0.7

### Dependencies
Expand Down
8 changes: 5 additions & 3 deletions examples/cooldown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use bevy::{prelude::*, reflect::Reflect};
use leafwing_abilities::prelude::*;
use leafwing_input_manager::{plugin::InputManagerSystem, prelude::*};

use bevy::color::palettes::css::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
Expand Down Expand Up @@ -80,8 +82,8 @@ struct CookieBundle {
}

impl CookieBundle {
const COOKIE_CLICKED_COLOR: Color = Color::BEIGE;
const COOKIE_COLOR: Color = Color::GOLD;
const COOKIE_CLICKED_COLOR: Srgba = BEIGE;
const COOKIE_COLOR: Srgba = BROWN;

/// Creates a Cookie bundle with a random position.
fn new() -> CookieBundle {
Expand All @@ -93,7 +95,7 @@ impl CookieBundle {
width: Val::Px(100.),
..Default::default()
},
background_color: BackgroundColor(Self::COOKIE_COLOR),
background_color: BackgroundColor(Self::COOKIE_COLOR.into()),
..default()
},
abilities_bundle: AbilitiesBundle {
Expand Down
2 changes: 1 addition & 1 deletion src/ability_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct AbilityState<A: Abilitylike, P: Pool + Component = NullPool> {
pub cooldowns: &'static mut CooldownState<A>,
/// The [`Pool`] of resources of type `P` that should be spent
pub pool: Option<&'static mut P>,
/// The [`AbilityCosts] of each ability, in terms of [`P::Quantity`](Pool::Quantity)
/// The [`AbilityCosts`] of each ability, in terms of [`P::Quantity`](Pool::Quantity)
pub ability_costs: Option<&'static mut AbilityCosts<A, P>>,
}

Expand Down
36 changes: 18 additions & 18 deletions tests/cooldowns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ fn cooldowns_on_entity() {
app.update();

// Cooldown start ready
let mut query_state = app.world.query::<&mut CooldownState<Action>>();
let mut cooldowns: Mut<CooldownState<Action>> = query_state.single_mut(&mut app.world);
let mut query_state = app.world_mut().query::<&mut CooldownState<Action>>();
let mut cooldowns: Mut<CooldownState<Action>> = query_state.single_mut(app.world_mut());
for action in Action::variants() {
assert!(cooldowns.ready(action).is_ok());
// Trigger all the cooldowns once
Expand All @@ -75,8 +75,8 @@ fn cooldowns_on_entity() {
app.update();

// No waiting
let mut query_state = app.world.query::<&CooldownState<Action>>();
let cooldowns: &CooldownState<Action> = query_state.single(&app.world);
let mut query_state = app.world_mut().query::<&CooldownState<Action>>();
let cooldowns: &CooldownState<Action> = query_state.single(app.world());
assert!(cooldowns.ready(NoCooldown).is_ok());
assert_eq!(cooldowns.ready(Short), Err(CannotUseAbility::OnCooldown));
assert_eq!(cooldowns.ready(Long), Err(CannotUseAbility::OnCooldown));
Expand All @@ -85,8 +85,8 @@ fn cooldowns_on_entity() {
app.update();

// Short wait
let mut query_state = app.world.query::<&CooldownState<Action>>();
let cooldowns: &CooldownState<Action> = query_state.single(&app.world);
let mut query_state = app.world_mut().query::<&CooldownState<Action>>();
let cooldowns: &CooldownState<Action> = query_state.single(&app.world());
assert!(cooldowns.ready(NoCooldown).is_ok());
assert!(cooldowns.ready(Short).is_ok());
assert_eq!(cooldowns.ready(Long), Err(CannotUseAbility::OnCooldown));
Expand All @@ -103,7 +103,7 @@ fn cooldowns_in_resource() {
.insert_resource(Action::cooldowns());

// Cooldown start ready
let mut cooldowns: Mut<CooldownState<Action>> = app.world.resource_mut();
let mut cooldowns: Mut<CooldownState<Action>> = app.world_mut().resource_mut();
for action in Action::variants() {
assert!(cooldowns.ready(action).is_ok());
let _ = cooldowns.trigger(action);
Expand All @@ -112,7 +112,7 @@ fn cooldowns_in_resource() {
app.update();

// No waiting
let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert!(cooldowns.ready(NoCooldown).is_ok());
assert_eq!(cooldowns.ready(Short), Err(CannotUseAbility::OnCooldown));
assert_eq!(cooldowns.ready(Long), Err(CannotUseAbility::OnCooldown));
Expand All @@ -121,7 +121,7 @@ fn cooldowns_in_resource() {
app.update();

// Short wait
let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert!(cooldowns.ready(NoCooldown).is_ok());
assert!(cooldowns.ready(Short).is_ok());
assert_eq!(cooldowns.ready(Long), Err(CannotUseAbility::OnCooldown));
Expand All @@ -135,15 +135,15 @@ fn global_cooldowns_tick() {
.add_plugins(InputPlugin)
.insert_resource(Action::cooldowns());

let mut cooldowns: Mut<CooldownState<Action>> = app.world.resource_mut();
let mut cooldowns: Mut<CooldownState<Action>> = app.world_mut().resource_mut();
let initial_gcd = Some(Cooldown::new(Duration::from_micros(15)));
cooldowns.global_cooldown = initial_gcd.clone();
// Trigger the GCD
let _ = cooldowns.trigger(Action::Long);

app.update();

let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert!(initial_gcd != cooldowns.global_cooldown);
}

Expand All @@ -158,7 +158,7 @@ fn global_cooldown_blocks_cooldownless_actions() {
// First delta time provided of each app is wonky
app.update();

let mut cooldowns: Mut<CooldownState<Action>> = app.world.resource_mut();
let mut cooldowns: Mut<CooldownState<Action>> = app.world_mut().resource_mut();
cooldowns.global_cooldown = Some(Cooldown::new(Duration::from_micros(15)));

assert!(cooldowns.ready(Action::NoCooldown).is_ok());
Expand All @@ -172,7 +172,7 @@ fn global_cooldown_blocks_cooldownless_actions() {
sleep(Duration::from_micros(30));
app.update();

let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert!(cooldowns.ready(Action::NoCooldown).is_ok());
}

Expand All @@ -189,7 +189,7 @@ fn global_cooldown_affects_other_actions() {
// First delta time provided of each app is wonky
app.update();

let mut cooldowns: Mut<CooldownState<Action>> = app.world.resource_mut();
let mut cooldowns: Mut<CooldownState<Action>> = app.world_mut().resource_mut();
cooldowns.global_cooldown = Some(Cooldown::new(Duration::from_micros(15)));
let _ = cooldowns.trigger(Action::Long);
assert_eq!(
Expand All @@ -204,7 +204,7 @@ fn global_cooldown_affects_other_actions() {
sleep(Duration::from_micros(30));
app.update();

let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert!(cooldowns.ready(Action::Short).is_ok());
assert_eq!(
cooldowns.ready(Action::Long),
Expand All @@ -225,7 +225,7 @@ fn global_cooldown_overrides_short_cooldowns() {
// First delta time provided of each app is wonky
app.update();

let mut cooldowns: Mut<CooldownState<Action>> = app.world.resource_mut();
let mut cooldowns: Mut<CooldownState<Action>> = app.world_mut().resource_mut();
cooldowns.global_cooldown = Some(Cooldown::from_secs(0.5));
let _ = cooldowns.trigger(Action::Short);
assert_eq!(
Expand All @@ -237,7 +237,7 @@ fn global_cooldown_overrides_short_cooldowns() {
sleep(Duration::from_millis(250));
app.update();

let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert_eq!(
cooldowns.ready(Action::Short),
Err(CannotUseAbility::OnCooldown)
Expand All @@ -247,6 +247,6 @@ fn global_cooldown_overrides_short_cooldowns() {
sleep(Duration::from_millis(250));
app.update();

let cooldowns: &CooldownState<Action> = app.world.resource();
let cooldowns: &CooldownState<Action> = app.world().resource();
assert!(cooldowns.ready(Action::Short).is_ok());
}

0 comments on commit bf585a7

Please sign in to comment.