The No Laggy Bed Mod fixes the fps drop when you select a bed or workbench.
No Laggy Bed Mod features
Some players (usually heavy-modded) experience this fps issue in their game when selecting a bed or workbench. I wish this mod fixed it.
If you’re not curious about where it comes from, stop here.
Long story short: this is a vanilla problem; more mods exacerbate it.
When you select a bed or a workbench, the game will try to find available linkable facilities like dressers and show them. BuildCopyCommandUtility.FindAllowedDesignator() scans all the designators in the database every frame to find a single build command. Typically, a game with a medium-size mod list contains thousands of designators. Hence, the game needs to validate millions of designators in 60 frames for a bed with 10ish linkables. The same case applies to workbenches. That’s the main reason why selecting them slows down your game drastically. The situation worsens with more modded buildable things. For example, VE furniture series add tons of buildable things in the game. In this mod, I build copies for needed designators and cache them to avoid scanning.
Some people claim the mod SRTS Expanded is also the culprit. To some extent, they’re right. SRTS has a harmony patch for research projects, which costs 0.005ms per call. It’s not bad itself but calling it 10k times per frame is. To avoid this, I also add caching for Designator_Build.Visible. It eliminates calling that method as much as possible, and it’s not a problem now. This caching should also speed up general gizmo drawing.
At last, I also replace GetRoom() in Building_Bed.DrawExtraSelectionOverlays() with a cached version. It’s a small lift without getting them every frame.
No free lunch! So what’s the price? Like other performance optimizers, it needs a little more memory to store the cache. It’s not a big deal from my testing. Of course, there might be other impacts I didn’t notice; if you find something, feel free to let me know.
Above is all my understandings of this problem. Please don’t quote me on that~