From b4aaabe6ab27727b24fe4726105d0eeef8e78b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Rica=20Pais=20da=20Silva?= Date: Sun, 15 Dec 2024 15:42:47 +0100 Subject: [PATCH] chore: Fix remaining EntropyComponent references --- bevy_prng/src/lib.rs | 4 ++-- src/lib.rs | 2 +- src/seed.rs | 6 +++--- src/traits.rs | 14 +++++++------- tutorial/01-choosing-prng.md | 2 +- tutorial/02-basic-usage.md | 2 +- tutorial/04-observer-driven-reseeding.md | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bevy_prng/src/lib.rs b/bevy_prng/src/lib.rs index 62ba6d1..2a09209 100644 --- a/bevy_prng/src/lib.rs +++ b/bevy_prng/src/lib.rs @@ -36,7 +36,7 @@ pub use wyrand::WyRand; pub use xoshiro::*; /// A marker trait to define the required trait bounds for a seedable PRNG to -/// integrate into `EntropyComponent` or `GlobalEntropy`. This is a sealed trait. +/// integrate into `Entropy` or `GlobalEntropy`. This is a sealed trait. #[cfg(feature = "serialize")] pub trait EntropySource: RngCore @@ -90,7 +90,7 @@ impl< } /// A marker trait to define the required trait bounds for a seedable PRNG to -/// integrate into `EntropyComponent` or `GlobalEntropy`. This is a sealed trait. +/// integrate into `Entropy` or `GlobalEntropy`. This is a sealed trait. #[cfg(not(feature = "serialize"))] pub trait EntropySource: RngCore diff --git a/src/lib.rs b/src/lib.rs index 154fa97..e410ad0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ pub mod resource; pub mod seed; #[cfg(feature = "thread_local_entropy")] mod thread_local_entropy; -/// Traits for enabling utility methods for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Traits for enabling utility methods for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. pub mod traits; #[cfg(doc)] pub mod tutorial; diff --git a/src/seed.rs b/src/seed.rs index 1a36df8..af8623a 100644 --- a/src/seed.rs +++ b/src/seed.rs @@ -10,9 +10,9 @@ use rand_core::SeedableRng; use crate::{component::Entropy, traits::SeedSource}; -/// The initial seed/state for an [`EntropyComponent`]. Adding this component to an `Entity` will cause -/// an `EntropyComponent` to be initialised as well. To force a reseed, just insert this component to an -/// `Entity` to overwrite the old value, and the `EntropyComponent` will be overwritten with the new seed +/// The initial seed/state for an [`Entropy`]. Adding this component to an `Entity` will cause +/// an `Entropy` to be initialised as well. To force a reseed, just insert this component to an +/// `Entity` to overwrite the old value, and the `Entropy` will be overwritten with the new seed /// in turn. #[derive(Debug, Reflect)] pub struct RngSeed { diff --git a/src/traits.rs b/src/traits.rs index 68b53ea..c41154c 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,7 +1,7 @@ use bevy_prng::EntropySource; use rand_core::{RngCore, SeedableRng}; -/// Trait for implementing Forking behaviour for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Trait for implementing Forking behaviour for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// Forking creates a new RNG instance using a generated seed from the original source. If the original is seeded with a known /// seed, this process is deterministic. pub trait ForkableRng: EcsEntropy { @@ -31,7 +31,7 @@ pub trait ForkableRng: EcsEntropy { } } -/// Trait for implementing Forking behaviour for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Trait for implementing Forking behaviour for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// Forking creates a new RNG instance using a generated seed from the original source. If the original is seeded with a known /// seed, this process is deterministic. This trait enables forking between different PRNG algorithm types. pub trait ForkableAsRng: EcsEntropy { @@ -63,7 +63,7 @@ pub trait ForkableAsRng: EcsEntropy { } } -/// Trait for implementing Forking behaviour for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Trait for implementing Forking behaviour for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// Forking creates a new RNG instance using a generated seed from the original source. If the original is seeded with a known /// seed, this process is deterministic. This trait enables forking the inner PRNG instance of the source component/resource. pub trait ForkableInnerRng: EcsEntropy { @@ -96,7 +96,7 @@ pub trait ForkableInnerRng: EcsEntropy { } } -/// Trait for implementing forking behaviour for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Trait for implementing forking behaviour for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// Forking creates a new RNG instance using a generated seed from the original source. If the original is seeded with a known /// seed, this process is deterministic. This trait enables forking from an entropy source to a seed component. pub trait ForkableSeed: EcsEntropy @@ -133,7 +133,7 @@ where } } -/// Trait for implementing Forking behaviour for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Trait for implementing Forking behaviour for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// Forking creates a new RNG instance using a generated seed from the original source. If the original is seeded with a known /// seed, this process is deterministic. This trait enables forking from an entropy source to a seed component of a different /// PRNG algorithm. @@ -174,7 +174,7 @@ pub trait ForkableAsSeed: EcsEntropy { } } -/// Trait for implementing forking behaviour for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// Trait for implementing forking behaviour for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// Forking creates a new RNG instance using a generated seed from the original source. If the original is seeded with a known /// seed, this process is deterministic. This trait enables forking from an entropy source to the RNG's seed type. pub trait ForkableInnerSeed: EcsEntropy @@ -251,7 +251,7 @@ where } } -/// A marker trait for [`crate::component::EntropyComponent`] and [`crate::resource::GlobalEntropy`]. +/// A marker trait for [`crate::component::Entropy`] and [`crate::resource::GlobalEntropy`]. /// This is a sealed trait and cannot be consumed by downstream. pub trait EcsEntropy: RngCore + SeedableRng + private::SealedSource {} diff --git a/tutorial/01-choosing-prng.md b/tutorial/01-choosing-prng.md index 9538312..0f6a43b 100644 --- a/tutorial/01-choosing-prng.md +++ b/tutorial/01-choosing-prng.md @@ -24,7 +24,7 @@ use bevy_rand::prelude::*; use bevy_prng::{ChaCha8Rng, WyRand}; ``` -When you've selected and imported the PRNG algorithm you want to use, you then need to enable it by adding the `EntropyPlugin` to your app. This then makes it available for use with `GlobalEntropy` and `EntropyComponent`, as well as registering the types for reflection. +When you've selected and imported the PRNG algorithm you want to use, you then need to enable it by adding the `EntropyPlugin` to your app. This then makes it available for use with `GlobalEntropy` and `Entropy`, as well as registering the types for reflection. ```rust use bevy_ecs::prelude::*; diff --git a/tutorial/02-basic-usage.md b/tutorial/02-basic-usage.md index 35ad0b1..3720510 100644 --- a/tutorial/02-basic-usage.md +++ b/tutorial/02-basic-usage.md @@ -70,4 +70,4 @@ fn randomise_npc_stat(mut rng: ResMut>, mut q_npc: Query<& } ``` -But how can we achieve determinism in cases of where we want to randomise values within a query iteration? Well, by not using `GlobalEntropy` but `EntropyComponent` instead, moving the RNG source to the entities themselves. The next section will cover their usage. +But how can we achieve determinism in cases of where we want to randomise values within a query iteration? Well, by not using `GlobalEntropy` but `Entropy` instead, moving the RNG source to the entities themselves. The next section will cover their usage. diff --git a/tutorial/04-observer-driven-reseeding.md b/tutorial/04-observer-driven-reseeding.md index c9571b8..48af90b 100644 --- a/tutorial/04-observer-driven-reseeding.md +++ b/tutorial/04-observer-driven-reseeding.md @@ -1,6 +1,6 @@ # EXPERIMENTAL - Observer-driven Reseeding -The following feature is _experimental_ so to enable it, you'll need to edit your Cargo.toml file and change the dependency declaration for `bevy_rand` to have `features=["experimental"]` applied. Once done, you'll get access to some utils that will enable easy setup of observer driven reseeding utilities for managing when entities with `EntropyComponent`s obtain new seeds from which sources. Keep in mind, this feature is not *stable* and will be subject to further work and iteration, so if problems and issues are encountered, please do create issues outlining the use-cases and difficulties. +The following feature is _experimental_ so to enable it, you'll need to edit your Cargo.toml file and change the dependency declaration for `bevy_rand` to have `features=["experimental"]` applied. Once done, you'll get access to some utils that will enable easy setup of observer driven reseeding utilities for managing when entities with `Entropy`s obtain new seeds from which sources. Keep in mind, this feature is not *stable* and will be subject to further work and iteration, so if problems and issues are encountered, please do create issues outlining the use-cases and difficulties. ```toml bevy_rand = { version = "0.8", features = ["rand_chacha", "wyrand", "experimental"] } @@ -42,7 +42,7 @@ fn reseed_target_entities_from_set_seed(mut commands: Commands, mut q_targets: Q } ``` -With these observers, you can initialise entropy components on all targetted entities simply by triggering a reseed event on them. As long as your entities have been spawned with a component you can target them with, they will automatically be given an `RngSeed` component (which stores the initial seed value) and an `EntropyComponent`. +With these observers, you can initialise entropy components on all targetted entities simply by triggering a reseed event on them. As long as your entities have been spawned with a component you can target them with, they will automatically be given an `RngSeed` component (which stores the initial seed value) and an `Entropy`. Additionally, you can link entities to draw their seeds from other source entities instead of the global resources. So one `Source` entity can then seed many `Target` entities, and whenever the `Source` entity is updated with a new seed value, it then automatically pushes new seeds to its linked targets. Note: this is NOT a `bevy_hierarchy` relationship, and while the `Source` will have "child" entities, removing/despawning the source entity will *not* despawn the children entities. They will simply no longer have a valid "link". A new link can be established by triggering another "link" event.