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