mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 08:14:34 +00:00
49 lines
659 B
C++
49 lines
659 B
C++
|
#ifndef __TRACYBUZZANIM_HPP__
|
||
|
#define __TRACYBUZZANIM_HPP__
|
||
|
|
||
|
#include <assert.h>
|
||
|
|
||
|
namespace tracy
|
||
|
{
|
||
|
|
||
|
template<typename T>
|
||
|
class BuzzAnim
|
||
|
{
|
||
|
public:
|
||
|
bool Match( const T& comp ) const
|
||
|
{
|
||
|
return active && comp == id;
|
||
|
}
|
||
|
|
||
|
float Time() const
|
||
|
{
|
||
|
assert( active );
|
||
|
return time;
|
||
|
}
|
||
|
|
||
|
void Enable( const T& val, float len )
|
||
|
{
|
||
|
active = true;
|
||
|
time = len;
|
||
|
id = val;
|
||
|
}
|
||
|
|
||
|
void Update( float dt )
|
||
|
{
|
||
|
if( active )
|
||
|
{
|
||
|
time -= dt;
|
||
|
if( time <= 0 ) active = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
bool active = false;
|
||
|
float time;
|
||
|
T id;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|