Skip to content

Commit

Permalink
Update to Bevy 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Jul 18, 2024
1 parent a98d549 commit 7dd10e6
Show file tree
Hide file tree
Showing 31 changed files with 1,172 additions and 844 deletions.
1,241 changes: 778 additions & 463 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ repository = "https://github.com/projectharmonia/project_harmonia"
project_harmonia_base = { path = "base" }
project_harmonia_ui = { path = "ui" }
project_harmonia_widgets = { path = "widgets" }
bevy = { version = "0.13.2", default-features = false }
bevy_atmosphere = "0.9"
bevy_replicon = "0.26"
bevy_replicon_renet = { version = "0.3", default-features = false, features = [
bevy = { version = "0.14", default-features = false }
bevy_atmosphere = "0.10"
bevy_replicon = "0.27"
bevy_replicon_renet = { git = "https://github.com/ironpeak/bevy_replicon_renet", default-features = false, features = [
"renet_transport",
] }
bevy_xpbd_3d = { version = "0.4", features = ["serialize"] }
bevy_mod_outline = "0.7"
bevy_simple_text_input = "0.7"
oxidized_navigation = { git = "https://github.com/TheGrimsey/oxidized_navigation", features = [
bevy_xpbd_3d = { version = "0.5", features = ["serialize"] }
bevy_mod_outline = "0.8"
bevy_simple_text_input = "0.8"
oxidized_navigation = { version = "0.11", default-features = false, features = [
"xpbd",
"debug_draw",
] }
leafwing-input-manager = { version = "0.13", default-features = false, features = [
leafwing-input-manager = { version = "0.14", default-features = false, features = [
"ui",
"block_ui_interactions",
] }
app_dirs2 = "2.5"
serde = "1.0"
Expand All @@ -41,11 +40,9 @@ num_enum = "0.7"
clap = { version = "4.5", features = ["derive"] }
anyhow = "1.0"
bincode = "1.3"
ron = "0.8"
walkdir = "2.5"
itertools = "0.12"
itertools = "0.13"
bitflags = "2.6"
futures-lite = "2.3"

[workspace.lints.clippy]
type_complexity = "allow"
Expand Down
4 changes: 1 addition & 3 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bevy = { workspace = true, features = [
bevy_atmosphere.workspace = true
bevy_replicon.workspace = true
bevy_replicon_renet.workspace = true
bevy_xpbd_3d = { version = "0.4", features = ["serialize"] }
bevy_xpbd_3d.workspace = true
bevy_mod_outline.workspace = true
bevy_simple_text_input.workspace = true
oxidized_navigation.workspace = true
Expand All @@ -32,11 +32,9 @@ num_enum.workspace = true
clap.workspace = true
anyhow.workspace = true
bincode.workspace = true
ron.workspace = true
walkdir.workspace = true
itertools.workspace = true
bitflags.workspace = true
futures-lite.workspace = true

[lints]
workspace = true
3 changes: 2 additions & 1 deletion app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod cli;

use bevy::{
color::palettes::css::ANTIQUE_WHITE,
pbr::wireframe::WireframePlugin,
prelude::*,
render::{
Expand Down Expand Up @@ -36,7 +37,7 @@ fn main() {
.init_resource::<Cli>()
.insert_resource(Msaa::Off) // Required by SSAO.
.insert_resource(AmbientLight {
color: Color::ANTIQUE_WHITE,
color: ANTIQUE_WHITE.into(),
brightness: 1000.0,
})
// TODO: workaround to place objects close together, remove after the next release.
Expand Down
5 changes: 1 addition & 4 deletions base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors.workspace = true
repository.workspace = true

[dependencies]
bevy = { workspace = true, features = ["animation"] }
bevy = { workspace = true, features = ["animation", "bevy_state"] }
bevy_atmosphere.workspace = true
bevy_replicon.workspace = true
bevy_replicon_renet.workspace = true
Expand All @@ -25,9 +25,6 @@ walkdir.workspace = true
earcut.workspace = true
num_enum.workspace = true
bitflags.workspace = true
# TODO 0.14: Remove direct dependencies on these crates
ron.workspace = true
futures-lite.workspace = true

[lints]
workspace = true
147 changes: 0 additions & 147 deletions base/src/animation_state.rs

This file was deleted.

24 changes: 11 additions & 13 deletions base/src/asset/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy::{
asset::{io::Reader, AssetLoader, AssetPath, AsyncReadExt, LoadContext},
prelude::*,
reflect::{TypeRegistry, TypeRegistryArc},
utils::BoxedFuture,
scene::ron,
};
use serde::{de::DeserializeSeed, Deserialize, Serialize};
use walkdir::WalkDir;
Expand Down Expand Up @@ -60,20 +60,18 @@ impl<T: Asset + Metadata> AssetLoader for MetadataLoader<T> {
type Settings = ();
type Error = anyhow::Error;

fn load<'a>(
async fn load<'a>(
&'a self,
reader: &'a mut Reader,
reader: &'a mut Reader<'_>,
_settings: &'a Self::Settings,
_load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
Box::pin(async move {
let mut data = String::new();
reader.read_to_string(&mut data).await?;
let metadata = ron::Options::default()
.from_str_seed(&data, T::deserializer(&self.registry.read()))?;

Ok(metadata)
})
_load_context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
let mut data = String::new();
reader.read_to_string(&mut data).await?;
let metadata =
ron::Options::default().from_str_seed(&data, T::deserializer(&self.registry.read()))?;

Ok(metadata)
}

fn extensions(&self) -> &[&str] {
Expand Down
1 change: 1 addition & 0 deletions base/src/asset/metadata/object_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ mod tests {
use std::fs;

use anyhow::Result;
use bevy::scene::ron;
use walkdir::WalkDir;

use super::*;
Expand Down
9 changes: 3 additions & 6 deletions base/src/component_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ impl EntityCommand for InsertReflectBundle {
.data::<ReflectBundle>()
.unwrap_or_else(|| panic!("{type_path} should have reflect(Bundle)"));

reflect_bundle.insert(&mut world.entity_mut(entity), &*self.0);
reflect_bundle.insert(&mut world.entity_mut(entity), &*self.0, &registry);
}
}

#[cfg(test)]
mod tests {
use bevy::ecs::system::CommandQueue;

use super::*;

#[test]
Expand All @@ -52,13 +50,12 @@ mod tests {
.register::<DummyBundle>();

let entity = world.spawn_empty().id();
let mut queue = CommandQueue::default();
let mut commands = Commands::new(&mut queue, &world);
let mut commands = world.commands();
commands
.entity(entity)
.insert_reflect_bundle(DummyBundle::default().clone_value());

queue.apply(&mut world);
world.flush_commands();

assert!(world.entity(entity).contains::<DummyComponent>());
}
Expand Down
8 changes: 6 additions & 2 deletions base/src/game_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ mod player_camera;
use std::fs;

use anyhow::{Context, Result};
use bevy::{prelude::*, scene::serde::SceneDeserializer};
use bevy::{
prelude::*,
scene::{ron, serde::SceneDeserializer},
};
use bevy_replicon::prelude::*;
use bevy_xpbd_3d::prelude::*;
use serde::de::DeserializeSeed;
Expand Down Expand Up @@ -70,9 +73,10 @@ impl GameWorldPlugin {
.with_context(|| format!("unable to create {world_path:?}"))?;

let mut scene = DynamicScene::default();
let registry = registry.read();
bevy_replicon::scene::replicate_into(&mut scene, world);
let bytes = scene
.serialize_ron(&registry)
.serialize(&registry)
.expect("game world should be serialized");

fs::write(&world_path, bytes)
Expand Down
Loading

0 comments on commit 7dd10e6

Please sign in to comment.