Skip to content

Commit

Permalink
Fix errors when disposing entities when another client is connected
Browse files Browse the repository at this point in the history
  • Loading branch information
tatelax committed Sep 3, 2021
1 parent 844cde3 commit 8a5d8b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Runtime/SimulationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ protected void Reset()
foreach (KeyValuePair<int,IWorld> world in Worlds)
{
world.Value.Teardown();
IDisposable disposableWorld = (IDisposable)world.Value;
disposableWorld.Dispose();
(world.Value as IDisposable).Dispose();
}

Worlds = new Dictionary<int, IWorld>();
Expand Down
6 changes: 3 additions & 3 deletions Runtime/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public void Dispose()
{
for (int i = 0; i < Groups.Count; i++)
{
Groups[i].Dispose();
Groups[i]?.Dispose();
}

for (int i = 0; i < Entities.Count; i++)
foreach (KeyValuePair<int, Entity.Entity> entity in Entities)
{
Entities[i].Dispose();
entity.Value.Dispose();
}

OnEntityCreatedEvent = null;
Expand Down

0 comments on commit 8a5d8b2

Please sign in to comment.