From 9aaa5d1d5aeadc5fa73a32c56e6871958369bceb Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 30 May 2019 00:26:02 +0200 Subject: [PATCH] -Renamed CharacterSkeletonBoneId to CharacterSkeletonPoints. -Added rank to spells. -Removed The Icon class, and the SpellManager. -More cleanup. -Removed more collection dynamic allocations. --- SCsub | 7 - data/aura.cpp | 13 + data/aura.h | 5 + data/bone_visual_attachment.cpp | 8 +- data/bone_visual_attachment.h | 6 +- data/character.cpp | 14 - data/character.h | 4 - data/character_spec.cpp | 13 - data/character_spec.h | 4 - data/craft_data_attribute.cpp | 14 - data/craft_data_attribute.h | 4 - data/craft_data_attribute_helper.h | 4 - data/data_manager.cpp | 400 ++++++++--------- data/data_manager.h | 61 ++- data/icon.cpp | 73 ---- data/icon.h | 41 -- data/item_template.cpp | 269 ++++++------ data/item_template.h | 3 + data/spell.cpp | 50 +++ data/spell.h | 39 +- entities/entity.cpp | 661 +---------------------------- entities/entity.h | 15 - entities/stats/stat.cpp | 57 ++- entities/stats/stat.h | 2 +- entity_enums.cpp | 3 +- entity_enums.h | 35 +- inventory/bag.cpp | 29 +- inventory/bag.h | 2 +- register_types.cpp | 6 - skeleton/character_skeleton.cpp | 22 +- skeleton/character_skeleton.h | 6 +- spells/spell_manager.cpp | 280 ------------ spells/spell_manager.h | 50 --- 33 files changed, 573 insertions(+), 1627 deletions(-) delete mode 100644 data/icon.cpp delete mode 100644 data/icon.h delete mode 100644 spells/spell_manager.cpp delete mode 100644 spells/spell_manager.h diff --git a/SCsub b/SCsub index 4881f84..4d0a3b8 100644 --- a/SCsub +++ b/SCsub @@ -1,8 +1,5 @@ Import('env') -if ARGUMENTS.get('entity_mem_tools', 'no') == 'yes': - env.Append(CPPDEFINES=['ENTITY_MEM_TOOLS']) - if ARGUMENTS.get('entities_2d', 'no') == 'yes': env.Append(CPPDEFINES=['ENTITIES_2D']) @@ -34,8 +31,6 @@ module_env.add_source_files(env.modules_sources,"data/craft_data_attribute.cpp") module_env.add_source_files(env.modules_sources,"data/spell.cpp") module_env.add_source_files(env.modules_sources,"data/spell/spell_data_constants.cpp") -module_env.add_source_files(env.modules_sources,"data/icon.cpp") - 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") @@ -55,8 +50,6 @@ module_env.add_source_files(env.modules_sources,"entities/entity.cpp") module_env.add_source_files(env.modules_sources,"entities/player.cpp") module_env.add_source_files(env.modules_sources,"entities/mob.cpp") -module_env.add_source_files(env.modules_sources,"spells/spell_manager.cpp") - module_env.add_source_files(env.modules_sources,"ui/unit_frame.cpp") module_env.add_source_files(env.modules_sources,"drag_and_drop/es_drag_and_drop.cpp") diff --git a/data/aura.cpp b/data/aura.cpp index 54bec24..b02296f 100644 --- a/data/aura.cpp +++ b/data/aura.cpp @@ -130,6 +130,14 @@ void Aura::OnAuraAbilityScalingDataLoaded(AbilityScalingDataLoaderHelper *h) { bool Aura::has_effect_visual() { return _effect_visual.is_valid(); } + +EntityEnums::CharacterSkeletonPoints Aura::get_effect_visual_point() { + return _effect_visual_point; +} +void Aura::set_effect_visual_point(EntityEnums::CharacterSkeletonPoints point) { + _effect_visual_point = point; +} + Ref Aura::get_effect_visual() { return _effect_visual; } @@ -889,6 +897,11 @@ void Aura::_bind_methods() { //Visual Effect ADD_GROUP("Visual Effect", "effect"); ClassDB::bind_method(D_METHOD("has_effect_visual"), &Aura::has_effect_visual); + + ClassDB::bind_method(D_METHOD("get_effect_visual_point"), &Aura::get_effect_visual_point); + ClassDB::bind_method(D_METHOD("set_effect_visual_point", "value"), &Aura::set_effect_visual_point); + ADD_PROPERTY(PropertyInfo(Variant::INT, "effect_visual_point", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS), "set_effect_visual_point", "get_effect_visual_point"); + ClassDB::bind_method(D_METHOD("get_effect_visual"), &Aura::get_effect_visual); ClassDB::bind_method(D_METHOD("set_effect_visual", "value"), &Aura::set_effect_visual); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "effect_visual", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_effect_visual", "get_effect_visual"); diff --git a/data/aura.h b/data/aura.h index 42b8c33..048bfda 100644 --- a/data/aura.h +++ b/data/aura.h @@ -72,6 +72,10 @@ public: //VisualEffect bool has_effect_visual(); + + EntityEnums::CharacterSkeletonPoints get_effect_visual_point(); + void set_effect_visual_point(EntityEnums::CharacterSkeletonPoints point); + Ref get_effect_visual(); void set_effect_visual(Ref value); @@ -338,6 +342,7 @@ private: String _aura_description; int ability_scale_data_id; + EntityEnums::CharacterSkeletonPoints _effect_visual_point; Ref _effect_visual; bool _damage_enabled; diff --git a/data/bone_visual_attachment.cpp b/data/bone_visual_attachment.cpp index 0d504ba..acf5d08 100644 --- a/data/bone_visual_attachment.cpp +++ b/data/bone_visual_attachment.cpp @@ -18,11 +18,11 @@ void BoneVisualAttachment::set_attachment_type(BoneVisualAttachment::BoneVisualA _attachment_type = attachment_type; } -EntityEnums::CharacterSkeletonBoneId BoneVisualAttachment::get_target_bone() { +EntityEnums::CharacterSkeletonPoints BoneVisualAttachment::get_target_bone() { return _target_bone; } -void BoneVisualAttachment::set_target_bone(EntityEnums::CharacterSkeletonBoneId target_bone) { +void BoneVisualAttachment::set_target_bone(EntityEnums::CharacterSkeletonPoints target_bone) { _target_bone = target_bone; } @@ -36,7 +36,7 @@ void BoneVisualAttachment::set_effect(Ref effect) { BoneVisualAttachment::BoneVisualAttachment() { _id = 0; - _target_bone = EntityEnums::BONE_ID_HIP; + _target_bone = EntityEnums::SKELETON_POINT_BASE; } void BoneVisualAttachment::_bind_methods() { @@ -50,7 +50,7 @@ void BoneVisualAttachment::_bind_methods() { ClassDB::bind_method(D_METHOD("get_target_bone"), &BoneVisualAttachment::get_target_bone); ClassDB::bind_method(D_METHOD("set_target_bone", "target_bone"), &BoneVisualAttachment::set_target_bone); - ADD_PROPERTY(PropertyInfo(Variant::INT, "target_bone", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_CHARCATER_SKELETON_BONE_ID), "set_target_bone", "get_target_bone"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "target_bone", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS), "set_target_bone", "get_target_bone"); ClassDB::bind_method(D_METHOD("get_effect"), &BoneVisualAttachment::get_effect); ClassDB::bind_method(D_METHOD("set_effect", "path"), &BoneVisualAttachment::set_effect); diff --git a/data/bone_visual_attachment.h b/data/bone_visual_attachment.h index 97d5fcc..e1fe444 100644 --- a/data/bone_visual_attachment.h +++ b/data/bone_visual_attachment.h @@ -27,8 +27,8 @@ public: BoneVisualAttachmentType get_attachment_type(); void set_attachment_type(BoneVisualAttachmentType attachment_type); - EntityEnums::CharacterSkeletonBoneId get_target_bone(); - void set_target_bone(EntityEnums::CharacterSkeletonBoneId bone); + EntityEnums::CharacterSkeletonPoints get_target_bone(); + void set_target_bone(EntityEnums::CharacterSkeletonPoints bone); Ref get_effect(); void set_effect(Ref effect); @@ -41,7 +41,7 @@ protected: private: int _id; BoneVisualAttachmentType _attachment_type; - EntityEnums::CharacterSkeletonBoneId _target_bone; + EntityEnums::CharacterSkeletonPoints _target_bone; Ref _effect; }; diff --git a/data/character.cpp b/data/character.cpp index 84a28d3..143502c 100644 --- a/data/character.cpp +++ b/data/character.cpp @@ -3,10 +3,6 @@ #include "../data/spell.h" #include "../entities/entity.h" -#if ENTITY_MEM_TOOLS -int CharacterClass::allocs = 0; -#endif - int CharacterClass::get_id() { return _id; } @@ -250,11 +246,6 @@ CharacterClass::CharacterClass() { _num_specs = 0; _num_spells = 0; _current_spell_page = 0; - -#if ENTITY_MEM_TOOLS - CharacterClass::allocs++; - print_error("CharacterClass alloc " + String::num(CharacterClass::allocs)); -#endif } CharacterClass::~CharacterClass() { @@ -263,9 +254,4 @@ CharacterClass::~CharacterClass() { //for (int i = 0; i < MAX_SPELLS; ++i) { //_spells[i] = Ref(NULL); //} - -#if ENTITY_MEM_TOOLS - CharacterClass::allocs--; - print_error("CharacterClass dealloc " + String::num(CharacterClass::allocs)); -#endif } diff --git a/data/character.h b/data/character.h index 512c478..bf2b16b 100644 --- a/data/character.h +++ b/data/character.h @@ -122,10 +122,6 @@ private: //Vector _mob_dislike_ids; //MobSpellData *_mob_spell_data; - -#if ENTITY_MEM_TOOLS - static int allocs; -#endif }; #endif diff --git a/data/character_spec.cpp b/data/character_spec.cpp index fb6b8f5..1026cdd 100644 --- a/data/character_spec.cpp +++ b/data/character_spec.cpp @@ -1,9 +1,5 @@ #include "character_spec.h" -#if ENTITY_MEM_TOOLS -int CharacterSpec::allocs = 0; -#endif - int CharacterSpec::get_spec_id() { return _spec_id; } @@ -69,18 +65,9 @@ CharacterSpec::CharacterSpec() { } _spec_id = 0; - -#if ENTITY_MEM_TOOLS - CharacterSpec::allocs++; - print_error("CharacterSpec alloc " + String::num(CharacterSpec::allocs)); -#endif } CharacterSpec::~CharacterSpec() { -#if ENTITY_MEM_TOOLS - CharacterSpec::allocs--; - print_error("CharacterSpec dealloc " + String::num(CharacterSpec::allocs)); -#endif } void CharacterSpec::_bind_methods() { diff --git a/data/character_spec.h b/data/character_spec.h index d9cc5b1..48bf2c3 100644 --- a/data/character_spec.h +++ b/data/character_spec.h @@ -49,10 +49,6 @@ private: int _spec_id; String _spec_name; Ref _rows[MAX_TALENT_ROWS]; - -#if ENTITY_MEM_TOOLS - static int allocs; -#endif }; #endif diff --git a/data/craft_data_attribute.cpp b/data/craft_data_attribute.cpp index 3f693af..44c5fa2 100644 --- a/data/craft_data_attribute.cpp +++ b/data/craft_data_attribute.cpp @@ -1,9 +1,5 @@ #include "craft_data_attribute.h" -#if ENTITY_MEM_TOOLS -int CraftDataAttribute::allocs = 0; -#endif - const String CraftDataAttribute::BINDING_STRING_CRAFT_CATEGORIES = "None, Alchemy"; const String CraftDataAttribute::BINDING_STRING_CRAFT_SUB_CATEGORIES = "None, Potions"; @@ -88,22 +84,12 @@ CraftDataAttribute::CraftDataAttribute() { //for (int i = 0; i < MAX_REQUIRED_MATERIALS; ++i) { // _required_materials[i] = Ref(memnew(CraftDataAttributeHelper())); //} - -#if ENTITY_MEM_TOOLS - CraftDataAttribute::allocs++; - print_error("CraftDataAttribute alloc " + String::num(CraftDataAttribute::allocs)); -#endif } CraftDataAttribute::~CraftDataAttribute() { //TODO check if the array destrutors actually unref the objects. //_item = Ref(NULL); - -#if ENTITY_MEM_TOOLS - CraftDataAttribute::allocs--; - print_error("CraftDataAttributede alloc " + String::num(CraftDataAttribute::allocs)); -#endif } void CraftDataAttribute::_validate_property(PropertyInfo &property) const { diff --git a/data/craft_data_attribute.h b/data/craft_data_attribute.h index 076321c..f69a457 100644 --- a/data/craft_data_attribute.h +++ b/data/craft_data_attribute.h @@ -79,10 +79,6 @@ private: Ref _required_materials[MAX_REQUIRED_MATERIALS]; Ref _item; - -#if ENTITY_MEM_TOOLS - static int allocs; -#endif }; VARIANT_ENUM_CAST(CraftDataAttribute::CraftSubCategories); diff --git a/data/craft_data_attribute_helper.h b/data/craft_data_attribute_helper.h index 88ba2e9..f955985 100644 --- a/data/craft_data_attribute_helper.h +++ b/data/craft_data_attribute_helper.h @@ -23,10 +23,6 @@ protected: private: Ref _item; int _count; - -#if ENTITY_MEM_TOOLS - static int allocs; -#endif }; #endif diff --git a/data/data_manager.cpp b/data/data_manager.cpp index 7b663f0..8db60a8 100644 --- a/data/data_manager.cpp +++ b/data/data_manager.cpp @@ -1,271 +1,321 @@ #include "data_manager.h" -#include "spell.h" #include "aura.h" #include "character.h" #include "craft_data_attribute.h" +#include "spell.h" DataManager *DataManager::instance; DataManager *DataManager::get_instance() { - return instance; + return instance; } void DataManager::_notification(int p_what) { - switch (p_what) { + switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - if (get_automatic_load()) { - load_all(); - } - } - break; - case NOTIFICATION_EXIT_TREE: { + case NOTIFICATION_ENTER_TREE: { + if (get_automatic_load()) { + load_all(); + } + } break; + case NOTIFICATION_EXIT_TREE: { - } break; - } + } break; + } +} + +String DataManager::get_character_classes_folder() { + return _character_classes_folder; +} + +void DataManager::set_character_classes_folder(String folder) { + _character_classes_folder = folder; +} + +Vector > *DataManager::get_character_classes() { + return &_character_classes; } Ref DataManager::get_character_class(int class_id) { - ERR_FAIL_COND_V(!_character_class_map->has(class_id), Ref(NULL)); + ERR_FAIL_COND_V(!_character_class_map.has(class_id), Ref(NULL)); - return _character_class_map->get(class_id); + return _character_class_map.get(class_id); } Ref DataManager::get_character_class_index(int index) { - ERR_FAIL_INDEX_V(index, _character_classes->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _character_classes.size(), Ref(NULL)); - return _character_classes->get(index); + return _character_classes.get(index); } int DataManager::get_character_class_count() { - return _character_classes->size(); + return _character_classes.size(); } void DataManager::add_character_class(Ref cls) { ERR_FAIL_COND(!cls.is_valid()); - _character_classes->push_back(cls); - _character_class_map->set(cls->get_id(), cls); + _character_classes.push_back(cls); + _character_class_map.set(cls->get_id(), cls); +} + +String DataManager::get_spells_folder() { + return _spells_folder; +} +void DataManager::set_spells_folder(String folder) { + _spells_folder = folder; +} +Vector > *DataManager::get_spells() { + return &_spells; } Ref DataManager::get_spell(int spell_id) { - ERR_FAIL_COND_V(!_spell_map->has(spell_id), Ref(NULL)); + ERR_FAIL_COND_V(!_spell_map.has(spell_id), Ref(NULL)); - return _spell_map->get(spell_id); + return _spell_map.get(spell_id); } Ref DataManager::get_spell_index(int index) { - ERR_FAIL_INDEX_V(index, _spells->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _spells.size(), Ref(NULL)); - return _spells->get(index); + return _spells.get(index); } int DataManager::get_spell_count() { - return _spells->size(); + return _spells.size(); } void DataManager::add_spell(Ref spell) { ERR_FAIL_COND(!spell.is_valid()); - _spells->push_back(spell); - _spell_map->set(spell->get_spell_id(), spell); + _spells.push_back(spell); + _spell_map.set(spell->get_spell_id(), spell); } void DataManager::add_aura(Ref aura) { ERR_FAIL_COND(!aura.is_valid()); - _auras->push_back(aura); - _aura_map->set(aura->get_id(), aura); + _auras.push_back(aura); + _aura_map.set(aura->get_id(), aura); +} + +String DataManager::get_auras_folder() { + return _auras_folder; +} +void DataManager::set_auras_folder(String folder) { + _auras_folder = folder; +} +Vector > *DataManager::get_auras() { + return &_auras; } Ref DataManager::get_aura(int aura_id) { - ERR_FAIL_COND_V(!_aura_map->has(aura_id), Ref(NULL)); + ERR_FAIL_COND_V(!_aura_map.has(aura_id), Ref(NULL)); - return _aura_map->get(aura_id); + return _aura_map.get(aura_id); } Ref DataManager::get_aura_index(int index) { - ERR_FAIL_INDEX_V(index, _auras->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _auras.size(), Ref(NULL)); - return _auras->get(index); + return _auras.get(index); } int DataManager::get_aura_count() { - return _auras->size(); + return _auras.size(); } void DataManager::add_craft_data(Ref cda) { ERR_FAIL_COND(!cda.is_valid()); - _craft_datas->push_back(cda); - _craft_data_map->set(cda->get_id(), cda); + _craft_datas.push_back(cda); + _craft_data_map.set(cda->get_id(), cda); +} + +String DataManager::get_craft_data_folder() { + return _craft_data_folder; +} +void DataManager::set_craft_data_folder(String folder) { + _craft_data_folder = folder; +} +Vector > *DataManager::get_craft_datas() { + return &_craft_datas; } Ref DataManager::get_craft_data(int craft_id) { - ERR_FAIL_COND_V(!_craft_data_map->has(craft_id), Ref(NULL)); + ERR_FAIL_COND_V(!_craft_data_map.has(craft_id), Ref(NULL)); - return _craft_data_map->get(craft_id); + return _craft_data_map.get(craft_id); } Ref DataManager::get_craft_data_index(int index) { - ERR_FAIL_INDEX_V(index, _craft_datas->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _craft_datas.size(), Ref(NULL)); - return _craft_datas->get(index); + return _craft_datas.get(index); } int DataManager::get_craft_data_count() { - return _craft_datas->size(); + return _craft_datas.size(); +} + +String DataManager::get_item_template_folder() { + return _item_template_folder; +} +void DataManager::set_item_template_folder(String folder) { + _item_template_folder = folder; +} +Vector > *DataManager::get_item_templates() { + return &_item_templates; } void DataManager::add_item_template(Ref cda) { ERR_FAIL_COND(!cda.is_valid()); - _craft_datas->push_back(cda); - _craft_data_map->set(cda->get_id(), cda); + _craft_datas.push_back(cda); + _craft_data_map.set(cda->get_id(), cda); } Ref DataManager::get_item_template(int item_id) { - ERR_FAIL_COND_V(!_craft_data_map->has(item_id), Ref(NULL)); + ERR_FAIL_COND_V(!_craft_data_map.has(item_id), Ref(NULL)); - return _item_template_map->get(item_id); + return _item_template_map.get(item_id); } Ref DataManager::get_item_template_index(int index) { - ERR_FAIL_INDEX_V(index, _craft_datas->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _craft_datas.size(), Ref(NULL)); - return _item_templates->get(index); + return _item_templates.get(index); } int DataManager::get_item_template_count() { - return _item_templates->size(); + return _item_templates.size(); } - void DataManager::load_all() { - load_spells(); - load_auras(); - load_characters(); + load_spells(); + load_auras(); + load_characters(); load_craft_datas(); load_item_templates(); } void DataManager::load_spells() { - _Directory dir; + _Directory dir; ERR_FAIL_COND(_spells_folder.ends_with("/")); - if (dir.open(_spells_folder) == OK) { + if (dir.open(_spells_folder) == OK) { - dir.list_dir_begin(); + dir.list_dir_begin(); - String filename = dir.get_next(); + String filename = dir.get_next(); - while (filename != "") { - if (!dir.current_is_dir()) { - String path = _spells_folder + "/" + filename; + while (filename != "") { + if (!dir.current_is_dir()) { + String path = _spells_folder + "/" + filename; - _ResourceLoader *rl = _ResourceLoader::get_singleton(); + _ResourceLoader *rl = _ResourceLoader::get_singleton(); - Ref resl = rl->load_interactive(path, "Spell"); + Ref resl = rl->load_interactive(path, "Spell"); - resl->wait(); + resl->wait(); - Ref s = resl->get_resource(); + Ref s = resl->get_resource(); ERR_CONTINUE(!s.is_valid()); - Ref spell = s; + Ref spell = s; ERR_CONTINUE(!spell.is_valid()); add_spell(spell); - } + } - filename = dir.get_next(); - } - } else { - print_error("An error occurred when trying to access the path."); - } + filename = dir.get_next(); + } + } else { + print_error("An error occurred when trying to access the path."); + } } void DataManager::load_auras() { - _Directory dir; + _Directory dir; ERR_FAIL_COND(_auras_folder.ends_with("/")); - if (dir.open(_auras_folder) == OK) { + if (dir.open(_auras_folder) == OK) { - dir.list_dir_begin(); + dir.list_dir_begin(); - String filename = dir.get_next(); + String filename = dir.get_next(); - while (filename != "") { - if (!dir.current_is_dir()) { - String path = _auras_folder + "/" + filename; + while (filename != "") { + if (!dir.current_is_dir()) { + String path = _auras_folder + "/" + filename; - _ResourceLoader *rl = _ResourceLoader::get_singleton(); + _ResourceLoader *rl = _ResourceLoader::get_singleton(); - Ref resl = rl->load_interactive(path, "Aura"); - - resl->wait(); + Ref resl = rl->load_interactive(path, "Aura"); - Ref s = resl->get_resource(); + resl->wait(); + + Ref s = resl->get_resource(); ERR_CONTINUE(!s.is_valid()); - Ref aura = s; + Ref aura = s; ERR_CONTINUE(!aura.is_valid()); - add_aura(aura); - } + add_aura(aura); + } - filename = dir.get_next(); - } - } else { - print_error("An error occurred when trying to access the path."); - } + filename = dir.get_next(); + } + } else { + print_error("An error occurred when trying to access the path."); + } } void DataManager::load_characters() { - _Directory dir; + _Directory dir; ERR_FAIL_COND(_character_classes_folder.ends_with("/")); - if (dir.open(_character_classes_folder) == OK) { + if (dir.open(_character_classes_folder) == OK) { - dir.list_dir_begin(); + dir.list_dir_begin(); - String filename = dir.get_next(); + String filename = dir.get_next(); - while (filename != "") { - if (!dir.current_is_dir()) { - String path = _character_classes_folder + "/" + filename; + while (filename != "") { + if (!dir.current_is_dir()) { + String path = _character_classes_folder + "/" + filename; - _ResourceLoader *rl = _ResourceLoader::get_singleton(); + _ResourceLoader *rl = _ResourceLoader::get_singleton(); - Ref resl = rl->load_interactive(path, "CharacterClass"); + Ref resl = rl->load_interactive(path, "CharacterClass"); - resl->wait(); + resl->wait(); - Ref s = resl->get_resource(); + Ref s = resl->get_resource(); ERR_CONTINUE(!s.is_valid()); - Ref cls = s; + Ref cls = s; ERR_CONTINUE(!cls.is_valid()); - add_character_class(cls); - } + add_character_class(cls); + } - filename = dir.get_next(); - } - } else { - print_error("An error occurred when trying to access the path."); - } + filename = dir.get_next(); + } + } else { + print_error("An error occurred when trying to access the path."); + } } void DataManager::load_craft_datas() { @@ -329,7 +379,7 @@ void DataManager::load_item_templates() { resl->wait(); Ref s = resl->get_resource(); - + ERR_CONTINUE(!s.is_valid()); Ref it = s; @@ -347,69 +397,69 @@ void DataManager::load_item_templates() { } void DataManager::list_characters() { - for (int i = 0; i < _character_classes->size(); ++i) { - print_error(itos(i) + ": " + _character_classes->get(i)->get_character_class_name()); - } + for (int i = 0; i < _character_classes.size(); ++i) { + print_error(itos(i) + ": " + _character_classes.get(i)->get_character_class_name()); + } } void DataManager::list_spells() { - for (int i = 0; i < _spells->size(); ++i) { - print_error(itos(i) + ": " + _spells->get(i)->get_spell_name()); - } + for (int i = 0; i < _spells.size(); ++i) { + print_error(itos(i) + ": " + _spells.get(i)->get_spell_name()); + } } void DataManager::list_auras() { - for (int i = 0; i < _auras->size(); ++i) { - print_error(itos(i) + ": " + _auras->get(i)->get_aura_name()); - } + for (int i = 0; i < _auras.size(); ++i) { + print_error(itos(i) + ": " + _auras.get(i)->get_aura_name()); + } } void DataManager::list_craft_data() { - for (int i = 0; i < _craft_datas->size(); ++i) { - print_error(itos(i) + ": " + _craft_datas->get(i)->get_name()); + for (int i = 0; i < _craft_datas.size(); ++i) { + print_error(itos(i) + ": " + _craft_datas.get(i)->get_name()); } } void DataManager::list_item_templates() { - for (int i = 0; i < _item_templates->size(); ++i) { - print_error(itos(i) + ": " + _item_templates->get(i)->get_name()); + for (int i = 0; i < _item_templates.size(); ++i) { + print_error(itos(i) + ": " + _item_templates.get(i)->get_name()); } } void DataManager::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_automatic_load"), &DataManager::get_automatic_load); - ClassDB::bind_method(D_METHOD("set_automatic_load", "load"), &DataManager::set_automatic_load); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load"); + ClassDB::bind_method(D_METHOD("get_automatic_load"), &DataManager::get_automatic_load); + ClassDB::bind_method(D_METHOD("set_automatic_load", "load"), &DataManager::set_automatic_load); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load"); - ClassDB::bind_method(D_METHOD("load_all"), &DataManager::load_all); - ClassDB::bind_method(D_METHOD("load_spells"), &DataManager::load_spells); - ClassDB::bind_method(D_METHOD("load_characters"), &DataManager::load_characters); + ClassDB::bind_method(D_METHOD("load_all"), &DataManager::load_all); + ClassDB::bind_method(D_METHOD("load_spells"), &DataManager::load_spells); + ClassDB::bind_method(D_METHOD("load_characters"), &DataManager::load_characters); ClassDB::bind_method(D_METHOD("load_craft_datas"), &DataManager::load_craft_datas); - //CharacterClass - ClassDB::bind_method(D_METHOD("get_character_classes_folder"), &DataManager::get_character_classes_folder); - ClassDB::bind_method(D_METHOD("set_character_classes_folder", "folder"), &DataManager::set_character_classes_folder); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "character_classes_folder"), "set_character_classes_folder", "get_character_classes_folder"); + //CharacterClass + ClassDB::bind_method(D_METHOD("get_character_classes_folder"), &DataManager::get_character_classes_folder); + ClassDB::bind_method(D_METHOD("set_character_classes_folder", "folder"), &DataManager::set_character_classes_folder); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "character_classes_folder"), "set_character_classes_folder", "get_character_classes_folder"); - ClassDB::bind_method(D_METHOD("add_character_class", "cls"), &DataManager::add_character_class); - ClassDB::bind_method(D_METHOD("get_character_class", "class_id"), &DataManager::get_character_class); + ClassDB::bind_method(D_METHOD("add_character_class", "cls"), &DataManager::add_character_class); + ClassDB::bind_method(D_METHOD("get_character_class", "class_id"), &DataManager::get_character_class); ClassDB::bind_method(D_METHOD("get_character_class_index", "index"), &DataManager::get_character_class_index); ClassDB::bind_method(D_METHOD("get_character_class_count"), &DataManager::get_character_class_count); - //Spell - ClassDB::bind_method(D_METHOD("get_spells_folder"), &DataManager::get_spells_folder); - ClassDB::bind_method(D_METHOD("set_spells_folder", "folder"), &DataManager::set_spells_folder); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "spells_folder"), "set_spells_folder", "get_spells_folder"); + //Spell + ClassDB::bind_method(D_METHOD("get_spells_folder"), &DataManager::get_spells_folder); + ClassDB::bind_method(D_METHOD("set_spells_folder", "folder"), &DataManager::set_spells_folder); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "spells_folder"), "set_spells_folder", "get_spells_folder"); - ClassDB::bind_method(D_METHOD("add_spell", "spell"), &DataManager::add_spell); - ClassDB::bind_method(D_METHOD("get_spell", "spell_id"), &DataManager::get_spell); + ClassDB::bind_method(D_METHOD("add_spell", "spell"), &DataManager::add_spell); + ClassDB::bind_method(D_METHOD("get_spell", "spell_id"), &DataManager::get_spell); ClassDB::bind_method(D_METHOD("get_spell_index", "index"), &DataManager::get_spell_index); ClassDB::bind_method(D_METHOD("get_spell_count"), &DataManager::get_spell_count); - //Aura - ClassDB::bind_method(D_METHOD("get_auras_folder"), &DataManager::get_auras_folder); - ClassDB::bind_method(D_METHOD("set_auras_folder", "folder"), &DataManager::set_auras_folder); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "auras_folder"), "set_auras_folder", "get_auras_folder"); + //Aura + ClassDB::bind_method(D_METHOD("get_auras_folder"), &DataManager::get_auras_folder); + ClassDB::bind_method(D_METHOD("set_auras_folder", "folder"), &DataManager::set_auras_folder); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "auras_folder"), "set_auras_folder", "get_auras_folder"); ClassDB::bind_method(D_METHOD("add_aura", "spell"), &DataManager::add_aura); ClassDB::bind_method(D_METHOD("get_aura", "id"), &DataManager::get_aura); @@ -436,61 +486,29 @@ void DataManager::_bind_methods() { ClassDB::bind_method(D_METHOD("get_item_template_index", "index"), &DataManager::get_item_template_index); ClassDB::bind_method(D_METHOD("get_item_template_count"), &DataManager::get_item_template_count); - //tests - ClassDB::bind_method(D_METHOD("list_spells"), &DataManager::list_spells); - ClassDB::bind_method(D_METHOD("list_characters"), &DataManager::list_characters); - ClassDB::bind_method(D_METHOD("list_auras"), &DataManager::list_auras); + //tests + ClassDB::bind_method(D_METHOD("list_spells"), &DataManager::list_spells); + ClassDB::bind_method(D_METHOD("list_characters"), &DataManager::list_characters); + ClassDB::bind_method(D_METHOD("list_auras"), &DataManager::list_auras); ClassDB::bind_method(D_METHOD("list_craft_data"), &DataManager::list_craft_data); ClassDB::bind_method(D_METHOD("list_item_templates"), &DataManager::list_item_templates); } DataManager::DataManager() { - instance = this; + instance = this; - _character_classes = memnew(Vector >()); - _character_class_map = memnew(CharacterClassHashMap()); - - _spells = memnew(Vector >()); - _spell_map = memnew(SpellHashMap()); - - _auras = memnew(Vector >()); - _aura_map = memnew(AuraHashMap()); - - _craft_datas = memnew(Vector >()); - _craft_data_map = memnew(CraftDataHashMap()); - - _item_templates = memnew(Vector >()); - _item_template_map = memnew(ItemTemplateHashMap()); - - _automatic_load = true; + _automatic_load = true; } DataManager::~DataManager() { - instance = NULL; + instance = NULL; - _character_classes->clear(); - _character_class_map->clear(); - _spells->clear(); - _spell_map->clear(); - _auras->clear(); - _aura_map->clear(); - _craft_datas->clear(); - _craft_data_map->clear(); - //_spell_scripts->clear(); - //_spell_script_map->clear(); - - memdelete(_character_classes); - memdelete(_character_class_map); - - memdelete(_spells); - memdelete(_spell_map); - - memdelete(_auras); - memdelete(_aura_map); - - memdelete(_craft_datas); - memdelete(_craft_data_map); - - memdelete(_item_templates); - memdelete(_item_template_map); + _character_classes.clear(); + _character_class_map.clear(); + _spells.clear(); + _spell_map.clear(); + _auras.clear(); + _aura_map.clear(); + _craft_datas.clear(); + _craft_data_map.clear(); } diff --git a/data/data_manager.h b/data/data_manager.h index 9ca02cc..0e1675d 100644 --- a/data/data_manager.h +++ b/data/data_manager.h @@ -19,54 +19,47 @@ class CharacterClass; class CraftDataAttribute; class ItemTemplate; -typedef HashMap > CharacterClassHashMap; -typedef HashMap > SpellHashMap; -typedef HashMap > AuraHashMap; -typedef HashMap > CraftDataHashMap; -typedef HashMap > ItemTemplateHashMap; -//typedef HashMap > SpellScriptHashMap; - class DataManager : public Node { GDCLASS(DataManager, Node); public: static DataManager *get_instance(); - String get_character_classes_folder() { return _character_classes_folder; } - void set_character_classes_folder(String folder) { _character_classes_folder = folder; } - Vector > *get_character_classes() { return _character_classes; } + String get_character_classes_folder(); + void set_character_classes_folder(String folder); + Vector > *get_character_classes(); Ref get_character_class(int class_id); Ref get_character_class_index(int index); int get_character_class_count(); void add_character_class(Ref cls); - String get_spells_folder() { return _spells_folder; } - void set_spells_folder(String folder) { _spells_folder = folder; } - Vector > *get_spells() { return _spells; } + String get_spells_folder(); + void set_spells_folder(String folder); + Vector > *get_spells(); Ref get_spell(int spell_id); Ref get_spell_index(int index); int get_spell_count(); void add_spell(Ref spell); - String get_auras_folder() { return _auras_folder; } - void set_auras_folder(String folder) { _auras_folder = folder; } - Vector > *get_auras() { return _auras; } + String get_auras_folder(); + void set_auras_folder(String folder); + Vector > *get_auras(); Ref get_aura(int aura_id); Ref get_aura_index(int index); int get_aura_count(); void add_aura(Ref aura); - String get_craft_data_folder() { return _craft_data_folder; } - void set_craft_data_folder(String folder) { _craft_data_folder = folder; } - Vector > *get_craft_datas() { return _craft_datas; } + String get_craft_data_folder(); + void set_craft_data_folder(String folder); + Vector > *get_craft_datas(); Ref get_craft_data(int craft_id); Ref get_craft_data_index(int index); int get_craft_data_count(); void add_craft_data(Ref aura); - String get_item_template_folder() { return _item_template_folder; } - void set_item_template_folder(String folder) { _item_template_folder = folder; } - Vector > *get_item_templates() { return _item_templates; } + String get_item_template_folder(); + void set_item_template_folder(String folder); + Vector > *get_item_templates(); void add_item_template(Ref aura); Ref get_item_template(int item_id); Ref get_item_template_index(int index); @@ -97,28 +90,24 @@ protected: private: String _character_classes_folder; - Vector > *_character_classes; - CharacterClassHashMap *_character_class_map; + Vector > _character_classes; + HashMap > _character_class_map; String _spells_folder; - Vector > *_spells; - SpellHashMap *_spell_map; + Vector > _spells; + HashMap > _spell_map; String _auras_folder; - Vector > *_auras; - AuraHashMap *_aura_map; + Vector > _auras; + HashMap > _aura_map; String _craft_data_folder; - Vector > *_craft_datas; - CraftDataHashMap *_craft_data_map; + Vector > _craft_datas; + HashMap > _craft_data_map; String _item_template_folder; - Vector > *_item_templates; - ItemTemplateHashMap *_item_template_map; - - /* - Vector > *_spell_scripts; - SpellScriptHashMap *_spell_script_map;*/ + Vector > _item_templates; + HashMap > _item_template_map; static DataManager *instance; diff --git a/data/icon.cpp b/data/icon.cpp deleted file mode 100644 index f5ba2cc..0000000 --- a/data/icon.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "icon.h" - -int Icon::get_id() { - return _id; -} - -void Icon::set_id(int value) { - _id = value; -} - -String Icon::get_icon_file_name() { - return _icon_file_name; -} - -void Icon::set_icon_file_name(String value) { - _icon_file_name = value; -} - -Vector2i Icon::get_icon_atlas_position() { - return _icon_atlas_position; -} - -void Icon::set_icon_atlas_position(Vector2i value) { - _icon_atlas_position = value; -} - -Ref Icon::get_icon() { - return _icon; -} - -void Icon::set_icon(Ref value) { - _icon = value; -} - -void Icon::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_id"), &Icon::get_id); - ClassDB::bind_method(D_METHOD("set_id", "value"), &Icon::set_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); - - ClassDB::bind_method(D_METHOD("get_icon_file_name"), &Icon::get_icon_file_name); - ClassDB::bind_method(D_METHOD("set_icon_file_name", "value"), &Icon::set_icon_file_name); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "icon_file_name"), "set_icon_file_name", "get_icon_file_name"); - - //ClassDB::bind_method(D_METHOD("get_icon_atlas_position"), &Icon::get_icon_atlas_position); - //ClassDB::bind_method(D_METHOD("set_icon_atlas_position", "value"), &Icon::set_icon_atlas_position); - //ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "icon_atlas_position"), "set_icon_atlas_position", "get_icon_atlas_position"); - - ClassDB::bind_method(D_METHOD("get_icon"), &Icon::get_icon); - ClassDB::bind_method(D_METHOD("set_icon", "value"), &Icon::set_icon); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon_atlas_position", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_icon", "get_icon"); - - ClassDB::bind_method(D_METHOD("Load_icon"), &Icon::Load_icon); - ClassDB::bind_method(D_METHOD("is_icon_loaded"), &Icon::is_icon_loaded); -} - -Icon::Icon() { - _id = 0; - _icon_file_name = ""; -} - -Icon::Icon(int id, String icon_file_name, Vector2i icon_atlas_position) { - _id = id; - _icon_file_name = icon_file_name; - _icon_atlas_position = icon_atlas_position; - //_icon ; -} - -/* -Rect* Icon::GetIconRect() -{ - return new Rect((float)(iconAtlasPosition->x * 16), (float)(iconAtlasPosition->y * 16), (float)16, (float)16); -} -*/ diff --git a/data/icon.h b/data/icon.h deleted file mode 100644 index 56c8f68..0000000 --- a/data/icon.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef ICON_H -#define ICON_H - -#include "core/resource.h" -#include "scene/resources/texture.h" - -class Icon : public Resource { - GDCLASS(Icon, Resource) - -public: - int get_id(); - void set_id(int value); - - String get_icon_file_name(); - void set_icon_file_name(String value); - - Vector2i get_icon_atlas_position(); - void set_icon_atlas_position(Vector2i value); - - Ref get_icon(); - void set_icon(Ref value); - - Icon(); - Icon(int id, String _icon_file_name, Vector2i iconAtlasPosition); - - void Load_icon() {} - //Rect *Get_icon_rect(); - - bool is_icon_loaded() { return _icon != nullptr; } - -protected: - static void _bind_methods(); - -public: - int _id; - String _icon_file_name; - Vector2i _icon_atlas_position; - Ref _icon; -}; - -#endif diff --git a/data/item_template.cpp b/data/item_template.cpp index c6aaaea..ecae41d 100644 --- a/data/item_template.cpp +++ b/data/item_template.cpp @@ -4,89 +4,85 @@ #include "spell.h" int ItemTemplate::get_id() { - return _id; + return _id; } void ItemTemplate::set_id(int value) { - _id = value; + _id = value; } String ItemTemplate::get_name_key() { - return _name_key; + return _name_key; } void ItemTemplate::set_name_key(String value) { - _name_key = value; + _name_key = value; } - ItemEnums::ItemType ItemTemplate::get_item_type() { - return _item_type; + return _item_type; } void ItemTemplate::set_item_type(ItemEnums::ItemType value) { - _item_type = value; + _item_type = value; } ItemEnums::ItemSubtype ItemTemplate::get_item_sub_type() { - return _item_sub_type; + return _item_sub_type; } void ItemTemplate::set_item_sub_type(ItemEnums::ItemSubtype value) { - _item_sub_type = value; + _item_sub_type = value; } ItemEnums::ItemSubSubtype ItemTemplate::get_item_sub_sub_type() { - return _item_sub_sub_type; + return _item_sub_sub_type; } void ItemTemplate::set_item_sub_sub_type(ItemEnums::ItemSubSubtype value) { - _item_sub_sub_type = value; + _item_sub_sub_type = value; } int ItemTemplate::get_rarity() { - return _rarity; + return _rarity; } void ItemTemplate::set_rarity(int value) { - _rarity = value; + _rarity = value; } - Ref ItemTemplate::get_icon() { - return _icon; + return _icon; } void ItemTemplate::set_icon(Ref value) { - _icon = value; + _icon = value; } - float ItemTemplate::get_scale_x() { - return _scale_x; + return _scale_x; } void ItemTemplate::set_scale_x(float value) { - _scale_x = value; + _scale_x = value; } float ItemTemplate::get_scale_y() { - return _scale_y; + return _scale_y; } void ItemTemplate::set_scale_y(float value) { - _scale_y = value; + _scale_y = value; } float ItemTemplate::get_scale_z() { - return _scale_z; + return _scale_z; } void ItemTemplate::set_scale_z(float value) { - _scale_z = value; + _scale_z = value; } - Ref ItemTemplate::get_spell() { if (_spell) return (*_spell); @@ -101,7 +97,6 @@ void ItemTemplate::set_spell(Ref spell) { _spell = memnew(Ref(spell)); } - Ref ItemTemplate::get_aura(int index) { if (_auras[index]) return (*_auras[index]); @@ -116,117 +111,130 @@ void ItemTemplate::set_aura(int index, Ref aura) { _auras[index] = memnew(Ref(aura)); } - int ItemTemplate::get_item_stat_modifier_count() { - return _modifier_count; + return _modifier_count; } void ItemTemplate::set_item_stat_modifier_count(int value) { - _modifier_count = value; + _modifier_count = value; } Stat::StatId ItemTemplate::get_item_stat_id(int index) { - return _modifiers[index]->get_stat_id(); + return _modifiers[index]->get_stat_id(); } void ItemTemplate::set_item_stat_id(int index, Stat::StatId value) { - _modifiers[index]->set_stat_id(value); + _modifiers[index]->set_stat_id(value); } float ItemTemplate::get_item_min_base_mod(int index) { - return _modifiers[index]->get_min_base_mod(); + return _modifiers[index]->get_min_base_mod(); } void ItemTemplate::set_item_min_base_mod(int index, float value) { - _modifiers[index]->set_min_base_mod(value); + _modifiers[index]->set_min_base_mod(value); } float ItemTemplate::get_item_max_base_mod(int index) { - return _modifiers[index]->get_max_base_mod(); + return _modifiers[index]->get_max_base_mod(); } void ItemTemplate::set_item_max_base_mod(int index, float value) { - _modifiers[index]->set_max_base_mod(value); + _modifiers[index]->set_max_base_mod(value); } - float ItemTemplate::get_item_min_bonus_mod(int index) { - return _modifiers[index]->get_min_bonus_mod(); + return _modifiers[index]->get_min_bonus_mod(); } void ItemTemplate::set_item_min_bonus_mod(int index, float value) { - _modifiers[index]->set_min_bonus_mod(value); + _modifiers[index]->set_min_bonus_mod(value); } float ItemTemplate::get_item_max_bonus_mod(int index) { - return _modifiers[index]->get_max_bonus_mod(); + return _modifiers[index]->get_max_bonus_mod(); } void ItemTemplate::set_item_max_bonus_mod(int index, float value) { - _modifiers[index]->set_max_bonus_mod(value); + _modifiers[index]->set_max_bonus_mod(value); } - float ItemTemplate::get_item_min_percent_mod(int index) { - return _modifiers[index]->get_min_percent_mod(); + return _modifiers[index]->get_min_percent_mod(); } void ItemTemplate::set_item_min_percent_mod(int index, float value) { - _modifiers[index]->set_min_percent_mod(value); + _modifiers[index]->set_min_percent_mod(value); } float ItemTemplate::get_item_max_percent_mod(int index) { - return _modifiers[index]->get_max_percent_mod(); + return _modifiers[index]->get_max_percent_mod(); } void ItemTemplate::set_item_max_percent_mod(int index, float value) { - _modifiers[index]->set_max_percent_mod(value); + _modifiers[index]->set_max_percent_mod(value); } - float ItemTemplate::get_item_scaling_factor(int index) { - return _modifiers[index]->get_scaling_factor(); + return _modifiers[index]->get_scaling_factor(); } void ItemTemplate::set_item_scaling_factor(int index, float value) { - _modifiers[index]->set_scaling_factor(value); + _modifiers[index]->set_scaling_factor(value); } Ref ItemTemplate::get_item_template_stat_modifier(int index) { - return Ref(_modifiers[index]); + return Ref(_modifiers[index]); } /* void ItemTemplate::set_item_stat_modifier(int index, ItemStatModifier modifier) { _modifiers[index] = modifier; }*/ - int ItemTemplate::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; + 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 ItemTemplate::create_item_instance() { + if (has_method("_create_item_instance")) { + Ref ii = call("_create_item_instance"); + + ERR_FAIL_COND_V(!ii.is_valid(), Ref()); + + return ii; + } + + Ref item; + item.instance(); + + //todo setup + ERR_EXPLAIN("NOT YET IMPLEMENTED!"); + ERR_FAIL_V(item); + + return item; +} ItemTemplate::ItemTemplate() { - _id = 0; - _name_key = ""; - _item_type = ItemEnums::ITEM_TYPE_NONE; - _item_sub_type = ItemEnums::ITEM_SUB_TYPE_NONE; - _item_sub_sub_type = ItemEnums::ITEM_SUB_SUB_TYPE_NONE; - _rarity = ItemEnums::ITEM_RARITY_NONE; + _id = 0; + _name_key = ""; + _item_type = ItemEnums::ITEM_TYPE_NONE; + _item_sub_type = ItemEnums::ITEM_SUB_TYPE_NONE; + _item_sub_sub_type = ItemEnums::ITEM_SUB_SUB_TYPE_NONE; + _rarity = ItemEnums::ITEM_RARITY_NONE; - _scale_x = 0; - _scale_y = 0; - _scale_z = 0; - _modifier_count = 0; + _scale_x = 0; + _scale_y = 0; + _scale_z = 0; + _modifier_count = 0; _spell = NULL; @@ -251,27 +259,29 @@ ItemTemplate::~ItemTemplate() { } void ItemTemplate::_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(); - if (frame >= _modifier_count) { - property.usage = 0; - } - } + String prop = property.name; + if (prop.begins_with("Modifiers_")) { + int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int(); + if (frame >= _modifier_count) { + property.usage = 0; + } + } } - void ItemTemplate::_bind_methods() { + BIND_VMETHOD(MethodInfo("_create_item_instance")); + + ClassDB::bind_method(D_METHOD("create_item_instance"), &ItemTemplate::create_item_instance); - ClassDB::bind_method(D_METHOD("get_id"), &ItemTemplate::get_id); - ClassDB::bind_method(D_METHOD("set_id", "count"), &ItemTemplate::set_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); + ClassDB::bind_method(D_METHOD("get_id"), &ItemTemplate::get_id); + ClassDB::bind_method(D_METHOD("set_id", "count"), &ItemTemplate::set_id); + ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); - ClassDB::bind_method(D_METHOD("get_name_key"), &ItemTemplate::get_name_key); - ClassDB::bind_method(D_METHOD("set_name_key", "count"), &ItemTemplate::set_name_key); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "name_key"), "set_name_key", "get_name_key"); + ClassDB::bind_method(D_METHOD("get_name_key"), &ItemTemplate::get_name_key); + ClassDB::bind_method(D_METHOD("set_name_key", "count"), &ItemTemplate::set_name_key); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "name_key"), "set_name_key", "get_name_key"); - ClassDB::bind_method(D_METHOD("get_item_type"), &ItemTemplate::get_item_type); + ClassDB::bind_method(D_METHOD("get_item_type"), &ItemTemplate::get_item_type); ClassDB::bind_method(D_METHOD("set_item_type", "count"), &ItemTemplate::set_item_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "item_type", PROPERTY_HINT_ENUM, ItemEnums::BINDING_STRING_ITEM_TYPE), "set_item_type", "get_item_type"); @@ -287,95 +297,82 @@ void ItemTemplate::_bind_methods() { 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"); - ClassDB::bind_method(D_METHOD("get_icon"), &ItemTemplate::get_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"); + 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"); + ClassDB::bind_method(D_METHOD("get_scale_x"), &ItemTemplate::get_scale_x); + ClassDB::bind_method(D_METHOD("set_scale_x", "count"), &ItemTemplate::set_scale_x); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_x"), "set_scale_x", "get_scale_x"); + ClassDB::bind_method(D_METHOD("get_scale_y"), &ItemTemplate::get_scale_y); + ClassDB::bind_method(D_METHOD("set_scale_y", "count"), &ItemTemplate::set_scale_y); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_y"), "set_scale_y", "get_scale_y"); - ClassDB::bind_method(D_METHOD("get_scale_x"), &ItemTemplate::get_scale_x); - ClassDB::bind_method(D_METHOD("set_scale_x", "count"), &ItemTemplate::set_scale_x); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_x"), "set_scale_x", "get_scale_x"); - - ClassDB::bind_method(D_METHOD("get_scale_y"), &ItemTemplate::get_scale_y); - ClassDB::bind_method(D_METHOD("set_scale_y", "count"), &ItemTemplate::set_scale_y); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale_y"), "set_scale_y", "get_scale_y"); - - ClassDB::bind_method(D_METHOD("get_scale_z"), &ItemTemplate::get_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"); - + ClassDB::bind_method(D_METHOD("get_scale_z"), &ItemTemplate::get_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"); ClassDB::bind_method(D_METHOD("get_spell"), &ItemTemplate::get_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"); + 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"); ClassDB::bind_method(D_METHOD("get_aura", "index"), &ItemTemplate::get_aura); - ClassDB::bind_method(D_METHOD("set_aura", "index", "aura"), &ItemTemplate::set_aura); + ClassDB::bind_method(D_METHOD("set_aura", "index", "aura"), &ItemTemplate::set_aura); for (int i = 0; i < MAX_AURAS; ++i) { - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "aura_" + itos(i + 1), PROPERTY_HINT_RESOURCE_TYPE, "Aura"), "set_aura", "get_aura", i); - } + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "aura_" + itos(i + 1), PROPERTY_HINT_RESOURCE_TYPE, "Aura"), "set_aura", "get_aura", i); + } - //StatMods Property binds - ClassDB::bind_method(D_METHOD("get_item_stat_modifier_count"), &ItemTemplate::get_item_stat_modifier_count); - ClassDB::bind_method(D_METHOD("set_item_stat_modifier_count", "count"), &ItemTemplate::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"); + //StatMods Property binds + ClassDB::bind_method(D_METHOD("get_item_stat_modifier_count"), &ItemTemplate::get_item_stat_modifier_count); + ClassDB::bind_method(D_METHOD("set_item_stat_modifier_count", "count"), &ItemTemplate::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"), &ItemTemplate::get_item_stat_id); - ClassDB::bind_method(D_METHOD("set_item_stat_id", "index", "value"), &ItemTemplate::set_item_stat_id); + ClassDB::bind_method(D_METHOD("get_item_stat_id", "index"), &ItemTemplate::get_item_stat_id); + ClassDB::bind_method(D_METHOD("set_item_stat_id", "index", "value"), &ItemTemplate::set_item_stat_id); - ClassDB::bind_method(D_METHOD("get_item_min_base_mod", "index"), &ItemTemplate::get_item_min_base_mod); - ClassDB::bind_method(D_METHOD("set_item_min_base_mod", "index", "value"), &ItemTemplate::set_item_min_base_mod); + ClassDB::bind_method(D_METHOD("get_item_min_base_mod", "index"), &ItemTemplate::get_item_min_base_mod); + ClassDB::bind_method(D_METHOD("set_item_min_base_mod", "index", "value"), &ItemTemplate::set_item_min_base_mod); ClassDB::bind_method(D_METHOD("get_item_max_base_mod", "index"), &ItemTemplate::get_item_max_base_mod); - ClassDB::bind_method(D_METHOD("set_item_max_base_mod", "index", "value"), &ItemTemplate::set_item_max_base_mod); + ClassDB::bind_method(D_METHOD("set_item_max_base_mod", "index", "value"), &ItemTemplate::set_item_max_base_mod); - - ClassDB::bind_method(D_METHOD("get_item_min_bonus_mod", "index"), &ItemTemplate::get_item_min_bonus_mod); - ClassDB::bind_method(D_METHOD("set_item_min_bonus_mod", "index", "value"), &ItemTemplate::set_item_min_bonus_mod); + ClassDB::bind_method(D_METHOD("get_item_min_bonus_mod", "index"), &ItemTemplate::get_item_min_bonus_mod); + ClassDB::bind_method(D_METHOD("set_item_min_bonus_mod", "index", "value"), &ItemTemplate::set_item_min_bonus_mod); ClassDB::bind_method(D_METHOD("get_item_max_bonus_mod", "index"), &ItemTemplate::get_item_max_bonus_mod); - ClassDB::bind_method(D_METHOD("set_item_max_bonus_mod", "index", "value"), &ItemTemplate::set_item_max_bonus_mod); - + ClassDB::bind_method(D_METHOD("set_item_max_bonus_mod", "index", "value"), &ItemTemplate::set_item_max_bonus_mod); ClassDB::bind_method(D_METHOD("get_item_min_percent_mod", "index"), &ItemTemplate::get_item_min_percent_mod); - ClassDB::bind_method(D_METHOD("set_item_min_percent_mod", "index", "value"), &ItemTemplate::set_item_min_percent_mod); + ClassDB::bind_method(D_METHOD("set_item_min_percent_mod", "index", "value"), &ItemTemplate::set_item_min_percent_mod); ClassDB::bind_method(D_METHOD("get_item_max_percent_mod", "index"), &ItemTemplate::get_item_max_percent_mod); - ClassDB::bind_method(D_METHOD("set_item_max_percent_mod", "index", "value"), &ItemTemplate::set_item_max_percent_mod); - + ClassDB::bind_method(D_METHOD("set_item_max_percent_mod", "index", "value"), &ItemTemplate::set_item_max_percent_mod); ClassDB::bind_method(D_METHOD("get_item_scaling_factor", "index"), &ItemTemplate::get_item_scaling_factor); - ClassDB::bind_method(D_METHOD("set_item_scaling_factor", "index", "value"), &ItemTemplate::set_item_scaling_factor); + ClassDB::bind_method(D_METHOD("set_item_scaling_factor", "index", "value"), &ItemTemplate::set_item_scaling_factor); + 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); - 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); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/min_base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_min_base_mod", "get_item_min_base_mod", i); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/max_base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_max_base_mod", "get_item_max_base_mod", i); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/min_base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_min_base_mod", "get_item_min_base_mod", i); - - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/max_base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_max_base_mod", "get_item_max_base_mod", i); - - - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/min_bonus_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_min_bonus_mod", "get_item_min_bonus_mod", i); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/min_bonus_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_min_bonus_mod", "get_item_min_bonus_mod", i); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/max_bonus_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_max_bonus_mod", "get_item_max_bonus_mod", i); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/min_percent_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_min_percent_mod", "get_item_min_percent_mod", i); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/max_percent_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_max_percent_mod", "get_item_max_percent_mod", i); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "Modifiers_" + itos(i) + "/scaling_factor", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_item_scaling_factor", "get_item_scaling_factor", i); - } + } - //ClassDB::bind_method(D_METHOD("get_item_stat_modifier", "index"), &ItemTemplate::get_item_stat_modifier); - //ClassDB::bind_method(D_METHOD("set_item_stat_modifier", "index", "value"), &ItemTemplate::set_item_stat_modifier); + //ClassDB::bind_method(D_METHOD("get_item_stat_modifier", "index"), &ItemTemplate::get_item_stat_modifier); + //ClassDB::bind_method(D_METHOD("set_item_stat_modifier", "index", "value"), &ItemTemplate::set_item_stat_modifier); ClassDB::bind_method(D_METHOD("get_animator_weapon_type"), &ItemTemplate::get_animator_weapon_type); - } diff --git a/data/item_template.h b/data/item_template.h index 175fec9..af0526e 100644 --- a/data/item_template.h +++ b/data/item_template.h @@ -8,6 +8,8 @@ #include "../entities/stats/stat.h" #include "../item_enums.h" +#include "item_instance.h" + class Aura; class Spell; @@ -83,6 +85,7 @@ public: int get_animator_weapon_type(); + Ref create_item_instance(); ItemTemplate(); ~ItemTemplate(); diff --git a/data/spell.cpp b/data/spell.cpp index 41b0492..9df55b6 100644 --- a/data/spell.cpp +++ b/data/spell.cpp @@ -96,6 +96,20 @@ void Spell::set_level(int value) { _level = value; } +int Spell::get_rank() { + return _rank; +} +void Spell::set_rank(int value) { + _rank = value; +} + +Ref Spell::get_next_rank() { + return _next_rank; +} +void Spell::set_next_rank(Ref value) { + _next_rank = value; +} + int Spell::get_item_cost() { return _item_cost; } @@ -359,6 +373,14 @@ void Spell::set_aoe_half_extents(Vector3 value) { bool Spell::has_effect_visual() { return _effect_visual.is_valid(); } + +EntityEnums::CharacterSkeletonPoints Spell::get_effect_visual_point() { + return _effect_visual_point; +} +void Spell::set_effect_visual_point(EntityEnums::CharacterSkeletonPoints point) { + _effect_visual_point = point; +} + Ref Spell::get_effect_visual() { return _effect_visual; } @@ -369,6 +391,14 @@ void Spell::set_effect_visual(Ref value) { bool Spell::has_spell_cast_finish_effect() { return _spell_cast_finish_effect.is_valid(); } + +EntityEnums::CharacterSkeletonPoints Spell::get_spell_cast_finish_effect_point() { + return _spell_cast_finish_effect_point; +} +void Spell::set_spell_cast_finish_effect_point(EntityEnums::CharacterSkeletonPoints point) { + _spell_cast_finish_effect_point = point; +} + Ref Spell::get_spell_cast_finish_effect() { return _spell_cast_finish_effect; } @@ -852,6 +882,14 @@ void Spell::_bind_methods() { ClassDB::bind_method(D_METHOD("set_level", "value"), &Spell::set_level); ADD_PROPERTY(PropertyInfo(Variant::INT, "level"), "set_level", "get_level"); + ClassDB::bind_method(D_METHOD("get_rank"), &Spell::get_rank); + ClassDB::bind_method(D_METHOD("set_rank", "value"), &Spell::set_rank); + ADD_PROPERTY(PropertyInfo(Variant::INT, "rank"), "set_rank", "get_rank"); + + ClassDB::bind_method(D_METHOD("get_next_rank"), &Spell::get_next_rank); + ClassDB::bind_method(D_METHOD("set_next_rank", "value"), &Spell::set_next_rank); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_rank", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_next_rank", "get_next_rank"); + ClassDB::bind_method(D_METHOD("get_is_local_spell"), &Spell::get_is_local_spell); ClassDB::bind_method(D_METHOD("set_is_local_spell", "value"), &Spell::set_is_local_spell); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_local_spell"), "set_is_local_spell", "get_is_local_spell"); @@ -1029,11 +1067,23 @@ void Spell::_bind_methods() { ADD_GROUP("Effect", "effect"); ClassDB::bind_method(D_METHOD("has_effect_visual"), &Spell::has_effect_visual); + + ClassDB::bind_method(D_METHOD("get_effect_visual_point"), &Spell::get_effect_visual_point); + ClassDB::bind_method(D_METHOD("set_effect_visual_point", "value"), &Spell::set_effect_visual_point); + ADD_PROPERTY(PropertyInfo(Variant::INT, "effect_visual_point", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS), "set_effect_visual_point", "get_effect_visual_point"); + + ClassDB::bind_method(D_METHOD("get_effect_visual"), &Spell::get_effect_visual); ClassDB::bind_method(D_METHOD("set_effect_visual", "value"), &Spell::set_effect_visual); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "effect_visual", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_effect_visual", "get_effect_visual"); ClassDB::bind_method(D_METHOD("has_spell_cast_finish_effect"), &Spell::has_spell_cast_finish_effect); + + ClassDB::bind_method(D_METHOD("get_spell_cast_finish_effect_point"), &Spell::get_spell_cast_finish_effect_point); + ClassDB::bind_method(D_METHOD("set_spell_cast_finish_effect_point", "value"), &Spell::set_spell_cast_finish_effect_point); + ADD_PROPERTY(PropertyInfo(Variant::INT, "spell_cast_finish_effect_point", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS), "set_spell_cast_finish_effect_point", "get_spell_cast_finish_effect_point"); + + ClassDB::bind_method(D_METHOD("get_spell_cast_finish_effect"), &Spell::get_spell_cast_finish_effect); ClassDB::bind_method(D_METHOD("set_spell_cast_finish_effect", "value"), &Spell::set_spell_cast_finish_effect); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "effect_spell_cast_finish_effect", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_spell_cast_finish_effect", "get_spell_cast_finish_effect"); diff --git a/data/spell.h b/data/spell.h index 8126177..71a8ade 100644 --- a/data/spell.h +++ b/data/spell.h @@ -3,8 +3,8 @@ #include "core/resource.h" #include "scene/resources/curve.h" -#include "scene/resources/texture.h" #include "scene/resources/packed_scene.h" +#include "scene/resources/texture.h" #include "../entity_enums.h" #include "../spell_enums.h" @@ -109,6 +109,12 @@ public: int get_level(); void set_level(int value); + int get_rank(); + void set_rank(int value); + + Ref get_next_rank(); + void set_next_rank(Ref value); + int get_item_cost(); void set_item_cost(int value); @@ -219,10 +225,18 @@ public: void set_aoe_half_extents(Vector3 value); bool has_effect_visual(); + + EntityEnums::CharacterSkeletonPoints get_effect_visual_point(); + void set_effect_visual_point(EntityEnums::CharacterSkeletonPoints point); + Ref get_effect_visual(); void set_effect_visual(Ref value); bool has_spell_cast_finish_effect(); + + EntityEnums::CharacterSkeletonPoints get_spell_cast_finish_effect_point(); + void set_spell_cast_finish_effect_point(EntityEnums::CharacterSkeletonPoints point); + Ref get_spell_cast_finish_effect(); void set_spell_cast_finish_effect(Ref value); @@ -255,19 +269,6 @@ public: int get_spell_cooldown_mainpulation_data_count(); void set_spell_cooldown_mainpulation_data_count(int value); - //AuraApplyData *getAuraApplyData() { return auraApplyData; } - //void setAuraApplyData(AuraApplyData *value) { auraApplyData = value; } - - /* - void Set(int _spell_id, SpellType _spell_type, int p_damage_min, int _damage_max, bool _hideFrom_actionbar, float _cast_time, - float cooldown, int casterAuraApply, int casterAuraApply2, int targetAuraApply, int targetAuraApply2, - int level, int itemCost, int crafMaterialCost, int requiredItem, String *costTypeString, int costResource, - String *giveResourceTypeString, int giveResource, bool hasGlobalCooldown, bool isLocalSpell, String *iconBundle, - String *iconFile, Vector2i *iconAtlasPosition, String *nameKey, String *spellName, String *spellDescription); - - void Set(bool needsTarget, bool canMoveWhileCasting); - */ - //// Spell Script //// float PLAYER_HIT_RADIUS; @@ -286,7 +287,7 @@ public: virtual void _sstart_casting(Ref info); //eventhandlers - void son_cast_player_moved(Ref info); + void son_cast_player_moved(Ref info); void son_cast_damage_received(Ref info); void son_spell_hit(Ref info); @@ -365,13 +366,11 @@ protected: private: int _spell_id; - int _spell_type; bool _hide_from_actionbar; float _cooldown; SpellTargetType _target_type; - //AuraApplyData *_aura_apply_data; Ref *_caster_aura_apply_ref; Ref *_caster_aura_apply2_ref; @@ -384,6 +383,8 @@ private: Aura *_target_aura_apply2; int _level; + int _rank; + Ref _next_rank; int _item_cost; int _craft_material_cost; int _required_item; @@ -427,8 +428,12 @@ private: SpellAOEColliderType _aoe_colliderType; Vector3 _aoe_half_extents; + EntityEnums::CharacterSkeletonPoints _effect_visual_point; Ref _effect_visual; + + EntityEnums::CharacterSkeletonPoints _spell_cast_finish_effect_point; Ref _spell_cast_finish_effect; + Ref _spell_cast_effect; Ref _projectile; diff --git a/entities/entity.cpp b/entities/entity.cpp index 81c4fa2..03f3d9b 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -1467,69 +1467,19 @@ void Entity::setc_target(Node *p_target) { //// TalentCOmponent //// void Entity::csend_request_rank_increase(int talentID) { - /* - if (CxNet::IsServer) { - CSendRequestRankIncreaseMsg cSendRequestRankIncreaseMsg = CSendRequestRankIncreaseMsg(); - cSendRequestRankIncreaseMsg.Guid = owner->PlayerData->GUID; - cSendRequestRankIncreaseMsg.TalentId = talentID; - cSendRequestRankIncreaseMsg.Serialize(CxNet::NetBuffer); - CxNet::SendBufferToAllClients(0); - }*/ + } void Entity::csend_request_rank_decrease(int talentID) { - /* - if (CxNet::IsServer) { - CSendRequestRankDecreaseMsg cSendRequestRankDecreaseMsg = CSendRequestRankDecreaseMsg(); - cSendRequestRankDecreaseMsg.Guid = owner->PlayerData->GUID; - cSendRequestRankDecreaseMsg.TalentId = talentID; - cSendRequestRankDecreaseMsg.Serialize(CxNet::NetBuffer); - CxNet::SendBufferToAllClients(0); - }*/ } void Entity::ssend_rank(int talentID, int rank) { - /* - if (CxNet::IsServer) { - SSendRankValueMsg sSendRankValueMsg = SSendRankValueMsg(); - sSendRankValueMsg.Guid = owner->PlayerData->GUID; - sSendRankValueMsg.TalentId = talentID; - sSendRankValueMsg.Rank = rank; - sSendRankValueMsg.Serialize(CxNet::NetBuffer); - CxNet::SendBufferToAllClients(0); - }*/ } void Entity::sreceive_rank_increase(int talentID) { - /* - PlayerTalent *playerTalent = SGetTalent(talentID, true); - if (owner->PlayerData->Character == null) { - return; - } - Talent *talent = Talents::Instance->GetData(talentID); - if (talent == null) { - return; - } - if (talent->MaxRank >= playerTalent->getRank()) { - PlayerTalent *expr_47 = playerTalent; - int rank = expr_47->getRank(); - expr_47->setRank(rank + 1); - SSendRank(talentID, playerTalent->getRank()); - }*/ } void Entity::sreceive_rank_decrease(int talentID) { - /* - PlayerTalent *playerTalent = SGetTalent(talentID, false); - if (playerTalent == null) { - return; - } - if (playerTalent->getRank() > 0) { - PlayerTalent *expr_17 = playerTalent; - int rank = expr_17->getRank(); - expr_17->setRank(rank - 1); - SSendRank(talentID, playerTalent->getRank()); - }*/ } void Entity::creceive_rank(int talentID, int rank) { @@ -1600,426 +1550,54 @@ Ref Entity::getc_bag(int index) { return _c_bags[index]; } -void Entity::sadd_craft_material(int itemId, int count) { - /* - for (int i = 0; i < sCraftMaterialInventory->Count; i += 1) { - ItemInstance *itemInstance = sCraftMaterialInventory->GetData(i); - if (itemInstance->getItemID() == itemId) { - ItemInstance *expr_1B = itemInstance; - expr_1B->setCount(count); - SSendAddCraftMaterial(itemId, count); - if (SOnCraftMaterialAdded != null) { - DELEGATE_INVOKE(SOnCraftMaterialAdded, itemInstance); - } - return; - } - } - ItemInstance *itemInstance2 = new ItemInstance(itemId, count); - sCraftMaterialInventory->Add(itemInstance2); - SSendAddCraftMaterial(itemId, count); - if (SOnCraftMaterialAdded != null) { - DELEGATE_INVOKE(SOnCraftMaterialAdded, itemInstance2); - }*/ -} - -void Entity::sremove_craft_material(int itemId, int count) { - /* - for (int i = 0; i < sCraftMaterialInventory->Count; i += 1) { - ItemInstance *itemInstance = sCraftMaterialInventory->GetData(i); - if (itemInstance->getItemID() == itemId) { - ItemInstance *expr_21 = itemInstance; - expr_21->setCount(count); - if (itemInstance->getCount() <= 0) { - if (itemInstance->getCount() < 0) { - Array *expr_46 = new Array(4); - expr_46->SetData(0, new String("inventory->SRemoveCraftMaterial: Material count was less than 0. Itemid=")); - expr_46->SetData(1, BOX(itemId)); - expr_46->SetData(2, new String(" player=")); - expr_46->SetData(3, owner->gameObject->name); - Debug::Log(String::Concat(expr_46)); - } - sCraftMaterialInventory->RemoveAt(i); - } - SSendRemoveCraftMaterial(itemId, count); - if (SOnCraftMaterialRemoved != null) { - DELEGATE_INVOKE(SOnCraftMaterialRemoved); - } - return; - } - } - Array *expr_BF = new Array(4); - expr_BF->SetData(0, new String("inventory->SRemoveCraftMaterial: Material didn't exist in player's inventory. Itemid=")); - expr_BF->SetData(1, BOX(itemId)); - expr_BF->SetData(2, new String(" player=")); - expr_BF->SetData(3, owner->gameObject->name); - Debug::Log(String::Concat(expr_BF));*/ -} - bool Entity::stry_to_add_item(int itemId, int count) { - /* - int num = -1; - for (int i = 0; i < getSInventory()->Count; i += 1) { - ItemInstance *itemInstance = getSInventory()->GetData(i); - if (itemInstance == null) { - if (num == -1) { - num = i; - } - } else { - if (itemInstance->getItemID() == itemId) { - ItemInstance *expr_28 = itemInstance; - expr_28->setCount(count); - SSendAddItem(i, itemId, count); - if (SOnItemAdded != null) { - DELEGATE_INVOKE(SOnItemAdded, itemInstance); - } - return true; - } - } - } - if (num == -1) { - return false; - } - ItemInstance *itemInstance2 = new ItemInstance(itemId, count); - getSInventory()->SetData(num, itemInstance2); - SSendAddItem(num, itemId, count); - if (SOnItemAdded != null) { - DELEGATE_INVOKE(SOnItemAdded, itemInstance2); - } - return true;*/ - return false; } bool Entity::stry_to_remove_item(int itemId, int count) { - /* - int i = 0; - while (i < getSInventory()->Count) { - ItemInstance *itemInstance = getSInventory()->GetData(i); - if ((itemInstance != null) && (itemInstance->getItemID() == itemId)) { - if (itemInstance->getCount() < count) { - return false; - } - if (itemInstance->getCount() == count) { - getSInventory()->SetData(i, null); - if (SOnItemRemoved != null) { - DELEGATE_INVOKE(SOnItemRemoved); - } - SSendRemoveItem(i); - return true; - } - ItemInstance *expr_5E = itemInstance; - expr_5E->setCount(count); - SSendChangeItemCount(i, itemInstance->getCount()); - if (SOnItemCountChanged != null) { - DELEGATE_INVOKE(SOnItemCountChanged, itemInstance); - } - return true; - } else { - i += 1; - } - } - return false;*/ - return false; } void Entity::ssend_add_item(int slotId, int itemId, int count) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendAddItemMsg sSendAddItemMsg = SSendAddItemMsg(); - sSendAddItemMsg.SlotId = slotId; - sSendAddItemMsg.ItemId = itemId; - sSendAddItemMsg.Count = count; - sSendAddItemMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ } void Entity::ssend_change_item_count(int slotId, int count) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendChangeItemCountMsg sSendChangeItemCountMsg = SSendChangeItemCountMsg(); - sSendChangeItemCountMsg.SlotId = slotId; - sSendChangeItemCountMsg.Count = count; - sSendChangeItemCountMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ } void Entity::ssend_remove_item(int slotId) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendRemoveItemMsg sSendRemoveItemMsg = SSendRemoveItemMsg(); - sSendRemoveItemMsg.SlotId = slotId; - sSendRemoveItemMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ } void Entity::ssend_move_item(int slot1, int slot2) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendMoveItemMsg sSendMoveItemMsg = SSendMoveItemMsg(); - sSendMoveItemMsg.Slot1 = slot1; - sSendMoveItemMsg.Slot2 = slot2; - sSendMoveItemMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ } void Entity::ssend_sent_items(String items) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendSentItemsMsg sSendSentItemsMsg = SSendSentItemsMsg(); - sSendSentItemsMsg.Items = items; - sSendSentItemsMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ } void Entity::csend_swap_items(int slot1, int slot2) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - CSendSwapItemsMsg cSendSwapItemsMsg = CSendSwapItemsMsg(); - cSendSwapItemsMsg.Slot1 = slot1; - cSendSwapItemsMsg.Slot2 = slot2; - cSendSwapItemsMsg.Serialize(CxNet::NetBuffer); - CxNet::SendBufferToServer(0); - }*/ } void Entity::csend_craft_item_request(int craftId) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - CSendCraftItemRequestMsg cSendCraftItemRequestMsg = CSendCraftItemRequestMsg(); - cSendCraftItemRequestMsg.CraftId = craftId; - cSendCraftItemRequestMsg.Serialize(CxNet::NetBuffer); - CxNet::SendBufferToServer(0); - }*/ -} - -void Entity::ssend_add_craft_material(int itemId, int count) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendAddCraftMaterialMsg sSendAddCraftMaterialMsg = SSendAddCraftMaterialMsg(); - sSendAddCraftMaterialMsg.ItemId = itemId; - sSendAddCraftMaterialMsg.Count = count; - sSendAddCraftMaterialMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ -} - -void Entity::ssend_remove_craft_material(int itemId, int count) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendRemoveCraftMaterialMsg sSendRemoveCraftMaterialMsg = SSendRemoveCraftMaterialMsg(); - sSendRemoveCraftMaterialMsg.ItemId = itemId; - sSendRemoveCraftMaterialMsg.Count = count; - sSendRemoveCraftMaterialMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ -} - -void Entity::ssend_sent_craft_materials(String materials) { - /* - if (CxNet::IsServer && (owner->Connection != null)) { - SSendSentCraftMaterialsMsg sSendSentCraftMaterialsMsg = SSendSentCraftMaterialsMsg(); - sSendSentCraftMaterialsMsg.Materials = materials; - sSendSentCraftMaterialsMsg.Serialize(CxNet::NetBuffer); - owner->Connection->SendBuffer(0, CxNet::NetBuffer); - }*/ } void Entity::creceive_add_item(int slotId, int itemId, int count) { - /* - if (getCInventory()->GetData(slotId) == null) { - getCInventory()->SetData(slotId, new ItemInstance(itemId, count)); - } else { - if (getCInventory()->GetData(slotId)->ItemID != itemId) { - Array *expr_40 = new Array(6); - expr_40->SetData(0, new String("Item did not match in slot ")); - expr_40->SetData(1, BOX(slotId)); - expr_40->SetData(2, new String(" ")); - expr_40->SetData(3, BOX(itemId)); - expr_40->SetData(4, new String(" orig id: ")); - expr_40->SetData(5, BOX(getCInventory()->GetData(slotId)->ItemID)); - Debug::Log(String::Concat(expr_40)); - getCInventory()->GetData(slotId)->ItemID = itemId; - } - ItemInstance *expr_AB = getCInventory()->GetData(slotId); - expr_AB->setCount(count); - } - if (COnItemAdded != null) { - DELEGATE_INVOKE(COnItemAdded, getCInventory()->GetData(slotId)); - }*/ } void Entity::creceive_change_item_count(int slotId, int count) { - /* - if (getCInventory()->GetData(slotId) == null) { - return; - } - getCInventory()->GetData(slotId)->ItemID = count; - if (COnItemCountChanged != null) { - DELEGATE_INVOKE(COnItemCountChanged, getCInventory()->GetData(slotId)); - }*/ } void Entity::creceive_remove_item(int slotId) { - /* - getCInventory()->SetData(slotId, null); - if (COnItemRemoved != null) { - DELEGATE_INVOKE(COnItemRemoved); - }*/ } void Entity::creceive_move_item(int slot1, int slot2) { - /* - if ((slot1 >= getCInventory()->Count) || (slot2 >= getCInventory()->Count)) { - return; - } - if ((getCInventory()->GetData(slot1) == null) && (getCInventory()->GetData(slot2) == null)) { - return; - } - ItemInstance *value = getCInventory()->GetData(slot1); - getCInventory()->SetData(slot1, getCInventory()->GetData(slot2)); - getCInventory()->SetData(slot2, value); - if (COnItemMoved != null) { - DELEGATE_INVOKE(COnItemMoved); - }*/ -} - -void Entity::creceive_add_craft_material(int itemId, int count) { - /* - for (int i = 0; i < cCraftMaterialInventory->Count; i += 1) { - ItemInstance *itemInstance = cCraftMaterialInventory->GetData(i); - if (itemInstance->getItemID() == itemId) { - ItemInstance *expr_1B = itemInstance; - expr_1B->setCount(count); - if (COnCraftMaterialAdded != null) { - DELEGATE_INVOKE(COnCraftMaterialAdded, itemInstance); - } - return; - } - } - ItemInstance *itemInstance2 = new ItemInstance(itemId, count); - cCraftMaterialInventory->Add(itemInstance2); - if (COnCraftMaterialAdded != null) { - DELEGATE_INVOKE(COnCraftMaterialAdded, itemInstance2); - }*/ -} - -void Entity::creceive_remove_craft_material(int itemId, int count) { - /* - for (int i = 0; i < getCCraftMaterialInventory()->Count; i += 1) { - ItemInstance *itemInstance = getCCraftMaterialInventory()->GetData(i); - if (itemInstance->getItemID() == itemId) { - ItemInstance *expr_1B = itemInstance; - expr_1B->setCount(count); - if (itemInstance->getCount() <= 0) { - getCCraftMaterialInventory()->RemoveAt(i); - } - if (COnCraftMaterialRemoved != null) { - DELEGATE_INVOKE(COnCraftMaterialRemoved); - } - return; - } - }*/ -} - -void Entity::creceive_sent_craft_materials(String materials) { - /* - Array *expr_07 = new Array(1); - expr_07->SetData(0, ';'); - Array *array = materials->Split(expr_07); - for (int i = 0; i < (array->Length - 1); i += 1) { - String arg_24_0 = array->GetData(i); - Array *expr_1F = new Array(1); - expr_1F->SetData(0, '='); - Array *array2 = arg_24_0->Split(expr_1F); - ItemInstance *item = new ItemInstance(BSConvert::ToInt(array2->GetData(0)), BSConvert::ToInt(array2->GetData(1))); - getCCraftMaterialInventory()->Add(item); - } - if (COnCraftMaterialsLoaded != null) { - DELEGATE_INVOKE(COnCraftMaterialsLoaded); - }*/ } void Entity::creceive_sent_items(String items) { - /* - Array *expr_07 = new Array(1); - expr_07->SetData(0, ';'); - Array *array = items->Split(expr_07); - for (int i = 0; i < (array->Length - 1); i += 1) { - String arg_24_0 = array->GetData(i); - Array *expr_1F = new Array(1); - expr_1F->SetData(0, '='); - Array *array2 = arg_24_0->Split(expr_1F); - ItemInstance *value = new ItemInstance(BSConvert::ToInt(array2->GetData(1)), BSConvert::ToInt(array2->GetData(2))); - getCInventory()->SetData(BSConvert::ToInt(array2->GetData(0)), value); - } - if (COnItemsLoaded != null) { - DELEGATE_INVOKE(COnItemsLoaded); - }*/ } void Entity::sreceive_swap_items(int slot1, int slot2) { - /* - if ((slot1 >= getSInventory()->Count) || (slot2 >= getSInventory()->Count)) { - return; - } - if ((getSInventory()->GetData(slot1) == null) && (getSInventory()->GetData(slot2) == null)) { - return; - } - ItemInstance *value = getSInventory()->GetData(slot1); - getSInventory()->SetData(slot1, getSInventory()->GetData(slot2)); - getSInventory()->SetData(slot2, value); - SSendMoveItem(slot1, slot2); - if (SOnItemMoved != null) { - DELEGATE_INVOKE(SOnItemMoved); - }*/ } void Entity::send_all_items() { - /* - StringBuilder *StringBuilder = new StringBuilder(); - for (int i = 0; i < getSCraftMaterialInventory()->Count; i += 1) { - StringBuilder->Append(getSCraftMaterialInventory()->GetData(i)->ItemID); - StringBuilder->Append('='); - StringBuilder->Append(getSCraftMaterialInventory()->GetData(i)->Count); - StringBuilder->Append(';'); - if (StringBuilder->Length >= 700) { - SSendSentCraftMaterials(StringBuilder->ToString()); - StringBuilder->Remove(0, StringBuilder->Length); - } - } - SSendSentCraftMaterials(StringBuilder->ToString()); - if (StringBuilder->Length > 0) { - StringBuilder->Remove(0, StringBuilder->Length); - } - for (int j = 0; j < getSInventory()->Count; j += 1) { - if (getSInventory()->GetData(j) != null) { - StringBuilder->Append(j); - StringBuilder->Append('='); - StringBuilder->Append(getSInventory()->GetData(j)->ItemID); - StringBuilder->Append('='); - StringBuilder->Append(getSInventory()->GetData(j)->Count); - StringBuilder->Append(';'); - } - } - SSendSentItems(StringBuilder->ToString());*/ -} - -bool Entity::shas_craft_material(int itemId, int count) { - /* - for (int i = 0; i < getSCraftMaterialInventory()->Count; i += 1) { - if ((getSCraftMaterialInventory()->GetData(i)->ItemID == itemId) && (getSCraftMaterialInventory()->GetData(i)->Count >= count)) { - return true; - } - } - return false;*/ - - return false; } bool Entity::shas_item(int itemId, int count) { @@ -2034,18 +1612,6 @@ bool Entity::shas_item(int itemId, int count) { return false; } -bool Entity::chas_craft_material(int itemId, int count) { - /* - for (int i = 0; i < getCCraftMaterialInventory()->Count; i += 1) { - if ((getCCraftMaterialInventory()->GetData(i)->ItemID == itemId) && (getCCraftMaterialInventory()->GetData(i)->Count >= count)) { - return true; - } - } - return false;*/ - - return false; -} - bool Entity::chas_item(int itemId, int count) { /* for (int i = 0; i < getCInventory()->Count; i += 1) { @@ -2059,136 +1625,32 @@ bool Entity::chas_item(int itemId, int count) { } int Entity::cget_item_count(int itemId) { - /* - for (int i = 0; i < getCInventory()->Count; i += 1) { - if ((getCInventory()->GetData(i) != null) && (getCInventory()->GetData(i)->ItemID == itemId)) { - return getCInventory()->GetData(i)->Count; - } - } - return 0;*/ - return 0; } int Entity::sget_item_count(int itemId) { - /* - for (int i = 0; i < getSInventory()->Count; i += 1) { - if ((getSInventory()->GetData(i) != null) && (getSInventory()->GetData(i)->ItemID == itemId)) { - return getSInventory()->GetData(i)->Count; - } - } - return 0;*/ - - return 0; -} - -int Entity::cget_craft_material_count(int itemId) { - /* - for (int i = 0; i < getCCraftMaterialInventory()->Count; i += 1) { - if (getCCraftMaterialInventory()->GetData(i)->ItemID == itemId) { - return getCCraftMaterialInventory()->GetData(i)->Count; - } - } - return 0;*/ - - return 0; -} - -int Entity::sget_craft_material_count(int itemId) { - /* - for (int i = 0; i < getSCraftMaterialInventory()->Count; i += 1) { - if (getSCraftMaterialInventory()->GetData(i)->ItemID == itemId) { - return getSCraftMaterialInventory()->GetData(i)->Count; - } - } - return 0;*/ - return 0; } bool Entity::ccan_craft(CraftDataAttribute *cda) { - /* - for (int i = 0; i < cda->RequiredItems->Count; i += 1) { - if (!CHasItem(cda->RequiredItems->GetData(i), 1)) { - return false; - } - } - for (int j = 0; j < cda->RequiredMaterials->Count; j += 1) { - CraftDataAttributeHelper *craftDataAttributeHelper = cda->RequiredMaterials->GetData(j); - if (!CHasCraftMaterial(craftDataAttributeHelper->ItemId, craftDataAttributeHelper->Count)) { - return false; - } - } - return true;*/ - return false; } bool Entity::ctry_to_craft(CraftDataAttribute *cda) { - /* - if (!CCanCraft(cda)) { - return false; - } - CSendCraftItemRequest(cda->Id); - return true;*/ - return false; } bool Entity::scan_craft(CraftDataAttribute *cda) { - /* - for (int i = 0; i < cda->RequiredItems->Count; i += 1) { - if (!SHasItem(cda->RequiredItems->GetData(i), 1)) { - return false; - } - } - for (int j = 0; j < cda->RequiredMaterials->Count; j += 1) { - CraftDataAttributeHelper *craftDataAttributeHelper = cda->RequiredMaterials->GetData(j); - if (!SHasCraftMaterial(craftDataAttributeHelper->ItemId, craftDataAttributeHelper->Count)) { - return false; - } - } - return true;*/ - return false; } void Entity::scraft(CraftDataAttribute *cda) { - /* - if (!STryToAddItem(cda->Item->ItemId, cda->Item->Count)) { - return; - } - for (int i = 0; i < cda->RequiredMaterials->Count; i += 1) { - CraftDataAttributeHelper *craftDataAttributeHelper = cda->RequiredMaterials->GetData(i); - SRemoveCraftMaterial(craftDataAttributeHelper->ItemId, craftDataAttributeHelper->Count); - }*/ } void Entity::sreceive_craft_item_msg(int craftId) { - /* - CraftDataLoader *instance = CraftDataLoader::Instance; - if (instance == null) { - return; - } - CraftDataAttribute *craftDataWithId = instance->getCraftDataWithId(craftId); - if (craftDataWithId == null) { - return; - } - if (!SCanCraft(craftDataWithId)) { - return; - } - SCraft(craftDataWithId);*/ } void Entity::cswap_items_in_slots(int slot1, int slot2) { - /* - if ((slot1 >= getCInventory()->Count) || (slot2 >= getCInventory()->Count)) { - return; - } - if ((getCInventory()->GetData(slot1) == null) && (getCInventory()->GetData(slot2) == null)) { - return; - } - CSendSwapItems(slot1, slot2); */ } void Entity::loaded() { @@ -2249,54 +1711,27 @@ void Entity::rpc_level_up() { }*/ } -void Entity::registers() { - /* - if (aiPlayer) { - Entity.CRegisterAIPlayer(GUID, owner); - - if (owner.isServer) { - Entity.SRegisterAIPlayer(GUID, owner); - } - - // owner.OnPlayerSpawned(owner, owner.isClient, owner.isServer, owner.isLocalPlayer); - - return; - } - - if (isLocalPlayer) { - Entity.RegisterLocalPlayer(GUID, owner); - - //Let's call the playerFactory, so it can modify this instance - // owner.OnPlayerSpawned(owner, owner.isClient, owner.isServer, owner.isLocalPlayer); - - return; - } - - if (owner.isClient) { - Entity.CRegisterNetworkedPlayer(GUID, owner); - - if (owner.isServer) { - Entity.SRegisterNetworkedPlayer(GUID, owner); - } - - //Let's call the playerFactory, so it can modify this instance - // owner.OnPlayerSpawned(owner, owner.isClient, owner.isServer, owner.isLocalPlayer); - } - */ - - /* - pl.CRegisterAIPlayer(transform.gameObject); - - if (isServer) - { - pl.SRegisterAIPlayer(transform.gameObject); - } - - //Let's call the playerFactory, so it can modify this instance - pf.OnPlayerSpawned(gameObject, isClient, isServer, isLocalPlayer);*/ -} - void Entity::update(float delta) { + if (_s_gcd > 0.0000001) { + _s_gcd -= delta; + + if (_s_gcd <= 0) { + _s_gcd = 0; + + emit_signal("sgcd_finished"); + } + } + + if (_c_gcd > 0.0000001) { + _c_gcd -= delta; + + if (_c_gcd <= 0) { + _c_gcd = 0; + + emit_signal("cgcd_finished"); + } + } + for (int i = 0; i < _s_cooldowns.size(); ++i) { Ref cd = _s_cooldowns.get(i); @@ -2324,58 +1759,6 @@ void Entity::update(float delta) { } } -void Entity::Update() { - /* - getInventory()->Update(); - getPlayerFacingComponent()->Update(); - getStateComponent()->Update(); - getPlayerSpellDataComponent()->Update(); - getOpmcc()->Update(); - getEntity()->Update(); - getFactionComponent()->Update();*/ - - /* - if (owner->isServer && sendstate) { - sendstate = false; - SendAllItems(); - } */ - - /* - if (send && owner->isServer) { - send = false; - for (int i = 0; i < getSSpellData()->Count; i += 1) { - PlayerSpellData *playerSpellData = getSSpellData()->GetData(i); - if (is_inst_of(playerSpellData)) { - PlayerSpellCooldownData *playerSpellCooldownData = as_cast(playerSpellData); - SSendAddCPlayerSpellCooldownData(playerSpellCooldownData->SpellId, playerSpellCooldownData->getCooldown(), playerSpellCooldownData->getRemainingCooldown()); - } - } - } - for (int j = 0; j < sSpellData->Count; j += 1) { - sSpellData->GetData(j)->Update(this); - } - for (int k = 0; k < cSpellData->Count; k += 1) { - cSpellData->GetData(k)->Update(this); - }*/ - - /* - if (owner->PlayerData->State != PlayerStates::STATE_NORMAL) { - return; - } - if (getSCasting()) { - setSCurrentCastTime(Time::deltaTime); - if (getSCurrentCastTime() >= getSCastTime()) { - SCastFinished(); - } - } - if (getCCasting()) { - setCCurrentCastTime(Time::deltaTime); - if (getCCurrentCastTime() >= getCCastTime()) { - CCastFinished(); - } - }*/ -} - String Entity::request_spell_name(int spellId) { return ""; } @@ -2593,7 +1976,9 @@ void Entity::_bind_methods() { //GCD ADD_SIGNAL(MethodInfo("sgcd_started", PropertyInfo(Variant::REAL, "value"))); + ADD_SIGNAL(MethodInfo("sgcd_finished", PropertyInfo(Variant::REAL, "value"))); ADD_SIGNAL(MethodInfo("cgcd_started", PropertyInfo(Variant::REAL, "value"))); + ADD_SIGNAL(MethodInfo("cgcd_finished", PropertyInfo(Variant::REAL, "value"))); ClassDB::bind_method(D_METHOD("getc_has_global_cooldown"), &Entity::getc_has_global_cooldown); ClassDB::bind_method(D_METHOD("gets_has_global_cooldown"), &Entity::gets_has_global_cooldown); diff --git a/entities/entity.h b/entities/entity.h index a6dd136..b5f3f46 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -422,13 +422,9 @@ public: //// Inventory //// - Ref gets_bag(int index); Ref getc_bag(int index); - //void Update(); - void sadd_craft_material(int itemId, int count); - void sremove_craft_material(int itemId, int count); bool stry_to_add_item(int itemId, int count); bool stry_to_remove_item(int itemId, int count); void ssend_add_item(int slotId, int itemId, int count); @@ -438,26 +434,16 @@ public: void ssend_sent_items(String items); void csend_swap_items(int slot1, int slot2); void csend_craft_item_request(int craftId); - void ssend_add_craft_material(int itemId, int count); - void ssend_remove_craft_material(int itemId, int count); - void ssend_sent_craft_materials(String materials); void creceive_add_item(int slotId, int itemId, int count); void creceive_change_item_count(int slotId, int count); void creceive_remove_item(int slotId); void creceive_move_item(int slot1, int slot2); - void creceive_add_craft_material(int itemId, int count); - void creceive_remove_craft_material(int itemId, int count); - void creceive_sent_craft_materials(String materials); void creceive_sent_items(String items); void sreceive_swap_items(int slot1, int slot2); - bool shas_craft_material(int itemId, int count); bool shas_item(int itemId, int count); - bool chas_craft_material(int itemId, int count); bool chas_item(int itemId, int count); int cget_item_count(int itemId); int sget_item_count(int itemId); - int cget_craft_material_count(int itemId); - int sget_craft_material_count(int itemId); bool ccan_craft(CraftDataAttribute *cda); bool ctry_to_craft(CraftDataAttribute *cda); bool scan_craft(CraftDataAttribute *cda); @@ -545,7 +531,6 @@ private: bool c; float sRezTimer; float cRezTimer; - //bool init; //// GCD //// float _s_gcd; diff --git a/entities/stats/stat.cpp b/entities/stats/stat.cpp index a00eecb..aa2d100 100644 --- a/entities/stats/stat.cpp +++ b/entities/stats/stat.cpp @@ -15,7 +15,6 @@ Stat::Stat() { _c_max = (float)(0); _c_current = (float)(0); - _modifiers = memnew(Vector >()); _disabled = false; _modifier_apply_type = MODIFIER_APPLY_TYPE_STANDARD; } @@ -31,7 +30,6 @@ Stat::Stat(Stat::StatId id) { _c_max = (float)(0); _c_current = (float)(0); - _modifiers = memnew(Vector >()); _disabled = false; _modifier_apply_type = MODIFIER_APPLY_TYPE_STANDARD; } @@ -47,7 +45,6 @@ Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type) { _c_max = (float)(0); _c_current = (float)(0); - _modifiers = memnew(Vector >()); _disabled = false; _modifier_apply_type = modifier_apply_type; _id = id; @@ -64,7 +61,6 @@ Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type, float bas _s_current = (float)(0); _c_max = (float)(0); _c_current = (float)(0); - _modifiers = memnew(Vector >()); _disabled = false; _modifier_apply_type = modifier_apply_type; @@ -88,7 +84,6 @@ Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type, float bas _c_max = (float)(0); _c_current = (float)(0); - _modifiers = memnew(Vector >()); _disabled = false; _modifier_apply_type = modifier_apply_type; _id = id; @@ -100,21 +95,19 @@ Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type, float bas } Stat::~Stat() { - _modifiers->clear(); - - memdelete(_modifiers); + _modifiers.clear(); } _FORCE_INLINE_ Vector > *Stat::get_modifiers() { - return _modifiers; + return &_modifiers; } int Stat::get_modifier_count() { - return _modifiers->size(); + return _modifiers.size(); } Ref Stat::get_modifier(int index) { - return _modifiers->get(index); + return _modifiers.get(index); } void Stat::set_dependency(Ref other, Ref curve) { @@ -168,14 +161,14 @@ void Stat::add_modifier(int id, float _max_mod, float percent_mod, bool apply) { apply_modifier(statModifier); } - _modifiers->push_back(statModifier); + _modifiers.push_back(statModifier); } void Stat::remove_modifier(int id, bool apply) { - for (int i = 0; i < _modifiers->size(); i += 1) { - if (_modifiers->get(i)->get_id() == id) { - Ref modifier = _modifiers->get(i); - _modifiers->remove(i); + for (int i = 0; i < _modifiers.size(); i += 1) { + if (_modifiers.get(i)->get_id() == id) { + Ref modifier = _modifiers.get(i); + _modifiers.remove(i); if (apply) { de_apply_modifier(modifier); @@ -199,16 +192,16 @@ void Stat::apply_modifier(Ref modifier) { if (get_modifiers()->size() > 0) { float percent_mod = get_modifiers()->get(0)->get_percent_mod(); for (int i = 1; i < get_modifiers()->size(); i += 1) { - if ((_modifiers->get(i)->get_percent_mod() < (float)0) && (_modifiers->get(i)->get_percent_mod() < percent_mod)) { + if ((_modifiers.get(i)->get_percent_mod() < (float)0) && (_modifiers.get(i)->get_percent_mod() < percent_mod)) { num = i; - percent_mod = _modifiers->get(i)->get_percent_mod(); + percent_mod = _modifiers.get(i)->get_percent_mod(); } } } if (num != -1) { - if (modifier->get_percent_mod() < _modifiers->get(num)->get_percent_mod()) { - _percent -= _modifiers->get(num)->get_percent_mod(); + if (modifier->get_percent_mod() < _modifiers.get(num)->get_percent_mod()) { + _percent -= _modifiers.get(num)->get_percent_mod(); } _percent += modifier->get_percent_mod(); @@ -236,20 +229,20 @@ void Stat::de_apply_modifier(Ref modifier) { float percent_mod = get_modifiers()->get(0)->get_percent_mod(); for (int i = 1; i < get_modifiers()->size(); i += 1) { - if ((_modifiers->get(i)->get_percent_mod() < (float)0) && (_modifiers->get(i)->get_percent_mod() < percent_mod)) { + if ((_modifiers.get(i)->get_percent_mod() < (float)0) && (_modifiers.get(i)->get_percent_mod() < percent_mod)) { num = i; - percent_mod = _modifiers->get(i)->get_percent_mod(); + percent_mod = _modifiers.get(i)->get_percent_mod(); } } } - if (num != -1 && (*_modifiers)[num] == modifier) { + if (num != -1 && _modifiers[num] == modifier) { _percent -= modifier->get_percent_mod(); } } } - if (_modifiers->size() == 0) { + if (_modifiers.size() == 0) { recalculate(); } @@ -260,8 +253,8 @@ void Stat::re_apply_modifiers() { reset_values(); if (_modifier_apply_type == MODIFIER_APPLY_TYPE_STANDARD) { - for (int i = 0; i < _modifiers->size(); i += 1) { - Ref mod = _modifiers->get(i); + for (int i = 0; i < _modifiers.size(); i += 1) { + Ref mod = _modifiers.get(i); _bonus += mod->get_bonus_mod(); _percent += mod->get_percent_mod(); @@ -270,7 +263,7 @@ void Stat::re_apply_modifiers() { re_apply_modifier_not_negative_stacking_percents(); } - if (_modifiers->size() == 0) { + if (_modifiers.size() == 0) { recalculate(); } @@ -281,8 +274,8 @@ void Stat::re_apply_modifier_not_negative_stacking_percents() { reset_values(); for (int i = 1; i < get_modifiers()->size(); i += 1) { - if (_modifiers->get(i)->get_percent_mod() > (float)0) { - Ref mod = _modifiers->get(i); + if (_modifiers.get(i)->get_percent_mod() > (float)0) { + Ref mod = _modifiers.get(i); _bonus += mod->get_bonus_mod(); _percent += mod->get_percent_mod(); @@ -295,15 +288,15 @@ void Stat::re_apply_modifier_not_negative_stacking_percents() { for (int j = 1; j < get_modifiers()->size(); ++j) { - if ((_modifiers->get(j)->get_percent_mod() < (float)0) && (_modifiers->get(j)->get_percent_mod() < percent_mod)) { + if ((_modifiers.get(j)->get_percent_mod() < (float)0) && (_modifiers.get(j)->get_percent_mod() < percent_mod)) { num = j; - percent_mod = _modifiers->get(j)->get_percent_mod(); + percent_mod = _modifiers.get(j)->get_percent_mod(); } } } if (num != -1) { - Ref mod = _modifiers->get(num); + Ref mod = _modifiers.get(num); _bonus += mod->get_bonus_mod(); _percent += mod->get_percent_mod(); diff --git a/entities/stats/stat.h b/entities/stats/stat.h index 55a7753..16492a4 100644 --- a/entities/stats/stat.h +++ b/entities/stats/stat.h @@ -178,7 +178,7 @@ private: StatModifierApplyType _modifier_apply_type; - Vector > *_modifiers; + Vector > _modifiers; bool _dirty; bool _disabled; diff --git a/entity_enums.cpp b/entity_enums.cpp index bcb21ef..4d6fb87 100644 --- a/entity_enums.cpp +++ b/entity_enums.cpp @@ -3,4 +3,5 @@ const String EntityEnums::BINDING_STRING_PLAYER_RESOURCE_TYPES = "None, Rage, Mana, Energy, Time Anomaly"; const String EntityEnums::BINDING_STRING_ENTITY_TYPES = "None, Player, AI, Mob"; const String EntityEnums::BINDING_STRING_ENTITY_STATE_TYPES = "None, Stun, Root, Frozen, Silenced, Disoriented, Feared, Burning, Cold, Cursed, Pacified"; -const String EntityEnums::BINDING_STRING_CHARCATER_SKELETON_BONE_ID = "Hip, Left Hand, Right Hand"; +const String EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS = "Hip, Left Hand, Right Hand, Weapon, Base, Body, Head, Right Eye, Left Eye"; + diff --git a/entity_enums.h b/entity_enums.h index 6fb91ba..b9c3853 100644 --- a/entity_enums.h +++ b/entity_enums.h @@ -11,7 +11,7 @@ public: static const String BINDING_STRING_PLAYER_RESOURCE_TYPES; static const String BINDING_STRING_ENTITY_TYPES; static const String BINDING_STRING_ENTITY_STATE_TYPES; - static const String BINDING_STRING_CHARCATER_SKELETON_BONE_ID; + static const String BINDING_STRING_CHARCATER_SKELETON_POINTS; enum PlayerResourceTypes { PLAYER_RESOURCE_TYPES_NONE, @@ -85,11 +85,18 @@ public: return ENTITY_STATE_TYPE_FLAG_NONE; } - enum CharacterSkeletonBoneId { - BONE_ID_HIP = 0, - BONE_ID_LEFT_HAND = 1, - BONE_ID_RIGHT_HAND = 2, - MAX_BONE_ID = 3, + enum CharacterSkeletonPoints { + SKELETON_POINT_HIP = 0, + SKELETON_POINT_LEFT_HAND = 1, + SKELETON_POINT_RIGHT_HAND = 2, + SKELETON_POINT_WEAPON = 3, + SKELETON_POINT_BASE = 4, + SKELETON_POINT_BODY = 5, + SKELETON_POINT_HEAD = 6, + SKELETON_POINT_RIGHT_EYE = 7, + SKELETON_POINT_LEFT_EYE = 8, + + SKELETON_POINTS_MAX = 9, }; EntityEnums() {} @@ -132,10 +139,16 @@ protected: BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_PACIFIED); BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_MAX); - BIND_ENUM_CONSTANT(BONE_ID_HIP); - BIND_ENUM_CONSTANT(BONE_ID_LEFT_HAND); - BIND_ENUM_CONSTANT(BONE_ID_RIGHT_HAND); - BIND_ENUM_CONSTANT(MAX_BONE_ID); + BIND_ENUM_CONSTANT(SKELETON_POINT_HIP); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_HAND); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_HAND); + BIND_ENUM_CONSTANT(SKELETON_POINT_WEAPON); + BIND_ENUM_CONSTANT(SKELETON_POINT_BASE); + BIND_ENUM_CONSTANT(SKELETON_POINT_BODY); + BIND_ENUM_CONSTANT(SKELETON_POINT_HEAD); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_EYE); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_EYE); + BIND_ENUM_CONSTANT(SKELETON_POINTS_MAX); } }; @@ -143,6 +156,6 @@ VARIANT_ENUM_CAST(EntityEnums::EntityType); VARIANT_ENUM_CAST(EntityEnums::PlayerResourceTypes); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeFlags); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeIndexes); -VARIANT_ENUM_CAST(EntityEnums::CharacterSkeletonBoneId); +VARIANT_ENUM_CAST(EntityEnums::CharacterSkeletonPoints); #endif diff --git a/inventory/bag.cpp b/inventory/bag.cpp index 0f00791..1bb49d6 100644 --- a/inventory/bag.cpp +++ b/inventory/bag.cpp @@ -1,38 +1,38 @@ #include "bag.h" Ref Bag::get_slot(int index) { - ERR_FAIL_INDEX_V(index, _slots->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _slots.size(), Ref(NULL)); - return (_slots->get(index)); + return (_slots.get(index)); } Ref Bag::get_and_remove_slot(int index) { - ERR_FAIL_INDEX_V(index, _slots->size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _slots.size(), Ref(NULL)); - Ref slot = _slots->get(index); + Ref slot = _slots.get(index); - _slots->set(index, Ref(memnew(BagSlot()))); + _slots.set(index, Ref(memnew(BagSlot()))); return slot; } int Bag::get_slot_count() { - return _slots->size(); + return _slots.size(); } void Bag::set_slot_count(int count) { - ERR_FAIL_COND(_slots->size() != 0); + ERR_FAIL_COND(_slots.size() > count); for (int i = 0; i < count; ++i) { - _slots->push_back(memnew(BagSlot())); + _slots.push_back(Ref(memnew(BagSlot()))); } } bool Bag::try_to_add_item(Ref item, int count) { ERR_FAIL_COND_V(!item.is_valid(), false); - for (int i = 0; i < _slots->size(); ++i) { - Ref slot = _slots->get(i); + for (int i = 0; i < _slots.size(); ++i) { + Ref slot = _slots.get(i); if (!slot->has_item()) { slot->set_item(item); @@ -48,9 +48,9 @@ bool Bag::try_to_add_item(Ref item, int count) { bool Bag::add_item_to_slot(Ref item, int slot_index, int count) { ERR_FAIL_COND_V(!item.is_valid(), false); - ERR_FAIL_INDEX_V(slot_index, _slots->size(), false); + ERR_FAIL_INDEX_V(slot_index, _slots.size(), false); - Ref slot = _slots->get(slot_index); + Ref slot = _slots.get(slot_index); ERR_FAIL_COND_V(!slot.is_valid(), false); @@ -64,13 +64,10 @@ bool Bag::add_item_to_slot(Ref item, int slot_index, int count) { } Bag::Bag() { - _slots = memnew(Vector >()); } Bag::~Bag() { - _slots->clear(); - - memdelete(_slots); + _slots.clear(); } void Bag::_bind_methods() { diff --git a/inventory/bag.h b/inventory/bag.h index b482754..6f83de8 100644 --- a/inventory/bag.h +++ b/inventory/bag.h @@ -26,7 +26,7 @@ protected: static void _bind_methods(); private: - Vector > *_slots; + Vector > _slots; }; #endif diff --git a/register_types.cpp b/register_types.cpp index a9ce9d5..73010a6 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -19,7 +19,6 @@ #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" @@ -41,7 +40,6 @@ #include "entities/entity.h" #include "entities/player.h" #include "entities/mob.h" -#include "spells/spell_manager.h" #include "data/aura_trigger_data.h" #include "data/aura_stat_attribute.h" @@ -60,7 +58,6 @@ void register_entity_spell_system_types() { ClassDB::register_class(); //data - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -108,9 +105,6 @@ void register_entity_spell_system_types() { ClassDB::register_class(); ClassDB::register_class(); - //deprecated - ClassDB::register_class(); - //spellinfos ClassDB::register_class(); diff --git a/skeleton/character_skeleton.cpp b/skeleton/character_skeleton.cpp index 0b26461..0035e5e 100644 --- a/skeleton/character_skeleton.cpp +++ b/skeleton/character_skeleton.cpp @@ -2,20 +2,20 @@ NodePath CharacterSkeleton::get_bone_path(int index) { - ERR_FAIL_INDEX_V(index, EntityEnums::MAX_BONE_ID, NodePath()); + ERR_FAIL_INDEX_V(index, EntityEnums::SKELETON_POINTS_MAX, NodePath()); return _bone_paths[index]; } void CharacterSkeleton::set_bone_path(int index, NodePath path) { - ERR_FAIL_INDEX(index, EntityEnums::MAX_BONE_ID); + ERR_FAIL_INDEX(index, EntityEnums::SKELETON_POINTS_MAX); _bone_paths[index] = path; _bone_nodes[index] = get_node_or_null(path); } -Node *CharacterSkeleton::get_bone_node(EntityEnums::CharacterSkeletonBoneId node_id) { +Node *CharacterSkeleton::get_bone_node(EntityEnums::CharacterSkeletonPoints node_id) { return _bone_nodes[node_id]; } @@ -60,7 +60,7 @@ AnimationTree *CharacterSkeleton::get_animation_tree() { } void CharacterSkeleton::update_nodes() { - for (int i = 0; i < EntityEnums::MAX_BONE_ID; ++i) { + for (int i = 0; i < EntityEnums::SKELETON_POINTS_MAX; ++i) { _bone_nodes[i] = get_node_or_null(_bone_paths[i]); } @@ -69,7 +69,7 @@ void CharacterSkeleton::update_nodes() { } CharacterSkeleton::CharacterSkeleton() { - for (int i = 0; i < EntityEnums::MAX_BONE_ID; ++i) { + for (int i = 0; i < EntityEnums::SKELETON_POINTS_MAX; ++i) { _bone_nodes[i] = NULL; } @@ -94,9 +94,15 @@ void CharacterSkeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bone_path", "index", "path"), &CharacterSkeleton::set_bone_path); ADD_GROUP("Bone Paths", "bone_path_"); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_hip"), "set_bone_path", "get_bone_path", EntityEnums::BONE_ID_HIP); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_left_hand"), "set_bone_path", "get_bone_path", EntityEnums::BONE_ID_LEFT_HAND); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_right_hand"), "set_bone_path", "get_bone_path", EntityEnums::BONE_ID_RIGHT_HAND); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_hip"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_HIP); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_left_hand"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_LEFT_HAND); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_right_hand"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_RIGHT_HAND); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_weapon"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_WEAPON); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_base"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_BASE); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_body"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_BODY); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_head"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_HEAD); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_right_eye"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_RIGHT_EYE); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "bone_path_left_eye"), "set_bone_path", "get_bone_path", EntityEnums::SKELETON_POINT_LEFT_EYE); ClassDB::bind_method(D_METHOD("get_bone_node", "bone_idx"), &CharacterSkeleton::get_bone_node); diff --git a/skeleton/character_skeleton.h b/skeleton/character_skeleton.h index cb8177c..ec4d0fc 100644 --- a/skeleton/character_skeleton.h +++ b/skeleton/character_skeleton.h @@ -30,7 +30,7 @@ public: NodePath get_bone_path(int index); void set_bone_path(int index, NodePath path); - Node *get_bone_node(EntityEnums::CharacterSkeletonBoneId node_id); + Node *get_bone_node(EntityEnums::CharacterSkeletonPoints node_id); NodePath get_animation_player_path(); void set_animation_player_path(NodePath path); @@ -54,12 +54,12 @@ private: NodePath _animation_player_path; NodePath _animation_tree_path; - NodePath _bone_paths[EntityEnums::MAX_BONE_ID]; + NodePath _bone_paths[EntityEnums::SKELETON_POINTS_MAX]; AnimationPlayer *_animation_player; AnimationTree *_animation_tree; - Node *_bone_nodes[EntityEnums::MAX_BONE_ID]; + Node *_bone_nodes[EntityEnums::SKELETON_POINTS_MAX]; }; diff --git a/spells/spell_manager.cpp b/spells/spell_manager.cpp deleted file mode 100644 index f747fe3..0000000 --- a/spells/spell_manager.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include "spell_manager.h" - -SpellManager *SpellManager::_instance; - -SpellManager *SpellManager::get_instance() { - return _instance; -} - -SpellManager::SpellManager() { - SpellManager::_instance = this; -} - -SpellManager::~SpellManager() { - SpellManager::_instance = NULL; -} - -void SpellManager::CastSpell(Entity *caster, int spellId, float scale) { -} - -void SpellManager::CastingFinished(Entity *caster, int spellId, float scale) { -} - -void SpellManager::UpdateAuras(Entity *ac) { -} - -void SpellManager::OnHit(Entity *ac, Entity *caster, Entity *target, Spell *spell, int damage) { -} - -void SpellManager::POnBeforeDamage(Entity *ac, SpellDamageInfo *data) { -} - -void SpellManager::OnDamageReceive(Entity *ac, Entity *caster, Entity *target, Spell *spell, int damage) { -} - -void SpellManager::RemoveAurasWithGroup(Entity *ac, int auraGroup) { -} - -void SpellManager::CRefreshAura(Entity *ac, int auraId, float time) { -} - -void SpellManager::CRefreshCasterAura(Entity *ac, int auraId, Entity *caster, float time) { -} - -void SpellManager::CAuraAdded(Entity *ac, int id, float remaining, Entity *caster, int casterGUID) { -} - -void SpellManager::CAuraRemoved(Entity *ac, int id) { -} - -void SpellManager::SetupOnPlayerMoves(Entity *bopmccc, Vector *sspells) { -} - -void SpellManager::COnCastFailed(Entity *caster, int spellId) { -} - -void SpellManager::COnCastStarted(Entity *caster, int spellId) { -} - -void SpellManager::COnCastStateChanged(Entity *caster, int spellId) { -} - -void SpellManager::COnCastFinished(Entity *caster, int spellId) { -} - -void SpellManager::COnSpellCastSuccess(Entity *caster, int spellId) { -} - -String SpellManager::RequestName(int spellId) { - return ""; -} - -String SpellManager::RequestDescription(int spellId, int level) { - return ""; -} - -/* - -void SpellManager::CastSpell(Entity *caster, int spellId, float scale) { - if (!Spells::Instance->SpellsDict->ContainsKey(spellId)) { - Debug::Log(*(new String("SpellManager->castSpell: SpellID Doesn't exists! spellId:")) + BOX(spellId)); - return; - } - Spell *spell = Spells::Instance->SpellsDict->GetData(spellId); - if (spell == null) { - Debug::Log(new String("SpellManager->castSpell: SpellData is null!")); - return; - } - (SpellScript *)(spell->SpellScript)->StartCasting((WorldEntity *)(caster), scale); -} - -void SpellManager::CastingFinished(Entity *caster, int spellId, float scale) { - if (!Spells::Instance->SpellsDict->ContainsKey(spellId)) { - Debug::Log(new String("SpellManager->CastingFinished: SpellID Doesn't exists!")); - return; - } - Spell *spell = Spells::Instance->SpellsDict->GetData(spellId); - if (spell == null) { - Debug::Log(new String("SpellManager->CastingFinished: SpellData is null!")); - return; - } - (SpellScript *)(spell->SpellScript)->CastingFinished((WorldEntity *)(caster), scale); -} - -void SpellManager::UpdateAuras(Entity *ac) { - AuraComponent *auraComponent = as_cast(ac); - for (int i = 0; i < auraComponent->serverAuras->Count; i += 1) { - AuraData *auraData = auraComponent->serverAuras->GetData(i); - AuraScript *auraScript = (AuraScript *)(auraData->Aura->AuraScript); - if (auraScript == null) { - Debug::Log(*(new String("AuraComponent->Update(): Aurascript is null! AuraId: ")) + BOX(auraData->AuraId)); - } else { - if (auraScript->AuraUpdate(auraComponent->Owner, auraData)) { - auraComponent->serverAuras->RemoveAt(i); - auraComponent->CReceiveAuraRemoved(auraData->AuraId); - i -= 1; - } - } - } -} - -void SpellManager::OnHit(Entity *ac, Entity *caster, Entity *target, MonoBehaviour *spell, int damage) { - AuraComponent *auraComponent = as_cast(ac); - int count = auraComponent->serverAuras->Count; - for (int i = 0; i < auraComponent->serverAuras->Count; i += 1) { - (AuraScript *)(auraComponent->serverAuras->GetData(i)->Aura->AuraScript)->OnHit((WorldEntity *)(caster), (WorldEntity *)(target), spell, auraComponent->serverAuras->GetData(i), damage); - if (count != auraComponent->serverAuras->Count) { - i -= count - *auraComponent->serverAuras->Count; - count = auraComponent->serverAuras->Count; - } - } -} - -void SpellManager::POnBeforeDamage(Entity *ac, SpellDamageInfo *data) { - AuraComponent *auraComponent = as_cast(ac); - int count = auraComponent->serverAuras->Count; - for (int i = 0; i < auraComponent->serverAuras->Count; i += 1) { - (AuraScript *)(auraComponent->serverAuras->GetData(i)->Aura->AuraScript)->POnBeforeDamage(data, auraComponent->serverAuras->GetData(i)); - if (count != auraComponent->serverAuras->Count) { - i -= count - *auraComponent->serverAuras->Count; - count = auraComponent->serverAuras->Count; - } - } -} - -void SpellManager::OnDamageReceive(Entity *ac, Entity *caster, Entity *target, MonoBehaviour *spell, int damage) { - AuraComponent *auraComponent = as_cast(ac); - int count = auraComponent->serverAuras->Count; - for (int i = 0; i < auraComponent->serverAuras->Count; i += 1) { - (AuraScript *)(auraComponent->serverAuras->GetData(i)->Aura->AuraScript)->OnDamageReceive((WorldEntity *)(caster), (WorldEntity *)(target), spell, auraComponent->serverAuras->GetData(i), damage); - if (count != auraComponent->serverAuras->Count) { - i -= count - *auraComponent->serverAuras->Count; - count = auraComponent->serverAuras->Count; - } - } -} - -void SpellManager::RemoveAurasWithGroup(Entity *ac, int auraGroup) { - AuraComponent *auraComponent = as_cast(ac); - for (int i = 0; i < auraComponent->serverAuras->Count; i += 1) { - AuraData *auraData = auraComponent->serverAuras->GetData(i); - if (auraData->AuraGroup == auraGroup) { - (AuraScript *)(Auras::Instance->GetData(auraData->AuraId)->AuraScript)->DeApply(auraComponent->Owner, auraData); - auraComponent->serverAuras->RemoveAt(i); - i -= 1; - auraComponent->CReceiveAuraRemoved(auraData->AuraId); - } - } -} - -void SpellManager::CRefreshAura(Entity *ac, int auraId, float time) { - AuraComponent *auraComponent = as_cast(ac); - for (int i = 0; i < auraComponent->auras->Count; i += 1) { - if (auraComponent->auras->GetData(i)->AuraId == auraId) { - auraComponent->auras->GetData(i)->Remaining = time; - Aura *aura = auraComponent->auras->GetData(i)->Aura; - (AuraScript *)(aura->AuraScript)->COnRefresh((WorldEntity *)(auraComponent->auras->GetData(i)->Caster), aura->gameObject, auraComponent->auras->GetData(i)); - return; - } - } -} - -void SpellManager::CRefreshCasterAura(Entity *ac, int auraId, Entity *caster, float time) { - AuraComponent *auraComponent = as_cast(ac); - for (int i = 0; i < auraComponent->auras->Count; i += 1) { - if ((auraComponent->auras->GetData(i)->AuraId == auraId) && (auraComponent->auras->GetData(i)->Caster == *caster)) { - auraComponent->auras->GetData(i)->Remaining = time; - Aura *aura = auraComponent->auras->GetData(i)->Aura; - (AuraScript *)(aura->AuraScript)->COnRefresh((WorldEntity *)(caster), aura->gameObject, auraComponent->auras->GetData(i)); - return; - } - } -} - -void SpellManager::CAuraAdded(Entity *ac, int id, float remaining, Entity *caster, uint casterGUID) { - AuraComponent *arg_18_0 = as_cast(ac); - AuraData *auraData = new AuraData(id, remaining, caster, casterGUID, 0, (float)1); - arg_18_0->auras->Add(auraData); - Aura *aura = Auras::Instance->GetData(id); - (AuraScript *)(aura->AuraScript)->COnAdded((WorldEntity *)(caster), aura, auraData); -} - -void SpellManager::CAuraRemoved(Entity *ac, int id) { - AuraComponent *auraComponent = as_cast(ac); - for (int i = 0; i < auraComponent->auras->Count; i += 1) { - if (auraComponent->auras->GetData(i)->AuraId == id) { - auraComponent->auras->RemoveAt(i); - Aura *aura = Auras::Instance->GetData(id); - (AuraScript *)(aura->AuraScript)->COnRemoved(auraComponent->Owner, aura); - return; - } - } -} - -void SpellManager::SetupOnPlayerMoves(BaseOnPlayerMoveCallbackComponent *bopmccc, List_T *sspells) { - OnPlayerMoveCallbackComponent *onPlayerMoveCallbackComponent = as_cast(bopmccc); - for (int i = 0; i < sspells->Count; i += 1) { - BaseOnPlayerMoveCallbackComponent *arg_38_0 = onPlayerMoveCallbackComponent; - SpellScript *expr_2C = (SpellScript *)(Spells::Instance->SpellsDict->GetData(sspells->GetData(i))->SpellScript); - arg_38_0->SOnPlayerMove += *(new BaseOnPlayerMoveCallbackComponent::OnPlayerMoved(expr_2C->OnPlayerMove)); - } -} - -void SpellManager::COnCastFailed(Entity *caster, int spellId) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return; - } - (SpellScript *)(spell->SpellScript)->COnSpellCastEnded((WorldEntity *)(caster)); -} - -void SpellManager::COnCastStarted(Entity *caster, int spellId) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return; - } - (SpellScript *)(spell->SpellScript)->COnSpellCastStarted((WorldEntity *)(caster)); -} - -void SpellManager::COnCastStateChanged(Entity *caster, int spellId) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return; - } - (SpellScript *)(spell->SpellScript)->OnCastStateChanged((WorldEntity *)(caster)); -} - -void SpellManager::COnCastFinished(Entity *caster, int spellId) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return; - } - (SpellScript *)(spell->SpellScript)->COnSpellCastEnded((WorldEntity *)(caster)); -} - -void SpellManager::COnSpellCastSuccess(Entity *caster, int spellId) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return; - } - (SpellScript *)(spell->SpellScript)->COnSpellCastSuccess((WorldEntity *)(caster)); -} - -String SpellManager::RequestName(int spellId) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return new String(""); - } - return (SpellScript *)(spell->SpellScript)->GetName(); -} - -String SpellManager::RequestDescription(int spellId, int level) { - Spell *spell; - if (!Spells::Instance->SpellsDict->TryGetValue(spellId, spell)) { - return new String(""); - } - return (SpellScript *)(spell->SpellScript)->GetDescription(level); -}*/ - -void SpellManager::_bind_methods() { -} diff --git a/spells/spell_manager.h b/spells/spell_manager.h deleted file mode 100644 index 5409621..0000000 --- a/spells/spell_manager.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SPELL_MANAGER_H -#define SPELL_MANAGER_H - -#include "scene/main/node.h" -#include "core/ustring.h" -#include "core/vector.h" -#include "../pipelines/spell_damage_info.h" -#include "../entities/entity.h" -#include "../data/spell.h" - -//Deprecated, delete later - -class SpellManager : public Node { - GDCLASS(SpellManager, Node); - -public: - static SpellManager *get_instance(); - - void CastSpell(Entity *caster, int spellId, float scale); - void CastingFinished(Entity *caster, int spellId, float scale); - void UpdateAuras(Entity *auraComponent); - void OnHit(Entity *auraComponent, Entity *caster, Entity *target, Spell *spell, int damage); - void POnBeforeDamage(Entity *ac, SpellDamageInfo *data); - void OnDamageReceive(Entity *ac, Entity *caster, Entity *target, Spell *spell, int damage); - void RemoveAurasWithGroup(Entity *ac, int auraGroup); - void CRefreshAura(Entity *ac, int auraId, float time); - void CRefreshCasterAura(Entity *ac, int auraId, Entity *caster, float time); - void CAuraAdded(Entity *ac, int id, float remaining, Entity *caster, int casterGUID); - void CAuraRemoved(Entity *ac, int id); - void COnCastFailed(Entity *caster, int spellId); - void SetupOnPlayerMoves(Entity *bopmccc, Vector *sspells); - void COnCastStarted(Entity *caster, int spellId); - void COnCastStateChanged(Entity *caster, int spellId); - void COnCastFinished(Entity *caster, int spellId); - void COnSpellCastSuccess(Entity *caster, int spellId); - - String RequestName(int spellId); - String RequestDescription(int spellId, int level); - - SpellManager(); - ~SpellManager(); - -protected: - static void _bind_methods(); - -private: - static SpellManager *_instance; -}; - -#endif