diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index 99c443a3cd0e1..c315ad79e6a39 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -39,6 +39,10 @@ smallvec = { version = "1.6", features = [ ], optional = true } glam = { version = "0.24", features = ["serde"], optional = true } smol_str = { version = "0.2.0", optional = true } +rand_chacha = { version = "0.3", features = ["serde1"], optional = true } +wyrand = { version = "0.1", features = ["serde1"], optional = true } +rand_pcg = { version = "0.3", features = ["serde1"], optional = true } +rand_xoshiro = { version = "0.6", features = ["serde1"], optional = true } [dev-dependencies] ron = "0.8.0" diff --git a/crates/bevy_reflect/src/impls/rand_chacha.rs b/crates/bevy_reflect/src/impls/rand_chacha.rs new file mode 100644 index 0000000000000..18bb7dc609d5b --- /dev/null +++ b/crates/bevy_reflect/src/impls/rand_chacha.rs @@ -0,0 +1,24 @@ +use crate::{self as bevy_reflect}; +use crate::{ReflectDeserialize, ReflectSerialize}; +use bevy_reflect_derive::impl_reflect_value; + +impl_reflect_value!(::rand_chacha::ChaCha8Rng( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_chacha::ChaCha12Rng( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_chacha::ChaCha20Rng( + Debug, + PartialEq, + Serialize, + Deserialize +)); diff --git a/crates/bevy_reflect/src/impls/rand_pcg.rs b/crates/bevy_reflect/src/impls/rand_pcg.rs new file mode 100644 index 0000000000000..279fde7fac2ca --- /dev/null +++ b/crates/bevy_reflect/src/impls/rand_pcg.rs @@ -0,0 +1,14 @@ +use crate::{self as bevy_reflect}; +use crate::{ReflectDeserialize, ReflectSerialize}; +use bevy_reflect_derive::impl_reflect_value; + +impl_reflect_value!(::rand_pcg::Pcg32(Debug, PartialEq, Serialize, Deserialize)); + +impl_reflect_value!(::rand_pcg::Pcg64(Debug, PartialEq, Serialize, Deserialize)); + +impl_reflect_value!(::rand_pcg::Pcg64Mcg( + Debug, + PartialEq, + Serialize, + Deserialize +)); diff --git a/crates/bevy_reflect/src/impls/rand_xoshiro.rs b/crates/bevy_reflect/src/impls/rand_xoshiro.rs new file mode 100644 index 0000000000000..82300ddb890c1 --- /dev/null +++ b/crates/bevy_reflect/src/impls/rand_xoshiro.rs @@ -0,0 +1,94 @@ +use crate::{self as bevy_reflect}; +use crate::{ReflectDeserialize, ReflectSerialize}; +use bevy_reflect_derive::impl_reflect_value; + +impl_reflect_value!(::rand_xoshiro::Xoshiro512StarStar( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro512PlusPlus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro512Plus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro256StarStar( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro256PlusPlus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro256Plus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro128StarStar( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro128PlusPlus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoshiro128Plus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoroshiro128StarStar( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoroshiro128PlusPlus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::Xoroshiro128Plus( + Debug, + PartialEq, + Serialize, + Deserialize +)); + +impl_reflect_value!(::rand_xoshiro::SplitMix64( + Debug, + PartialEq, + Serialize, + Deserialize +)); diff --git a/crates/bevy_reflect/src/impls/wyrand.rs b/crates/bevy_reflect/src/impls/wyrand.rs new file mode 100644 index 0000000000000..13d9f4bf4c0bb --- /dev/null +++ b/crates/bevy_reflect/src/impls/wyrand.rs @@ -0,0 +1,5 @@ +use crate::{self as bevy_reflect}; +use crate::{ReflectDeserialize, ReflectSerialize}; +use bevy_reflect_derive::impl_reflect_value; + +impl_reflect_value!(::wyrand::WyRand(Debug, PartialEq, Serialize, Deserialize)); diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 1290ebf48cd16..7bc5276285925 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -484,24 +484,40 @@ mod type_uuid_impl; mod impls { #[cfg(feature = "glam")] mod glam; + #[cfg(feature = "rand_chacha")] + mod rand_chacha; + #[cfg(feature = "rand_pcg")] + mod rand_pcg; + #[cfg(feature = "rand_xoshiro")] + mod rand_xoshiro; #[cfg(feature = "bevy_math")] mod rect; #[cfg(feature = "smallvec")] mod smallvec; #[cfg(feature = "smol_str")] mod smol_str; + #[cfg(feature = "wyrand")] + mod wyrand; mod std; mod uuid; #[cfg(feature = "glam")] pub use self::glam::*; + #[cfg(feature = "rand_chacha")] + pub use self::rand_chacha::*; + #[cfg(feature = "rand_pcg")] + pub use self::rand_pcg::*; + #[cfg(feature = "rand_xoshiro")] + pub use self::rand_xoshiro::*; #[cfg(feature = "bevy_math")] pub use self::rect::*; #[cfg(feature = "smallvec")] pub use self::smallvec::*; pub use self::std::*; pub use self::uuid::*; + #[cfg(feature = "wyrand")] + pub use self::wyrand::*; } mod enums;