ITraversalProvider - blocking villagers from walking in certain areas

I am building a city builder game. When a building is built I want that location to be accessible to villagers that work or live at that building but not to others. I was reading about the ITraversalProvider and the turn based blocking. I have made a system that uses the turn based node blocking by basically finding all of the nodes on the building site and adding a SingleNodeBlocker to each of them. I then use BlockMode.AllExcept so that all building sites are blocked for villagers and then when I add the villager as an employee of that building I add all that’s buildings nodes to it’s selection list so that those nodes become accessible. This all works however the issue I have is if a villager that is not an employee already has a path that happens to finish on that site when it is created then they will finish that path and then get stuck as they are on a blocked node that is not in their selector list. Or I can have a situation where the builders of the building get caught on the new building site as once the building is built they are no longer employees and thus don’t have that buildings nodes in their selector list.

Firstly, is what I am doing stupid and is there a better way? I appreciate I have taken the turn based system and used for something else which could be the issue. If what I am doing isn’t super stupid, is there a solution for the issue of the trapped villagers. I have thought of some hacky solutions like checking if they are starting on a blocked node and if so then adding those nodes to their selector list and then removing them later but it is just going to be a hacky mess and I really don’t think that is a good approach.

Hi

Coincidentally, I have a fix for this already planned for the next update. It will make everything work as you’d expect.

Oh amazing! I will just wait for that then. Thanks