#include "mockclassicnote.h" #include "game/classicgraphicsmanager.h" // Replace with interface by dependency injection #include "graphics/classicflyinganimationscenario.h" #include "graphics/classicdyinganimationscenario.h" // #include // A LOT OF CODE DUPLICATES game/arrowclassicnote, DO SOMETHING D:< MockClassicNote::MockClassicNote(MockArrowNoteInitializer&& init) : Note(init.initializer.perfect_offset), _state(State::NONE), _context(init.initializer.context) { _elements.resize(init.elements.size()); for (std::size_t i = 0; i < _elements.size(); ++i) { _elements[i].coordinates = init.elements[i].coordinates; _elements[i].type = init.elements[i].type; } } bool MockClassicNote::isActive(const microsec& offset) const { return offset == Note::offset(); } bool MockClassicNote::isInGame() const { return _state == State::FLYING || _state == State::DYING; } bool MockClassicNote::shouldRemove() const { return _state == State::DEAD || _state == State::NONE; } void MockClassicNote::putToGame(const microsec &music_offset) { _state = State::FLYING; (void)music_offset; } void MockClassicNote::update(const microsec &music_offset) { switch (_state) { default: return; break; case State::FLYING: if (music_offset > offset()) _state = State::DEAD; break; } for (auto& element : _elements) if (element.animations[_state]) element.animations[_state]->update(music_offset); }