Skip to content

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

Closed
@felippeduran

Description

@felippeduran

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions