diff options
author | Bartosz Taudul <wolf.pld@gmail.com> | 2018-08-17 23:23:04 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf.pld@gmail.com> | 2018-08-17 23:23:04 +0300 |
commit | 841f18885e029191dc16bbb5e42831c71f345f30 (patch) | |
tree | 719a1255d435214844f430c397f853aafc9ac687 /server/TracyBuzzAnim.hpp | |
parent | 12f20803870d3e19f19fd0e96da180f5036908f9 (diff) |
Add simple animation controller.
Diffstat (limited to 'server/TracyBuzzAnim.hpp')
-rw-r--r-- | server/TracyBuzzAnim.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/server/TracyBuzzAnim.hpp b/server/TracyBuzzAnim.hpp new file mode 100644 index 00000000..fa3151d3 --- /dev/null +++ b/server/TracyBuzzAnim.hpp @@ -0,0 +1,48 @@ +#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 |