I'm just working at the possibility to explore systems in-game (i.e. changing a system from unexplored to explored during play). I've already working code in my system_exploration branch, but the more I thought about it, the more I came to the conclusion, that this is only a special case of a much broader problem: Modifying the universe from its randomly-generated form, saving the differences, and re-applying the differences when re-generating the affected part (e.g. the Sector/StarSystem).
I'm not sure which is the better proceeding now:
- Solving that special case "system exploration" and later generalize from it (so essentially finishing above branch and merging it).
- Trying to generalize a persistence overlay now and rebuild the "system exploration" feature on it.
I'm already quite tired now, so I will only give a very short overview about what I did so far (this is more the logical order, not the order in which the commits appear):
- Moved the explored state from StarSystem to Sector::System, since this is a very coarse property of the whole system.
- Made sure that of each sector there is at most one Sector object. This is important, since if this deviates from the randomly generated/custom system state, we do not want inconsistent information about the same sector. Thanks to fluffyfreak's SectorCache this was actually quite easy, as only a few places still generated their own sector. But this could become messier with threaded cache pre-population of #2604
- Stored systems that were explored in-game in a static PersistSystemData structure and lookup if a system is stored there, when creating a Sector::System. This will definitely become a problem with #2604 as each Sector constructor needs to access the common data (from potentially different threads).
- The explored state can be set from Lua on a StarSystem object (which needs to redirect to the associated Sector::System). This redirection doesn't feel totally right, but in my first try, I left the explored state in StarSystem and that didn't feel right, either.
- I wrote a Lua module that just sets an unexplored system to explored when entering it.