how can an AI move by in turn?

Hello guys, I am trying to make a game in an office where customers enter an office take a seat or go to the counter if it’s not busy and when the counter is free the waiting customer stands up and goes to the counter, and when he is done he leaves the office then another customer would stand up to go to the counter and so on … I wrote those scripts that work perfectly

(pastemyst | AI_Customer Attached to each Customer Prefab) AI Customer Attached to each customer prefab (pastemyst | Seats List) Multidimensional list of seats which tells the AI if the seat is busy or is a counter (pastemyst | Customer Spawner) Customer Spawner which spawns a random customer in a random given position… The part I am struggling with is that when the counter becomes free how can I make it that it picks a random sitting customer to stand up and go to the counter so I complete that loop of customers coming in and out the store I thought for so long and I couldn’t come up with an idea on how I can approach this also if you believe that my code could be written better in any way I would love to know. sorry, the question is too long, Thank you!

One way you could approach this is to create a CustomerManager class that contains a list of sitting customers as well as a public function that, when called, 1.) picks a random customer from the “sitting” list, 2.) tells that customer to go to the counter, 3.) removes that customer from the list. The function could be called something like SendSittingCustomerToCounter().

The idea is that every customer would have a reference to the CustomerManager, and the moment one of them left the office he/she would call the manager’s public SendSittingCustomerToCounter() function to let the manager know that another customer was ready to be taken care of.

Another approach would be to set up an event/messaging system, but I think the method I described above is probably the simplest and easiest to get started with.