2021-03-19 22:23:26 +00:00
|
|
|
#ifndef OPENMW_MECHANICS_AITIMER_H
|
|
|
|
#define OPENMW_MECHANICS_AITIMER_H
|
|
|
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
#include <components/misc/timer.hpp>
|
|
|
|
|
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
constexpr float AI_REACTION_TIME = 0.25f;
|
|
|
|
|
|
|
|
class AiReactionTimer
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
|
|
|
static constexpr float sDeviation = 0.1f;
|
2021-03-19 22:23:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
AiReactionTimer(Misc::Rng::Generator& prng)
|
|
|
|
: mPrng{ prng }
|
|
|
|
, mImpl{ AI_REACTION_TIME, sDeviation, Misc::Rng::deviate(0, sDeviation, prng) }
|
|
|
|
{
|
|
|
|
}
|
2021-03-19 22:23:26 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
Misc::TimerStatus update(float duration) { return mImpl.update(duration, mPrng); }
|
2022-03-06 19:56:02 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void reset() { mImpl.reset(Misc::Rng::deviate(0, sDeviation, mPrng)); }
|
2022-03-06 19:56:02 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
private:
|
|
|
|
Misc::Rng::Generator& mPrng;
|
|
|
|
Misc::DeviatingPeriodicTimer mImpl;
|
2021-03-19 22:23:26 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|