#pragma once

#include <set>
#include <string>
#include <vector>

#include "adapters/il2cpp/Il2CppObjectInstance.h"
#include "adapters/unity/chams/ChamsSupport.h"

namespace ta::adapters::unity::chams
{
class NpcChamsService
{
public:
    void update(const Il2CppClass* game_world_class,
                const Il2CppImage* unity_image,
                ta::adapters::il2cpp::Il2CppObjectInstance game_world_instance,
                const std::string& main_nickname,
                const ChamsConfigSnapshot& config);

    void reset();
    void discard_session() noexcept;

private:
    struct Signature
    {
        bool npc_chams = false;
        bool gear_chams = false;
        int chams_type = 0;
        ta::foundation::RgbaColor visible_color{};
        ta::foundation::RgbaColor invisible_color{};

        bool operator==(const Signature&) const = default;
    };

    std::set<size_t> applied_npcs{};
    std::vector<ChamsMaterialState> original_materials_{};
    Signature cached_signature_{};

    static Signature make_signature(const ChamsConfigSnapshot& config);
    void restore_all();
};
}
