Skip to content

Commit 6bdd629

Browse files
authored
Merge pull request #265 from YarnSpinnerTool/prep-release-now
Prep release
2 parents 99b9fdd + 1dcb010 commit 6bdd629

File tree

82 files changed

+629
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+629
-486
lines changed

crates/bevy_plugin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_yarnspinner"
33
version = "0.6.0"
4-
edition = "2021"
4+
edition = "2024"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
77
keywords = ["gamedev", "dialog", "yarn", "bevy"]

crates/bevy_plugin/src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy::prelude::*;
2-
pub(crate) use command_registry::wait::update_wait;
32
pub use command_registry::YarnCommands;
3+
pub(crate) use command_registry::wait::update_wait;
44
pub use command_wrapping::{TaskFinishedIndicator, UntypedYarnCommand, YarnCommand};
55

66
mod command_registry;

crates/bevy_plugin/src/commands/command_registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::commands::command_wrapping::YarnCommandWrapper;
21
use crate::commands::UntypedYarnCommand;
2+
use crate::commands::command_wrapping::YarnCommandWrapper;
33
use crate::prelude::*;
44
use bevy::prelude::*;
55
use std::borrow::Cow;

crates/bevy_plugin/src/commands/command_registry/wait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use crate::prelude::YarnSpinnerSystemSet;
55
use bevy::platform::collections::HashMap;
66
use bevy::prelude::*;
7-
use std::sync::atomic::{AtomicBool, Ordering};
87
use std::sync::Arc;
8+
use std::sync::atomic::{AtomicBool, Ordering};
99
use std::time::Duration;
1010

1111
pub(crate) fn wait_command_plugin(app: &mut App) {

crates/bevy_plugin/src/commands/execution.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ fn clone_command(
5050

5151
fn get_dialogue_runner(world: &mut World, entity: Entity) -> &DialogueRunner {
5252
let mut dialogue_runners = world.query::<&DialogueRunner>();
53-
let dialogue_runner = dialogue_runners.get(world, entity).unwrap();
54-
dialogue_runner
53+
54+
(dialogue_runners.get(world, entity).unwrap()) as _
5555
}
5656

5757
fn get_dialogue_runner_mut(world: &mut World, entity: Entity) -> Mut<'_, DialogueRunner> {
5858
let mut dialogue_runners = world.query::<&mut DialogueRunner>();
59-
let dialogue_runner = dialogue_runners.get_mut(world, entity).unwrap();
60-
dialogue_runner
59+
60+
dialogue_runners.get_mut(world, entity).unwrap()
6161
}

crates/bevy_plugin/src/dialogue_runner.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ pub use self::{
88
inner::{InnerDialogue, InnerDialogueMut},
99
localized_line::LocalizedLine,
1010
};
11+
use crate::UnderlyingYarnLine;
1112
use crate::commands::TaskFinishedIndicator;
1213
use crate::line_provider::LineAssets;
1314
use crate::prelude::*;
14-
use crate::UnderlyingYarnLine;
15-
use anyhow::{anyhow, bail, Result};
15+
use anyhow::{Result, anyhow, bail};
1616
use bevy::asset::LoadedUntypedAsset;
1717
use bevy::{
1818
platform::collections::{HashMap, HashSet},
@@ -70,7 +70,9 @@ impl DialogueRunner {
7070
/// - All previously called [`YarnCommand`]s are finished, indicated by their return type's [`TaskFinishedIndicator::is_finished`] returning `true`.
7171
pub fn continue_in_next_update(&mut self) -> &mut Self {
7272
if !self.is_running {
73-
panic!("Can't continue dialogue that isn't running. Please call `DialogueRunner::start_node()` before calling `DialogueRunner::continue_in_next_update()`.");
73+
panic!(
74+
"Can't continue dialogue that isn't running. Please call `DialogueRunner::start_node()` before calling `DialogueRunner::continue_in_next_update()`."
75+
);
7476
}
7577
self.will_continue_in_next_update = true;
7678
self
@@ -87,7 +89,9 @@ impl DialogueRunner {
8789
/// Implies [`DialogueRunner::continue_in_next_update`].
8890
pub fn select_option(&mut self, option: OptionId) -> Result<&mut Self> {
8991
if !self.is_running {
90-
bail!("Can't select option {option}: the dialogue is currently not running. Please call `DialogueRunner::continue_in_next_update()` only after receiving a `PresentOptionsEvent`.")
92+
bail!(
93+
"Can't select option {option}: the dialogue is currently not running. Please call `DialogueRunner::continue_in_next_update()` only after receiving a `PresentOptionsEvent`."
94+
)
9195
}
9296
self.inner_mut()
9397
.0
@@ -157,7 +161,9 @@ impl DialogueRunner {
157161
pub fn try_start_node(&mut self, node_name: impl AsRef<str>) -> Result<&mut Self> {
158162
let node_name = node_name.as_ref();
159163
if self.is_running {
160-
bail!("Can't start dialogue from node {node_name}: the dialogue is currently in the middle of running. Stop the dialogue first.");
164+
bail!(
165+
"Can't start dialogue from node {node_name}: the dialogue is currently in the middle of running. Stop the dialogue first."
166+
);
161167
}
162168
self.is_running = true;
163169
self.just_started = true;

crates/bevy_plugin/src/dialogue_runner/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::line_provider::SharedTextProvider;
44
use crate::prelude::*;
55
use bevy::platform::collections::HashMap;
66
use bevy::prelude::*;
7-
use rand::{rngs::SmallRng, Rng, SeedableRng};
7+
use rand::{Rng, SeedableRng, rngs::SmallRng};
88
use std::any::{Any, TypeId};
99
use std::fmt::Debug;
1010

@@ -125,10 +125,10 @@ fn create_extended_standard_library() -> YarnLibrary {
125125
library
126126
.add_function("random", || SmallRng::from_os_rng().random_range(0.0..1.0))
127127
.add_function("random_range", |min: f32, max: f32| {
128-
if let Some(min) = min.as_int() {
129-
if let Some(max_inclusive) = max.as_int() {
130-
return SmallRng::from_os_rng().random_range(min..=max_inclusive) as f32;
131-
}
128+
if let Some(min) = min.as_int()
129+
&& let Some(max_inclusive) = max.as_int()
130+
{
131+
return SmallRng::from_os_rng().random_range(min..=max_inclusive) as f32;
132132
}
133133
SmallRng::from_os_rng().random_range(min..max)
134134
})

crates/bevy_plugin/src/dialogue_runner/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::prelude::*;
21
use crate::UnderlyingYarnCommand;
2+
use crate::prelude::*;
33
use bevy::prelude::*;
44

55
pub(crate) fn dialogue_runner_events_plugin(app: &mut App) {

crates/bevy_plugin/src/dialogue_runner/localized_line.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ impl LocalizedLine {
6767
/// assert_eq!("Great, thanks", line.text);
6868
/// assert!(line.character_name().is_none());
6969
pub fn character_name(&self) -> Option<&str> {
70-
if let Some(attribute) = self.attribute(CHARACTER_ATTRIBUTE) {
71-
if let Some(name) = attribute.property(CHARACTER_ATTRIBUTE_NAME_PROPERTY) {
72-
let MarkupValue::String(name) = name else {
73-
bug!(
74-
"Attribute \"character\" has a \"name\" property, but it is not a string."
75-
);
76-
};
77-
return Some(name.as_str());
78-
}
70+
if let Some(attribute) = self.attribute(CHARACTER_ATTRIBUTE)
71+
&& let Some(name) = attribute.property(CHARACTER_ATTRIBUTE_NAME_PROPERTY)
72+
{
73+
let MarkupValue::String(name) = name else {
74+
bug!("Attribute \"character\" has a \"name\" property, but it is not a string.");
75+
};
76+
return Some(name.as_str());
7977
}
8078
None
8179
}

crates/bevy_plugin/src/dialogue_runner/runtime_interaction.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,27 @@ fn continue_runtime(
7575
}
7676
dialogue_runner.will_continue_in_next_update = false;
7777

78-
if dialogue_runner.run_selected_options_as_lines {
79-
if let Some(option) = dialogue_runner.last_selected_option.take() {
80-
let options = last_options
78+
if dialogue_runner.run_selected_options_as_lines
79+
&& let Some(option) = dialogue_runner.last_selected_option.take()
80+
{
81+
let options = last_options
8182
.remove(&source)
8283
.expect_or_bug("Failed to get last presented options when trying to run selected option as line.");
83-
let Some(option) = options.into_iter().find(|o| o.id == option) else {
84-
let expected_options = last_options
85-
.values()
86-
.flat_map(|options| options.iter().map(|option| option.id.to_string()))
87-
.collect::<Vec<_>>()
88-
.join(", ");
89-
bail!("Dialogue options does not contain selected option. Expected one of [{expected_options}], but found {option}");
90-
};
91-
present_line_events.write(PresentLineEvent {
92-
line: option.line,
93-
source,
94-
});
95-
continue;
96-
}
84+
let Some(option) = options.into_iter().find(|o| o.id == option) else {
85+
let expected_options = last_options
86+
.values()
87+
.flat_map(|options| options.iter().map(|option| option.id.to_string()))
88+
.collect::<Vec<_>>()
89+
.join(", ");
90+
bail!(
91+
"Dialogue options does not contain selected option. Expected one of [{expected_options}], but found {option}"
92+
);
93+
};
94+
present_line_events.write(PresentLineEvent {
95+
line: option.line,
96+
source,
97+
});
98+
continue;
9799
}
98100
}
99101

0 commit comments

Comments
 (0)