Skip to content

Commit

Permalink
chore: update to bevy 0.14.0-rc.4 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimJentzsch committed Jul 1, 2024
1 parent 989f447 commit 4530fb3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_turborand"
version = "0.8.2"
version = "0.9.0-rc.1"
edition = "2021"
authors = ["Gonçalo Rica Pais da Silva <bluefinger@gmail.com>"]
description = "A plugin to enable ECS optimised random number generation for the Bevy game engine."
Expand All @@ -19,9 +19,12 @@ serialize = ["turborand/serialize", "dep:serde"]
rand = ["turborand/rand"]

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy = { version = "0.14.0-rc.4", default-features = false }
serde = { version = "1.0", features = ["derive"], optional = true }
turborand = { version = "0.10", default-features = false, features=["std", "fmt"] }
turborand = { version = "0.10", default-features = false, features = [
"std",
"fmt",
] }

[target.'cfg(target_arch = "wasm32")'.dependencies.instant]
version = "0.1"
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ To see an example of this, view the [project's tests](tests/determinism.rs) to s

## Supported Versions

| `bevy_turborand` | `bevy` |
|------------------|--------|
| v0.8 | v0.13 |
| v0.7 | v0.12 |
| v0.6 | v0.11 |
| v0.5 | v0.10 |
| v0.4 | v0.9 |
| v0.2, v0.3 | v0.8 |
| v0.1 | v0.7 |
| `bevy_turborand` | `bevy` |
|--------------------|--------------|
| v0.9.0-rc.1 | v0.14.0-rc.4 |
| v0.8 | v0.13 |
| v0.7 | v0.12 |
| v0.6 | v0.11 |
| v0.5 | v0.10 |
| v0.4 | v0.9 |
| v0.2, v0.3 | v0.8 |
| v0.1 | v0.7 |

MSRV for `bevy_turborand` is the same as in `bevy`, so always the latest Rust compiler version.

Expand Down
46 changes: 24 additions & 22 deletions tests/determinism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn deterministic_play_through() {
// Set up the game App and World
let mut app = App::new();

let world = &mut app.world;
let world = app.world_mut();

// Initialise our global Rng resource
let mut global_rng = GlobalRng::with_seed(12345);
Expand Down Expand Up @@ -170,25 +170,25 @@ fn deterministic_play_through() {
app.update();

// Check to see the health of our combatants
assert_eq!(app.world.get::<HitPoints>(player).unwrap().total, 100);
assert_eq!(app.world.get::<HitPoints>(enemy_1).unwrap().total, 20);
assert_eq!(app.world.get::<HitPoints>(enemy_2).unwrap().total, 11);
assert_eq!(app.world().get::<HitPoints>(player).unwrap().total, 100);
assert_eq!(app.world().get::<HitPoints>(enemy_1).unwrap().total, 20);
assert_eq!(app.world().get::<HitPoints>(enemy_2).unwrap().total, 11);

// Again!
app.update();

// Player OP. Enemy 2 is in trouble
assert_eq!(app.world.get::<HitPoints>(player).unwrap().total, 90);
assert_eq!(app.world.get::<HitPoints>(enemy_1).unwrap().total, 20);
assert_eq!(app.world.get::<HitPoints>(enemy_2).unwrap().total, 3);
assert_eq!(app.world().get::<HitPoints>(player).unwrap().total, 90);
assert_eq!(app.world().get::<HitPoints>(enemy_1).unwrap().total, 20);
assert_eq!(app.world().get::<HitPoints>(enemy_2).unwrap().total, 3);

// And again!
app.update();

// Enemy 2 is now deceased
assert_eq!(app.world.get::<HitPoints>(player).unwrap().total, 88);
assert_eq!(app.world.get::<HitPoints>(enemy_1).unwrap().total, 20);
assert_eq!(app.world.get::<HitPoints>(enemy_2).unwrap().total, 0);
assert_eq!(app.world().get::<HitPoints>(player).unwrap().total, 88);
assert_eq!(app.world().get::<HitPoints>(enemy_1).unwrap().total, 20);
assert_eq!(app.world().get::<HitPoints>(enemy_2).unwrap().total, 0);
}

#[test]
Expand All @@ -203,14 +203,16 @@ fn deterministic_setup() {
app.update();

let mut q_player = app
.world
.world_mut()
.query_filtered::<&mut RngComponent, With<Player>>();
let mut player = q_player.single_mut(&mut app.world);
let mut player = q_player.single_mut(app.world_mut());

assert_eq!(player.u32(..=10), 10);

let mut q_enemies = app.world.query_filtered::<&mut RngComponent, With<Enemy>>();
let mut enemies = q_enemies.iter_mut(&mut app.world);
let mut q_enemies = app
.world_mut()
.query_filtered::<&mut RngComponent, With<Enemy>>();
let mut enemies = q_enemies.iter_mut(app.world_mut());

let mut enemy_1 = enemies.next().unwrap();

Expand All @@ -234,16 +236,16 @@ fn deterministic_secure_setup() {
app.update();

let mut q_player = app
.world
.world_mut()
.query_filtered::<&mut ChaChaRngComponent, With<Player>>();
let mut player = q_player.single_mut(&mut app.world);
let mut player = q_player.single_mut(app.world_mut());

assert_eq!(player.u32(..=10), 0);

let mut q_enemies = app
.world
.world_mut()
.query_filtered::<&mut ChaChaRngComponent, With<Enemy>>();
let mut enemies = q_enemies.iter_mut(&mut app.world);
let mut enemies = q_enemies.iter_mut(app.world_mut());

let mut enemy_1 = enemies.next().unwrap();

Expand Down Expand Up @@ -281,7 +283,7 @@ fn load_chacha_rng_setup() {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rng_reflection() {
use bevy::reflect::{
serde::{ReflectSerializer, UntypedReflectDeserializer},
serde::{ReflectDeserializer, ReflectSerializer},
TypeRegistry,
};
use ron::ser::to_string;
Expand All @@ -303,7 +305,7 @@ fn rng_reflection() {

let mut deserializer = ron::Deserializer::from_str(&serialized).unwrap();

let de = UntypedReflectDeserializer::new(&registry);
let de = ReflectDeserializer::new(&registry);

let value = de.deserialize(&mut deserializer).unwrap();

Expand All @@ -321,7 +323,7 @@ fn rng_reflection() {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn chacha_rng_reflection() {
use bevy::reflect::{
serde::{ReflectSerializer, UntypedReflectDeserializer},
serde::{ReflectDeserializer, ReflectSerializer},
TypeRegistry,
};
use serde::de::DeserializeSeed;
Expand Down Expand Up @@ -351,7 +353,7 @@ fn chacha_rng_reflection() {

let mut deserializer = ron::Deserializer::from_str(&serialized).unwrap();

let de = UntypedReflectDeserializer::new(&registry);
let de = ReflectDeserializer::new(&registry);

let value = de.deserialize(&mut deserializer).unwrap();

Expand Down

0 comments on commit 4530fb3

Please sign in to comment.