#pragma once

#include <list>
#include <set>
#include "buttonManager.h"
#include "note.hpp"
#include "defs.hpp"

namespace game {

class NoteManager
{
private:
    std::list<noteInfo*> *timeline;
    std::list<noteInfo*>::iterator cursor;
    std::list<Note*> activeNotes;
    std::list<Note*> visibleNotes;
    std::set<Note*> notesForRemove;

    Level *root;

    buttonState controlState;

    bool playing = false;

    float startTime;
    float currentTime;
    float songLength;
    bool shouldChangeState;
    bool longActive;
public:

    NoteManager(Level *root);
    //~NoteManager();

    void Load(std::list<noteInfo*>*);

    void Start();
    void Pause();
    void Reset(float songLength);

    float GetTime() const noexcept {
        return currentTime;
    }

    void RemoveNote(Note*);

    void Update(const buttonState &state);
    void Render();
private:
    void UpdateNoteList();
    void UpdateNoteAction();
    void CreateNote(noteInfo*);
};


}
