Let’s say I have a role-play job system that consist of these steps:
Grab item in the floor
Show an arrow indicating the player where to go
Deliver it to a door with a proximity prompt (wait for player to trigger the prompt, then continue to next step)
Repeat until player clicks end job shift
Everything is fine, however, ending the job is where the issue is. When the job is ended, all of the proximity prompts gets their Enabled property set to false, and the arrow gets deleted. However, the proximity prompt would be still waiting for the player to trigger the prompt, and when it triggers it again in the future, the steps will be duplicated and in this case create a second arrow (and also continue the other steps, which would be waiting again for the proximity prompt to be triggered and repeat the steps) because in one job shift the proximity prompt was waiting for it to be triggered, and in this current shift it got triggered so both of the shifts were executed. How can this be fixed?
I know I could use a flag for this (a variable indicating, in this case, if the job has ended then doing checks), but if I do so, in my real code there will be a lot of if conditions checking for that flag, because I have extra steps and some of them are also proximity prompts waiting to be triggered, plus, it can also be considered code smell.
It’s pretty complicated to explain, tried my best.
Hello, could you provide us with scripts please?
(Not the actual job part where player does stuff, just starting and ending. Basically main aspects that cause the problem)
I don’t think promises might be useful in this case… Considering promises are to perform asynchronous actions and then do something with the result of that action, I don’t think they will be helpful because the steps of the job are happening in a sequential order, and do not involve any asynchronous operations… Thank you so much your help and your time though!