Reward assignment strategies for games with async "indefinite" tasks

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.

I think I would need more information if you need a more direct answer regarding the development. I think that it may be important to take the other design aspects of the game into account when evaluating a proper approach.

If this is for a mobile game, kind of like and IDLE game you probably want a different solution.

1 Like

That’s word by word what ChatGPT already told me… I was looking for a more specific advice with Unreal Engine 5 api :sweat_smile:

Check my previous answer! :slight_smile: