I'm not sure how I'm relevant to this in any way. Yes, it would reduce CPU usage since the level would no longer have to be updated. However, if off-level updates are using meaningful resources then something is extremely, extremely wrong with your mod.
The simple way to destroy all objects on a level is
Code: Select all
for i in Dungeon.getMap(levelNumber):allEntities() do i:destroy() end
but you'd want to make absolutely sure that nothing is ever going to use any object on that level ever again. It would be a lot safer and faster to fix whatever insane thing you're doing that's making off-level updates use significant CPU time. Also there's always a risk that the object can't destroy properly and will crash, or that you'll accidentally activate an unfound secret, or...
The only case I can think of where I'd do this is if I'm making some kind of "infinite dungeon" where levels are randomly generated, in which case I would need to reuse levels, and destroy all objects on a level before replacing them with a new generated level. Otherwise this optimization is too small and too dangerous to be worth it IMO, and I do some pretty small and dangerous optimizations. I guess it would reduce save/load times significantly as the game goes on, but I'd rather be able to return to earlier levels instead.