project-kyoku/include/core/note.h

56 lines
1.0 KiB
C
Raw Normal View History

#pragma once
2021-12-29 15:59:18 +01:00
#include "core/time.h"
#include "core/gameevent.h"
namespace kku
{
class Note
{
public:
explicit Note(microsec perfect_offset) :
_perfect_offset(perfect_offset) {}
virtual ~Note() = default;
virtual bool isActive(const microsec& offset) const = 0;
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
{
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
}
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
{
bool operator()(const Note* lhs, const Note* rhs) const noexcept
{
2021-12-29 15:59:18 +01:00
return lhs->getPerfectOffset() < rhs->getPerfectOffset();
}
2021-10-03 17:23:28 +02:00
};
2021-12-29 15:59:18 +01:00
}