1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 10:10:23 +00:00
OpenMW/apps/openmw/mwmechanics/aitimer.hpp

33 lines
788 B
C++
Raw Normal View History

#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;
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) }
{
}
2022-09-22 18:26:05 +00:00
Misc::TimerStatus update(float duration) { return mImpl.update(duration, mPrng); }
2022-09-22 18:26:05 +00:00
void reset() { mImpl.reset(Misc::Rng::deviate(0, sDeviation, mPrng)); }
2022-09-22 18:26:05 +00:00
private:
Misc::Rng::Generator& mPrng;
Misc::DeviatingPeriodicTimer mImpl;
};
}
#endif