Hi, I’m developing a prototype in which the player collects characters and assigns them different jobs. The characters work indefinitely and produce a series of rewards and gain experience every few minutes. My question is about how to implement the rewards system. I’m thinking of some kind of task that runs in the background and checks how much time has passed since the last reward to produce the next one.
However, I have concerns about using asynchronous tasks and the possibility of errors occurring if the list of characters assigned to a job is modified while the asynchronous task is reading that list and assigning rewards.
I’ve also considered the option of registering events with a delay every time a character is assigned to a job, granting the reward when the job is completed, and then re-registering the event for the next time. But I also have concerns about concurrency in this approach.
Does anyone have any ideas on how to solve these problems or could suggest another approach? I would appreciate any help or advice.