Skip to content

Commit 5fedb74

Browse files
committed
cleaned up 'tuples as join' implementation
1 parent 5d9ca62 commit 5fedb74

File tree

3 files changed

+13
-80
lines changed

3 files changed

+13
-80
lines changed

crates/bevy_ecs/src/system/combinator.rs

-78
Original file line numberDiff line numberDiff line change
@@ -125,84 +125,6 @@ impl<Func, A, B> CombinatorSystem<Func, A, B> {
125125
}
126126
}
127127

128-
impl<In, A, B> System for (A, B)
129-
where
130-
In: Copy,
131-
A: System<In = In>,
132-
B: System<In = In>,
133-
{
134-
type In = In;
135-
type Out = (A::Out, B::Out);
136-
137-
fn name(&self) -> Cow<'static, str> {
138-
Cow::Owned(format!("Join({}, {})", self.0.name().clone(), self.1.name().clone()))
139-
}
140-
141-
fn type_id(&self) -> std::any::TypeId {
142-
std::any::TypeId::of::<Self>()
143-
}
144-
145-
fn component_access(&self) -> &Access<ComponentId> {
146-
self.0.component_access() // needs to add component access of .1
147-
}
148-
149-
fn archetype_component_access(&self) -> &Access<ArchetypeComponentId> {
150-
self.0.archetype_component_access() // idem
151-
}
152-
153-
fn is_send(&self) -> bool {
154-
self.0.is_send() && self.1.is_send()
155-
}
156-
157-
fn is_exclusive(&self) -> bool {
158-
self.0.is_exclusive() || self.1.is_exclusive()
159-
}
160-
161-
unsafe fn run_unsafe(&mut self, input: Self::In, world: UnsafeWorldCell) -> Self::Out {
162-
(self.0.run_unsafe(input, world), self.1.run_unsafe(input, world))
163-
}
164-
165-
fn run<'w>(&mut self, input: Self::In, world: &'w mut World) -> Self::Out {
166-
let world: &'w UnsafeCell<World> = unsafe { std::mem::transmute(world) };
167-
(self.0.run(input, unsafe { world.deref_mut() }), self.1.run(input, unsafe { world.deref_mut() }))
168-
}
169-
170-
fn apply_buffers(&mut self, world: &mut World) {
171-
self.0.apply_buffers(world);
172-
self.1.apply_buffers(world);
173-
}
174-
175-
fn initialize(&mut self, world: &mut World) {
176-
self.0.initialize(world);
177-
self.1.initialize(world);
178-
}
179-
180-
fn update_archetype_component_access(&mut self, world: UnsafeWorldCell) {
181-
self.0.update_archetype_component_access(world);
182-
self.1.update_archetype_component_access(world);
183-
}
184-
185-
fn check_change_tick(&mut self, change_tick: Tick) {
186-
self.0.check_change_tick(change_tick);
187-
self.1.check_change_tick(change_tick);
188-
}
189-
190-
fn get_last_run(&self) -> Tick {
191-
self.0.get_last_run()
192-
}
193-
194-
fn set_last_run(&mut self, last_run: Tick) {
195-
self.0.set_last_run(last_run);
196-
self.1.set_last_run(last_run);
197-
}
198-
199-
fn default_system_sets(&self) -> Vec<Box<dyn crate::schedule::SystemSet>> {
200-
let mut default_sets = self.0.default_system_sets();
201-
default_sets.append(&mut self.1.default_system_sets());
202-
default_sets
203-
}
204-
}
205-
206128
impl<A, B, Func> System for CombinatorSystem<Func, A, B>
207129
where
208130
Func: Combine<A, B> + 'static,

crates/bevy_ecs/src/system/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ impl<T: System> IntoSystem<T::In, T::Out, ()> for T {
247247
}
248248
}
249249

250+
impl<A, B, In, AOut, BOut, AMarker, BMarker> IntoSystem<In, (AOut, BOut), (Join, AMarker, BMarker)> for (A, B)
251+
where In: Copy,
252+
A: IntoSystem<In, AOut, AMarker>,
253+
B: IntoSystem<In, BOut, BMarker>,
254+
{
255+
type System = JoinSystem<A::System, B::System>;
256+
fn into_system(this: Self) -> Self::System {
257+
this.0.join(this.1)
258+
}
259+
}
260+
250261
/// Wrapper type to mark a [`SystemParam`] as an input.
251262
///
252263
/// [`System`]s may take an optional input which they require to be passed to them when they

examples/ecs/system_piping.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn main() {
2424
warning_pipe_system.pipe(warn),
2525
parse_error_message_system.pipe(error),
2626
parse_message_system.pipe(ignore),
27-
calc1.join(calc2).join(calc3).pipe(readnew),
28-
(IntoSystem::into_system(calc1), IntoSystem::into_system(calc2)).pipe(read)
27+
((calc1, calc2), calc3).pipe(readnew),
28+
(calc1, calc2).pipe(read)
2929
),
3030
)
3131
.run();

0 commit comments

Comments
 (0)