You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lines 232-241. There are list modifications in enumerations here:
foreach(Entity e in liberals)
{
if (e != null && !e.getComponent<Body>().Alive)
liberals[liberals.IndexOf(e)] = null;
}
foreach(Entity e in conservatives)
{
if (e != null && !e.getComponent<Body>().Alive)
conservatives[conservatives.IndexOf(e)] = null;
}
It crashes for me when someone dies:
InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.ThrowHelper.ThrowInvalidOperationException (System.ExceptionResource resource) (at :0)
System.Collections.Generic.List1+Enumerator[T].MoveNextRare () (at <c8d0d7b9135640958bff528a1e374758>:0) System.Collections.Generic.List1+Enumerator[T].MoveNext () (at :0)
LCS.Engine.Scenes.Fight.doCleanup (System.Collections.Generic.List1[T] liberals, System.Collections.Generic.List1[T] conservatives) (at Assets/Scripts/Engine/Scenes/Fight.cs:232)
It's more correct to use an enumeration of indexes or to store indices in a list, e.g.:
foreach(Entity e in liberals)
if (e != null && !e.getComponent<Body>().Alive)
indicesToClear.Add(liberals.IndexOf(e));
foreach (int index in indicesToClear)
liberals[index] = null;
...
The text was updated successfully, but these errors were encountered:
Hmm, weirdly I don't get this exception when I'm running it, but I can see why it would be thrown. I've put in a fix for it that stores the entities in a temporary list that is iterated instead of directly iterating the list that's being modified.
Lines 232-241. There are list modifications in enumerations here:
It crashes for me when someone dies:
It's more correct to use an enumeration of indexes or to store indices in a list, e.g.:
The text was updated successfully, but these errors were encountered: