2022-05-14 00:48:46 -04:00
|
|
|
#include "game/classicarrownote.h"
|
|
|
|
#include "classicmode/context.h"
|
2022-05-17 19:47:47 -04:00
|
|
|
#include "graphics/classicgraphicsmanager.h"
|
2022-05-14 00:48:46 -04:00
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
ClassicArrowNote::ClassicArrowNote(Init &&init)
|
|
|
|
: ClassicNote(init.perfect_offset, init.id),
|
|
|
|
_evaluator(init.intervals, init.perfect_offset), _context(init.context),
|
|
|
|
_is_holding(init.is_holding)
|
2022-05-14 00:48:46 -04:00
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
_elements.resize(init.elements.size());
|
2022-05-14 00:48:46 -04:00
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
for (std::size_t i = 0; i < _elements.size(); ++i)
|
|
|
|
{
|
|
|
|
_elements[i].keys = init.elements[i].keys;
|
|
|
|
_elements[i].position = init.elements[i].position;
|
|
|
|
_elements[i].type = init.elements[i].type;
|
|
|
|
}
|
2022-05-14 00:48:46 -04:00
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
bool ClassicArrowNote::isActive(const kku::microsec &offset) const
|
2022-05-14 00:48:46 -04:00
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
return _evaluator.isActive(offset) && _state != State::DYING;
|
2022-05-14 00:48:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClassicArrowNote::update(const kku::microsec &music_offset)
|
|
|
|
{
|
|
|
|
_context->update(this, music_offset);
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
void ClassicArrowNote::input(kku::GameEvent &&input)
|
2022-05-14 00:48:46 -04:00
|
|
|
{
|
|
|
|
_context->input(this, std::move(input));
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
void ClassicArrowNote::draw(
|
|
|
|
const std::shared_ptr<const ClassicGraphicsManager> &graphics_manager) const
|
2022-05-17 19:47:47 -04:00
|
|
|
{
|
2022-05-28 01:52:59 -04:00
|
|
|
graphics_manager->draw(this);
|
2022-05-17 19:47:47 -04:00
|
|
|
}
|
|
|
|
|
2022-05-17 00:22:18 -04:00
|
|
|
bool ClassicArrowNote::isHold() const
|
|
|
|
{
|
|
|
|
return _is_holding;
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
std::vector<ArrowElement> &ClassicArrowNote::getElements()
|
2022-05-14 00:48:46 -04:00
|
|
|
{
|
|
|
|
return _elements;
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
const std::vector<ArrowElement> &ClassicArrowNote::getElements() const
|
2022-05-28 01:52:59 -04:00
|
|
|
{
|
|
|
|
return _elements;
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
auto ClassicArrowNote::calculatePrecision(const kku::microsec &offset) const
|
|
|
|
-> Grade
|
2022-05-14 00:48:46 -04:00
|
|
|
{
|
|
|
|
return _evaluator.calculatePrecision(offset);
|
|
|
|
}
|
2022-05-17 00:22:18 -04:00
|
|
|
|
|
|
|
bool ClassicArrowNote::isPressedAs(kku::SystemEvent::Key::Code key) const
|
|
|
|
{
|
|
|
|
return std::any_of(_elements.begin(), _elements.end(),
|
2022-10-17 22:59:51 -04:00
|
|
|
[key](const auto &element)
|
|
|
|
{ return key == element.pressed_as; });
|
2022-05-17 00:22:18 -04:00
|
|
|
}
|