Okay. I got my save/load system working. My issue is, is there a better way for me to be doing this?
Lets say I’m saving a bunch of data. All of this data is tied to FACTION_A.
Right now, being as lost as I am, I’m simply copying pasting all of the code used to save FACTION_A’s data, and slightly renaming it to match FACTION_B. Its a lot of copy pasting and I intend to have more factions.
is there perhaps a technique, something along the lines of “For every faction… save XYZ” ?
Is this something a “dictionary” or “list” can help me with? I’ve never used either one.
^this, JSP can be a good start to data/program structures though. could probably have a int and a byte array in a class, then just serialise, deserialise depending on the int? but without seeing anything, stab in the dark.
First place to start is to create a Faction class that stores all the information relevant to a single faction. Have you done this step yet? It sounds like maybe you have a “FactionA” class and are thinking about making a “FactionB” class. That would be the wrong approach. Just create a general “Faction” class and give it properties such as “FactionName” and whatever else you need.
After that, any code that processes a faction should be able to accept any Faction object you give it. Then it is easy to handle multiple factions in your game.
Not so much scriptable object (at least for savings) but rather serialize it with JSON.
Look into JSON, work through some tutorials… basically its just a way to turn data into a string, and back into the original data, and that’s the essence of savegames.
While we’re at it, here’s a few more of my mad ramblings about loading/saving:
Don’t use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.