2021-09-14 15:02:23 -04:00
|
|
|
#pragma once
|
|
|
|
|
2021-12-29 09:59:18 -05:00
|
|
|
#include "core/time.h"
|
|
|
|
#include "core/gameevent.h"
|
|
|
|
|
|
|
|
namespace kku
|
|
|
|
{
|
2021-09-14 15:02:23 -04:00
|
|
|
|
|
|
|
class Note
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit Note(microsec perfect_offset) :
|
|
|
|
_perfect_offset(perfect_offset) {}
|
|
|
|
virtual ~Note() = default;
|
|
|
|
|
2021-12-08 13:00:47 -05:00
|
|
|
virtual bool isActive(const microsec& offset) const = 0;
|
2021-09-14 15:02:23 -04:00
|
|
|
virtual void update(const microsec& music_offset) = 0;
|
|
|
|
|
2021-12-29 09:59:18 -05:00
|
|
|
virtual void input(kku::GameEvent&& input) = 0;
|
|
|
|
|
|
|
|
inline const microsec& getPerfectOffset() const noexcept
|
2021-09-14 15:02:23 -04:00
|
|
|
{
|
|
|
|
return _perfect_offset;
|
|
|
|
}
|
|
|
|
|
2021-10-03 11:23:28 -04:00
|
|
|
bool operator<(const Note& note) const
|
|
|
|
{
|
2021-12-29 09:59:18 -05:00
|
|
|
return _perfect_offset < note._perfect_offset;
|
2021-10-03 11:23:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const Note& note) const
|
|
|
|
{
|
2021-12-29 09:59:18 -05:00
|
|
|
return _perfect_offset == note._perfect_offset;
|
2021-10-03 11:23:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>(const Note& note) const
|
|
|
|
{
|
2021-12-29 09:59:18 -05:00
|
|
|
return _perfect_offset > note._perfect_offset;
|
2021-10-03 11:23:28 -04:00
|
|
|
}
|
|
|
|
|
2021-09-14 15:02:23 -04:00
|
|
|
protected:
|
|
|
|
microsec _perfect_offset;
|
|
|
|
};
|
2021-10-03 11:23:28 -04:00
|
|
|
|
2021-12-29 09:59:18 -05:00
|
|
|
struct NotePtrComparator
|
2021-10-03 11:23:28 -04:00
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
bool operator()(const Note* lhs, const Note* rhs) const noexcept
|
|
|
|
{
|
2021-12-29 09:59:18 -05:00
|
|
|
return lhs->getPerfectOffset() < rhs->getPerfectOffset();
|
2021-11-02 13:03:27 -04:00
|
|
|
}
|
2021-10-03 11:23:28 -04:00
|
|
|
};
|
2021-12-29 09:59:18 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|