Skip to content

Commit e48cd26

Browse files
committed
Rename Components to WorldData
the Components struct was not just storing metadata on components, but also on resources. WorldData is a new umbrella term for components and resources. also rename the following: `ComponentId` -> `DataId` `ComponentInfo` -> `DataInfo` `ComponentDescriptor` -> `DataDescriptor`
1 parent 8a354c0 commit e48cd26

26 files changed

+285
-303
lines changed

crates/bevy_core/src/time/fixed_timestep.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::Time;
22
use bevy_ecs::{
33
archetype::{Archetype, ArchetypeComponentId},
4-
component::ComponentId,
4+
component::DataId,
55
query::Access,
66
schedule::ShouldRun,
77
system::{ConfigurableSystem, IntoSystem, Local, Res, ResMut, System},
@@ -156,7 +156,7 @@ impl System for FixedTimestep {
156156
self.internal_system.archetype_component_access()
157157
}
158158

159-
fn component_access(&self) -> &Access<ComponentId> {
159+
fn component_access(&self) -> &Access<DataId> {
160160
self.internal_system.component_access()
161161
}
162162

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
147147
let struct_name = &ast.ident;
148148

149149
TokenStream::from(quote! {
150-
/// SAFE: ComponentId is returned in field-definition-order. [from_components] and [get_components] use field-definition-order
150+
/// SAFE: DataId is returned in field-definition-order. [from_components] and [get_components] use field-definition-order
151151
unsafe impl #impl_generics #ecs_path::bundle::Bundle for #struct_name#ty_generics #where_clause {
152152
fn component_ids(
153-
components: &mut #ecs_path::component::Components,
153+
components: &mut #ecs_path::component::WorldData,
154154
storages: &mut #ecs_path::storage::Storages,
155-
) -> Vec<#ecs_path::component::ComponentId> {
155+
) -> Vec<#ecs_path::component::DataId> {
156156
let mut component_ids = Vec::with_capacity(#field_len);
157157
#(#field_component_ids)*
158158
component_ids
@@ -195,7 +195,7 @@ pub fn impl_query_set(_input: TokenStream) -> TokenStream {
195195
pub fn #fn_name(&mut self) -> Query<'_, '_, #query, #filter> {
196196
// SAFE: systems run without conflicts with other systems.
197197
// Conflicting queries in QuerySet are not accessible at the same time
198-
// QuerySets are guaranteed to not conflict with other SystemParams
198+
// QuerySets are guaranteed to not onflict with other SystemParams
199199
unsafe {
200200
Query::new(self.world, &self.query_states.#index, self.last_change_tick, self.change_tick)
201201
}
@@ -219,7 +219,7 @@ pub fn impl_query_set(_input: TokenStream) -> TokenStream {
219219
where #(#query::Fetch: ReadOnlyFetch,)* #(#filter::Fetch: FilterFetch,)*
220220
{ }
221221

222-
// SAFE: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If any QueryState conflicts
222+
// SAFE: Relevant query DataId and ArchetypeComponentId access is applied to SystemMeta. If any QueryState conflicts
223223
// with any prior access, a panic will occur.
224224
unsafe impl<#(#query: WorldQuery + 'static,)* #(#filter: WorldQuery + 'static,)*> SystemParamState for QuerySetState<(#(QueryState<#query, #filter>,)*)>
225225
where #(#filter::Fetch: FilterFetch,)*

crates/bevy_ecs/src/archetype.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use crate::{
55
bundle::BundleId,
6-
component::{ComponentId, StorageType},
6+
component::{DataId, StorageType},
77
entity::{Entity, EntityLocation},
88
storage::{Column, SparseArray, SparseSet, SparseSetIndex, TableId},
99
};
@@ -121,18 +121,18 @@ pub struct Archetype {
121121
entities: Vec<Entity>,
122122
edges: Edges,
123123
table_info: TableInfo,
124-
table_components: Cow<'static, [ComponentId]>,
125-
sparse_set_components: Cow<'static, [ComponentId]>,
126-
pub(crate) unique_components: SparseSet<ComponentId, Column>,
127-
pub(crate) components: SparseSet<ComponentId, ArchetypeComponentInfo>,
124+
table_components: Cow<'static, [DataId]>,
125+
sparse_set_components: Cow<'static, [DataId]>,
126+
pub(crate) unique_components: SparseSet<DataId, Column>,
127+
pub(crate) components: SparseSet<DataId, ArchetypeComponentInfo>,
128128
}
129129

130130
impl Archetype {
131131
pub fn new(
132132
id: ArchetypeId,
133133
table_id: TableId,
134-
table_components: Cow<'static, [ComponentId]>,
135-
sparse_set_components: Cow<'static, [ComponentId]>,
134+
table_components: Cow<'static, [DataId]>,
135+
sparse_set_components: Cow<'static, [DataId]>,
136136
table_archetype_components: Vec<ArchetypeComponentId>,
137137
sparse_set_archetype_components: Vec<ArchetypeComponentId>,
138138
) -> Self {
@@ -198,27 +198,27 @@ impl Archetype {
198198
}
199199

200200
#[inline]
201-
pub fn table_components(&self) -> &[ComponentId] {
201+
pub fn table_components(&self) -> &[DataId] {
202202
&self.table_components
203203
}
204204

205205
#[inline]
206-
pub fn sparse_set_components(&self) -> &[ComponentId] {
206+
pub fn sparse_set_components(&self) -> &[DataId] {
207207
&self.sparse_set_components
208208
}
209209

210210
#[inline]
211-
pub fn unique_components(&self) -> &SparseSet<ComponentId, Column> {
211+
pub fn unique_components(&self) -> &SparseSet<DataId, Column> {
212212
&self.unique_components
213213
}
214214

215215
#[inline]
216-
pub fn unique_components_mut(&mut self) -> &mut SparseSet<ComponentId, Column> {
216+
pub fn unique_components_mut(&mut self) -> &mut SparseSet<DataId, Column> {
217217
&mut self.unique_components
218218
}
219219

220220
#[inline]
221-
pub fn components(&self) -> impl Iterator<Item = ComponentId> + '_ {
221+
pub fn components(&self) -> impl Iterator<Item = DataId> + '_ {
222222
self.components.indices()
223223
}
224224

@@ -286,22 +286,19 @@ impl Archetype {
286286
}
287287

288288
#[inline]
289-
pub fn contains(&self, component_id: ComponentId) -> bool {
289+
pub fn contains(&self, component_id: DataId) -> bool {
290290
self.components.contains(component_id)
291291
}
292292

293293
#[inline]
294-
pub fn get_storage_type(&self, component_id: ComponentId) -> Option<StorageType> {
294+
pub fn get_storage_type(&self, component_id: DataId) -> Option<StorageType> {
295295
self.components
296296
.get(component_id)
297297
.map(|info| info.storage_type)
298298
}
299299

300300
#[inline]
301-
pub fn get_archetype_component_id(
302-
&self,
303-
component_id: ComponentId,
304-
) -> Option<ArchetypeComponentId> {
301+
pub fn get_archetype_component_id(&self, component_id: DataId) -> Option<ArchetypeComponentId> {
305302
self.components
306303
.get(component_id)
307304
.map(|info| info.archetype_component_id)
@@ -331,8 +328,8 @@ impl ArchetypeGeneration {
331328

332329
#[derive(Hash, PartialEq, Eq)]
333330
pub struct ArchetypeIdentity {
334-
table_components: Cow<'static, [ComponentId]>,
335-
sparse_set_components: Cow<'static, [ComponentId]>,
331+
table_components: Cow<'static, [DataId]>,
332+
sparse_set_components: Cow<'static, [DataId]>,
336333
}
337334

338335
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
@@ -474,8 +471,8 @@ impl Archetypes {
474471
pub(crate) fn get_id_or_insert(
475472
&mut self,
476473
table_id: TableId,
477-
table_components: Vec<ComponentId>,
478-
sparse_set_components: Vec<ComponentId>,
474+
table_components: Vec<DataId>,
475+
sparse_set_components: Vec<DataId>,
479476
) -> ArchetypeId {
480477
let table_components = Cow::from(table_components);
481478
let sparse_set_components = Cow::from(sparse_set_components);

crates/bevy_ecs/src/bundle.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use bevy_ecs_macros::Bundle;
66

77
use crate::{
88
archetype::{AddBundle, Archetype, ArchetypeId, Archetypes, ComponentStatus},
9-
component::{Component, ComponentId, ComponentTicks, Components, StorageType},
9+
component::{Component, ComponentTicks, DataId, StorageType, WorldData},
1010
entity::{Entities, Entity, EntityLocation},
1111
storage::{SparseSetIndex, SparseSets, Storages, Table},
1212
};
@@ -71,25 +71,25 @@ use std::{any::TypeId, collections::HashMap};
7171
///
7272
/// # Safety
7373
///
74-
/// - [Bundle::component_ids] must return the ComponentId for each component type in the bundle, in the
74+
/// - [Bundle::component_ids] must return the DataId for each component type in the bundle, in the
7575
/// _exact_ order that [Bundle::get_components] is called.
76-
/// - [Bundle::from_components] must call `func` exactly once for each [ComponentId] returned by
76+
/// - [Bundle::from_components] must call `func` exactly once for each [DataId] returned by
7777
/// [Bundle::component_ids].
7878
pub unsafe trait Bundle: Send + Sync + 'static {
79-
/// Gets this [Bundle]'s component ids, in the order of this bundle's Components
80-
fn component_ids(components: &mut Components, storages: &mut Storages) -> Vec<ComponentId>;
79+
/// Gets this [Bundle]'s component ids, in the order of this bundle's WorldData
80+
fn component_ids(components: &mut WorldData, storages: &mut Storages) -> Vec<DataId>;
8181

8282
/// Calls `func`, which should return data for each component in the bundle, in the order of
83-
/// this bundle's Components
83+
/// this bundle's WorldData
8484
///
8585
/// # Safety
8686
/// Caller must return data for each component in the bundle, in the order of this bundle's
87-
/// Components
87+
/// WorldData
8888
unsafe fn from_components(func: impl FnMut() -> *mut u8) -> Self
8989
where
9090
Self: Sized;
9191

92-
/// Calls `func` on each value, in the order of this bundle's Components. This will
92+
/// Calls `func` on each value, in the order of this bundle's WorldData. This will
9393
/// "mem::forget" the bundle fields, so callers are responsible for dropping the fields if
9494
/// that is desirable.
9595
fn get_components(self, func: impl FnMut(*mut u8));
@@ -100,7 +100,7 @@ macro_rules! tuple_impl {
100100
/// SAFE: Component is returned in tuple-order. [Bundle::from_components] and [Bundle::get_components] use tuple-order
101101
unsafe impl<$($name: Component),*> Bundle for ($($name,)*) {
102102
#[allow(unused_variables)]
103-
fn component_ids(components: &mut Components, storages: &mut Storages) -> Vec<ComponentId> {
103+
fn component_ids(components: &mut WorldData, storages: &mut Storages) -> Vec<DataId> {
104104
vec![$(components.init_component::<$name>(storages)),*]
105105
}
106106

@@ -152,7 +152,7 @@ impl SparseSetIndex for BundleId {
152152

153153
pub struct BundleInfo {
154154
pub(crate) id: BundleId,
155-
pub(crate) component_ids: Vec<ComponentId>,
155+
pub(crate) component_ids: Vec<DataId>,
156156
pub(crate) storage_types: Vec<StorageType>,
157157
}
158158

@@ -163,7 +163,7 @@ impl BundleInfo {
163163
}
164164

165165
#[inline]
166-
pub fn components(&self) -> &[ComponentId] {
166+
pub fn components(&self) -> &[DataId] {
167167
&self.component_ids
168168
}
169169

@@ -176,7 +176,7 @@ impl BundleInfo {
176176
&'b self,
177177
entities: &'a mut Entities,
178178
archetypes: &'a mut Archetypes,
179-
components: &mut Components,
179+
components: &mut WorldData,
180180
storages: &'a mut Storages,
181181
archetype_id: ArchetypeId,
182182
change_tick: u32,
@@ -236,7 +236,7 @@ impl BundleInfo {
236236
&'b self,
237237
entities: &'a mut Entities,
238238
archetypes: &'a mut Archetypes,
239-
components: &mut Components,
239+
components: &mut WorldData,
240240
storages: &'a mut Storages,
241241
change_tick: u32,
242242
) -> BundleSpawner<'a, 'b> {
@@ -308,7 +308,7 @@ impl BundleInfo {
308308
&self,
309309
archetypes: &mut Archetypes,
310310
storages: &mut Storages,
311-
components: &mut Components,
311+
components: &mut WorldData,
312312
archetype_id: ArchetypeId,
313313
) -> ArchetypeId {
314314
if let Some(add_bundle) = archetypes[archetype_id].edges().get_add_bundle(self.id) {
@@ -591,7 +591,7 @@ impl Bundles {
591591

592592
pub(crate) fn init_info<'a, T: Bundle>(
593593
&'a mut self,
594-
components: &mut Components,
594+
components: &mut WorldData,
595595
storages: &mut Storages,
596596
) -> &'a BundleInfo {
597597
let bundle_infos = &mut self.bundle_infos;
@@ -612,12 +612,12 @@ impl Bundles {
612612

613613
/// # Safety
614614
///
615-
/// `component_id` must be valid [ComponentId]'s
615+
/// `component_id` must be valid [DataId]'s
616616
unsafe fn initialize_bundle(
617617
bundle_type_name: &'static str,
618-
component_ids: Vec<ComponentId>,
618+
component_ids: Vec<DataId>,
619619
id: BundleId,
620-
components: &mut Components,
620+
components: &mut WorldData,
621621
) -> BundleInfo {
622622
let mut storage_types = Vec::new();
623623

0 commit comments

Comments
 (0)