A Dictionary inside other Dictionary?

Hey! First of all, I’m not an english native speaker, so I believe something will pass without me noticing :slight_smile:

But I want to fully unsterstand what is going on at this moment of the course.

for Capturing the state:

  • The SavingSystem will search for all SaveableEntity in the scene - it puts what SaveableEntity “CaptureState” returns on a Dictionary
  • The SaveableEntity (when called by the line above) will search for all ISaveable in the Game Object it is attached to - and puts all serializable objects on another Dictionary that will be returned to SavingSystem.
  • And these informations will be wrote on the save file by SavingSystem (using an UUID that is a key for each Dictionary that have each ISaveable inside)

for Restoring:

  • The SavingSystem will read the save file
  • And the opposite way is going to happen (passing the read states as parameters) , up to the point to each class will restore the states with the passed informations.

So, we are putting a Dictionary inside other Dictionary? and each class will know what to do with it?

If it’s correct, I think I would never reach that conclusion to build this system by myself hahahaha that’s a great solution to we reach the single responsability here, I think.

If i’m miss something, please bring me up!

I’m loving the course! :smiley:

You’ve got an excellent understanding of the saving system. Well done!

We are indeed putting a Dictionary inside of a Dictionary. That’s something that’s not entirely noticed, and this is the easy one. Once we get to stats we’ll be stuffing an arrays into Dictionaries, and then putting those Dictionaries into another Dictionary. :slight_smile: Data structures can be fun!

By using UUIDs for the SaveableEntities and the class names for each of the ISaveable components, it’s relatively easy to capture and restore the data, allowing each class to pack and unpack their own data.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms