Closed ChickenHacker1 closed 2 years ago
This is a bit out of scope for the system unfortunately. Optimization for civics, server and client are generally ongoing tasks, though, so I'm going to close this suggestion.
Feel free to instead provide profilings with the integrated profiler tools for specific laws that you noticed specific lag occurances. That's what White Tiger does as well and lots of optimizations have been made that way. You can post these in the issues tracker.
With us drawing closer to towns and cities, I see the civics system being more popular in the future.
One downside to the civics system in it's current state, is the limitations you will run into. Not limitations in that you can't do the things you want to do. The civics system is very powerful and provides all players a tool to modify the game experience in game with ease.
The limitation is more that you can do anything, but should you? There are certain actions we have found that will cause server-wide lag spikes in certain civics implementations.
The few I recall was regarding running some tests through the civics system when placing land claims, and now we may have encountered another in a law that tracks actions performed by the players, like cutting trees, mining rocks, cooking things, etc. We're currently testing to determine if the civics are the cause of the lag spikes this time around or not.
Bottom line, though, is the civics system should be optimized further. I haven't looked too deep into how it functions, but as far as I know, there is no c# that is generated and then compiled by the civics system. It would be hugely beneficial if this could be compiled at some point, whether when a client disconnects, connects, or on a server reboot. I realize it probably could not be compiled mid-game. But if it could eventually be compiled, that should lead to a huge boost in performance.
So basically, the suggestion is to keep the current civics system as a fallback, but have it default to a generated and compiled system if available. The code could be generated on draft, or when the law passes, and then perhaps downloaded to the client and compiled as the client connects. Or, if it's run server side, compile when the server starts.