#pragma once

#include "../../entity.hpp"

#include "area_manager.hpp"
#include "text.hpp"

#include <optional>

namespace game::state::play
{
  class ItemManager
  {
  public:
    static constexpr auto LIMIT = 100;

    bool isDisabled{};
    bool isAutomation{};
    std::vector<Entity> items{};
    int heldItemIndex{-1};
    int queuedRemoveItemIndex{-1};

    bool isItemHovered{};
    bool isItemHoveredPrevious{};
    bool isJustItemHoveredStopped{};

    bool isItemHeld{};
    bool isItemHeldPrevious{};
    bool isJustItemHeldStopped{};
    bool isJustItemHeld{};
    bool isJustItemThrown{};

    bool isQueueFinishFood{};

    bool isItemFinished{};

    glm::vec2 cursorPositionPrevious{};
    glm::vec2 cursorDeltaPrevious{};

    std::vector<int> queuedItemIDs{};
    std::vector<int> returnItemIDs{};

    struct Particle
    {
      std::string label{};
      glm::vec2 position{};
    };

    struct Input
    {
      bool isImguiCaptureMouse{};
      bool isMouseLeftClicked{};
      bool isMouseLeftDown{};
      bool isMouseLeftReleased{};
      bool isMouseRightClicked{};
      bool isMouseRightDown{};
      bool isAutomation{};
    };

    std::optional<Input> inputOverride{};
    std::vector<Particle> particles{};

    void update(Entity&, Entity&, AreaManager&, Text&, const glm::vec4& bounds, Canvas&);
  };
}
