Skip to content

Commit 0fa4b82

Browse files
committed
Restrict to only immutable components
1 parent 486b1cd commit 0fa4b82

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/shared/replication/related_entities.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use core::any::{self, TypeId};
22

3-
use bevy::{ecs::relationship::Relationship, platform::collections::HashMap, prelude::*};
3+
use bevy::{
4+
ecs::{component::Immutable, relationship::Relationship},
5+
platform::collections::HashMap,
6+
prelude::*,
7+
};
48
use log::{debug, trace};
59
use petgraph::{
610
Direction,
@@ -39,11 +43,16 @@ pub trait ReplicateTogetherAppExt {
3943
/// children![(Replicated, Transform::default())],
4044
/// ));
4145
/// ```
42-
fn replicate_together<C: Relationship>(&mut self) -> &mut Self;
46+
fn replicate_together<C>(&mut self) -> &mut Self
47+
where
48+
C: Relationship + Component<Mutability = Immutable>;
4349
}
4450

4551
impl ReplicateTogetherAppExt for App {
46-
fn replicate_together<C: Relationship>(&mut self) -> &mut Self {
52+
fn replicate_together<C>(&mut self) -> &mut Self
53+
where
54+
C: Relationship + Component<Mutability = Immutable>,
55+
{
4756
self.add_observer(add_relation::<C>)
4857
.add_observer(remove_relation::<C>)
4958
.add_observer(start_replication::<C>)

0 commit comments

Comments
 (0)