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