-
Notifications
You must be signed in to change notification settings - Fork 1
Okay, what's the concept?
The best generic explanation of concept you will find here.
Below i will only explain only how things work in Rimworld and what is actually needed to make this work.
Not as much as you might expect. First of all, calls of methods, that are very close to user input handling, are hooked up and mocked to do NOTHING, until their time comes, and, together with their respective arguments, stored into command pool until their time comes, while command pool being distributed between clients. Their times comes whenever it's time for all clients to execute command pool. Command pool is executed at the same tick number between all clients, so, results are actually the same. This is how AOE approach works. So, yes, there would be local latency between issuing a command and result, until some cosmetic changes would be made. Second, I made sure that initial RNG seed is always the same upon map generation (while, in vanilla, it depends on system time) start AND pushed new state for RNG upon game start, as well as new state for RNG is pushed at each tick. This ensures of RNG results always same on different clients.
You have to keep in mind following things:
-
Issuing new input methods may require some manual labour in order to make your mod MP compatible. New gizmos, hotkeys and float panel entries might not catch up automatically. You would need testing. If they won't catch up automatically, refer to RimAlongContaner wiki on how to catch up your input manually (WIP).
-
Using Verse.Rand somewhere outside of existing licklist context would cause desync for sure. Using it outside TickList context OR in a context of UI callback, hotkey callback or float panel callback, would cause session to desynchronize because it would move session to volatile state with internal RNG having different iteration count in different clients. tldr: in case automatic desync detection routines detect desync, just stick with System.Random or UnityEngine.Random. Or you might ask me in discord/create an issue in this repo and explain what's the problem. If I won't be too much busy, I would help.
So, even if those conditions aren't satisfied, it's not the end of the world! It is always possible to make other mods MP compatible. Refer to RimAlong source code and other sections on a wiki.