I have a concept that involves a world being simulated. Lots of entities and processes acting upon them, not to mention interactions, etc...
Every SimulationTick
, the simulation updates (preferably a fixed interval, I don't expect the simulation to tax the CPU and don't need a fast tick [a few/second]).
The game will allow players to see an environment that allows them to interact with the simulation.
I need the simulation to be far larger than the area visible at any given time, and I don't need any Unity functionality, so it could in theory run completely isolated, just passing back relevant state as needed.
What's the best way to architect this application?
At one extreme, I could have the simulation running in its own process, exposing a network port/RPC call for the game engine to query/invoke.
At the other, I could just build it all into one assembly and tie the simulation tick to either physics or some other time keeping mechanism.
It feels like it should have its own thread, but what spawns/manages it? I'm guessing that if Unity serialises the object holding the reference to the thread, it'll lose it? How do I work around that?