project-kyoku/include/core/note.h

60 lines
1.2 KiB
C++

#pragma once
#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;
virtual void input(kku::GameEvent&& input) = 0;
inline const microsec& getPerfectOffset() const noexcept
{
return _perfect_offset;
}
bool operator<(const Note& note) const
{
return _perfect_offset < note._perfect_offset;
}
bool operator==(const Note& note) const
{
return _perfect_offset == note._perfect_offset;
}
bool operator>(const Note& note) const
{
return _perfect_offset > note._perfect_offset;
}
protected:
microsec _perfect_offset;
};
struct NotePtrComparator
{
bool operator()(const Note* lhs, const Note* rhs) const noexcept
{
return lhs->getPerfectOffset() < rhs->getPerfectOffset();
}
};
}