#pragma once // Metin2Proto — GDExtension node exposing item_proto / mob_proto to GDScript. // // var proto = Metin2Proto.new() // proto.load_item_proto("/locale/locale/en/item_proto") // var d := proto.item(19) # { vnum, name, locale_name, type, sub_type, ... } // // Used by the P2 inventory/equipment windows for names / types / tooltips and by // the equip->model path. #include #include #include #include #include #include #include "proto.h" namespace mtgodot { class Metin2Proto : public godot::Node { GDCLASS(Metin2Proto, godot::Node) public: bool load_item_proto(const godot::String &path); bool load_mob_proto(const godot::String &path); godot::Dictionary item(int vnum) const; godot::Dictionary mob(int vnum) const; int item_count() const { return (int)m_item.elements; } int mob_count() const { return (int)m_mob.elements; } godot::String get_last_error() const { return last_error; } protected: static void _bind_methods(); private: mtproto::Proto m_item; mtproto::Proto m_mob; std::unordered_map m_item_ix; // vnum -> record index std::unordered_map m_mob_ix; godot::String last_error; }; } // namespace mtgodot