-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Bluefinger/forking-refactor
refactor: Forking via traits
- Loading branch information
Showing
16 changed files
with
432 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "bevy_rand" | ||
version = "0.3.0" | ||
version = "0.4.0" | ||
edition = "2021" | ||
authors = ["Gonçalo Rica Pais da Silva <[email protected]>"] | ||
description = "A plugin to integrate rand for ECS optimised RNG for the Bevy game engine." | ||
|
@@ -16,21 +16,33 @@ rust-version = "1.70.0" | |
default = ["serialize", "thread_local_entropy"] | ||
thread_local_entropy = ["dep:rand_chacha"] | ||
serialize = ["dep:serde", "rand_core/serde1"] | ||
rand_chacha = ["bevy_prng/rand_chacha"] | ||
rand_pcg = ["bevy_prng/rand_pcg"] | ||
rand_xoshiro = ["bevy_prng/rand_xoshiro"] | ||
wyrand = ["bevy_prng/wyrand"] | ||
|
||
[workspace] | ||
members = ["bevy_prng"] | ||
|
||
[dependencies] | ||
# bevy | ||
bevy = { version = "0.11", default-features = false } | ||
bevy = { version = "0.12.0", default-features = false } | ||
bevy_prng = { path = "bevy_prng", version = "0.2" } | ||
|
||
# others | ||
serde = { version = "1.0", features = ["derive"], optional = true } | ||
rand_core = { version = "0.6", features = ["std"] } | ||
rand_chacha = { version = "0.3", optional = true } | ||
|
||
# This cfg cannot be enabled, but it forces Cargo to keep bevy_prng's | ||
# version in lockstep with bevy_rand, so that even minor versions | ||
# cannot be out of step with bevy_rand due to dependencies on traits | ||
# and implementations between the two crates. | ||
[target.'cfg(any())'.dependencies] | ||
bevy_prng = { path = "bevy_prng", version = "=0.2" } | ||
|
||
[dev-dependencies] | ||
bevy_prng = { path = "bevy_prng", version = "0.1", features = ["rand_chacha"] } | ||
bevy_prng = { path = "bevy_prng", version = "0.2", features = ["rand_chacha", "wyrand"] } | ||
rand = "0.8" | ||
ron = { version = "0.8.0", features = ["integer128"] } | ||
|
||
|
@@ -43,3 +55,8 @@ getrandom = { version = "0.2", features = ["js"] } | |
[[example]] | ||
name = "turn_based_game" | ||
path = "examples/turn_based_game.rs" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
rustc-args = ["--cfg", "docsrs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Migration Notes | ||
|
||
## Migrating from v0.2 to v0.3 | ||
|
||
As v0.3 is a breaking change to v0.2, the process to migrate over is fairly simple. The rand algorithm crates can no longer be used directly, but they can be swapped wholesale with `bevy_prng` instead. So the following `Cargo.toml` changes: | ||
|
||
```diff | ||
- rand_chacha = { version = "0.3", features = ["serde1"] } | ||
+ bevy_prng = { version = "0.1", features = ["rand_chacha"] } | ||
``` | ||
|
||
allows then you to swap your import like so, which should then plug straight into existing `bevy_rand` usage seamlessly: | ||
|
||
```diff | ||
use bevy::prelude::*; | ||
use bevy_rand::prelude::*; | ||
- use rand_chacha::ChaCha8Rng; | ||
+ use bevy_prng::ChaCha8Rng; | ||
``` | ||
|
||
This **will** change the type path and the serialization format for the PRNGs, but currently, moving between different bevy versions has this problem as well as there's currently no means to migrate serialized formats from one version to another yet. The rationale for this change is to enable stable `TypePath` that is being imposed by bevy's reflection system, so that future compiler changes won't break things unexpectedly as `std::any::type_name` has no stability guarantees. Going forward, this should resolve any stability problems `bevy_rand` might have and be able to hook into any migration tool `bevy` might offer for when scene formats change/update. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "bevy_prng" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors = ["Gonçalo Rica Pais da Silva <[email protected]>"] | ||
description = "A crate providing newtyped RNGs for integration into Bevy." | ||
|
@@ -24,10 +24,15 @@ serialize = [ | |
] | ||
|
||
[dependencies] | ||
bevy = { version = "0.11", default-features = false } | ||
bevy = { version = "0.12.0", default-features = false } | ||
rand_core = { version = "0.6", features = ["std"] } | ||
serde = { version = "1.0", features = ["derive"], optional = true } | ||
rand_chacha = { version = "0.3", optional = true } | ||
wyrand = { version = "0.1", optional = true } | ||
rand_pcg = { version = "0.3", optional = true } | ||
rand_xoshiro = { version = "0.6", optional = true } | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
rustc-args = ["--cfg", "docsrs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.