Debain 9, MonoDevelop 6.2 Stable, MonoGame 3.6, latest clone of Monogame.Extended.
Forewarning: I am only an intermediate programmer. Just enough to make me dangerous but nowhere near an expert.
EntityComponentSystem inside of a game screen class. The game runs fine the first time around. If you quit the game screen and return to the main menu, then try to play again, this exception is thrown when
EntityComponentSystem is calling
Scan(params Assembly assemblies), which calls
CreateSystems(List systemTypeInfos, int componentCount) and in turn
EntityManager.FillComponentBits(andMask, aspectAttribute.Components). The exception is thrown inside of
BitVector (which is the
FillComponentBits is trying to assign a value to the
BitVector[int index] property but the index is out of range and throws an exception.
EDIT: I set a break point and inspected the variables and the first time the index value of
BitVector[int index] was 26. The second time when the exception is thrown it’s 53. EDIT2: It’s pretty clear that the index value is being doubled.
Am I supposed to be resetting or destroying the
EntityComponentSystem some how when a game is quit, even if it’s just returning to the main menu? I assume this problem is happening because
EntityComponentSystem is trying to do something it’s already done. I’m sure you can imagine this creates a problem for a game intended to be fully featured and finished. This is just my guess though, I suppose I could be wrong. I tried to work around it but I was unsuccessful.
If you need more info on how I am managing the game states/screens, let me know.
Here’s the stack trace: https://pastebin.com/2PCL4Uv0
Thanks in advance!