Skip to content

Commit

Permalink
fixed Entity.Dispose when using multiple EntityMap/MultiMap with the …
Browse files Browse the repository at this point in the history
…same component key (fix #123)
  • Loading branch information
Doraku committed Jul 27, 2021
1 parent ce21ac2 commit 9aa503c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions documentation/NEXT_RELEASENOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixed Entity.Dispose when using multiple EntityMap/MultiMap with the same component key (#123)
2 changes: 1 addition & 1 deletion source/DefaultEcs/EntityQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ internal EntityQueryBuilder(World world, bool withEnabledEntities)
_nonReactSubscriptions = new List<Func<EntityContainerWatcher, World, IDisposable>>();

_addCreated = withEnabledEntities;
_subscriptions.Add((s, w) => w.Subscribe<EntityDisposedMessage>(s.Remove));
_subscriptions.Add((s, w) => w.Subscribe<EntityDisposingMessage>(s.Remove));
_withFilter[World.IsAliveFlag] = true;
if (withEnabledEntities)
{
Expand Down
2 changes: 1 addition & 1 deletion source/DefaultEcs/Technical/EntityContainerWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void CheckedAdd<T>(in ComponentDisabledMessage<T> message)
}
}

public void Remove(in EntityDisposedMessage message) => _container.Remove(message.EntityId);
public void Remove(in EntityDisposingMessage message) => _container.Remove(message.EntityId);

public void Remove(in EntityEnabledMessage message) => _container.Remove(message.EntityId);

Expand Down
2 changes: 1 addition & 1 deletion source/DefaultEcs/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public IDisposable SubscribeEntityDisposed(EntityDisposedHandler action)
{
IEnumerable<IDisposable> GetSubscriptions(EntityDisposedHandler a)
{
yield return Subscribe((in EntityDisposingMessage message) => action(new Entity(WorldId, message.EntityId)));
yield return Subscribe((in EntityDisposingMessage message) => a(new Entity(WorldId, message.EntityId)));
yield return Subscribe((in WorldDisposedMessage _) =>
{
foreach (Entity entity in this)
Expand Down

0 comments on commit 9aa503c

Please sign in to comment.