How to implement temporal bonus which isn't Monobehaviour ?
I have set of Stats (attack, defense...) inside Monobehaviour controller. Each Stat has List of modifiers.
public class Stat : BaseStat
{
List<StatModifier> modifiers = new List<StatModifier> ();
}
public class StatModifier
{
public float duration;
}
How can I manage these temporal modifiers? As far as I understand I can't deal with System.Timers.Timer and give modifier opportunity to delete itself from list after over. One way is to Start coroutine in Controller and check list of modifiers one time per 1-2 seconds removing complete modifiers.
The easiest/fastest way to implement this is probably as you say by a coroutine, yield 1 sec, decrement the duration then on the duration you can use an accessor to execute a function when the value is set to 0 or below, or just remove it from the list.
or you just save the time they're created and pass the current time to them from the controller. they can then check themselves if it's time to decay
Your answer
![](https://koobas.hobune.stream/wayback/20220612110628im_/https://answers.unity.com/themes/thub/images/avi.jpg)