diff --git a/inventory/bag.cpp b/inventory/bag.cpp index eb47879..8aff7d0 100644 --- a/inventory/bag.cpp +++ b/inventory/bag.cpp @@ -3,6 +3,14 @@ #include "../data/item_template.h" #include "../data/item_instance.h" +int Bag::get_allowed_item_types() const { + return _allowed_item_types; +} + +void Bag::set_allowed_item_types(const int value) { + _allowed_item_types = value; +} + bool Bag::add_item(Ref item) { ERR_FAIL_COND_V(!item.is_valid(), true); @@ -239,6 +247,8 @@ void Bag::set_size(const int x, const int y) { } Bag::Bag() { + _allowed_item_types = 0x1FFF; + _size_x = 0; _size_y = 0; } @@ -249,6 +259,10 @@ Bag::~Bag() { } void Bag::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_allowed_item_types"), &Bag::get_allowed_item_types); + ClassDB::bind_method(D_METHOD("set_allowed_item_types", "count"), &Bag::set_allowed_item_types); + ADD_PROPERTY(PropertyInfo(Variant::INT, "allowed_item_types", PROPERTY_HINT_FLAGS, ItemEnums::BINDING_STRING_ITEM_TYPE_FLAGS), "set_allowed_item_types", "get_allowed_item_types"); + ClassDB::bind_method(D_METHOD("add_item", "item"), &Bag::add_item); ClassDB::bind_method(D_METHOD("add_item_to_position", "x", "y", "item"), &Bag::add_item_to_position); diff --git a/inventory/bag.h b/inventory/bag.h index 4ce6f05..6398d8d 100644 --- a/inventory/bag.h +++ b/inventory/bag.h @@ -4,6 +4,8 @@ #include "core/reference.h" #include "core/vector.h" +#include "../item_enums.h" + class itemTemplate; class ItemInstance; @@ -11,6 +13,9 @@ class Bag : public Reference { GDCLASS(Bag, Reference); public: + int get_allowed_item_types() const; + void set_allowed_item_types(const int value); + bool add_item(Ref item); bool add_item_to_position(const int x, const int y, Ref item); @@ -44,6 +49,8 @@ protected: static void _bind_methods(); private: + int _allowed_item_types; + int _size_x; int _size_y; diff --git a/item_enums.cpp b/item_enums.cpp index 494f8ac..cd3fa8b 100644 --- a/item_enums.cpp +++ b/item_enums.cpp @@ -4,5 +4,6 @@ const String ItemEnums::BINDING_STRING_RARITY = "None,Common,Uncommon,Superior,Heroic,Mythic,Artifact"; const String ItemEnums::BINDING_STRING_RARITY_FLAG = "Common,Uncommon,Superior,Heroic,Mythic,Artifact"; const String ItemEnums::BINDING_STRING_ITEM_TYPE = "None,Equipment,Weapon,Potion,Herb,Ore,Gemstone,Food,Alchemy,Engineering,Enchanting,Tailoring,Recipe,Currency,Bag"; +const String ItemEnums::BINDING_STRING_ITEM_TYPE_FLAGS = "Equipment,Weapon,Potion,Herb,Ore,Gemstone,Food,Alchemy,Engineering,Enchanting,Tailoring,Recipe,Currency,Bag"; const String ItemEnums::BINDING_STRING_ITEM_SUB_TYPE = "None,Sword,Axe,Mace,Dagger,Bow,Crossbow,Gun,Quest Item"; const String ItemEnums::BINDING_STRING_ITEM_SUB_SUB_TYPE = "None,Two Hand,One Hand,Left Hand,Right Hand"; diff --git a/item_enums.h b/item_enums.h index 3eb7648..45bc25d 100644 --- a/item_enums.h +++ b/item_enums.h @@ -10,6 +10,7 @@ public: static const String BINDING_STRING_RARITY; static const String BINDING_STRING_RARITY_FLAG; static const String BINDING_STRING_ITEM_TYPE; + static const String BINDING_STRING_ITEM_TYPE_FLAGS; static const String BINDING_STRING_ITEM_SUB_TYPE; static const String BINDING_STRING_ITEM_SUB_SUB_TYPE;