Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityIsAlreadyRetainedByOwnerException is thrown when a MultiReactiveSystem is triggered by the same entity and different collectors #818

Closed
felippeduran opened this issue Oct 31, 2018 · 1 comment

Comments

@felippeduran
Copy link

Hi,

When there are multiple collectors defined as triggers within a MultiReactiveSystem and more than one is met, Entitas throws an EntityIsAlreadyRetainedByOwnerException. It's possible that I might not be using the MultiReactiveSystem as it's intended to be, but I think that the exception should not be the expected behaviour in cases like this. Probably the best would be to simply not retain it again (or duplicate its reference) in the execution list.

protected override ICollector[] GetTrigger(Contexts contexts)
{
    return new ICollector[] {
        contexts.gameState.CreateCollector(Matcher.A.AddedOrRemoved()),
        contexts.gameState.CreateCollector(Matcher.B.Removed())
    };
}

The typical case where I'm experiencing this issue is when I've one entity with both A and B components and I remove both of them in the same frame. I can't listen to just one of them because there are other cases where A and B might be removed separately.

Is there a solution or turn around for this, or maybe this is more of a conceptual discussion regarding the API behaviour?

Cheers and thanks in advance!

@felippeduran felippeduran changed the title EntityIsAlreadyRetainedByOwnerException is thrown when a MultiReactiveSystem is trigger by the same entity and different collectors EntityIsAlreadyRetainedByOwnerException is thrown when a MultiReactiveSystem is triggered by the same entity and different collectors Oct 31, 2018
@sschmid sschmid closed this as completed in cbabb12 Nov 3, 2018
@sschmid
Copy link
Owner

sschmid commented Nov 3, 2018

@felippeduran thanks for pointing out. That was actually a bug. MultiReactiveSystem didn't remove duplicates when an entity was collected in multiple collectors. Fixed it in Entitas 1.9.1
https://github.com/sschmid/Entitas-CSharp/releases

@sschmid sschmid added this to Entitas Jul 2, 2023
@github-project-automation github-project-automation bot moved this to Todo in Entitas Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants