Entitas icon indicating copy to clipboard operation
Entitas copied to clipboard

collector's bug

Open 1115803755 opened this issue 4 years ago • 4 comments

Hi,

I have found a bug want to contribute.

Here's some code

public void Activate() { for (int i = 0; i < _groups.Length; i++) { var group = _groups[i]; var groupEvent = _groupEvents[i]; switch (groupEvent) { case GroupEvent.Added: group.OnEntityAdded -= _addEntityCache; group.OnEntityAdded += _addEntityCache; break; case GroupEvent.Removed: group.OnEntityRemoved -= _addEntityCache; group.OnEntityRemoved += _addEntityCache; break; case GroupEvent.AddedOrRemoved: group.OnEntityAdded -= _addEntityCache; group.OnEntityAdded += _addEntityCache; group.OnEntityRemoved -= _addEntityCache; group.OnEntityRemoved += _addEntityCache; break; } } }

As you can see, "group.OnEntityRemoved += _addEntityCache;" is add wrong EventHandle

1115803755 avatar Sep 25 '19 06:09 1115803755

Collector caches entities on Added/Removed/AddedOrRemoved, it looks as intended.

c0ffeeartc avatar Sep 25 '19 08:09 c0ffeeartc

I mean why did group.OnEntityRemoved and group.OnEntityAdded add the same EventCache

1115803755 avatar Sep 25 '19 08:09 1115803755

I mean why did group.OnEntityRemoved and group.OnEntityAdded add the same EventCache

group.OnEntityRemoved and group.OnEntityAdded can add to the same HashSet. Based on how Collector was set up.

c0ffeeartc avatar Sep 25 '19 09:09 c0ffeeartc

Think you, I got it wrong.

1115803755 avatar Sep 25 '19 10:09 1115803755