Hi everyone. so I have this map where you create a village. I'd like the created villagers to go about their lives, but I'm not sure how to make it work.
In my mind what would happen is that you would have a priority list attached to each villager through a hashtable, which would assign orders.
for example -
idle
go to work
work
go home
sleep
flee
what would be best is if the game would be able to detect if the villager was idle and then assign him an order based on his list of priorities. if the villager is attacked, he would be forced to flee until he could be idle again.
the problem is that I can't think of a way to directly find out if a villager has stopped to assign him a task. the only way I can imagine is to loop through every single villager every second or so to find idle villagers, but that sounds like it could really affect performance, especially if there are tonnes of villagers.
am I going about this the wrong way?
In my mind what would happen is that you would have a priority list attached to each villager through a hashtable, which would assign orders.
for example -
idle
go to work
work
go home
sleep
flee
what would be best is if the game would be able to detect if the villager was idle and then assign him an order based on his list of priorities. if the villager is attacked, he would be forced to flee until he could be idle again.
the problem is that I can't think of a way to directly find out if a villager has stopped to assign him a task. the only way I can imagine is to loop through every single villager every second or so to find idle villagers, but that sounds like it could really affect performance, especially if there are tonnes of villagers.
am I going about this the wrong way?