Skip to content

Commit 8172209

Browse files
authored
Merge pull request #221 from YarnSpinnerTool/bevy-0.16
Update to Bevy 0.16.0-RC
2 parents d1291d6 + 28289ac commit 8172209

Some content is hidden

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

53 files changed

+811
-663
lines changed

Cargo.lock

Lines changed: 593 additions & 434 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bevy_plugin/Cargo.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_yarnspinner"
3-
version = "0.4.0"
3+
version = "0.5.0-rc.1"
44
edition = "2021"
55
repository = "https://github.com/YarnSpinnerTool/YarnSpinner-Rust"
66
homepage = "https://docs.yarnspinner.dev/"
@@ -20,30 +20,28 @@ audio_assets = ["bevy/bevy_audio", "bevy/vorbis"]
2020
anyhow = "1"
2121
csv = "1"
2222
serde = { version = "1", features = ["derive"] }
23-
yarnspinner = { path = "../yarnspinner", features = ["bevy", "serde"], version = "0.4.0" }
23+
yarnspinner = { path = "../yarnspinner", features = [
24+
"bevy",
25+
"serde",
26+
], version = "0.5.0-rc" }
2427
sha2 = "0.10"
2528
rand = { version = "0.8", features = ["small_rng"] }
29+
variadics_please = "1"
2630

2731

2832
[dependencies.bevy]
29-
version = "0.15.0"
33+
version = "0.16.0-rc"
3034
default-features = false
31-
features = [
32-
"bevy_asset",
33-
"multi_threaded",
34-
]
35+
features = ["bevy_asset", "multi_threaded"]
3536

3637
[dev-dependencies]
3738
tempfile = "3"
3839
static_assertions = "1.1.0"
3940

4041
[dev-dependencies.bevy]
41-
version = "0.15.0"
42+
version = "0.16.0-rc"
4243
default-features = false
43-
features = [
44-
"bevy_core_pipeline",
45-
"bevy_audio",
46-
]
44+
features = ["bevy_core_pipeline", "bevy_audio"]
4745

4846
[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))'.dependencies]
4947
glob = "0.3.1"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! Alas, Wasm forces us to do this
33
44
use crate::prelude::YarnSpinnerSystemSet;
5+
use bevy::platform_support::collections::HashMap;
56
use bevy::prelude::*;
6-
use bevy::utils::HashMap;
77
use std::sync::atomic::{AtomicBool, Ordering};
88
use std::sync::Arc;
99
use std::time::Duration;

crates/bevy_plugin/src/commands/command_wrapping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use crate::prelude::*;
22
use bevy::ecs::system::{SystemParam, SystemParamItem, SystemState};
33
use bevy::prelude::*;
44
use bevy::tasks::Task;
5-
use bevy::utils::all_tuples;
65
use std::fmt::{Debug, Display, Formatter};
76
use std::marker::PhantomData;
87
use std::sync::atomic::{AtomicBool, Ordering};
98
use std::sync::{Arc, RwLock};
9+
use variadics_please::all_tuples;
1010
use yarnspinner::core::{YarnFnParam, YarnFnParamItem, YarnValueWrapper};
1111

1212
pub(crate) fn command_wrapping_plugin(_app: &mut App) {}

crates/bevy_plugin/src/dialogue_runner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use crate::commands::TaskFinishedIndicator;
1212
use crate::line_provider::LineAssets;
1313
use crate::prelude::*;
1414
use crate::UnderlyingYarnLine;
15-
use anyhow::{anyhow, bail};
15+
use anyhow::{anyhow, bail, Result};
1616
use bevy::asset::LoadedUntypedAsset;
17-
use bevy::utils::HashSet;
18-
use bevy::{prelude::*, utils::HashMap};
17+
use bevy::platform_support::collections::HashSet;
18+
use bevy::{platform_support::collections::HashMap, prelude::*};
1919
pub(crate) use runtime_interaction::DialogueExecutionSystemSet;
2020
use std::any::TypeId;
2121
use std::fmt::Debug;

