| 13 | } |
| 14 | |
| 15 | bool CooldownTimer::Trigger() |
| 16 | { |
| 17 | if (instances_.empty()) |
| 18 | { |
| 19 | timer_.Mark(); |
| 20 | instances_.push_back(0.f); |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | instances_.push_back(float(timer_.Peek())); |
| 25 | |
| 26 | if (ThresholdExceeded()) |
| 27 | { |
| 28 | // if we're above the threshold, run the update just in case |
| 29 | // there are stale entries and then check again to be sure |
| 30 | Update(); |
| 31 | if (ThresholdExceeded()) |
| 32 | { |
| 33 | return true; |
| 34 | } |
| 35 | } |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | bool CooldownTimer::ThresholdExceeded() const |
| 40 | { |