Skip to content

Commit a43457b

Browse files
committed
Implement System::system_metas(&self) and System::system_metas_mut(&mut self)
for system exploration and configuration Part of #16168
1 parent 619c5e3 commit a43457b

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

crates/bevy_ecs/src/system/adapter_system.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ where
208208
fn set_last_run(&mut self, last_run: crate::component::Tick) {
209209
self.system.set_last_run(last_run);
210210
}
211+
212+
fn system_metas(&self) -> &super::SystemMeta {
213+
todo!()
214+
}
215+
216+
fn system_metas_mut(&mut self) -> &mut super::SystemMeta {
217+
todo!()
218+
}
211219
}
212220

213221
// SAFETY: The inner system is read-only.

crates/bevy_ecs/src/system/combinator.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ where
253253
self.a.set_last_run(last_run);
254254
self.b.set_last_run(last_run);
255255
}
256+
257+
fn system_metas(&self) -> &super::SystemMeta {
258+
todo!()
259+
}
260+
261+
fn system_metas_mut(&mut self) -> &mut super::SystemMeta {
262+
todo!()
263+
}
256264
}
257265

258266
/// SAFETY: Both systems are read-only, so any system created by combining them will only read from the world.
@@ -476,6 +484,14 @@ where
476484
self.a.set_last_run(last_run);
477485
self.b.set_last_run(last_run);
478486
}
487+
488+
fn system_metas(&self) -> &super::SystemMeta {
489+
todo!()
490+
}
491+
492+
fn system_metas_mut(&mut self) -> &mut super::SystemMeta {
493+
todo!()
494+
}
479495
}
480496

481497
/// SAFETY: Both systems are read-only, so any system created by piping them will only read from the world.

crates/bevy_ecs/src/system/exclusive_function_system.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ where
184184
fn set_last_run(&mut self, last_run: Tick) {
185185
self.system_meta.last_run = last_run;
186186
}
187+
188+
fn system_metas(&self) -> &SystemMeta {
189+
&self.system_meta
190+
}
191+
192+
fn system_metas_mut(&mut self) -> &mut SystemMeta {
193+
&mut self.system_meta
194+
}
187195
}
188196

189197
/// A trait implemented for all exclusive system functions that can be used as [`System`]s.

crates/bevy_ecs/src/system/function_system.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,14 @@ where
815815
fn set_last_run(&mut self, last_run: Tick) {
816816
self.system_meta.last_run = last_run;
817817
}
818+
819+
fn system_metas(&self) -> &SystemMeta {
820+
&self.system_meta
821+
}
822+
823+
fn system_metas_mut(&mut self) -> &mut SystemMeta {
824+
&mut self.system_meta
825+
}
818826
}
819827

820828
/// SAFETY: `F`'s param is [`ReadOnlySystemParam`], so this system will only read from the world.

crates/bevy_ecs/src/system/system.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
use alloc::borrow::Cow;
1515
use core::any::TypeId;
1616

17-
use super::IntoSystem;
17+
use super::{IntoSystem, SystemMeta};
1818

1919
/// An ECS system that can be added to a [`Schedule`](crate::schedule::Schedule)
2020
///
@@ -163,6 +163,12 @@ pub trait System: Send + Sync + 'static {
163163
/// However, it can be an essential escape hatch when, for example,
164164
/// you are trying to synchronize representations using change detection and need to avoid infinite recursion.
165165
fn set_last_run(&mut self, last_run: Tick);
166+
167+
/// .
168+
fn system_metas(&self) -> &SystemMeta;
169+
170+
/// .
171+
fn system_metas_mut(&mut self) -> &mut SystemMeta;
166172
}
167173

168174
/// [`System`] types that do not modify the [`World`] when run.

0 commit comments

Comments
 (0)