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.