How does game like hollow knight save the room they're in

In hollow knight, everytime you go to a new room, the room before you will be saved (like enemy killed) and also certain places condition will be saved, like a door closed. My question is do they just save some specific variable like door A close, door b open, etc. Or do they save the scene you were in.
And if you have knowhow, giving me links to tutorial like this would help very much
Thanks in advanve

You’d probably want to read up on serializing and deserializing data structures, but one way I would do it is have system deticated to saving little bits of data like that, and all it would need is a key-value map
with key names that are easy to look up.

Pseudo code:

Map<string,string> map = new Map();
map.set("roomA.doorLeft.state", "open");
map.set("", "10");

You could then easily save that to a file and when the game loads, load that file into back into memory into the same data structure. The objects in every room themselves would know what values to look for in the map to know what state to put themselves in.

I know this isn’t a tutorial, but conceptually it’s the first idea that pops into my head.

Like I mentioned, look up serializing structures, or just reading and writing data back into data structures however you like.