crates/bevy_plugin/src/dialogue_runner/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::default_impl::{MemoryVariableStorage, StringsFileTextProvider};
22
use crate::fmt_utils::SkipDebug;
33
use crate::line_provider::SharedTextProvider;
44
use crate::prelude::*;
5+
use bevy::platform_support::collections::HashMap;
56
use bevy::prelude::*;
6-
use bevy::utils::HashMap;
77
use rand::{rngs::SmallRng, Rng, SeedableRng};
88
use std::any::{Any, TypeId};
99
use std::fmt::Debug;
@@ -31,7 +31,7 @@ impl DialogueRunnerBuilder {
3131
text_provider: SharedTextProvider::new(StringsFileTextProvider::from_yarn_project(
3232
yarn_project,
3333
)),
34-
asset_providers: HashMap::new(),
34+
asset_providers: HashMap::default(),
3535
library: create_extended_standard_library(),
3636
commands: YarnCommands::builtin_commands(),
3737
compilation: yarn_project.compilation().clone(),

crates/bevy_plugin/src/dialogue_runner/localized_line.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@ impl LocalizedLine {
145145
/// and updates the other attributes in this markup as follows:
146146
///
147147
/// - Attributes that start and end before the deleted attribute are
148-
/// unmodified.
148+
/// unmodified.
149149
/// - Attributes that start before the deleted attribute and end inside it
150-
/// are truncated to remove the part overlapping the deleted attribute.
150+
/// are truncated to remove the part overlapping the deleted attribute.
151151
/// - Attributes that have the same position and length as the deleted
152-
/// attribute are deleted, if they apply to any text.
152+
/// attribute are deleted, if they apply to any text.
153153
/// - Attributes that start and end within the deleted attribute are deleted.
154154
/// - Attributes that start within the deleted attribute, and end outside
155-
/// it, have their start truncated to remove the part overlapping the
156-
/// deleted attribute.
155+
/// it, have their start truncated to remove the part overlapping the
156+
/// deleted attribute.
157157
/// - Attributes that start after the deleted attribute have their start
158-
/// point adjusted to account for the deleted text.
158+
/// point adjusted to account for the deleted text.
159159
///
160160
/// This method does not modify the current object. A new [`LocalizedLine`] is returned.
161161
///

crates/bevy_plugin/src/dialogue_runner/runtime_interaction.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::line_provider::LineProviderSystemSet;
55
use crate::prelude::*;
66
use anyhow::bail;
77
use bevy::asset::LoadedUntypedAsset;
8+
use bevy::platform_support::collections::HashMap;
89
use bevy::prelude::*;
9-
use bevy::utils::HashMap;
1010

1111
pub(crate) fn runtime_interaction_plugin(app: &mut App) {
1212
app.add_systems(
@@ -46,7 +46,7 @@ fn continue_runtime(
4646
let is_sending_missed_events = !dialogue_runner.unsent_events.is_empty();
4747
if !is_sending_missed_events {
4848
if dialogue_runner.just_started {
49-
dialogue_start_events.send(DialogueStartEvent { source });
49+
dialogue_start_events.write(DialogueStartEvent { source });
5050
dialogue_runner.just_started = false;
5151
}
5252
if !dialogue_runner.is_running {
@@ -55,7 +55,7 @@ fn continue_runtime(
5555
}
5656

5757
if let Some(line_ids) = std::mem::take(&mut dialogue_runner.popped_line_hints) {
58-
line_hints_events.send(LineHintsEvent { line_ids, source });
58+
line_hints_events.write(LineHintsEvent { line_ids, source });
5959
}
6060

6161
if !(dialogue_runner.will_continue_in_next_update
@@ -80,7 +80,7 @@ fn continue_runtime(
8080
.join(", ");
8181
bail!("Dialogue options does not contain selected option. Expected one of [{expected_options}], but found {option}");
8282
};
83-
present_line_events.send(PresentLineEvent {
83+
present_line_events.write(PresentLineEvent {
8484
line: option.line,
8585
source,
8686
});
@@ -99,7 +99,7 @@ fn continue_runtime(
9999
DialogueEvent::Line(line) => {
100100
let assets = dialogue_runner.get_assets(&line);
101101
let metadata = project.line_metadata(&line.id).unwrap_or_default().to_vec();
102-
present_line_events.send(PresentLineEvent {
102+
present_line_events.write(PresentLineEvent {
103103
line: LocalizedLine::from_yarn_line(line, assets, metadata),
104104
source,
105105
});
@@ -117,26 +117,26 @@ fn continue_runtime(
117117
})
118118
.collect();
119119
last_options.insert(source, options.clone());
120-
present_options_events.send(PresentOptionsEvent { options, source });
120+
present_options_events.write(PresentOptionsEvent { options, source });
121121
}
122122
DialogueEvent::Command(command) => {
123-
execute_command_events.send(ExecuteCommandEvent { command, source });
123+
execute_command_events.write(ExecuteCommandEvent { command, source });
124124
dialogue_runner.continue_in_next_update();
125125
}
126126
DialogueEvent::NodeComplete(node_name) => {
127-
node_complete_events.send(NodeCompleteEvent { node_name, source });
127+
node_complete_events.write(NodeCompleteEvent { node_name, source });
128128
}
129129
DialogueEvent::NodeStart(node_name) => {
130-
node_start_events.send(NodeStartEvent { node_name, source });
130+
node_start_events.write(NodeStartEvent { node_name, source });
131131
}
132132
DialogueEvent::LineHints(line_ids) => {
133-
line_hints_events.send(LineHintsEvent { line_ids, source });
133+
line_hints_events.write(LineHintsEvent { line_ids, source });
134134
}
135135
DialogueEvent::DialogueComplete => {
136136
if !is_sending_missed_events {
137137
dialogue_runner.is_running = false;
138138
}
139-
dialogue_complete_events.send(DialogueCompleteEvent { source });
139+
dialogue_complete_events.write(DialogueCompleteEvent { source });
140140
}
141141
}
142142
}

crates/bevy_plugin/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! - [`YarnSpinnerPlugin`]: The plugin registering all systems and types.
1010
//! - [`YarnProject`]: A [`Resource`](bevy::prelude::Resource) for the compiled Yarn project, which is created for you when [`YarnSpinnerPlugin`] is added.
1111
//! - [`DialogueRunner`]: The [`Component`](bevy::prelude::Component) running through the Yarn files and sending events for things you should draw on the screen.
12-
//! Can be created from a [`YarnProject`].
12+
//! Can be created from a [`YarnProject`].
1313
//!
1414
//! ## Dialogue Views
1515
//!
@@ -39,7 +39,7 @@
3939
//! The main workflow is as follows:
4040
//! - Register the [`YarnSpinnerPlugin`]
4141
//! - When the [`YarnProject`] [`Resource`](bevy::prelude::Resource) is added, spawn a [`DialogueRunner`] from it.
42-
//! The latter can nicely be done with `my_system.run_if(resource_added::<YarnProject>)`.
42+
//! The latter can nicely be done with `my_system.run_if(resource_added::<YarnProject>)`.
4343
//!
4444
//! The following example is adapted from the [hello world example](https://github.com/YarnSpinnerTool/YarnSpinner-Rust/blob/main/examples/bevy_yarnspinner/src/bin/hello_world.rs).
4545
//!
@@ -53,7 +53,7 @@
5353
//!
5454
//! ```no_run
5555
//! // src/main.rs
56-
//! use bevy::{prelude::*, utils::Duration};
56+
//! use bevy::prelude::*;
5757
//! use bevy_yarnspinner::prelude::*;
5858
//! // Use the example dialogue view to see the dialogue in action. Requires the `bevy_yarnspinner_example_dialogue_view` crate.
5959
//! // use bevy_yarnspinner_example_dialogue_view::prelude::*;
@@ -79,7 +79,7 @@
7979
//! }
8080
//!
8181
//! fn setup_camera(mut commands: Commands) {
82-
//! commands.spawn(Camera2dBundle::default());
82+
//! commands.spawn(Camera2d::default());
8383
//! }
8484
//!
8585
//! fn spawn_dialogue_runner(mut commands: Commands, project: Res<YarnProject>) {
@@ -144,14 +144,14 @@ pub mod prelude {
144144
yarn_file_asset::YarnFile,
145145
};
146146
pub(crate) use crate::{localization::StringsFile, utils::*};
147-
pub(crate) use anyhow::{Context, Error, Result};
147+
pub(crate) use anyhow::{Context, Error};
148148
pub(crate) use serde::{Deserialize, Serialize};
149149
pub(crate) use yarnspinner::prelude::*;
150150
pub use yarnspinner::prelude::{
151151
IntoYarnValueFromNonYarnValue, Language, LineId, MarkupAttribute, MarkupValue, OptionId,
152152
VariableStorage, YarnFn, YarnLibrary, YarnValue,
153153
};
154-
pub(crate) type SystemResult = Result<()>;
154+
pub(crate) type SystemResult = anyhow::Result<()>;
155155
}
156156

157157
pub use crate::commands::{TaskFinishedIndicator, UntypedYarnCommand};

crates/bevy_plugin/src/line_provider/asset_provider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::UnderlyingYarnLine;
33
#[cfg(feature = "audio_assets")]
44
pub use audio_asset_provider_plugin::AudioAssetProvider;
55
use bevy::asset::{Asset, LoadedUntypedAsset};
6+
use bevy::platform_support::collections::HashMap;
67
use bevy::prelude::*;
7-
use bevy::utils::HashMap;
88
pub use file_extension_asset_provider_plugin::{file_extensions, FileExtensionAssetProvider};
99
use std::any::Any;
1010
use std::fmt::Debug;
@@ -157,7 +157,7 @@ pub struct LineAssets(HashMap<&'static str, UntypedHandle>);
157157
impl LineAssets {
158158
/// Creates a new empty [`LineAssets`] struct.
159159
pub fn new() -> Self {
160-
Self(HashMap::new())
160+
Self(HashMap::default())
161161
}
162162

163163
/// Creates a new [`LineAssets`] struct from an iterator of untyped [`Handle`]s and the [`TypePath::type_path`] of the [`Asset`] they reference.

0 commit comments

Comments
 (0)