2021-11-23 19:35:13 +01:00
|
|
|
#include "mockclassicnote.h"
|
2021-12-21 18:07:19 +01:00
|
|
|
#include "game/classicgraphicsmanager.h"
|
2021-11-24 19:21:30 +01:00
|
|
|
|
|
|
|
// Replace with interface by dependency injection
|
|
|
|
#include "graphics/classicflyinganimationscenario.h"
|
|
|
|
#include "graphics/classicdyinganimationscenario.h"
|
|
|
|
//
|
|
|
|
|
2021-12-06 20:18:04 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
2021-11-24 19:21:30 +01:00
|
|
|
// A LOT OF CODE DUPLICATES game/arrowclassicnote, DO SOMETHING D:<
|
2021-11-23 19:35:13 +01:00
|
|
|
|
|
|
|
MockClassicNote::MockClassicNote(MockArrowNoteInitializer&& init) :
|
2021-11-24 19:21:30 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-08 19:00:47 +01:00
|
|
|
bool MockClassicNote::isActive(const microsec& offset) const
|
2021-11-24 19:21:30 +01:00
|
|
|
{
|
2021-12-08 19:00:47 +01:00
|
|
|
return offset == Note::offset();
|
2021-11-24 19:21:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MockClassicNote::isInGame() const
|
|
|
|
{
|
|
|
|
return _state == State::FLYING
|
|
|
|
|| _state == State::DYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MockClassicNote::shouldRemove() const
|
|
|
|
{
|
2021-12-08 19:00:47 +01:00
|
|
|
return _state == State::DEAD
|
|
|
|
|| _state == State::NONE;
|
2021-11-24 19:21:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MockClassicNote::putToGame(const microsec &music_offset)
|
|
|
|
{
|
2021-12-08 19:00:47 +01:00
|
|
|
_state = State::FLYING; (void)music_offset;
|
2021-11-24 19:21:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|