#[Resolved;Issue was elsewhere]Integrating `Resource` with `Arc<Mutex<SomeType>>` into `.add_system()

16 messages · Page 1 of 1 (latest)

digital siren
#

That system_with_arc_mutex should just work AFAIUI

#

What are you trying to accomplish with the Arc/Mutex?

slim flame
#

Thanks for answering! The system itself does not complain, it is the .add_systems(Update, system_with_arc_mutex) that produces a long error of "The trait bevy::prelude::IntoSystem is not implemented for ...".

digital siren
#

What does ComponentWithArcMutex look like then?

slim flame
#

The component in question is a Genome, containing Genes and Connections, which reference each other. I used to make it work before with RefCell, but it is !Sync, so that went out of the window right away.

#

So the component is

struct GenomicData {
    genome: Genome,
}

And Genome is

pub struct Genome {
    /// A [`Vec`] containing the [`Layer`]s which contain references to the [`NodeGene`]s.
    pub layers: Vec<Layer>,
...

The Layer is
```/// A struct containing the details about a [Layer].
#[derive(Clone, Debug)]
pub struct Layer {
/// A collection of references to the [NodeGene]s that are present in the [Layer].
pub nodes: Vec<Arc<Mutex<NodeGene>>>,
...

digital siren
#

And you're doing Query<&mut GenomicData>?

slim flame
#

Looks like so:

    mut creatures_query: Query<
        (
            &Transform,
            &mut Decisions,
            &mut GenomicData,
            &Energetics,
            &Health,
            &Replication,
        ),
        With<Creature>,
    >,
    game_assets: &Res<GameAssets>,
    time: Res<Time>,
) {```
digital siren
#

&Res should just be Res

slim flame
#

o_o

#

okay, now i feel dumb.

#

Thank you very much!

#

I will remove the thread (if I can) because the title doesn't match the issue I had, but thank you from the bottom of my heart, hahaha.

digital siren
#

😄 it happens - the easiest way I've found to debug this sort of thing is to create a new empty system and add things one at a time until it complains, but IIRC there's a macro helper to isolate those errors somewhere around here too

slim flame
#

I'll remember that tip.

#

The long compiler issue was not very helpful, but from what I saw, I am not the only one that sees it that way.