I'm a little stuck on the logic to how i use my path finder efficiently in my game.
This is basically how the game works:
Building generates goods "Factory" > AI transports goods to "Warehouse" on path tiles > Warehouse receives goods > AI goes back to Factory.
Now im wondering how I use my path finder efficiently so its checking the "Factory" is connected to a warehouse by path.
So heres my logic im wondering if it can be improved:
User places factory down > game checks path. Result 1: No path found> Keep checking every frame.. Result 2: Path found > Store path stop rechecking every frame.
The two problems i have is: Well checking every frame is going to hurt the game's performance, secondly if I stop rechecking - it won't know when a faster route may become available or unavailable =/
Is my logic correct or is there a better method?