@@ -4,7 +4,7 @@ use bevy_utils::{tracing::warn, HashSet};
4
4
5
5
use crate :: { component:: ComponentId , prelude:: Bundle , world:: World } ;
6
6
7
- /// A rule about which [`Component`]s can coexist on entities
7
+ /// A rule about which [`Component`](crate::component::Component) s can coexist on entities
8
8
///
9
9
/// These rules must be true at all times for all entities in the [`World`].
10
10
/// The generic [`Bundle`] type `B1` is always used in the `predicate`,
@@ -13,7 +13,7 @@ use crate::{component::ComponentId, prelude::Bundle, world::World};
13
13
///
14
14
/// When added to the [`World`], archetype invariants behave like [`assert!`];
15
15
/// all archetype invariants must be true for every entity in the [`World`].
16
- /// Archetype invariants are checked each time [`Archetypes`] is modified;
16
+ /// Archetype invariants are checked each time [`Archetypes`](crate::archetype::Archetypes) is modified;
17
17
/// this can occur on component addition, component removal, and entity spawning.
18
18
///
19
19
/// Archetypes are only modified when a novel archetype (set of components) is seen for the first time;
@@ -66,7 +66,7 @@ impl<B: Bundle> ArchetypeInvariant<B, B> {
66
66
/// For single component bundles, `AllOf` and `AtLeastOneOf` are equivalent.
67
67
/// Prefer `ArchetypeStatement::<(C,)>::all_of` over `ArchetypeStatement::<(C,)>::at_least_one_of` for consistency and clarity.
68
68
///
69
- /// Note that this is converted to an [`UntypedArchetypeStatment `] when added to a [`World`].
69
+ /// Note that this is converted to an [`UntypedArchetypeStatement `] when added to a [`World`].
70
70
/// This is to ensure compatibility between different invariants.
71
71
#[ derive( Clone , Debug , PartialEq ) ]
72
72
pub enum ArchetypeStatement < B : Bundle > {
@@ -75,7 +75,7 @@ pub enum ArchetypeStatement<B: Bundle> {
75
75
/// The entity has at least one component in the bundle `B`, and may have all of them.
76
76
/// When using a single-component bundle, `AllOf` is preferred.
77
77
AtLeastOneOf ( PhantomData < B > ) ,
78
- /// The entity has zero or one of the components in the bundle `B`, and may have all of them .
78
+ /// The entity has zero or one of the components in the bundle `B`, but no more .
79
79
/// When using a single-component bundle, this is a tautology.
80
80
AtMostOneOf ( PhantomData < B > ) ,
81
81
/// The entity has none of the components in the bundle `B`
@@ -145,7 +145,7 @@ pub struct UntypedArchetypeInvariant {
145
145
impl UntypedArchetypeInvariant {
146
146
/// Assert that the provided iterator of [`ComponentId`]s obeys this archetype invariant
147
147
///
148
- /// `component_ids` is generally provided via the `components` field on [`Archetype`].
148
+ /// `component_ids` is generally provided via the `components` field on [`Archetype`](crate::archetype::Archetype) .
149
149
/// When testing against multiple archetypes, [`ArchetypeInvariants::test_archetype`] is preferred,
150
150
/// as it can more efficiently cache checks between archetypes.
151
151
///
@@ -165,17 +165,17 @@ impl UntypedArchetypeInvariant {
165
165
}
166
166
}
167
167
168
- /// A type-erased version of [`ArchetypeStatment `]
168
+ /// A type-erased version of [`ArchetypeStatement `]
169
169
/// Intended to be used with dynamic components that cannot be represented with Rust types.
170
- /// Prefer [`ArchetypeStatment `] when possible.
170
+ /// Prefer [`ArchetypeStatement `] when possible.
171
171
#[ derive( Clone , Debug , PartialEq ) ]
172
172
pub enum UntypedArchetypeStatement {
173
173
/// Evaluates to true if and only if the entity has all of the components present in the set
174
174
AllOf ( HashSet < ComponentId > ) ,
175
175
/// The entity has at least one component in the set, and may have all of them.
176
176
/// When using a single-component set, `AllOf` is preferred
177
177
AtLeastOneOf ( HashSet < ComponentId > ) ,
178
- /// The entity has zero or one of the components in the set, and may have all of them .
178
+ /// The entity has zero or one of the components in the set, but no more .
179
179
/// When using a single-component set, this is a tautology.
180
180
AtMostOneOf ( HashSet < ComponentId > ) ,
181
181
/// The entity has none of the components in the set
@@ -254,14 +254,11 @@ impl ArchetypeInvariants {
254
254
255
255
/// Assert that the provided iterator of [`ComponentId`]s obeys all archetype invariants
256
256
///
257
- /// `component_ids` is generally provided via the `components` field on [`Archetype`].
257
+ /// `component_ids` is generally provided via the `components` field on [`Archetype`](crate::archetype::Archetype) .
258
258
///
259
259
/// # Panics
260
260
/// Panics if any archetype invariant is violated
261
- pub ( crate ) fn test_archetype (
262
- & self ,
263
- component_ids_of_archetype : impl Iterator < Item = ComponentId > ,
264
- ) {
261
+ pub fn test_archetype ( & self , component_ids_of_archetype : impl Iterator < Item = ComponentId > ) {
265
262
let component_ids_of_archetype: HashSet < ComponentId > = component_ids_of_archetype. collect ( ) ;
266
263
267
264
for invariant in & self . raw_list {
0 commit comments