Lance Harrington - Milestone 3 Part 1: Save System


Lance Harrington

Milestone 3 Part 1: Saving System

 

                For this milestone I was tasked with coming up with a saving system. Luckily, I had one already made from when I took the GameDev.tv course for RPG Core Combat. I was able to extract the files I needed and bring them over to Iron Echoes, implementing the core code. This saving system stores all the data that we give into a JSON file, that we can then just extract the data from, to start our game right where we left off. The system at its core is made up of 3 scripts, ISavable, SavableEntity, and SaveSystem. Along with them, the Unity package for Newtonsoft Json is also used, but I will not be going into a lot of detail about that.

The ISavable script is an interface that will allow us to add methods for saving and restoring data on any object that we see fit:


A JToken is part of the Newtonsoft Json package that allows us to capture the state of an object and turn it into JSON. Within these methods we will have to write unique code for every object that we want to save, telling it exactly what parts we want to save.

                The Savable Entity Script gives our entities in the game a Unique Identifier in the editor that allows our game to tell different instances of prefabs apart in the scene:


This also takes care of gathering any ISavable instances on the entity and calling either CaptureAsJToken or RestoreFromJToken on those scripts, linking them to the Unique Identifier.

                Finally, we have the SaveingSystem itself, which takes care of capturing all the savable entities into JTokens and also handles the reading and writing of the JSON file. If we break it down the flow goes like this:


                These three scripts work together to help capture components of a scene that we want. While the saving systems core is in place, the saving system is something that will consistently be evolving. I will further work on this to make sure that saving our game is smooth and works the way we want it to.

Get Iron Echos: Zenith's Uprising

Leave a comment

Log in with itch.io to leave a comment.