Skip to content

v0.5.0

Choose a tag to compare

@janhohenheim janhohenheim released this 27 Apr 19:22
· 86 commits to main since this release
87eb66e

What's Changed

Bevy version

This release supports Bevy 0.16

Bevy systems as Yarn functions

@alec-deason has kindly spearheaded a long-requested feature. Yarn functions can now be regular Bevy systems! This means that your functions can query the ECS directly.

Take this dialogue for example:

<<if get_player_money() < 3>>
Shopkeeper: Sorry, you don't have enough cash on hand
<<else>>
Shopkeeper: Pleasure doing business with you!
<<subtract_money 3>>
<<endif>>
===

the relevant function looks like this:

fn get_player_money(wallet: Single<Wallet, With<Player>>) -> usize {
  wallet.available_money()
}

and is registered like that:

dialogue_runner
  .library_mut()
  .add_function("get_player_money", commands.register_system(get_player_money));

Users that don't use Bevy are not affected by this. If you are interfacing deeply with the Yarn Spinner API, you should know that calls to Dialogue::continue_ should be replace with Dialogue::continue_with_world in Bevy contexts.

Function and Command unification

In Bevy, Yarn function and Yarn commands now work very similar under the hood. This means that some previous limitations, like having to provide In<()> to commands without params, no longer apply:

// before
fn refresh_health(_: In<()>, health: Single<&mut Health, With<Player>>) {
    *health = 100.0;
}

// now
fn refresh_health(health: Single<&mut Health, With<Player>>) {
    *health = 100.0;
}

no_std progress

There's some progress towards #[no_std], kindly implemented by @stargazing-dino. Let's see if we can get Yarn Spinner running on a Game Boy Advance one day!

Migration

Yarn functions and commands are now registered systems, so we need to pass their system id instead of their function pointers when creating them:

// before
dialogue_runner
    .commands_mut()
    .add_command("change_sprite", change_sprite);
dialogue_runner
   .library_mut()
   .add_function("has_enough_money", has_enough_money);

// now
dialogue_runner
    .commands_mut()
    .add_command("change_sprite", commands.register_system(change_sprite));
dialogue_runner
   .library_mut()
   .add_function("has_enough_money", commands.register_system(has_enough_money));

where commands is a good old mut commands: Commands.

New Contributors

Full Changelog: v0.4.0...v0.5.0