Hello everyone,
I come here because I am having a small question that I like to have some other people's opinion on.
So, I have quarry entities that every minute distributes minerals, and I wonder whats better to use for checking this..
1: I made a component (QuarryHandler) inheriting from MonoBehavior, then I add this handler to the 'quarry.gameObject.AddComponent' and in this handler I have Awake() to 'hook' the quarry to a variable inside, and Update() which checks with a datetime property if 60 seconds have passed or not, when they have passed, execute some code, then resets for next time. But ive noticed that Update() is fired LOTS of times.
So to alter that 'lots of time firing', I thought about the second solution:
2: Keep an internal dictionary holding the quarry ID and a timer object which uses timer.Every() which fires every minute and executes code then resets to do it again next minute.
Can somebody please tell me which way is better to use? Either make the component inheriting from monobehavior or using dictionary and timer?
I dont need any code or anything, just a clear answer on which of the 2 to use. I have already code written out for both solutions but yeah, im stuck at deciding. If possible explain too why exactly the choice you tell me, so I can understand all mechanics a bit better as well.
Thanks in advance and a happy christmas!