1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 06:39:49 +00:00
OpenMW/apps/openmw/mwmechanics/stat.hpp

50 lines
1.1 KiB
C++
Raw Normal View History

#ifndef GAME_MWMECHANICS_STAT_H
#define GAME_MWMECHANICS_STAT_H
namespace MWMechanics
{
template<typename T>
class Stat
{
T mBase;
T mModified;
public:
Stat() : mBase (0), mModified (0) {}
const T& getBase() const
{
return mBase;
}
const T& getModified() const
{
return mModified;
}
/// Set base and modified to \a value.
void set (const T& value)
{
mBase = mModified = value;
}
/// Set base and adjust modified accordingly.
void setBase (const T& value)
{
T diff = value - mBase;
mBase = value;
mModified += diff;
}
/// Change modified relatively.
void modify (const T& diff)
{
mModified += diff;
}
};
}
#endif