I was messing around in my own fork of Thrive and came across four issues related to despawning. They are kind of related so I just put them all in this thread. As far as I can tell, my fork doesn’t cause these issues. I do have changes in my fork that make observing these issues easier, like printing the amount of living cells in the console or changing spawning radius to better see spawning and despawning. I can provide more details if wanted.
Despawning entities takes a long time and doesn’t keep up with spawning. Despawning only happens about once a second. This means that over time the amount of living cells can climb to over 100, and it usually doesn’t really decrease from that even after dying. This causes a lot of lag.
One simple fix is to raise Constants.MAX_DESPAWNS_PER_FRAME from 1 to 100. That makes it so dying or just swimming to another area actually successfully despawns entities so they drop below 10 in a couple of seconds and your fps goes back to normal. You can also make the max despawns per frame 10 if you’re worried about issue (4). That still despawns cells pretty fast but not as fast. I think 100 is good, though.
Cells can spawn outside the despawn radius. This is because the despawn radius is equal to the spawning radius, which means that parts of bacterial colonies can reach outside the radius. This is especially important after fixing issue (1) because it makes those cells despawn instantly.
This can be fixed by adding a bigger despawn radius, for example spawning radius + 50 = 220.
Enemy cells spawned by cheats don’t despawn at all.
This can be fixed by using the method AddEntityToTracked.
A massive pile of entities despawning very fast can crash the game. I could only reproduce this while stress testing my fork by using cheats to spawn a massive ball of cells and then dying or migrating. I think this is impossible to reproduce without cheats, so this is probably very low priority. I don’t have a fix for this.
Should I make proper issues on Github? Oh and by the way, if my simple fixes sound good then I guess could make a pull request for them.