project-kyoku/include/core/note.h

60 lines
1.2 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;
virtual void putToGame() = 0;
virtual bool isInGame() const = 0;
virtual bool shouldRemove() const = 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
}