mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-22 17:18:12 +01:00
-Started working on inventory-related classes, and added helper classes for cooldowns.
This commit is contained in:
parent
4c586d459f
commit
53227bb6fe
7
SCsub
7
SCsub
@ -24,7 +24,7 @@ module_env.add_source_files(env.modules_sources,"data/data_manager.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/xp_data.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/item_stat_modifier.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/item_template_stat_modifier.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/item_data_instance.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/item_instance.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/item_template.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"data/spell_cooldown_manipulation_data.cpp")
|
||||
|
||||
@ -40,7 +40,7 @@ module_env.add_source_files(env.modules_sources,"entities/stats/stat.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/item_instance.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"inventory/bag_slot.cpp")
|
||||
|
||||
module_env.add_source_files(env.modules_sources,"spells/aura_infos.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"spells/spell_cast_info.cpp")
|
||||
@ -65,5 +65,6 @@ module_env.add_source_files(env.modules_sources,"skeleton/character_skeleton.cpp
|
||||
|
||||
module_env.add_source_files(env.modules_sources,"utility/entity_create_info.cpp")
|
||||
|
||||
|
||||
module_env.add_source_files(env.modules_sources,"utility/cooldown.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"utility/category_cooldown.cpp")
|
||||
|
||||
|
BIN
config.pyc
BIN
config.pyc
Binary file not shown.
@ -1,98 +1,98 @@
|
||||
#include "item_data_instance.h"
|
||||
#include "item_instance.h"
|
||||
|
||||
#if ENTITY_MEM_TOOLS
|
||||
int ItemDataInstance::allocs = 0;
|
||||
int ItemInstance::allocs = 0;
|
||||
#endif
|
||||
|
||||
int ItemDataInstance::get_id() {
|
||||
int ItemInstance::get_id() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_id(int value) {
|
||||
void ItemInstance::set_id(int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
String ItemDataInstance::get_name_key() {
|
||||
String ItemInstance::get_name_key() {
|
||||
return _name_key;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_name_key(String value) {
|
||||
void ItemInstance::set_name_key(String value) {
|
||||
_name_key = value;
|
||||
}
|
||||
|
||||
ItemEnums::ItemType ItemDataInstance::get_item_type() {
|
||||
ItemEnums::ItemType ItemInstance::get_item_type() {
|
||||
return _item_type;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_type(ItemEnums::ItemType value) {
|
||||
void ItemInstance::set_item_type(ItemEnums::ItemType value) {
|
||||
_item_type = value;
|
||||
}
|
||||
|
||||
ItemEnums::ItemSubtype ItemDataInstance::get_item_sub_type() {
|
||||
ItemEnums::ItemSubtype ItemInstance::get_item_sub_type() {
|
||||
return _item_sub_type;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_sub_type(ItemEnums::ItemSubtype value) {
|
||||
void ItemInstance::set_item_sub_type(ItemEnums::ItemSubtype value) {
|
||||
_item_sub_type = value;
|
||||
}
|
||||
|
||||
ItemEnums::ItemSubSubtype ItemDataInstance::get_item_sub_sub_type() {
|
||||
ItemEnums::ItemSubSubtype ItemInstance::get_item_sub_sub_type() {
|
||||
return _item_sub_sub_type;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_sub_sub_type(ItemEnums::ItemSubSubtype value) {
|
||||
void ItemInstance::set_item_sub_sub_type(ItemEnums::ItemSubSubtype value) {
|
||||
_item_sub_sub_type = value;
|
||||
}
|
||||
|
||||
ItemEnums::ItemRarity ItemDataInstance::get_rarity() {
|
||||
ItemEnums::ItemRarity ItemInstance::get_rarity() {
|
||||
return _rarity;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_rarity(ItemEnums::ItemRarity value) {
|
||||
void ItemInstance::set_rarity(ItemEnums::ItemRarity value) {
|
||||
_rarity = value;
|
||||
}
|
||||
|
||||
int ItemDataInstance::get_spell_id() {
|
||||
int ItemInstance::get_spell_id() {
|
||||
return _spell_id;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_spell_id(int value) {
|
||||
void ItemInstance::set_spell_id(int value) {
|
||||
_spell_id = value;
|
||||
}
|
||||
|
||||
float ItemDataInstance::get_scale_x() {
|
||||
float ItemInstance::get_scale_x() {
|
||||
return _scale_x;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_scale_x(float value) {
|
||||
void ItemInstance::set_scale_x(float value) {
|
||||
_scale_x = value;
|
||||
}
|
||||
|
||||
float ItemDataInstance::get_scale_y() {
|
||||
float ItemInstance::get_scale_y() {
|
||||
return _scale_y;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_scale_y(float value) {
|
||||
void ItemInstance::set_scale_y(float value) {
|
||||
_scale_y = value;
|
||||
}
|
||||
|
||||
float ItemDataInstance::get_scale_z() {
|
||||
float ItemInstance::get_scale_z() {
|
||||
return _scale_z;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_scale_z(float value) {
|
||||
void ItemInstance::set_scale_z(float value) {
|
||||
_scale_z = value;
|
||||
}
|
||||
|
||||
Ref<Texture> ItemDataInstance::get_icon() {
|
||||
Ref<Texture> ItemInstance::get_icon() {
|
||||
return _icon;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_icon(Ref<Texture> value) {
|
||||
void ItemInstance::set_icon(Ref<Texture> value) {
|
||||
_icon = value;
|
||||
}
|
||||
|
||||
int ItemDataInstance::get_animator_weapon_type() {
|
||||
int ItemInstance::get_animator_weapon_type() {
|
||||
if (_item_sub_type == ItemEnums::ITEM_SUB_TYPE_SWORD) {
|
||||
return 1;
|
||||
}
|
||||
@ -105,55 +105,55 @@ int ItemDataInstance::get_animator_weapon_type() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ref<ItemStatModifier> ItemDataInstance::get_item_stat_modifier(int index) {
|
||||
Ref<ItemStatModifier> ItemInstance::get_item_stat_modifier(int index) {
|
||||
return _modifiers[index];
|
||||
}
|
||||
/*
|
||||
void ItemDataInstance::set_item_stat_modifier(int index, ItemStatModifier modifier) {
|
||||
void ItemInstance::set_item_stat_modifier(int index, ItemStatModifier modifier) {
|
||||
_modifiers[index] = modifier;
|
||||
}*/
|
||||
|
||||
int ItemDataInstance::get_item_stat_modifier_count() {
|
||||
int ItemInstance::get_item_stat_modifier_count() {
|
||||
return _modifier_count;
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_stat_modifier_count(int value) {
|
||||
void ItemInstance::set_item_stat_modifier_count(int value) {
|
||||
_modifier_count = value;
|
||||
}
|
||||
|
||||
Stat::StatId ItemDataInstance::get_item_stat_id(int index) {
|
||||
Stat::StatId ItemInstance::get_item_stat_id(int index) {
|
||||
return _modifiers[index]->get_stat_id();
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_stat_id(int index, Stat::StatId value) {
|
||||
void ItemInstance::set_item_stat_id(int index, Stat::StatId value) {
|
||||
_modifiers[index]->set_stat_id(value);
|
||||
}
|
||||
|
||||
float ItemDataInstance::get_item_base_mod(int index) {
|
||||
float ItemInstance::get_item_base_mod(int index) {
|
||||
return _modifiers[index]->get_base_mod();
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_base_mod(int index, float value) {
|
||||
void ItemInstance::set_item_base_mod(int index, float value) {
|
||||
_modifiers[index]->set_base_mod(value);
|
||||
}
|
||||
|
||||
float ItemDataInstance::get_item_bonus_mod(int index) {
|
||||
float ItemInstance::get_item_bonus_mod(int index) {
|
||||
return _modifiers[index]->get_bonus_mod();
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_item_bonus_mod(int index, float value) {
|
||||
void ItemInstance::set_item_bonus_mod(int index, float value) {
|
||||
_modifiers[index]->set_bonus_mod(value);
|
||||
}
|
||||
|
||||
float ItemDataInstance::get_percent_mod(int index) {
|
||||
float ItemInstance::get_percent_mod(int index) {
|
||||
return _modifiers[index]->get_percent_mod();
|
||||
}
|
||||
|
||||
void ItemDataInstance::set_percent_mod(int index, float value) {
|
||||
void ItemInstance::set_percent_mod(int index, float value) {
|
||||
_modifiers[index]->set_percent_mod(value);
|
||||
}
|
||||
|
||||
ItemDataInstance::ItemDataInstance() {
|
||||
ItemInstance::ItemInstance() {
|
||||
_id = 0;
|
||||
_name_key = "";
|
||||
_item_type = ItemEnums::ITEM_TYPE_NONE;
|
||||
@ -171,19 +171,19 @@ ItemDataInstance::ItemDataInstance() {
|
||||
}
|
||||
|
||||
#if ENTITY_MEM_TOOLS
|
||||
ItemDataInstance::allocs++;
|
||||
print_error("ItemDataInstance alloc " + String::num(ItemDataInstance::allocs));
|
||||
ItemInstance::allocs++;
|
||||
print_error("ItemInstance alloc " + String::num(ItemInstance::allocs));
|
||||
#endif
|
||||
}
|
||||
|
||||
ItemDataInstance::~ItemDataInstance() {
|
||||
ItemInstance::~ItemInstance() {
|
||||
#if ENTITY_MEM_TOOLS
|
||||
ItemDataInstance::allocs--;
|
||||
print_error("ItemDataInstance dealloc " + String::num(ItemDataInstance::allocs));
|
||||
ItemInstance::allocs--;
|
||||
print_error("ItemInstance dealloc " + String::num(ItemInstance::allocs));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ItemDataInstance::_validate_property(PropertyInfo &property) const {
|
||||
void ItemInstance::_validate_property(PropertyInfo &property) const {
|
||||
String prop = property.name;
|
||||
if (prop.begins_with("Modifiers_")) {
|
||||
int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int();
|
||||
@ -194,73 +194,73 @@ void ItemDataInstance::_validate_property(PropertyInfo &property) const {
|
||||
}
|
||||
|
||||
|
||||
void ItemDataInstance::_bind_methods() {
|
||||
void ItemInstance::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &ItemDataInstance::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "count"), &ItemDataInstance::set_id);
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &ItemInstance::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "count"), &ItemInstance::set_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_name_key"), &ItemDataInstance::get_name_key);
|
||||
ClassDB::bind_method(D_METHOD("set_name_key", "count"), &ItemDataInstance::set_name_key);
|
||||
ClassDB::bind_method(D_METHOD("get_name_key"), &ItemInstance::get_name_key);
|
||||
ClassDB::bind_method(D_METHOD("set_name_key", "count"), &ItemInstance::set_name_key);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "name_key"), "set_name_key", "get_name_key");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_type"), &ItemDataInstance::get_item_type);
|
||||
ClassDB::bind_method(D_METHOD("set_item_type", "count"), &ItemDataInstance::set_item_type);
|
||||
ClassDB::bind_method(D_METHOD("get_item_type"), &ItemInstance::get_item_type);
|
||||
ClassDB::bind_method(D_METHOD("set_item_type", "count"), &ItemInstance::set_item_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "item_type", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ITEM_TYPE), "set_item_type", "get_item_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_sub_type"), &ItemDataInstance::get_item_sub_type);
|
||||
ClassDB::bind_method(D_METHOD("set_item_sub_type", "count"), &ItemDataInstance::set_item_sub_type);
|
||||
ClassDB::bind_method(D_METHOD("get_item_sub_type"), &ItemInstance::get_item_sub_type);
|
||||
ClassDB::bind_method(D_METHOD("set_item_sub_type", "count"), &ItemInstance::set_item_sub_type);
|
||||
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"), &ItemDataInstance::get_item_sub_sub_type);
|
||||
ClassDB::bind_method(D_METHOD("set_item_sub_sub_type", "count"), &ItemDataInstance::set_item_sub_sub_type);
|
||||
ClassDB::bind_method(D_METHOD("get_item_sub_sub_type"), &ItemInstance::get_item_sub_sub_type);
|
||||
ClassDB::bind_method(D_METHOD("set_item_sub_sub_type", "count"), &ItemInstance::set_item_sub_sub_type);
|
||||
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");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rarity"), &ItemDataInstance::get_rarity);
|
||||
ClassDB::bind_method(D_METHOD("set_rarity", "count"), &ItemDataInstance::set_rarity);
|
||||
ClassDB::bind_method(D_METHOD("get_rarity"), &ItemInstance::get_rarity);
|
||||
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"), &ItemDataInstance::get_spell_id);
|
||||
ClassDB::bind_method(D_METHOD("set_spell_id", "count"), &ItemDataInstance::set_spell_id);
|
||||
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"), &ItemDataInstance::get_scale_x);
|
||||
ClassDB::bind_method(D_METHOD("set_scale_x", "count"), &ItemDataInstance::set_scale_x);
|
||||
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"), &ItemDataInstance::get_scale_y);
|
||||
ClassDB::bind_method(D_METHOD("set_scale_y", "count"), &ItemDataInstance::set_scale_y);
|
||||
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"), &ItemDataInstance::get_scale_z);
|
||||
ClassDB::bind_method(D_METHOD("set_scale_z", "count"), &ItemDataInstance::set_scale_z);
|
||||
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"), &ItemDataInstance::get_icon);
|
||||
ClassDB::bind_method(D_METHOD("set_icon", "count"), &ItemDataInstance::set_icon);
|
||||
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"), &ItemDataInstance::get_animator_weapon_type);
|
||||
ClassDB::bind_method(D_METHOD("get_animator_weapon_type"), &ItemInstance::get_animator_weapon_type);
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("get_item_stat_modifier", "index"), &ItemDataInstance::get_item_stat_modifier);
|
||||
//ClassDB::bind_method(D_METHOD("set_item_stat_modifier", "index", "value"), &ItemDataInstance::set_item_stat_modifier);
|
||||
//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);
|
||||
|
||||
//StatMods Property binds
|
||||
ClassDB::bind_method(D_METHOD("get_item_stat_modifier_count"), &ItemDataInstance::get_item_stat_modifier_count);
|
||||
ClassDB::bind_method(D_METHOD("set_item_stat_modifier_count", "count"), &ItemDataInstance::set_item_stat_modifier_count);
|
||||
ClassDB::bind_method(D_METHOD("get_item_stat_modifier_count"), &ItemInstance::get_item_stat_modifier_count);
|
||||
ClassDB::bind_method(D_METHOD("set_item_stat_modifier_count", "count"), &ItemInstance::set_item_stat_modifier_count);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "set_item_stat_modifier_count", PROPERTY_HINT_RANGE, "0," + itos(MAX_ITEM_STAT_MOD), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_item_stat_modifier_count", "get_item_stat_modifier_count");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_stat_id", "index"), &ItemDataInstance::get_item_stat_id);
|
||||
ClassDB::bind_method(D_METHOD("set_item_stat_id", "index", "value"), &ItemDataInstance::set_item_stat_id);
|
||||
ClassDB::bind_method(D_METHOD("get_item_stat_id", "index"), &ItemInstance::get_item_stat_id);
|
||||
ClassDB::bind_method(D_METHOD("set_item_stat_id", "index", "value"), &ItemInstance::set_item_stat_id);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_base_mod", "index"), &ItemDataInstance::get_item_base_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_item_base_mod", "index", "value"), &ItemDataInstance::set_item_base_mod);
|
||||
ClassDB::bind_method(D_METHOD("get_item_base_mod", "index"), &ItemInstance::get_item_base_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_item_base_mod", "index", "value"), &ItemInstance::set_item_base_mod);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_bonus_mod", "index"), &ItemDataInstance::get_item_bonus_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_item_bonus_mod", "index", "value"), &ItemDataInstance::set_item_bonus_mod);
|
||||
ClassDB::bind_method(D_METHOD("get_item_bonus_mod", "index"), &ItemInstance::get_item_bonus_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_item_bonus_mod", "index", "value"), &ItemInstance::set_item_bonus_mod);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_percent_mod", "index"), &ItemDataInstance::get_percent_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_percent_mod", "index", "value"), &ItemDataInstance::set_percent_mod);
|
||||
ClassDB::bind_method(D_METHOD("get_percent_mod", "index"), &ItemInstance::get_percent_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_percent_mod", "index", "value"), &ItemInstance::set_percent_mod);
|
||||
|
||||
for (int i = 0; i < MAX_ITEM_STAT_MOD; ++i) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "Modifiers_" + itos(i) + "/stat_id", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_stat_id", "get_item_stat_id", i);
|
@ -1,5 +1,5 @@
|
||||
#ifndef ITEM_DATA_INSTANCE_H
|
||||
#define ITEM_DATA_INSTANCE_H
|
||||
#ifndef ITEM_INSTANCE_H
|
||||
#define ITEM_INSTANCE_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "scene/resources/texture.h"
|
||||
@ -8,8 +8,8 @@
|
||||
#include "../entities/stats/stat.h"
|
||||
#include "../item_enums.h"
|
||||
|
||||
class ItemDataInstance : public Reference {
|
||||
GDCLASS(ItemDataInstance, Reference);
|
||||
class ItemInstance : public Reference {
|
||||
GDCLASS(ItemInstance, Reference);
|
||||
|
||||
public:
|
||||
int get_id();
|
||||
@ -65,8 +65,8 @@ public:
|
||||
float get_percent_mod(int index);
|
||||
void set_percent_mod(int index, float value);
|
||||
|
||||
ItemDataInstance();
|
||||
~ItemDataInstance();
|
||||
ItemInstance();
|
||||
~ItemInstance();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
@ -9,7 +9,8 @@
|
||||
#include "core/object.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/vector.h"
|
||||
#include "item_instance.h"
|
||||
#include "../inventory/bag_slot.h"
|
||||
#include "../data/item_instance.h"
|
||||
#include "player_talent.h"
|
||||
#include "scene/2d/physics_body_2d.h"
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
#include "item_instance.h"
|
||||
|
||||
int ItemInstance::get_item_id() {
|
||||
return _item_id;
|
||||
}
|
||||
|
||||
void ItemInstance::set_item_id(int value) {
|
||||
_item_id = value;
|
||||
}
|
||||
|
||||
int ItemInstance::get_count() {
|
||||
return _count;
|
||||
}
|
||||
|
||||
void ItemInstance::set_count(int value) {
|
||||
_count = value;
|
||||
}
|
||||
|
||||
int ItemInstance::get_slot_id() {
|
||||
return _slot_id;
|
||||
}
|
||||
|
||||
void ItemInstance::set_slot_id(int value) {
|
||||
_slot_id = value;
|
||||
}
|
||||
|
||||
ItemInstance::ItemInstance() {
|
||||
}
|
||||
|
||||
ItemInstance::ItemInstance(int _item_id) {
|
||||
set_item_id(_item_id);
|
||||
_count = 1;
|
||||
}
|
||||
|
||||
ItemInstance::ItemInstance(int _item_id, int count) {
|
||||
set_item_id(_item_id);
|
||||
set_count(count);
|
||||
}
|
||||
|
||||
void ItemInstance::_bind_methods() {
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
#ifndef ITEM_INSTANCE_H
|
||||
#define ITEM_INSTANCE_H
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
class ItemInstance : public Object {
|
||||
GDCLASS(ItemInstance, Object);
|
||||
|
||||
private:
|
||||
int _item_id;
|
||||
int _count;
|
||||
int _slot_id;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
int get_item_id();
|
||||
void set_item_id(int value);
|
||||
int get_count();
|
||||
void set_count(int value);
|
||||
int get_slot_id();
|
||||
void set_slot_id(int value);
|
||||
|
||||
ItemInstance();
|
||||
ItemInstance(int itemId);
|
||||
ItemInstance(int itemId, int count);
|
||||
};
|
||||
|
||||
#endif
|
67
inventory/bag.cpp
Normal file
67
inventory/bag.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
#include "bag.h"
|
||||
|
||||
Ref<BagSlot> Bag::get_slot(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _slots->size(), Ref<BagSlot>(NULL));
|
||||
|
||||
return(_slots->get(index));
|
||||
}
|
||||
|
||||
Ref<BagSlot> Bag::get_and_remove_slot(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _slots->size(), Ref<BagSlot>(NULL));
|
||||
|
||||
Ref<BagSlot> slot = _slots->get(index);
|
||||
|
||||
_slots->set(index, Ref<BagSlot>(memnew(BagSlot()));
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
int Bag::get_slot_count() {
|
||||
return _slots->size();
|
||||
}
|
||||
|
||||
void Bag::set_slot_count(int count) {
|
||||
ERR_FAIL_COND(_slots->size() != 0);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
_slots->push_back(memnew(BagSlot()));
|
||||
}
|
||||
}
|
||||
|
||||
bool Bag::try_to_add_item(Ref<ItemInstance> item, int count = 1) {
|
||||
ERR_FAIL_COND_V(!item.is_valid(), false);
|
||||
|
||||
for (int i = 0; i < _slots->size(); ++i) {
|
||||
Ref<BagSlot> slot = _slots->get(i);
|
||||
//cont
|
||||
}
|
||||
}
|
||||
|
||||
bool Bag::add_item_to_slot(Ref<ItemInstance> item, int slot_index) {
|
||||
}
|
||||
|
||||
|
||||
Bag::Bag() {
|
||||
_slots = memnew(Vector<Ref<BagSlot> >());
|
||||
}
|
||||
|
||||
Bag::~Bag() {
|
||||
_slots->clear();
|
||||
|
||||
memdelete(_slots);
|
||||
}
|
||||
|
||||
void Bag::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_item"), &Bag::get_item);
|
||||
ClassDB::bind_method(D_METHOD("set_item", "item"), &Bag::set_item);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"), "set_item", "get_item");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_count"), &Bag::get_count);
|
||||
ClassDB::bind_method(D_METHOD("set_count", "value"), &Bag::set_count);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_slot_id"), &Bag::get_slot_id);
|
||||
ClassDB::bind_method(D_METHOD("set_slot_id", "value"), &Bag::set_slot_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "slot_id"), "set_slot_id", "get_slot_id");
|
||||
}
|
||||
|
32
inventory/bag.h
Normal file
32
inventory/bag.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef BAG_H
|
||||
#define BAG_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "../data/item_instance.h"
|
||||
#include "bag_slot.h"
|
||||
|
||||
class Bag : public Reference {
|
||||
GDCLASS(Bag, Reference);
|
||||
|
||||
public:
|
||||
Ref<BagSlot> get_slot(int index);
|
||||
Ref<BagSlot> get_and_remove_slot(int index);
|
||||
int get_slot_count();
|
||||
void set_slot_count(int count);
|
||||
bool try_to_add_item(Ref<ItemInstance> item, int count = 1);
|
||||
bool add_item_to_slot(Ref<ItemInstance> item, int slot_index);
|
||||
|
||||
Bag();
|
||||
~Bag();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Vector<Ref<BagSlot> > *_slots;
|
||||
};
|
||||
|
||||
#endif
|
54
inventory/bag_slot.cpp
Normal file
54
inventory/bag_slot.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "bag_slot.h"
|
||||
|
||||
Ref<ItemInstance> BagSlot::get_item() {
|
||||
return _item;
|
||||
}
|
||||
|
||||
void BagSlot::set_item(Ref<ItemInstance> item) {
|
||||
_item = Ref<ItemInstance>(item);
|
||||
}
|
||||
|
||||
int BagSlot::get_count() {
|
||||
return _count;
|
||||
}
|
||||
|
||||
void BagSlot::set_count(int value) {
|
||||
_count = value;
|
||||
}
|
||||
|
||||
int BagSlot::get_slot_id() {
|
||||
return _slot_index;
|
||||
}
|
||||
|
||||
void BagSlot::set_slot_id(int index) {
|
||||
_slot_index = index;
|
||||
}
|
||||
|
||||
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_id"), &BagSlot::get_slot_id);
|
||||
ClassDB::bind_method(D_METHOD("set_slot_id", "value"), &BagSlot::set_slot_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "slot_id"), "set_slot_id", "get_slot_id");
|
||||
}
|
||||
|
31
inventory/bag_slot.h
Normal file
31
inventory/bag_slot.h
Normal file
@ -0,0 +1,31 @@
|
||||
#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);
|
||||
int get_count();
|
||||
void set_count(int value);
|
||||
int get_slot_index();
|
||||
void set_slot_index(int value);
|
||||
|
||||
BagSlot();
|
||||
BagSlot(Ref<ItemInstance> item);
|
||||
BagSlot(Ref<ItemInstance> item, int count);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<ItemInstance> _item;
|
||||
int _count;
|
||||
int _slot_ndex;
|
||||
};
|
||||
|
||||
#endif
|
@ -16,14 +16,14 @@
|
||||
#include "data/spell_cooldown_manipulation_data.h"
|
||||
|
||||
#include "data/item_template.h"
|
||||
#include "data/item_data_instance.h"
|
||||
#include "data/item_instance.h"
|
||||
|
||||
#include "data/spell.h"
|
||||
#include "data/icon.h"
|
||||
#include "entities/stats/stat.h"
|
||||
#include "entities/stats/stat_data.h"
|
||||
#include "entities/player_talent.h"
|
||||
#include "entities/item_instance.h"
|
||||
#include "inventory/bag_slot.h"
|
||||
|
||||
#include "data/craft_data_attribute_helper.h"
|
||||
#include "data/craft_data_attribute.h"
|
||||
@ -52,6 +52,8 @@
|
||||
#include "skeleton/character_skeleton.h"
|
||||
|
||||
#include "utility/entity_create_info.h"
|
||||
#include "utility/cooldown.h"
|
||||
#include "utility/category_cooldown.h"
|
||||
|
||||
void register_entity_spell_system_types() {
|
||||
|
||||
@ -68,7 +70,7 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<ItemTemplateStatModifier>();
|
||||
ClassDB::register_class<ItemEnums>();
|
||||
ClassDB::register_class<ItemTemplate>();
|
||||
ClassDB::register_class<ItemDataInstance>();
|
||||
ClassDB::register_class<ItemInstance>();
|
||||
ClassDB::register_class<SpellCooldownManipulationData>();
|
||||
ClassDB::register_class<Talent>();
|
||||
ClassDB::register_class<TalentRowData>();
|
||||
@ -88,8 +90,9 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<StatData>();
|
||||
|
||||
ClassDB::register_class<PlayerTalent>();
|
||||
ClassDB::register_class<ItemInstance>();
|
||||
ClassDB::register_class<CharacterSpec>();
|
||||
|
||||
ClassDB::register_class<BagSlot>();
|
||||
|
||||
|
||||
ClassDB::register_class<SpellDamageInfo>();
|
||||
@ -119,6 +122,9 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<ESDragAndDrop>();
|
||||
|
||||
ClassDB::register_class<CharacterSkeleton>();
|
||||
|
||||
ClassDB::register_class<Cooldown>();
|
||||
ClassDB::register_class<CategoryCooldown>();
|
||||
}
|
||||
|
||||
void unregister_entity_spell_system_types() {
|
||||
|
33
utility/category_cooldown.cpp
Normal file
33
utility/category_cooldown.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "category_cooldown.h"
|
||||
|
||||
int CategoryCooldown::get_category_id()
|
||||
{
|
||||
return _category_id;
|
||||
}
|
||||
|
||||
void CategoryCooldown::set_category_id(int value)
|
||||
{
|
||||
_category_id = value;
|
||||
}
|
||||
|
||||
int CategoryCooldown::get_remaining()
|
||||
{
|
||||
return _remaining;
|
||||
|
||||
}
|
||||
|
||||
void CategoryCooldown::set_remaining(int value)
|
||||
{
|
||||
_remaining = value;
|
||||
}
|
||||
|
||||
|
||||
void CategoryCooldown::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_category_id"), &CategoryCooldown::get_category_id);
|
||||
ClassDB::bind_method(D_METHOD("set_category_id", "value"), &CategoryCooldown::set_category_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "category_id"), "set_category_id", "get_category_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_remaining"), &CategoryCooldown::get_remaining);
|
||||
ClassDB::bind_method(D_METHOD("set_remaining", "value"), &CategoryCooldown::set_remaining);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "remaining"), "set_remaining", "get_remaining");
|
||||
}
|
24
utility/category_cooldown.h
Normal file
24
utility/category_cooldown.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef CATEGORY_COOLDOWN_H
|
||||
#define CATEGORY_COOLDOWN_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class CategoryCooldown : public Reference {
|
||||
GDCLASS(CategoryCooldown, Reference);
|
||||
|
||||
public:
|
||||
int get_category_id();
|
||||
void set_category_id(int value);
|
||||
|
||||
int get_remaining();
|
||||
void set_remaining(int value);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _category_id;
|
||||
int _remaining;
|
||||
};
|
||||
|
||||
#endif
|
33
utility/cooldown.cpp
Normal file
33
utility/cooldown.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "cooldown.h"
|
||||
|
||||
int Cooldown::get_spell_id()
|
||||
{
|
||||
return _spell_id;
|
||||
}
|
||||
|
||||
void Cooldown::set_spell_id(int value)
|
||||
{
|
||||
_spell_id = value;
|
||||
}
|
||||
|
||||
int Cooldown::get_remaining()
|
||||
{
|
||||
return _remaining;
|
||||
|
||||
}
|
||||
|
||||
void Cooldown::set_remaining(int value)
|
||||
{
|
||||
_remaining = value;
|
||||
}
|
||||
|
||||
|
||||
void Cooldown::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_spell_id"), &Cooldown::get_spell_id);
|
||||
ClassDB::bind_method(D_METHOD("set_spell_id", "value"), &Cooldown::set_spell_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "spell_id"), "set_spell_id", "get_spell_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_remaining"), &Cooldown::get_remaining);
|
||||
ClassDB::bind_method(D_METHOD("set_remaining", "value"), &Cooldown::set_remaining);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "remaining"), "set_remaining", "get_remaining");
|
||||
}
|
24
utility/cooldown.h
Normal file
24
utility/cooldown.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef COOLDOWN_H
|
||||
#define COOLDOWN_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class Cooldown : public Reference {
|
||||
GDCLASS(Cooldown, Reference);
|
||||
|
||||
public:
|
||||
int get_spell_id();
|
||||
void set_spell_id(int value);
|
||||
|
||||
int get_remaining();
|
||||
void set_remaining(int value);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _spell_id;
|
||||
int _remaining;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user