mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-22 17:18:12 +01:00
Work on fleshing out the inventory system.
This commit is contained in:
parent
38b155d4ad
commit
895525a998
1
SCsub
1
SCsub
@ -36,7 +36,6 @@ module_env.add_source_files(env.modules_sources,"entities/stats/stat_modifier.cp
|
|||||||
module_env.add_source_files(env.modules_sources,"entities/stats/stat_data.cpp")
|
module_env.add_source_files(env.modules_sources,"entities/stats/stat_data.cpp")
|
||||||
|
|
||||||
module_env.add_source_files(env.modules_sources,"entities/player_talent.cpp")
|
module_env.add_source_files(env.modules_sources,"entities/player_talent.cpp")
|
||||||
module_env.add_source_files(env.modules_sources,"inventory/bag_slot.cpp")
|
|
||||||
module_env.add_source_files(env.modules_sources,"inventory/bag.cpp")
|
module_env.add_source_files(env.modules_sources,"inventory/bag.cpp")
|
||||||
|
|
||||||
module_env.add_source_files(env.modules_sources,"infos/aura_infos.cpp")
|
module_env.add_source_files(env.modules_sources,"infos/aura_infos.cpp")
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include "item_instance.h"
|
#include "item_instance.h"
|
||||||
|
|
||||||
#if ENTITY_MEM_TOOLS
|
#include "item_template.h"
|
||||||
int ItemInstance::allocs = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int ItemInstance::get_id() {
|
int ItemInstance::get_id() {
|
||||||
return _id;
|
return _id;
|
||||||
@ -12,97 +10,25 @@ void ItemInstance::set_id(int value) {
|
|||||||
_id = value;
|
_id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ItemInstance::get_name_key() {
|
int ItemInstance::get_inventory_position_x() const {
|
||||||
return _name_key;
|
return _inventory_position_x;
|
||||||
|
}
|
||||||
|
void ItemInstance::set_inventory_position_x(const int value) {
|
||||||
|
_inventory_position_x = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemInstance::set_name_key(String value) {
|
int ItemInstance::get_inventory_position_y() const {
|
||||||
_name_key = value;
|
return _inventory_position_y;
|
||||||
|
}
|
||||||
|
void ItemInstance::set_inventory_position_y(const int value) {
|
||||||
|
_inventory_position_y = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemEnums::ItemType ItemInstance::get_item_type() {
|
Ref<ItemTemplate> ItemInstance::get_item_template() const {
|
||||||
return _item_type;
|
return _item_template;
|
||||||
}
|
}
|
||||||
|
void ItemInstance::set_item_template(const Ref<ItemTemplate> value) {
|
||||||
void ItemInstance::set_item_type(ItemEnums::ItemType value) {
|
_item_template = value;
|
||||||
_item_type = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemEnums::ItemSubtype ItemInstance::get_item_sub_type() {
|
|
||||||
return _item_sub_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_item_sub_type(ItemEnums::ItemSubtype value) {
|
|
||||||
_item_sub_type = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemEnums::ItemSubSubtype ItemInstance::get_item_sub_sub_type() {
|
|
||||||
return _item_sub_sub_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_item_sub_sub_type(ItemEnums::ItemSubSubtype value) {
|
|
||||||
_item_sub_sub_type = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemEnums::ItemRarity ItemInstance::get_rarity() {
|
|
||||||
return _rarity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_rarity(ItemEnums::ItemRarity value) {
|
|
||||||
_rarity = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ItemInstance::get_spell_id() {
|
|
||||||
return _spell_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_spell_id(int value) {
|
|
||||||
_spell_id = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ItemInstance::get_scale_x() {
|
|
||||||
return _scale_x;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_scale_x(float value) {
|
|
||||||
_scale_x = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ItemInstance::get_scale_y() {
|
|
||||||
return _scale_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_scale_y(float value) {
|
|
||||||
_scale_y = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ItemInstance::get_scale_z() {
|
|
||||||
return _scale_z;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_scale_z(float value) {
|
|
||||||
_scale_z = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<Texture> ItemInstance::get_icon() {
|
|
||||||
return _icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemInstance::set_icon(Ref<Texture> value) {
|
|
||||||
_icon = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ItemInstance::get_animator_weapon_type() {
|
|
||||||
if (_item_sub_type == ItemEnums::ITEM_SUB_TYPE_SWORD) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (_item_sub_type == ItemEnums::ITEM_SUB_TYPE_BOW) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if (_item_sub_type == ItemEnums::ITEM_SUB_TYPE_AXE) {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ItemStatModifier> ItemInstance::get_item_stat_modifier(int index) {
|
Ref<ItemStatModifier> ItemInstance::get_item_stat_modifier(int index) {
|
||||||
@ -153,34 +79,30 @@ void ItemInstance::set_percent_mod(int index, float value) {
|
|||||||
_modifiers[index]->set_percent_mod(value);
|
_modifiers[index]->set_percent_mod(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ItemInstance::get_count() {
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemInstance::set_count(int value) {
|
||||||
|
_count = value;
|
||||||
|
}
|
||||||
|
|
||||||
ItemInstance::ItemInstance() {
|
ItemInstance::ItemInstance() {
|
||||||
_id = 0;
|
_id = 0;
|
||||||
_name_key = "";
|
|
||||||
_item_type = ItemEnums::ITEM_TYPE_NONE;
|
_s_bag = NULL;
|
||||||
_item_sub_type = ItemEnums::ITEM_SUB_TYPE_NONE;
|
_c_bag = NULL;
|
||||||
_item_sub_sub_type = ItemEnums::ITEM_SUB_SUB_TYPE_NONE;
|
|
||||||
_rarity = ItemEnums::ITEM_RARITY_UNCOMMON;
|
_count = 0;
|
||||||
_spell_id = 0;
|
|
||||||
_scale_x = 0;
|
|
||||||
_scale_y = 0;
|
|
||||||
_scale_z = 0;
|
|
||||||
_modifier_count = 0;
|
_modifier_count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_ITEM_STAT_MOD; ++i) {
|
for (int i = 0; i < MAX_ITEM_STAT_MOD; ++i) {
|
||||||
_modifiers[i] = Ref<ItemStatModifier>(memnew(ItemStatModifier()));
|
_modifiers[i] = Ref<ItemStatModifier>(memnew(ItemStatModifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENTITY_MEM_TOOLS
|
|
||||||
ItemInstance::allocs++;
|
|
||||||
print_error("ItemInstance alloc " + String::num(ItemInstance::allocs));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemInstance::~ItemInstance() {
|
ItemInstance::~ItemInstance() {
|
||||||
#if ENTITY_MEM_TOOLS
|
|
||||||
ItemInstance::allocs--;
|
|
||||||
print_error("ItemInstance dealloc " + String::num(ItemInstance::allocs));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemInstance::_validate_property(PropertyInfo &property) const {
|
void ItemInstance::_validate_property(PropertyInfo &property) const {
|
||||||
@ -200,49 +122,22 @@ void ItemInstance::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_id", "count"), &ItemInstance::set_id);
|
ClassDB::bind_method(D_METHOD("set_id", "count"), &ItemInstance::set_id);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_name_key"), &ItemInstance::get_name_key);
|
ClassDB::bind_method(D_METHOD("get_inventory_position_x"), &ItemInstance::get_inventory_position_x);
|
||||||
ClassDB::bind_method(D_METHOD("set_name_key", "count"), &ItemInstance::set_name_key);
|
ClassDB::bind_method(D_METHOD("set_inventory_position_x", "value"), &ItemInstance::set_inventory_position_x);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "name_key"), "set_name_key", "get_name_key");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "inventory_position_x"), "set_inventory_position_x", "get_inventory_position_x");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_item_type"), &ItemInstance::get_item_type);
|
ClassDB::bind_method(D_METHOD("get_inventory_position_y"), &ItemInstance::get_inventory_position_y);
|
||||||
ClassDB::bind_method(D_METHOD("set_item_type", "count"), &ItemInstance::set_item_type);
|
ClassDB::bind_method(D_METHOD("set_inventory_position_y", "value"), &ItemInstance::set_inventory_position_y);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "item_type", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ITEM_TYPE), "set_item_type", "get_item_type");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "inventory_position_y"), "set_inventory_position_y", "get_inventory_position_y");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_item_sub_type"), &ItemInstance::get_item_sub_type);
|
ClassDB::bind_method(D_METHOD("get_item_template"), &ItemInstance::get_item_template);
|
||||||
ClassDB::bind_method(D_METHOD("set_item_sub_type", "count"), &ItemInstance::set_item_sub_type);
|
ClassDB::bind_method(D_METHOD("set_item_template", "value"), &ItemInstance::set_item_template);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "item_sub_type", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ITEM_SUB_TYPE), "set_item_sub_type", "get_item_sub_type");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_item_sub_sub_type"), &ItemInstance::get_item_sub_sub_type);
|
ClassDB::bind_method(D_METHOD("get_count"), &ItemInstance::get_count);
|
||||||
ClassDB::bind_method(D_METHOD("set_item_sub_sub_type", "count"), &ItemInstance::set_item_sub_sub_type);
|
ClassDB::bind_method(D_METHOD("set_count", "count"), &ItemInstance::set_count);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "item_sub_sub_type", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ITEM_SUB_SUB_TYPE), "set_item_sub_sub_type", "get_item_sub_sub_type");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "ount"), "set_count", "get_count");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_rarity"), &ItemInstance::get_rarity);
|
ClassDB::bind_method(D_METHOD("get_item_stat_modifier", "index"), &ItemInstance::get_item_stat_modifier);
|
||||||
ClassDB::bind_method(D_METHOD("set_rarity", "count"), &ItemInstance::set_rarity);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rarity", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_RARITY), "set_rarity", "get_rarity");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_spell_id"), &ItemInstance::get_spell_id);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_spell_id", "count"), &ItemInstance::set_spell_id);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "spell_id"), "set_spell_id", "get_spell_id");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_scale_x"), &ItemInstance::get_scale_x);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_scale_x", "count"), &ItemInstance::set_scale_x);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_x"), "set_scale_x", "get_scale_x");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_scale_y"), &ItemInstance::get_scale_y);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_scale_y", "count"), &ItemInstance::set_scale_y);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_y"), "set_scale_y", "get_scale_y");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_scale_z"), &ItemInstance::get_scale_z);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_scale_z", "count"), &ItemInstance::set_scale_z);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_z"), "set_scale_z", "get_scale_z");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_icon"), &ItemInstance::get_icon);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_icon", "count"), &ItemInstance::set_icon);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_icon", "get_icon");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_animator_weapon_type"), &ItemInstance::get_animator_weapon_type);
|
|
||||||
|
|
||||||
//ClassDB::bind_method(D_METHOD("get_item_stat_modifier", "index"), &ItemInstance::get_item_stat_modifier);
|
|
||||||
//ClassDB::bind_method(D_METHOD("set_item_stat_modifier", "index", "value"), &ItemInstance::set_item_stat_modifier);
|
//ClassDB::bind_method(D_METHOD("set_item_stat_modifier", "index", "value"), &ItemInstance::set_item_stat_modifier);
|
||||||
|
|
||||||
//StatMods Property binds
|
//StatMods Property binds
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#include "../entities/stats/stat.h"
|
#include "../entities/stats/stat.h"
|
||||||
#include "../item_enums.h"
|
#include "../item_enums.h"
|
||||||
|
|
||||||
|
class Bag;
|
||||||
|
class ItemTemplate;
|
||||||
|
|
||||||
class ItemInstance : public Reference {
|
class ItemInstance : public Reference {
|
||||||
GDCLASS(ItemInstance, Reference);
|
GDCLASS(ItemInstance, Reference);
|
||||||
|
|
||||||
@ -15,37 +18,14 @@ public:
|
|||||||
int get_id();
|
int get_id();
|
||||||
void set_id(int value);
|
void set_id(int value);
|
||||||
|
|
||||||
String get_name_key();
|
int get_inventory_position_x() const;
|
||||||
void set_name_key(String value);
|
void set_inventory_position_x(const int value);
|
||||||
|
|
||||||
ItemEnums::ItemType get_item_type();
|
int get_inventory_position_y() const;
|
||||||
void set_item_type(ItemEnums::ItemType value);
|
void set_inventory_position_y(const int value);
|
||||||
|
|
||||||
ItemEnums::ItemSubtype get_item_sub_type();
|
Ref<ItemTemplate> get_item_template() const;
|
||||||
void set_item_sub_type(ItemEnums::ItemSubtype value);
|
void set_item_template(const Ref<ItemTemplate> value);
|
||||||
|
|
||||||
ItemEnums::ItemSubSubtype get_item_sub_sub_type();
|
|
||||||
void set_item_sub_sub_type(ItemEnums::ItemSubSubtype value);
|
|
||||||
|
|
||||||
ItemEnums::ItemRarity get_rarity();
|
|
||||||
void set_rarity(ItemEnums::ItemRarity value);
|
|
||||||
|
|
||||||
int get_spell_id();
|
|
||||||
void set_spell_id(int value);
|
|
||||||
|
|
||||||
float get_scale_x();
|
|
||||||
void set_scale_x(float value);
|
|
||||||
|
|
||||||
float get_scale_y();
|
|
||||||
void set_scale_y(float value);
|
|
||||||
|
|
||||||
float get_scale_z();
|
|
||||||
void set_scale_z(float value);
|
|
||||||
|
|
||||||
Ref<Texture> get_icon();
|
|
||||||
void set_icon(Ref<Texture> value);
|
|
||||||
|
|
||||||
int get_animator_weapon_type();
|
|
||||||
|
|
||||||
Ref<ItemStatModifier> get_item_stat_modifier(int index);
|
Ref<ItemStatModifier> get_item_stat_modifier(int index);
|
||||||
//void set_item_stat_modifier(int index, ItemStatModifier modifier);
|
//void set_item_stat_modifier(int index, ItemStatModifier modifier);
|
||||||
@ -65,6 +45,12 @@ public:
|
|||||||
float get_percent_mod(int index);
|
float get_percent_mod(int index);
|
||||||
void set_percent_mod(int index, float value);
|
void set_percent_mod(int index, float value);
|
||||||
|
|
||||||
|
int get_count();
|
||||||
|
void set_count(int value);
|
||||||
|
|
||||||
|
//to_dict();
|
||||||
|
//from_dict();
|
||||||
|
|
||||||
ItemInstance();
|
ItemInstance();
|
||||||
~ItemInstance();
|
~ItemInstance();
|
||||||
|
|
||||||
@ -78,23 +64,20 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
int _id;
|
int _id;
|
||||||
String _name_key;
|
|
||||||
ItemEnums::ItemType _item_type;
|
int _inventory_position_x;
|
||||||
ItemEnums::ItemSubtype _item_sub_type;
|
int _inventory_position_y;
|
||||||
ItemEnums::ItemSubSubtype _item_sub_sub_type;
|
|
||||||
ItemEnums::ItemRarity _rarity;
|
int _item_tamplate_id;
|
||||||
int _spell_id;
|
Ref<ItemTemplate> _item_template;
|
||||||
float _scale_x;
|
|
||||||
float _scale_y;
|
int _count;
|
||||||
float _scale_z;
|
|
||||||
Ref<Texture> _icon;
|
Ref<Bag> *_s_bag;
|
||||||
|
Ref<Bag> *_c_bag;
|
||||||
|
|
||||||
int _modifier_count;
|
int _modifier_count;
|
||||||
Ref<ItemStatModifier> _modifiers[MAX_ITEM_STAT_MOD];
|
Ref<ItemStatModifier> _modifiers[MAX_ITEM_STAT_MOD];
|
||||||
|
|
||||||
#if ENTITY_MEM_TOOLS
|
|
||||||
static int allocs;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,117 +1,140 @@
|
|||||||
#include "item_template.h"
|
#include "item_template.h"
|
||||||
|
|
||||||
|
#include "item_instance.h"
|
||||||
#include "aura.h"
|
#include "aura.h"
|
||||||
#include "spell.h"
|
#include "spell.h"
|
||||||
|
#include "../inventory/bag.h"
|
||||||
|
|
||||||
int ItemTemplate::get_id() {
|
int ItemTemplate::get_id() const {
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_id(int value) {
|
void ItemTemplate::set_id(const int value) {
|
||||||
_id = value;
|
_id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ItemTemplate::get_name_key() {
|
String ItemTemplate::get_name_key() const {
|
||||||
return _name_key;
|
return _name_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_name_key(String value) {
|
void ItemTemplate::set_name_key(const String value) {
|
||||||
_name_key = value;
|
_name_key = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemEnums::ItemType ItemTemplate::get_item_type() {
|
ItemEnums::ItemType ItemTemplate::get_item_type() const {
|
||||||
return _item_type;
|
return _item_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_item_type(ItemEnums::ItemType value) {
|
void ItemTemplate::set_item_type(const ItemEnums::ItemType value) {
|
||||||
_item_type = value;
|
_item_type = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemEnums::ItemSubtype ItemTemplate::get_item_sub_type() {
|
ItemEnums::ItemSubtype ItemTemplate::get_item_sub_type() const {
|
||||||
return _item_sub_type;
|
return _item_sub_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_item_sub_type(ItemEnums::ItemSubtype value) {
|
void ItemTemplate::set_item_sub_type(const ItemEnums::ItemSubtype value) {
|
||||||
_item_sub_type = value;
|
_item_sub_type = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemEnums::ItemSubSubtype ItemTemplate::get_item_sub_sub_type() {
|
ItemEnums::ItemSubSubtype ItemTemplate::get_item_sub_sub_type() const {
|
||||||
return _item_sub_sub_type;
|
return _item_sub_sub_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_item_sub_sub_type(ItemEnums::ItemSubSubtype value) {
|
void ItemTemplate::set_item_sub_sub_type(const ItemEnums::ItemSubSubtype value) {
|
||||||
_item_sub_sub_type = value;
|
_item_sub_sub_type = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemTemplate::get_rarity() {
|
ItemEnums::ItemRarity ItemTemplate::get_rarity() const {
|
||||||
return _rarity;
|
return _rarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_rarity(int value) {
|
void ItemTemplate::set_rarity(const ItemEnums::ItemRarity value) {
|
||||||
_rarity = value;
|
_rarity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Texture> ItemTemplate::get_icon() {
|
int ItemTemplate::get_inventory_size_x() const {
|
||||||
|
return _inventory_size_x;
|
||||||
|
}
|
||||||
|
void ItemTemplate::set_inventory_size_x(const int value) {
|
||||||
|
_inventory_size_x = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ItemTemplate::get_inventory_size_y() const {
|
||||||
|
return _inventory_size_y;
|
||||||
|
}
|
||||||
|
void ItemTemplate::set_inventory_size_y(const int value) {
|
||||||
|
_inventory_size_y = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Texture> ItemTemplate::get_icon() const {
|
||||||
return _icon;
|
return _icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_icon(Ref<Texture> value) {
|
void ItemTemplate::set_icon(const Ref<Texture> value) {
|
||||||
_icon = value;
|
_icon = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ItemTemplate::get_scale_x() {
|
float ItemTemplate::get_scale_x() const {
|
||||||
return _scale_x;
|
return _scale_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_scale_x(float value) {
|
void ItemTemplate::set_scale_x(const float value) {
|
||||||
_scale_x = value;
|
_scale_x = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ItemTemplate::get_scale_y() {
|
float ItemTemplate::get_scale_y() const {
|
||||||
return _scale_y;
|
return _scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_scale_y(float value) {
|
void ItemTemplate::set_scale_y(const float value) {
|
||||||
_scale_y = value;
|
_scale_y = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ItemTemplate::get_scale_z() {
|
float ItemTemplate::get_scale_z() const {
|
||||||
return _scale_z;
|
return _scale_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_scale_z(float value) {
|
void ItemTemplate::set_scale_z(const float value) {
|
||||||
_scale_z = value;
|
_scale_z = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Spell> ItemTemplate::get_spell() {
|
int ItemTemplate::get_bag_size() const {
|
||||||
|
return _bag_size;
|
||||||
|
}
|
||||||
|
void ItemTemplate::set_bag_size(const int size) {
|
||||||
|
_bag_size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Spell> ItemTemplate::get_spell() const {
|
||||||
if (_spell)
|
if (_spell)
|
||||||
return (*_spell);
|
return (*_spell);
|
||||||
|
|
||||||
return Ref<Spell>(NULL);
|
return Ref<Spell>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_spell(Ref<Spell> spell) {
|
void ItemTemplate::set_spell(const Ref<Spell> spell) {
|
||||||
if (_spell)
|
if (_spell)
|
||||||
memdelete(_spell);
|
memdelete(_spell);
|
||||||
|
|
||||||
_spell = memnew(Ref<Spell>(spell));
|
_spell = memnew(Ref<Spell>(spell));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Aura> ItemTemplate::get_aura(int index) {
|
Ref<Aura> ItemTemplate::get_aura(const int index) const {
|
||||||
if (_auras[index])
|
if (_auras[index])
|
||||||
return (*_auras[index]);
|
return (*_auras[index]);
|
||||||
|
|
||||||
return Ref<Aura>(NULL);
|
return Ref<Aura>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemTemplate::set_aura(int index, Ref<Aura> aura) {
|
void ItemTemplate::set_aura(const int index, const Ref<Aura> aura) {
|
||||||
if (_auras[index])
|
if (_auras[index])
|
||||||
memdelete(_auras[index]);
|
memdelete(_auras[index]);
|
||||||
|
|
||||||
_auras[index] = memnew(Ref<Aura>(aura));
|
_auras[index] = memnew(Ref<Aura>(aura));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemTemplate::get_item_stat_modifier_count() {
|
int ItemTemplate::get_item_stat_modifier_count() const {
|
||||||
return _modifier_count;
|
return _modifier_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,6 +259,10 @@ ItemTemplate::ItemTemplate() {
|
|||||||
_scale_z = 0;
|
_scale_z = 0;
|
||||||
_modifier_count = 0;
|
_modifier_count = 0;
|
||||||
|
|
||||||
|
_inventory_size_x = 0;
|
||||||
|
_inventory_size_y = 0;
|
||||||
|
_bag_size = 0;
|
||||||
|
|
||||||
_spell = NULL;
|
_spell = NULL;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_AURAS; ++i) {
|
for (int i = 0; i < MAX_AURAS; ++i) {
|
||||||
@ -297,6 +324,14 @@ void ItemTemplate::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_rarity", "count"), &ItemTemplate::set_rarity);
|
ClassDB::bind_method(D_METHOD("set_rarity", "count"), &ItemTemplate::set_rarity);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rarity", PROPERTY_HINT_FLAGS, ItemEnums::BINDING_STRING_RARITY), "set_rarity", "get_rarity");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "rarity", PROPERTY_HINT_FLAGS, ItemEnums::BINDING_STRING_RARITY), "set_rarity", "get_rarity");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_inventory_size_x"), &ItemTemplate::get_inventory_size_x);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_inventory_size_x", "value"), &ItemTemplate::set_inventory_size_x);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "inventory_size_x"), "set_inventory_size_x", "get_inventory_size_x");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_inventory_size_y"), &ItemTemplate::get_inventory_size_y);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_inventory_size_y", "value"), &ItemTemplate::set_inventory_size_y);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "inventory_size_y"), "set_inventory_size_y", "get_inventory_size_y");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_icon"), &ItemTemplate::get_icon);
|
ClassDB::bind_method(D_METHOD("get_icon"), &ItemTemplate::get_icon);
|
||||||
ClassDB::bind_method(D_METHOD("set_icon", "value"), &ItemTemplate::set_icon);
|
ClassDB::bind_method(D_METHOD("set_icon", "value"), &ItemTemplate::set_icon);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_icon", "get_icon");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_icon", "get_icon");
|
||||||
@ -313,6 +348,10 @@ void ItemTemplate::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_scale_z", "count"), &ItemTemplate::set_scale_z);
|
ClassDB::bind_method(D_METHOD("set_scale_z", "count"), &ItemTemplate::set_scale_z);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_z"), "set_scale_z", "get_scale_z");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_z"), "set_scale_z", "get_scale_z");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_bag_size"), &ItemTemplate::get_bag_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_bag_size", "size"), &ItemTemplate::set_bag_size);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "bag_size"), "set_bag_size", "get_bag_size");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_spell"), &ItemTemplate::get_spell);
|
ClassDB::bind_method(D_METHOD("get_spell"), &ItemTemplate::get_spell);
|
||||||
ClassDB::bind_method(D_METHOD("set_spell", "spell"), &ItemTemplate::set_spell);
|
ClassDB::bind_method(D_METHOD("set_spell", "spell"), &ItemTemplate::set_spell);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_spell", "get_spell");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_spell", "get_spell");
|
||||||
|
@ -8,59 +8,64 @@
|
|||||||
#include "../entities/stats/stat.h"
|
#include "../entities/stats/stat.h"
|
||||||
#include "../item_enums.h"
|
#include "../item_enums.h"
|
||||||
|
|
||||||
#include "item_instance.h"
|
class ItemInstance;
|
||||||
|
|
||||||
class Aura;
|
class Aura;
|
||||||
class Spell;
|
class Spell;
|
||||||
|
class Bag;
|
||||||
|
|
||||||
class ItemTemplate : public Resource {
|
class ItemTemplate : public Resource {
|
||||||
GDCLASS(ItemTemplate, Resource);
|
GDCLASS(ItemTemplate, Resource);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int get_id();
|
int get_id() const;
|
||||||
void set_id(int value);
|
void set_id(const int value);
|
||||||
|
|
||||||
String get_name_key();
|
String get_name_key() const;
|
||||||
void set_name_key(String value);
|
void set_name_key(const String value);
|
||||||
|
|
||||||
|
ItemEnums::ItemType get_item_type() const;
|
||||||
|
void set_item_type(const ItemEnums::ItemType value);
|
||||||
|
|
||||||
|
ItemEnums::ItemSubtype get_item_sub_type() const;
|
||||||
|
void set_item_sub_type(const ItemEnums::ItemSubtype value);
|
||||||
|
|
||||||
|
ItemEnums::ItemSubSubtype get_item_sub_sub_type() const;
|
||||||
|
void set_item_sub_sub_type(const ItemEnums::ItemSubSubtype value);
|
||||||
|
|
||||||
|
ItemEnums::ItemRarity get_rarity() const;
|
||||||
|
void set_rarity(const ItemEnums::ItemRarity value);
|
||||||
|
|
||||||
|
int get_inventory_size_x() const;
|
||||||
|
void set_inventory_size_x(const int value);
|
||||||
|
|
||||||
|
int get_inventory_size_y() const;
|
||||||
|
void set_inventory_size_y(const int value);
|
||||||
|
|
||||||
|
Ref<Texture> get_icon() const;
|
||||||
|
void set_icon(const Ref<Texture> value);
|
||||||
|
|
||||||
|
float get_scale_x() const;
|
||||||
|
void set_scale_x(const float value);
|
||||||
|
|
||||||
|
float get_scale_y() const;
|
||||||
|
void set_scale_y(const float value);
|
||||||
|
|
||||||
|
float get_scale_z() const;
|
||||||
|
void set_scale_z(const float value);
|
||||||
|
|
||||||
|
int get_bag_size() const;
|
||||||
|
void set_bag_size(const int size);
|
||||||
|
|
||||||
|
Ref<Spell> get_spell() const;
|
||||||
|
void set_spell(const Ref<Spell> spell);
|
||||||
|
|
||||||
|
Ref<Aura> get_aura(int index) const;
|
||||||
|
void set_aura(const int index, const Ref<Aura> aura);
|
||||||
|
|
||||||
|
|
||||||
ItemEnums::ItemType get_item_type();
|
int get_item_stat_modifier_count() const;
|
||||||
void set_item_type(ItemEnums::ItemType value);
|
void set_item_stat_modifier_count(const int value);
|
||||||
|
|
||||||
ItemEnums::ItemSubtype get_item_sub_type();
|
|
||||||
void set_item_sub_type(ItemEnums::ItemSubtype value);
|
|
||||||
|
|
||||||
ItemEnums::ItemSubSubtype get_item_sub_sub_type();
|
|
||||||
void set_item_sub_sub_type(ItemEnums::ItemSubSubtype value);
|
|
||||||
|
|
||||||
int get_rarity();
|
|
||||||
void set_rarity(int value);
|
|
||||||
|
|
||||||
|
|
||||||
Ref<Texture> get_icon();
|
|
||||||
void set_icon(Ref<Texture> value);
|
|
||||||
|
|
||||||
|
|
||||||
float get_scale_x();
|
|
||||||
void set_scale_x(float value);
|
|
||||||
|
|
||||||
float get_scale_y();
|
|
||||||
void set_scale_y(float value);
|
|
||||||
|
|
||||||
float get_scale_z();
|
|
||||||
void set_scale_z(float value);
|
|
||||||
|
|
||||||
|
|
||||||
Ref<Spell> get_spell();
|
|
||||||
void set_spell(Ref<Spell> spell);
|
|
||||||
|
|
||||||
Ref<Aura> get_aura(int index);
|
|
||||||
void set_aura(int index, Ref<Aura> aura);
|
|
||||||
|
|
||||||
|
|
||||||
int get_item_stat_modifier_count();
|
|
||||||
void set_item_stat_modifier_count(int value);
|
|
||||||
|
|
||||||
Stat::StatId get_item_stat_id(int index);
|
Stat::StatId get_item_stat_id(int index);
|
||||||
void set_item_stat_id(int index, Stat::StatId value);
|
void set_item_stat_id(int index, Stat::StatId value);
|
||||||
@ -102,17 +107,22 @@ private:
|
|||||||
|
|
||||||
int _id;
|
int _id;
|
||||||
String _name_key;
|
String _name_key;
|
||||||
int _rarity;
|
ItemEnums::ItemRarity _rarity;
|
||||||
ItemEnums::ItemType _item_type;
|
ItemEnums::ItemType _item_type;
|
||||||
ItemEnums::ItemSubtype _item_sub_type;
|
ItemEnums::ItemSubtype _item_sub_type;
|
||||||
ItemEnums::ItemSubSubtype _item_sub_sub_type;
|
ItemEnums::ItemSubSubtype _item_sub_sub_type;
|
||||||
|
|
||||||
|
int _inventory_size_x;
|
||||||
|
int _inventory_size_y;
|
||||||
|
|
||||||
Ref<Texture> _icon;
|
Ref<Texture> _icon;
|
||||||
|
|
||||||
float _scale_x;
|
float _scale_x;
|
||||||
float _scale_y;
|
float _scale_y;
|
||||||
float _scale_z;
|
float _scale_z;
|
||||||
|
|
||||||
|
int _bag_size;
|
||||||
|
|
||||||
Ref<Spell> *_spell;
|
Ref<Spell> *_spell;
|
||||||
Ref<Aura> *_auras[MAX_AURAS];
|
Ref<Aura> *_auras[MAX_AURAS];
|
||||||
|
|
||||||
|
@ -2424,18 +2424,38 @@ PlayerTalent *Entity::cget_talent(int id, bool create) {
|
|||||||
|
|
||||||
//// Inventory ////
|
//// Inventory ////
|
||||||
|
|
||||||
Ref<Bag> Entity::gets_bag(int index) {
|
Ref<Bag> Entity::gets_bag() const {
|
||||||
ERR_FAIL_INDEX_V(index, MAX_BAG_SLOTS, Ref<Bag>());
|
return _s_bag;
|
||||||
|
|
||||||
return _s_bags[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Bag> Entity::getc_bag(int index) {
|
Ref<Bag> Entity::getc_bag() const {
|
||||||
ERR_FAIL_INDEX_V(index, MAX_BAG_SLOTS, Ref<Bag>());
|
return _c_bag;
|
||||||
|
|
||||||
return _c_bags[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Entity::sets_bag(const Ref<Bag> bag) {
|
||||||
|
_s_bag = bag;
|
||||||
|
}
|
||||||
|
void Entity::setc_bag(const Ref<Bag> bag) {
|
||||||
|
_c_bag = bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Bag> Entity::gets_target_bag() const {
|
||||||
|
return _s_target_bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Entity::sets_target_bag(const Ref<Bag> bag) {
|
||||||
|
_s_target_bag = bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Bag> Entity::getc_target_bag() const {
|
||||||
|
return _c_target_bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Entity::setc_target_bag(const Ref<Bag> bag) {
|
||||||
|
_c_target_bag = bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Entity::stry_to_add_item(int itemId, int count) {
|
bool Entity::stry_to_add_item(int itemId, int count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3120,8 +3140,19 @@ void Entity::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("sitem_added", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
ADD_SIGNAL(MethodInfo("sitem_added", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
||||||
ADD_SIGNAL(MethodInfo("citem_added", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
ADD_SIGNAL(MethodInfo("citem_added", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("gets_bag", "index"), &Entity::gets_bag);
|
ClassDB::bind_method(D_METHOD("gets_bag"), &Entity::gets_bag);
|
||||||
ClassDB::bind_method(D_METHOD("getc_bag", "index"), &Entity::getc_bag);
|
ClassDB::bind_method(D_METHOD("getc_bag"), &Entity::getc_bag);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("sets_bag", "bag"), &Entity::sets_bag);
|
||||||
|
ClassDB::bind_method(D_METHOD("setc_bag", "bag"), &Entity::setc_bag);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("gets_target_bag"), &Entity::gets_target_bag);
|
||||||
|
ClassDB::bind_method(D_METHOD("sets_target_bag", "bag"), &Entity::sets_target_bag);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "starget_bag", PROPERTY_HINT_RESOURCE_TYPE, "Bag"), "sets_target_bag", "gets_target_bag");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("getc_target_bag"), &Entity::getc_target_bag);
|
||||||
|
ClassDB::bind_method(D_METHOD("setc_target_bag", "bag"), &Entity::setc_target_bag);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ctarget_bag", PROPERTY_HINT_RESOURCE_TYPE, "Bag"), "setc_target_bag", "getc_target_bag");
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(BACKPACK_SIZE);
|
BIND_ENUM_CONSTANT(BACKPACK_SIZE);
|
||||||
BIND_ENUM_CONSTANT(MAX_BAG_SLOTS);
|
BIND_ENUM_CONSTANT(MAX_BAG_SLOTS);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
#include "core/vector.h"
|
#include "core/vector.h"
|
||||||
#include "../inventory/bag_slot.h"
|
|
||||||
#include "../data/item_instance.h"
|
#include "../data/item_instance.h"
|
||||||
#include "player_talent.h"
|
#include "player_talent.h"
|
||||||
|
|
||||||
@ -461,8 +460,19 @@ public:
|
|||||||
|
|
||||||
//// Inventory ////
|
//// Inventory ////
|
||||||
|
|
||||||
Ref<Bag> gets_bag(int index);
|
Ref<Bag> gets_bag() const;
|
||||||
Ref<Bag> getc_bag(int index);
|
Ref<Bag> getc_bag() const;
|
||||||
|
|
||||||
|
void sets_bag(const Ref<Bag> bag);
|
||||||
|
void setc_bag(const Ref<Bag> bag);
|
||||||
|
|
||||||
|
Ref<Bag> gets_target_bag() const;
|
||||||
|
void sets_target_bag(const Ref<Bag> bag);
|
||||||
|
|
||||||
|
Ref<Bag> getc_target_bag() const;
|
||||||
|
void setc_target_bag(const Ref<Bag> bag);
|
||||||
|
|
||||||
|
bool add_item_to_bag(Ref<ItemInstance> item);
|
||||||
|
|
||||||
bool stry_to_add_item(int itemId, int count);
|
bool stry_to_add_item(int itemId, int count);
|
||||||
bool stry_to_remove_item(int itemId, int count);
|
bool stry_to_remove_item(int itemId, int count);
|
||||||
@ -624,8 +634,11 @@ private:
|
|||||||
|
|
||||||
//// Inventory ////
|
//// Inventory ////
|
||||||
|
|
||||||
Ref<Bag> _s_bags[MAX_BAG_SLOTS];
|
Ref<Bag> _s_bag;
|
||||||
Ref<Bag> _c_bags[MAX_BAG_SLOTS];
|
Ref<Bag> _c_bag;
|
||||||
|
|
||||||
|
Ref<Bag> _s_target_bag;
|
||||||
|
Ref<Bag> _c_target_bag;
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(Entity::InventorySizes);
|
VARIANT_ENUM_CAST(Entity::InventorySizes);
|
||||||
|
@ -1,194 +0,0 @@
|
|||||||
#ifndef STAT_H
|
|
||||||
#define STAT_H
|
|
||||||
|
|
||||||
#include "core/reference.h"
|
|
||||||
#include "core/vector.h"
|
|
||||||
|
|
||||||
|
|
||||||
class StatModifier : public Reference {
|
|
||||||
GDCLASS(StatModifier, Reference);
|
|
||||||
|
|
||||||
public:
|
|
||||||
StatModifier() {
|
|
||||||
}
|
|
||||||
|
|
||||||
StatModifier(int i, float maxM, float percentM) {
|
|
||||||
_id = i;
|
|
||||||
_max_mod = maxM;
|
|
||||||
_percent_mod = percentM;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_id() { return _id; }
|
|
||||||
void set_id(int value) { _id = value; }
|
|
||||||
float get_bonus_mod() { return _max_mod; }
|
|
||||||
void set_bonus_mod(float value) { _max_mod = value; }
|
|
||||||
float get_percent_mod() { return _percent_mod; }
|
|
||||||
void set_percent_mod(float value) { _percent_mod = value; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_id"), &StatModifier::get_id);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_id", "value"), &StatModifier::set_id);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "id"), "set_id", "get_id");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_bonus_mod"), &StatModifier::get_bonus_mod);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_bonus_mod", "value"), &StatModifier::set_bonus_mod);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus_mod"), "set_bonus_mod", "get_bonus_mod");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_percent_mod"), &StatModifier::get_percent_mod);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_percent_mod", "value"), &StatModifier::set_percent_mod);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_mod"), "set_percent_mod", "get_percent_mod");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _id;
|
|
||||||
float _max_mod;
|
|
||||||
float _percent_mod;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Stat : public Reference {
|
|
||||||
GDCLASS(Stat, Reference);
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum StatId {
|
|
||||||
STAT_ID_HEALTH = 0,
|
|
||||||
STAT_ID_SPEED = 1,
|
|
||||||
STAT_ID_MANA = 2,
|
|
||||||
STAT_ID_GLOBAL_COOLDOWN = 3,
|
|
||||||
STAT_ID_HASTE = 4,
|
|
||||||
|
|
||||||
STAT_ID_AGILITY = 5,
|
|
||||||
STAT_ID_STRENGTH = 6,
|
|
||||||
STAT_ID_STAMINA = 7,
|
|
||||||
STAT_ID_INTELLECT = 8,
|
|
||||||
STAT_ID_LUCK = 9, //+crit, + loot
|
|
||||||
|
|
||||||
STAT_ID_HASTE_RATING = 10,
|
|
||||||
STAT_ID_RESLILIENCE = 11,
|
|
||||||
STAT_ID_ARMOR = 12,
|
|
||||||
|
|
||||||
STAT_ID_ATTACK_POWER = 13,
|
|
||||||
STAT_ID_SPELL_POWER = 14,
|
|
||||||
|
|
||||||
STAT_ID_MELEE_CRIT = 15,
|
|
||||||
STAT_ID_MELEE_CRIT_BONUS = 16,
|
|
||||||
STAT_ID_SPELL_CRIT = 17,
|
|
||||||
STAT_ID_SPELL_CRIT_BONUS = 18,
|
|
||||||
STAT_ID_BLOCK = 19,
|
|
||||||
STAT_ID_PARRY = 20,
|
|
||||||
STAT_ID_DAMAGE_REDUCTION = 21,
|
|
||||||
STAT_ID_MELEE_DAMAGE_REDUCTION = 22,
|
|
||||||
STAT_ID_SPELL_DAMAGE_REDUCTION = 23,
|
|
||||||
STAT_ID_DAMAGE_TAKEN = 24,
|
|
||||||
STAT_ID_MELEE_DAMAGE = 25,
|
|
||||||
STAT_ID_SPELL_DAMAGE = 26,
|
|
||||||
|
|
||||||
STAT_ID_HOLY_RESIST = 27,
|
|
||||||
STAT_ID_SHADOW_RESIST = 28,
|
|
||||||
STAT_ID_NATURE_RESIST = 29,
|
|
||||||
STAT_ID_FIRE_RESIST = 30,
|
|
||||||
STAT_ID_FROST_RESIST = 31,
|
|
||||||
STAT_ID_LIGHTNING_RESIST = 32,
|
|
||||||
STAT_ID_CHAOS_RESIST = 33,
|
|
||||||
STAT_ID_SILENCE_RESIST = 34,
|
|
||||||
STAT_ID_FEAR_RESIST = 35,
|
|
||||||
|
|
||||||
STAT_ID_TOTAL_STATS = 36,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum StatModifierApplyType {
|
|
||||||
MODIFIER_APPLY_TYPE_STANDARD,
|
|
||||||
MODIFIER_APPLY_TYPE_ONLY_MIN_MODIFIER,
|
|
||||||
MODIFIER_APPLY_TYPE_ONLY_MAX_MODIFIER,
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
Stat();
|
|
||||||
Stat(int id, StatModifierApplyType modifier_apply_type);
|
|
||||||
Stat(int id, StatModifierApplyType modifier_apply_type, float base, float bonus, float percent);
|
|
||||||
Stat(int id, StatModifierApplyType modifier_apply_type, float base);
|
|
||||||
~Stat();
|
|
||||||
|
|
||||||
int get_id();
|
|
||||||
|
|
||||||
StatModifierApplyType get_stat_modifier_type();
|
|
||||||
void set_stat_modifier_type(StatModifierApplyType value);
|
|
||||||
|
|
||||||
bool get_dirty();
|
|
||||||
void set_dirty(bool value);
|
|
||||||
bool get_disabled();
|
|
||||||
void set_disabled(bool value);
|
|
||||||
|
|
||||||
float get_base();
|
|
||||||
void set_base(float value);
|
|
||||||
float get_bonus();
|
|
||||||
void set_bonus(float value);
|
|
||||||
float get_percent();
|
|
||||||
void set_percent(float value);
|
|
||||||
|
|
||||||
float gets_current();
|
|
||||||
void sets_current(float value);
|
|
||||||
float gets_max();
|
|
||||||
void sets_max(float value);
|
|
||||||
|
|
||||||
float getc_current();
|
|
||||||
void setc_current(float value);
|
|
||||||
float getc_max();
|
|
||||||
void setc_max(float value);
|
|
||||||
|
|
||||||
void reset_values();
|
|
||||||
void recalculate();
|
|
||||||
bool iss_current_zero();
|
|
||||||
bool isc_current_zero();
|
|
||||||
void set(float current, float max, float modCurrent, float modMax, float modPercent);
|
|
||||||
void set_from_stat(Ref<Stat> other);
|
|
||||||
|
|
||||||
void set_to_max();
|
|
||||||
void set_values(float current, float base, float percent);
|
|
||||||
|
|
||||||
void apply_modifier(Ref<StatModifier> modifier);
|
|
||||||
void de_apply_modifier(Ref<StatModifier> modifier);
|
|
||||||
void re_apply_modifier_not_negative_stacking_percents();
|
|
||||||
|
|
||||||
Vector<Ref<StatModifier> > *get_modifiers();
|
|
||||||
void add_modifier(int id, float maxMod, float percentMod, bool apply = true);
|
|
||||||
void remove_modifier(int id, bool apply = true);
|
|
||||||
void re_apply_modifiers();
|
|
||||||
int get_modifier_count();
|
|
||||||
Ref<StatModifier> get_modifier(int index);
|
|
||||||
|
|
||||||
void set_dependency(Ref<Stat> other, Ref<Curve> curve);
|
|
||||||
|
|
||||||
void send();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _id;
|
|
||||||
|
|
||||||
StatModifierApplyType _modifier_apply_type;
|
|
||||||
|
|
||||||
Vector<Ref<StatModifier> > *_modifiers;
|
|
||||||
|
|
||||||
bool _dirty;
|
|
||||||
bool _disabled;
|
|
||||||
|
|
||||||
float _base;
|
|
||||||
float _bonus;
|
|
||||||
float _percent;
|
|
||||||
|
|
||||||
float _s_current;
|
|
||||||
float _s_max;
|
|
||||||
|
|
||||||
float _c_current;
|
|
||||||
float _c_max;
|
|
||||||
|
|
||||||
Ref<Stat> _dependency;
|
|
||||||
Ref<Curve> _dependency_curve;
|
|
||||||
};
|
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(Stat::StatId);
|
|
||||||
VARIANT_ENUM_CAST(Stat::StatModifierApplyType);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,80 +1,275 @@
|
|||||||
#include "bag.h"
|
#include "bag.h"
|
||||||
|
|
||||||
Ref<BagSlot> Bag::get_slot(int index) {
|
#include "../data/item_template.h"
|
||||||
ERR_FAIL_INDEX_V(index, _slots.size(), Ref<BagSlot>(NULL));
|
#include "../data/item_instance.h"
|
||||||
|
|
||||||
return (_slots.get(index));
|
bool Bag::add_item(Ref<ItemInstance> item) {
|
||||||
}
|
ERR_FAIL_COND_V(!item.is_valid(), true);
|
||||||
|
|
||||||
Ref<BagSlot> Bag::get_and_remove_slot(int index) {
|
Ref<ItemTemplate> item_template = item->get_item_template();
|
||||||
ERR_FAIL_INDEX_V(index, _slots.size(), Ref<BagSlot>(NULL));
|
|
||||||
|
|
||||||
Ref<BagSlot> slot = _slots.get(index);
|
ERR_FAIL_COND_V(!item_template.is_valid(), true);
|
||||||
|
|
||||||
_slots.set(index, Ref<BagSlot>(memnew(BagSlot())));
|
int _item_size_x = item_template->get_inventory_size_x();
|
||||||
|
int _item_size_y = item_template->get_inventory_size_y();
|
||||||
|
|
||||||
return slot;
|
for (int x = 0; x < _size_x - _item_size_x; ++x) {
|
||||||
}
|
for (int y = 0; y < _size_y - _item_size_y; ++y) {
|
||||||
|
if (_space_map[x * _size_x + y] == 0) {
|
||||||
|
|
||||||
int Bag::get_slot_count() {
|
bool found = true;
|
||||||
return _slots.size();
|
for (int xx = x; xx < _item_size_x; ++xx) {
|
||||||
}
|
for (int yy = y; yy < _item_size_y; ++yy) {
|
||||||
|
if (_space_map[xx * _size_x + yy] != 0) {
|
||||||
void Bag::set_slot_count(int count) {
|
found = false;
|
||||||
ERR_FAIL_COND(_slots.size() > count);
|
break;
|
||||||
|
}
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
_slots.push_back(Ref<BagSlot>(memnew(BagSlot())));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool Bag::try_to_add_item(Ref<ItemInstance> item, int count) {
|
if (!found)
|
||||||
ERR_FAIL_COND_V(!item.is_valid(), false);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _slots.size(); ++i) {
|
if (found) {
|
||||||
Ref<BagSlot> slot = _slots.get(i);
|
item->set_inventory_position_x(x);
|
||||||
|
item->set_inventory_position_y(y);
|
||||||
|
|
||||||
if (!slot->has_item()) {
|
_items.push_back(item);
|
||||||
slot->set_item(item);
|
|
||||||
slot->set_count(count);
|
|
||||||
|
|
||||||
return true;
|
int index = _items.size() - 1;
|
||||||
|
|
||||||
|
for (int xx = x; xx < _item_size_x; ++xx) {
|
||||||
|
for (int yy = y; yy < _item_size_y; ++yy) {
|
||||||
|
_space_map.set(xx * _size_x + yy, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bag::add_item_to_slot(Ref<ItemInstance> item, int slot_index, int count) {
|
bool Bag::add_item_to_position(const int x, const int y, Ref<ItemInstance> item) {
|
||||||
ERR_FAIL_COND_V(!item.is_valid(), false);
|
ERR_FAIL_COND_V(!item.is_valid(), false);
|
||||||
|
ERR_FAIL_COND_V(x < 0 || y < 0, false);
|
||||||
|
ERR_FAIL_COND_V(x > _size_x || y > _size_y, false);
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(slot_index, _slots.size(), false);
|
Ref<ItemTemplate> item_template = item->get_item_template();
|
||||||
|
|
||||||
Ref<BagSlot> slot = _slots.get(slot_index);
|
ERR_FAIL_COND_V(!item_template.is_valid(), true);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!slot.is_valid(), false);
|
int _item_size_x = item_template->get_inventory_size_x();
|
||||||
|
int _item_size_y = item_template->get_inventory_size_y();
|
||||||
|
|
||||||
if (slot->has_item()) {
|
ERR_FAIL_COND_V(x + _item_size_x > _size_x || y + _item_size_y > _size_y, false);
|
||||||
|
|
||||||
|
int sx = x + _item_size_x;
|
||||||
|
int sy = y + _item_size_y;
|
||||||
|
|
||||||
|
for (int xx = x; xx < sx; ++xx) {
|
||||||
|
for (int yy = y; yy < sy; ++yy) {
|
||||||
|
if (_space_map[xx * _size_x + yy] != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
slot->set_item_count(item, count);
|
item->set_inventory_position_x(x);
|
||||||
|
item->set_inventory_position_y(y);
|
||||||
|
|
||||||
|
_items.push_back(item);
|
||||||
|
|
||||||
|
int index = _items.size() - 1;
|
||||||
|
|
||||||
|
for (int xx = x; xx < sx; ++xx) {
|
||||||
|
for (int yy = y; yy < sy; ++yy) {
|
||||||
|
_space_map.set(xx * _size_x + yy, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Bag::can_add_item_at(const int x, const int y, const Ref<ItemInstance> item) const {
|
||||||
|
ERR_FAIL_COND_V(!item.is_valid(), false);
|
||||||
|
ERR_FAIL_COND_V(x < 0 || y < 0, false);
|
||||||
|
ERR_FAIL_COND_V(x > _size_x || y > _size_y, false);
|
||||||
|
|
||||||
|
int indx = _space_map[x * _size_x + y];
|
||||||
|
|
||||||
|
if (indx != 0) {
|
||||||
|
Ref<ItemInstance> it = _items[indx];
|
||||||
|
|
||||||
|
if (it.is_valid()) {
|
||||||
|
if (it->get_item_template() == item->get_item_template()) {
|
||||||
|
//todo check stacks
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<ItemTemplate> item_template = item->get_item_template();
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V(!item_template.is_valid(), true);
|
||||||
|
|
||||||
|
int _item_size_x = item_template->get_inventory_size_x();
|
||||||
|
int _item_size_y = item_template->get_inventory_size_y();
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V(x + _item_size_x > _size_x || y + _item_size_y > _size_y, false);
|
||||||
|
|
||||||
|
int sx = x + _item_size_x;
|
||||||
|
int sy = y + _item_size_y;
|
||||||
|
|
||||||
|
for (int xx = x; xx < sx; ++xx) {
|
||||||
|
for (int yy = y; yy < sy; ++yy) {
|
||||||
|
if (_space_map[xx * _size_x + yy] != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
int Bag::item_count_under_area(const int x, const int y, const int size_x, const int size_y) const {
|
||||||
|
ERR_FAIL_COND_V(x < 0 || y < 0, false);
|
||||||
|
ERR_FAIL_COND_V(x > _size_x || y > _size_y, false);
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V(x + size_x > _size_x || y + size_y > _size_y, false);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
int sx = x + size_x;
|
||||||
|
int sy = y + size_y;
|
||||||
|
|
||||||
|
for (int xx = x; xx < sx; ++xx) {
|
||||||
|
for (int yy = y; yy < sy; ++yy) {
|
||||||
|
if (_space_map[xx * _size_x + yy] != 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<ItemInstance> Bag::get_item(const int index) const {
|
||||||
|
ERR_FAIL_INDEX_V(index, _items.size(), Ref<ItemInstance>(NULL));
|
||||||
|
|
||||||
|
return (_items.get(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<ItemInstance> Bag::get_and_remove_item(const int index) {
|
||||||
|
ERR_FAIL_INDEX_V(index, _items.size(), Ref<ItemInstance>(NULL));
|
||||||
|
|
||||||
|
Ref<ItemInstance> item = _items.get(index);
|
||||||
|
|
||||||
|
_items.remove(index);
|
||||||
|
|
||||||
|
//Go over everything, to make sure item site changes won't cause bugs.
|
||||||
|
for (int x = 0; x < _size_x; ++x) {
|
||||||
|
for (int y = 0; y < _size_y ; ++y) {
|
||||||
|
int indx = x * _size_x + y;
|
||||||
|
|
||||||
|
if (_space_map[indx] == index) {
|
||||||
|
_space_map.set(indx, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bag::remove_item(const int index) {
|
||||||
|
ERR_FAIL_INDEX(index, _items.size());
|
||||||
|
|
||||||
|
_items.remove(index);
|
||||||
|
|
||||||
|
//Go over everything, to make sure item site changes won't cause bugs.
|
||||||
|
for (int x = 0; x < _size_x; ++x) {
|
||||||
|
for (int y = 0; y < _size_y ; ++y) {
|
||||||
|
int indx = x * _size_x + y;
|
||||||
|
|
||||||
|
if (_space_map[indx] == index) {
|
||||||
|
_space_map.set(indx, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bag::basic_add_item(const Ref<ItemInstance> item) {
|
||||||
|
_items.push_back(item);
|
||||||
|
}
|
||||||
|
void Bag::basic_remove_item(const int index){
|
||||||
|
_items.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Bag::get_item_count() const {
|
||||||
|
return _items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Bag::get_space_map_entry(const int index) const {
|
||||||
|
return _space_map[index];
|
||||||
|
}
|
||||||
|
void Bag::set_space_map_entry(const int index, const int value) {
|
||||||
|
_space_map.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Bag::get_size_x() const {
|
||||||
|
return _size_x;
|
||||||
|
}
|
||||||
|
int Bag::get_size_y() const {
|
||||||
|
return _size_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bag::set_size(const int x, const int y) {
|
||||||
|
ERR_FAIL_COND(x == 0 || y == 0);
|
||||||
|
ERR_FAIL_COND(_size_x != 0 || _size_y != 0);
|
||||||
|
|
||||||
|
_size_x = x;
|
||||||
|
_size_y = y;
|
||||||
|
|
||||||
|
_space_map.resize(x * y);
|
||||||
|
|
||||||
|
for (int i = 0; i < _space_map.size(); ++i) {
|
||||||
|
_space_map.set(i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bag::Bag() {
|
Bag::Bag() {
|
||||||
|
_size_x = 0;
|
||||||
|
_size_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bag::~Bag() {
|
Bag::~Bag() {
|
||||||
_slots.clear();
|
_items.clear();
|
||||||
|
_space_map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bag::_bind_methods() {
|
void Bag::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_slot", "index"), &Bag::get_slot);
|
ClassDB::bind_method(D_METHOD("add_item", "item"), &Bag::add_item);
|
||||||
ClassDB::bind_method(D_METHOD("get_and_remove_slot", "index"), &Bag::get_and_remove_slot);
|
ClassDB::bind_method(D_METHOD("add_item_to_position", "x", "y", "item"), &Bag::add_item_to_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_slot_count"), &Bag::get_slot_count);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_slot_count", "count"), &Bag::set_slot_count);
|
ClassDB::bind_method(D_METHOD("can_add_item_at", "x", "y", "item"), &Bag::can_add_item_at);
|
||||||
ClassDB::bind_method(D_METHOD("try_to_add_item", "item", "count"), &Bag::try_to_add_item, DEFVAL(1));
|
ClassDB::bind_method(D_METHOD("item_count_under_area", "x", "y", "item"), &Bag::item_count_under_area);
|
||||||
ClassDB::bind_method(D_METHOD("add_item_to_slot", "item", "slot_index", "count"), &Bag::add_item_to_slot, DEFVAL(1));
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_item", "index"), &Bag::get_item);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_and_remove_item", "index"), &Bag::get_and_remove_item);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove_item", "index"), &Bag::remove_item);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("basic_add_item", "item"), &Bag::basic_add_item);
|
||||||
|
ClassDB::bind_method(D_METHOD("basic_remove_item", "index"), &Bag::basic_remove_item);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_item_count"), &Bag::get_item_count);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_space_map_entry", "index"), &Bag::get_space_map_entry);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_space_map_entry", "index", "value"), &Bag::set_space_map_entry);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_size_x"), &Bag::get_size_x);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_size_y"), &Bag::get_size_y);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("set_size", "x", "y"), &Bag::set_size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,22 +2,40 @@
|
|||||||
#define BAG_H
|
#define BAG_H
|
||||||
|
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
|
|
||||||
#include "core/vector.h"
|
#include "core/vector.h"
|
||||||
|
|
||||||
#include "../data/item_instance.h"
|
class itemTemplate;
|
||||||
#include "bag_slot.h"
|
class ItemInstance;
|
||||||
|
|
||||||
class Bag : public Reference {
|
class Bag : public Reference {
|
||||||
GDCLASS(Bag, Reference);
|
GDCLASS(Bag, Reference);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ref<BagSlot> get_slot(int index);
|
bool add_item(Ref<ItemInstance> item);
|
||||||
Ref<BagSlot> get_and_remove_slot(int index);
|
bool add_item_to_position(const int x, const int y, Ref<ItemInstance> item);
|
||||||
int get_slot_count();
|
|
||||||
void set_slot_count(int count);
|
bool can_add_item_at(const int x, const int y, const Ref<ItemInstance> item) const;
|
||||||
bool try_to_add_item(Ref<ItemInstance> item, int count = 1);
|
int item_count_under_area(const int x, const int y, const int size_x, const int size_y) const;
|
||||||
bool add_item_to_slot(Ref<ItemInstance> item, int slot_index, int count = 1);
|
|
||||||
|
Ref<ItemInstance> get_item(const int index) const;
|
||||||
|
Ref<ItemInstance> get_and_remove_item(const int index);
|
||||||
|
void remove_item(const int index);
|
||||||
|
|
||||||
|
void basic_add_item(const Ref<ItemInstance> item);
|
||||||
|
void basic_remove_item(const int index);
|
||||||
|
|
||||||
|
int get_item_count() const;
|
||||||
|
|
||||||
|
int get_space_map_entry(const int index) const;
|
||||||
|
void set_space_map_entry(const int index, const int value);
|
||||||
|
|
||||||
|
int get_size_x() const;
|
||||||
|
int get_size_y() const;
|
||||||
|
|
||||||
|
void set_size(const int x, const int y);
|
||||||
|
|
||||||
|
//to_dict();
|
||||||
|
//from_dict();
|
||||||
|
|
||||||
Bag();
|
Bag();
|
||||||
~Bag();
|
~Bag();
|
||||||
@ -26,7 +44,11 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Ref<BagSlot> > _slots;
|
int _size_x;
|
||||||
|
int _size_y;
|
||||||
|
|
||||||
|
Vector<Ref<ItemInstance> > _items;
|
||||||
|
Vector<int> _space_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
#include "bag_slot.h"
|
|
||||||
|
|
||||||
Ref<ItemInstance> BagSlot::get_item() {
|
|
||||||
return _item;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BagSlot::set_item(Ref<ItemInstance> item) {
|
|
||||||
_item = Ref<ItemInstance>(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BagSlot::set_item_count(Ref<ItemInstance> item, int count) {
|
|
||||||
_item = Ref<ItemInstance>(item);
|
|
||||||
_count = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BagSlot::get_count() {
|
|
||||||
return _count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BagSlot::set_count(int value) {
|
|
||||||
_count = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BagSlot::get_slot_index() {
|
|
||||||
return _slot_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BagSlot::set_slot_index(int index) {
|
|
||||||
_slot_index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BagSlot::has_item() {
|
|
||||||
return _item.is_valid();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BagSlot::clear() {
|
|
||||||
_item = Ref<ItemInstance>(NULL);
|
|
||||||
_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BagSlot::BagSlot() {
|
|
||||||
_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BagSlot::BagSlot(Ref<ItemInstance> item) {
|
|
||||||
_item = item;
|
|
||||||
_count = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
BagSlot::BagSlot(Ref<ItemInstance> item, int count) {
|
|
||||||
_item = item;
|
|
||||||
_count = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BagSlot::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_item"), &BagSlot::get_item);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_item", "item"), &BagSlot::set_item);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"), "set_item", "get_item");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_count"), &BagSlot::get_count);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_count", "value"), &BagSlot::set_count);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_slot_index"), &BagSlot::get_slot_index);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_slot_index", "value"), &BagSlot::set_slot_index);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "slot_index"), "set_slot_index", "get_slot_index");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_item_count", "item", "count"), &BagSlot::set_item_count, DEFVAL(1));
|
|
||||||
ClassDB::bind_method(D_METHOD("has_item"), &BagSlot::has_item);
|
|
||||||
ClassDB::bind_method(D_METHOD("clear"), &BagSlot::clear);
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
#ifndef BAG_SLOT_H
|
|
||||||
#define BAG_SLOT_H
|
|
||||||
|
|
||||||
#include "core/reference.h"
|
|
||||||
#include "../data/item_instance.h"
|
|
||||||
|
|
||||||
class BagSlot : public Reference {
|
|
||||||
GDCLASS(BagSlot, Reference);
|
|
||||||
|
|
||||||
public:
|
|
||||||
Ref<ItemInstance> get_item();
|
|
||||||
void set_item(Ref<ItemInstance> item);
|
|
||||||
void set_item_count(Ref<ItemInstance> item, int count = 1);
|
|
||||||
int get_count();
|
|
||||||
void set_count(int value);
|
|
||||||
int get_slot_index();
|
|
||||||
void set_slot_index(int value);
|
|
||||||
bool has_item();
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
BagSlot();
|
|
||||||
BagSlot(Ref<ItemInstance> item);
|
|
||||||
BagSlot(Ref<ItemInstance> item, int count);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ref<ItemInstance> _item;
|
|
||||||
int _count;
|
|
||||||
int _slot_index;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,8 @@
|
|||||||
#include "item_enums.h"
|
#include "item_enums.h"
|
||||||
|
|
||||||
|
|
||||||
const String ItemEnums::BINDING_STRING_RARITY = "None,Common,Uncommon,Superior,Heroic,Mythic,Artifact,Class Neck";
|
const String ItemEnums::BINDING_STRING_RARITY = "None,Common,Uncommon,Superior,Heroic,Mythic,Artifact";
|
||||||
const String ItemEnums::BINDING_STRING_ITEM_TYPE = "None,Weapon,Craft,Currency,Item";
|
const String ItemEnums::BINDING_STRING_RARITY_FLAG = "Common,Uncommon,Superior,Heroic,Mythic,Artifact";
|
||||||
const String ItemEnums::BINDING_STRING_ITEM_SUB_TYPE = "None,Two Hand,One Hand,Left Hand,Right Hand";
|
const String ItemEnums::BINDING_STRING_ITEM_TYPE = "Equipment,Weapon,Potion,Herb,Ore,Gemstone,Food,Alchemy,Engineering,Enchanting,Tailoring,Recipe,Currency,Bag";
|
||||||
const String ItemEnums::BINDING_STRING_ITEM_SUB_SUB_TYPE = "None,Sword,Bow,Axe";
|
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";
|
||||||
|
102
item_enums.h
102
item_enums.h
@ -8,26 +8,59 @@ class ItemEnums : public Object {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static const String BINDING_STRING_RARITY;
|
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;
|
||||||
static const String BINDING_STRING_ITEM_SUB_TYPE;
|
static const String BINDING_STRING_ITEM_SUB_TYPE;
|
||||||
static const String BINDING_STRING_ITEM_SUB_SUB_TYPE;
|
static const String BINDING_STRING_ITEM_SUB_SUB_TYPE;
|
||||||
|
|
||||||
enum ItemRarity {
|
enum ItemRarity {
|
||||||
ITEM_RARITY_NONE = 0,
|
ITEM_RARITY_NONE = 0,
|
||||||
ITEM_RARITY_COMMON = 1 << 0,
|
ITEM_RARITY_COMMON = 1,
|
||||||
ITEM_RARITY_UNCOMMON = 1 << 1,
|
ITEM_RARITY_UNCOMMON = 2,
|
||||||
ITEM_RARITY_SUPERIOR = 1 << 2,
|
ITEM_RARITY_SUPERIOR = 3,
|
||||||
ITEM_RARITY_HEROIC = 1 << 3,
|
ITEM_RARITY_HEROIC = 4,
|
||||||
ITEM_RARITY_MYTHIC = 1 << 4,
|
ITEM_RARITY_MYTHIC = 5,
|
||||||
ITEM_RARITY_ARTIFACT = 1 << 5,
|
ITEM_RARITY_ARTIFACT = 6,
|
||||||
ITEM_RARITY_CLASS_NECK = 1 << 6,
|
};
|
||||||
|
|
||||||
|
enum ItemRarityFlag {
|
||||||
|
ITEM_RARITY_FLAG_NONE = 0,
|
||||||
|
ITEM_RARITY_FLAG_COMMON = 1 << 0,
|
||||||
|
ITEM_RARITY_FLAG_UNCOMMON = 1 << 1,
|
||||||
|
ITEM_RARITY_FLAG_SUPERIOR = 1 << 2,
|
||||||
|
ITEM_RARITY_FLAG_HEROIC = 1 << 3,
|
||||||
|
ITEM_RARITY_FLAG_MYTHIC = 1 << 4,
|
||||||
|
ITEM_RARITY_FLAG_ARTIFACT = 1 << 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ItemType {
|
||||||
|
ITEM_TYPE_NONE = 0,
|
||||||
|
ITEM_TYPE_EQUIPMENT = 1 << 0,
|
||||||
|
ITEM_TYPE_WEAPON = 1 << 1,
|
||||||
|
ITEM_TYPE_POTION = 1 << 2,
|
||||||
|
ITEM_TYPE_HERB = 1 << 3,
|
||||||
|
ITEM_TYPE_ORE = 1 << 4,
|
||||||
|
ITEM_TYPE_GEMSTONE = 1 << 5,
|
||||||
|
ITEM_TYPE_FOOD = 1 << 6,
|
||||||
|
ITEM_TYPE_ALCHEMY = 1 << 7,
|
||||||
|
ITEM_TYPE_ENGINEERING = 1 << 8,
|
||||||
|
ITEM_TYPE_ENCHANTING = 1 << 9,
|
||||||
|
ITEM_TYPE_TAILORING = 1 << 10,
|
||||||
|
ITEM_TYPE_RECIPE = 1 << 11,
|
||||||
|
ITEM_TYPE_CURRENCY = 1 << 12,
|
||||||
|
ITEM_TYPE_BAG = 1 << 13,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ItemSubtype {
|
enum ItemSubtype {
|
||||||
ITEM_SUB_TYPE_NONE,
|
ITEM_SUB_TYPE_NONE = 0,
|
||||||
ITEM_SUB_TYPE_SWORD,
|
ITEM_SUB_TYPE_SWORD,
|
||||||
|
ITEM_SUB_TYPE_AXE,
|
||||||
|
ITEM_SUB_TYPE_MACE,
|
||||||
|
ITEM_SUB_TYPE_DAGGER,
|
||||||
ITEM_SUB_TYPE_BOW,
|
ITEM_SUB_TYPE_BOW,
|
||||||
ITEM_SUB_TYPE_AXE
|
ITEM_SUB_TYPE_CROSSBOW,
|
||||||
|
ITEM_SUB_TYPE_GUN,
|
||||||
|
ITEM_SUB_TYPE_QUEST_ITEM,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ItemSubSubtype {
|
enum ItemSubSubtype {
|
||||||
@ -38,15 +71,6 @@ public:
|
|||||||
ITEM_SUB_SUB_TYPE_RIGHT_HAND
|
ITEM_SUB_SUB_TYPE_RIGHT_HAND
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ItemType {
|
|
||||||
ITEM_TYPE_NONE,
|
|
||||||
ITEM_TYPE_WEAPON,
|
|
||||||
ITEM_TYPE_CRAFT,
|
|
||||||
ITEM_TYPE_CURRENCY,
|
|
||||||
ITEM_TYPE_ITEM
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ItemEnums() {}
|
ItemEnums() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -58,30 +82,54 @@ protected:
|
|||||||
BIND_ENUM_CONSTANT(ITEM_RARITY_HEROIC);
|
BIND_ENUM_CONSTANT(ITEM_RARITY_HEROIC);
|
||||||
BIND_ENUM_CONSTANT(ITEM_RARITY_MYTHIC);
|
BIND_ENUM_CONSTANT(ITEM_RARITY_MYTHIC);
|
||||||
BIND_ENUM_CONSTANT(ITEM_RARITY_ARTIFACT);
|
BIND_ENUM_CONSTANT(ITEM_RARITY_ARTIFACT);
|
||||||
BIND_ENUM_CONSTANT(ITEM_RARITY_CLASS_NECK);
|
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_NONE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_COMMON);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_UNCOMMON);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_SUPERIOR);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_HEROIC);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_MYTHIC);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_RARITY_FLAG_ARTIFACT);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_NONE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_EQUIPMENT);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_WEAPON);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_POTION);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_HERB);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_ORE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_GEMSTONE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_FOOD);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_ALCHEMY);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_ENGINEERING);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_ENCHANTING);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_TAILORING);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_RECIPE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_CURRENCY);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_TYPE_BAG);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_NONE);
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_NONE);
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_SWORD);
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_SWORD);
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_BOW);
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_AXE);
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_AXE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_MACE);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_DAGGER);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_BOW);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_CROSSBOW);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_GUN);
|
||||||
|
BIND_ENUM_CONSTANT(ITEM_SUB_TYPE_QUEST_ITEM);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_NONE);
|
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_NONE);
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_TWO_HAND);
|
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_TWO_HAND);
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_ONE_HAND);
|
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_ONE_HAND);
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_LEFT_HAND);
|
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_LEFT_HAND);
|
||||||
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_RIGHT_HAND);
|
BIND_ENUM_CONSTANT(ITEM_SUB_SUB_TYPE_RIGHT_HAND);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_TYPE_NONE);
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_TYPE_WEAPON);
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_TYPE_CRAFT);
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_TYPE_CURRENCY);
|
|
||||||
BIND_ENUM_CONSTANT(ITEM_TYPE_ITEM);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(ItemEnums::ItemRarity);
|
VARIANT_ENUM_CAST(ItemEnums::ItemRarity);
|
||||||
|
VARIANT_ENUM_CAST(ItemEnums::ItemRarityFlag);
|
||||||
|
VARIANT_ENUM_CAST(ItemEnums::ItemType);
|
||||||
VARIANT_ENUM_CAST(ItemEnums::ItemSubtype);
|
VARIANT_ENUM_CAST(ItemEnums::ItemSubtype);
|
||||||
VARIANT_ENUM_CAST(ItemEnums::ItemSubSubtype);
|
VARIANT_ENUM_CAST(ItemEnums::ItemSubSubtype);
|
||||||
VARIANT_ENUM_CAST(ItemEnums::ItemType);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "entities/stats/stat_modifier.h"
|
#include "entities/stats/stat_modifier.h"
|
||||||
#include "entities/stats/stat_data.h"
|
#include "entities/stats/stat_data.h"
|
||||||
#include "entities/player_talent.h"
|
#include "entities/player_talent.h"
|
||||||
#include "inventory/bag_slot.h"
|
|
||||||
#include "inventory/bag.h"
|
#include "inventory/bag.h"
|
||||||
|
|
||||||
#include "data/craft_data_attribute_helper.h"
|
#include "data/craft_data_attribute_helper.h"
|
||||||
@ -107,7 +106,6 @@ void register_entity_spell_system_types() {
|
|||||||
ClassDB::register_class<PlayerTalent>();
|
ClassDB::register_class<PlayerTalent>();
|
||||||
ClassDB::register_class<CharacterSpec>();
|
ClassDB::register_class<CharacterSpec>();
|
||||||
|
|
||||||
ClassDB::register_class<BagSlot>();
|
|
||||||
ClassDB::register_class<Bag>();
|
ClassDB::register_class<Bag>();
|
||||||
|
|
||||||
ClassDB::register_class<SpellDamageInfo>();
|
ClassDB::register_class<SpellDamageInfo>();
|
||||||
|
Loading…
Reference in New Issue
Block a user