I’ve been thinking about how I would go about implementing this sort of thing, just theoretically, and I think some kind of intentional action on the part of the character would be best - say, something in the zone menu, perhaps.
The player would need to designate some kind of “this area large area contains a secure area inside it” box, and then the program could attempt to path out of that box from each square within it. Any square that could not path out would be “secure” - that is, wanderings zombie would not spawn there.
Now, that’s not to say that zombies passing by couldn’t BASH their way in, of course, but that would probably only need to be handled when in the reality bubble (and the zombies are actually spawned, not part of horde off-screen).
That brings up the issue of what makes something “secure”, and that is that all solid squares that border it would be marked “securing” or some such, and when one of them is destroyed (or left OPEN, in the case of door), the secure space would lose it’s secure status.
Adjoining “secure” spaces could still turn this into a big mess. Ick. Perhaps instead of marking individual squares, create some kind of pseudo-vehicle-type creation in memory that holds the “secure” squares and the “securing” squares all as one, with the possibility of overlapping secure areas? That way, if you open a door between two secure rooms, the individual rooms are now unsecure, but the secure area that represents the entire building would still be secure (doors closed), and thus everything is still secure.
Yes, that would be abusable in certain ways, but it does avoid being a massive processor drain AND it manages to keep zombies form spawning in locked closets (houses could by default have certain square marked “secure”).
Anyway, you get the idea of why it’s hard - anything too flexible quickly becomes a massive processor drain from all the pathing.