From 3cce6b0ae870c25116dcab066c2d7efeec18b212 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 13 Aug 2019 23:58:42 +0200 Subject: [PATCH] -Talent is now inherited from Aura. -Cleaned up the talent system specific classes. -The ResourceManager now loads talents aswell. -Cleaned up, and made the EntityResource system scriptable. -Fixed the stat signals, the stat parameter was null every time. ("this" should've been wrapped in a Ref.) --- data/aura.cpp | 2 + data/aura.h | 1 + data/character_class.cpp | 15 +- data/character_class.h | 18 +- data/character_spec.cpp | 81 +-- data/character_spec.h | 25 +- data/data_manager.cpp | 97 ++++ data/data_manager.h | 15 + data/spell.cpp | 12 +- data/spell.h | 12 +- data/talent.cpp | 193 +------- data/talent.h | 52 +- data/talent_rank_data.cpp | 1 - data/talent_rank_data.h | 74 --- data/talent_row_data.cpp | 68 +-- data/talent_row_data.h | 33 +- entities/entity.cpp | 930 +++++++++++++++++++---------------- entities/entity.h | 18 +- entities/entity_resource.cpp | 142 +++++- entities/entity_resource.h | 33 ++ entities/player_talent.cpp | 30 -- entities/player_talent.h | 25 - entities/stats/stat.cpp | 47 +- entity_enums.cpp | 84 ++++ entity_enums.h | 94 +--- register_types.cpp | 4 - spell_enums.cpp | 2 +- spell_enums.h | 2 + 28 files changed, 1019 insertions(+), 1091 deletions(-) delete mode 100644 data/talent_rank_data.cpp delete mode 100644 data/talent_rank_data.h delete mode 100644 entities/player_talent.cpp delete mode 100644 entities/player_talent.h diff --git a/data/aura.cpp b/data/aura.cpp index ca97f41..479ef33 100644 --- a/data/aura.cpp +++ b/data/aura.cpp @@ -1363,6 +1363,8 @@ void Aura::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::REAL, "StatModAttribute_" + itos(i) + "/percent_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_aura_stat_attribute_percent_mod", "get_aura_stat_attribute_percent_mod", i); } + ClassDB::bind_method(D_METHOD("is_talent"), &Aura::is_talent); + BIND_CONSTANT(MAX_AURA_STATS); BIND_CONSTANT(MAX_TRIGGER_DATA); } diff --git a/data/aura.h b/data/aura.h index 74fa2c6..3031656 100644 --- a/data/aura.h +++ b/data/aura.h @@ -301,6 +301,7 @@ public: virtual void _calculate_initial_heal(Ref aura_data, Ref info); virtual void _handle_aura_heal(Ref aura_data, Ref data); + _FORCE_INLINE_ bool is_talent() const { return _aura_type == SpellEnums::AURA_TYPE_TALENT; } Aura(); ~Aura(); diff --git a/data/character_class.cpp b/data/character_class.cpp index c191412..bda9b8b 100644 --- a/data/character_class.cpp +++ b/data/character_class.cpp @@ -3,6 +3,8 @@ #include "../data/spell.h" #include "../data/aura.h" #include "../entities/entity.h" +#include "character_spec.h" +#include "../infos/spell_cast_info.h" int CharacterClass::get_id() { return _id; @@ -28,11 +30,11 @@ void CharacterClass::set_icon(Ref value) { _icon = Ref(value); } -EntityEnums::PlayerResourceTypes CharacterClass::get_player_resource_type() { +int CharacterClass::get_player_resource_type() { return _player_resource_type; } -void CharacterClass::set_player_resource_type(EntityEnums::PlayerResourceTypes value) { +void CharacterClass::set_player_resource_type(int value) { _player_resource_type = value; } @@ -107,6 +109,13 @@ void CharacterClass::set_aura(int index, Ref aura) { _auras[index] = aura; } +void CharacterClass::setup_resources(Entity *entity) { + if (has_method("_setup_resources")) + call("_setup_resources", entity); +} +//void CharacterClass::_setup_resources(Entity *entity) { +//} + /* Vector CharacterClass::get_mob_party_ids() { return _mob_party_ids; @@ -638,6 +647,8 @@ void CharacterClass::_bind_methods() { BIND_VMETHOD(MethodInfo("_son_gcd_started", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::REAL, "gcd"))); BIND_VMETHOD(MethodInfo("_son_gcd_finished", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + + BIND_VMETHOD(MethodInfo("_setup_resources", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); //Clientside Event Handlers ClassDB::bind_method(D_METHOD("con_cast_failed", "info"), &CharacterClass::con_cast_failed); diff --git a/data/character_class.h b/data/character_class.h index 79abae4..e7b1d1b 100644 --- a/data/character_class.h +++ b/data/character_class.h @@ -7,12 +7,10 @@ #include "../entities/stats/stat_data.h" #include "../entity_enums.h" -#include "character_spec.h" #include "../entities/auras/aura_data.h" #include "../pipelines/spell_damage_info.h" #include "../pipelines/spell_heal_info.h" -#include "../infos/spell_cast_info.h" #include "../utility/cooldown.h" #include "../utility/category_cooldown.h" @@ -22,6 +20,7 @@ class Spell; class Entity; class CharacterSpec; class Entity; +class SpellCastInfo; enum CharacterWeaponDataTypes { CHARACTER_WEAPON_DATA_TYPES_NONE, @@ -47,8 +46,8 @@ public: Ref get_stat_data(); void set_stat_data(Ref value); - EntityEnums::PlayerResourceTypes get_player_resource_type(); - void set_player_resource_type(EntityEnums::PlayerResourceTypes value); + int get_player_resource_type(); + void set_player_resource_type(int value); int get_num_spells(); void set_num_spells(int value); @@ -68,13 +67,10 @@ public: Ref get_aura(int index); void set_aura(int index, Ref aura); + void setup_resources(Entity *entity); + //void _setup_resources(Entity *entity); + /* - Vector get_talent_ids(); - void set_talent_ids(Vector ids); - - Vector get_spec_ids(); - void set_spec_ids(Vector ids); - Vector get_mob_party_ids(); void set_mob_party_ids(Vector ids); @@ -186,7 +182,7 @@ private: String _character_class_name; Ref _icon; - EntityEnums::PlayerResourceTypes _player_resource_type; + int _player_resource_type; Ref _stat_data; diff --git a/data/character_spec.cpp b/data/character_spec.cpp index 1026cdd..91a9050 100644 --- a/data/character_spec.cpp +++ b/data/character_spec.cpp @@ -1,5 +1,7 @@ #include "character_spec.h" +#include "talent.h" + int CharacterSpec::get_spec_id() { return _spec_id; } @@ -17,57 +19,36 @@ void CharacterSpec::set_spec_name(String value) { } Ref CharacterSpec::get_talent_row(int index) const { + ERR_FAIL_INDEX_V(index, MAX_TALENT_ROWS, Ref(NULL)); + return _rows[index]; } -Ref CharacterSpec::get_talent0_in_row(int index) const { - return _rows[index]->get_talent0(); +void CharacterSpec::set_talent_row(const int index, const Ref row) { + ERR_FAIL_INDEX(index, MAX_TALENT_ROWS); + + _rows[index] = row; } -void CharacterSpec::set_talent0_in_row(int index, Ref talent) { - _rows[index]->set_talent0(talent); -} +Ref CharacterSpec::get_talent(const int row_index, const int index) const { + ERR_FAIL_INDEX_V(row_index, MAX_TALENT_ROWS, Ref(NULL)); -Ref CharacterSpec::get_talent1_in_row(int index) const { - return _rows[index]->get_talent1(); -} -void CharacterSpec::set_talent1_in_row(int index, Ref talent) { - _rows[index]->set_talent1(talent); -} - -Ref CharacterSpec::get_talent2_in_row(int index) const { - return _rows[index]->get_talent2(); -} - -void CharacterSpec::set_talent2_in_row(int index, Ref talent) { - _rows[index]->set_talent2(talent); -} - -Ref CharacterSpec::get_talent3_in_row(int index) const { - return _rows[index]->get_talent3(); -} - -void CharacterSpec::set_talent3_in_row(int index, Ref talent) { - _rows[index]->set_talent3(talent); -} - -Ref CharacterSpec::get_talent4_in_row(int index) const { - return _rows[index]->get_talent4(); -} - -void CharacterSpec::set_talent4_in_row(int index, Ref talent) { - _rows[index]->set_talent4(talent); -} - -CharacterSpec::CharacterSpec() { - for (int i = 0; i < MAX_TALENT_ROWS; ++i) { - _rows[i] = Ref(memnew(TalentRowData())); + if (_rows[row_index].is_valid()) { + return _rows[row_index]->get_talent(index); } + return Ref(NULL); +} + + +CharacterSpec::CharacterSpec() { _spec_id = 0; } CharacterSpec::~CharacterSpec() { + for (int i = 0; i < MAX_TALENT_ROWS; ++i) { + _rows[i].unref(); + } } void CharacterSpec::_bind_methods() { @@ -79,24 +60,14 @@ void CharacterSpec::_bind_methods() { ClassDB::bind_method(D_METHOD("set_spec_name", "value"), &CharacterSpec::set_spec_name); ADD_PROPERTY(PropertyInfo(Variant::STRING, "spec_name"), "set_spec_name", "get_spec_name"); - ClassDB::bind_method(D_METHOD("get_talent0_in_row", "index"), &CharacterSpec::get_talent0_in_row); - ClassDB::bind_method(D_METHOD("set_talent0_in_row", "index", "value"), &CharacterSpec::set_talent0_in_row); - ClassDB::bind_method(D_METHOD("get_talent1_in_row", "index"), &CharacterSpec::get_talent0_in_row); - ClassDB::bind_method(D_METHOD("set_talent1_in_row", "index", "value"), &CharacterSpec::set_talent0_in_row); - ClassDB::bind_method(D_METHOD("get_talent2_in_row", "index"), &CharacterSpec::get_talent0_in_row); - ClassDB::bind_method(D_METHOD("set_talent2_in_row", "index", "value"), &CharacterSpec::set_talent0_in_row); - ClassDB::bind_method(D_METHOD("get_talent3_in_row", "index"), &CharacterSpec::get_talent0_in_row); - ClassDB::bind_method(D_METHOD("set_talent3_in_row", "index", "value"), &CharacterSpec::set_talent0_in_row); - ClassDB::bind_method(D_METHOD("get_talent4_in_row", "index"), &CharacterSpec::get_talent0_in_row); - ClassDB::bind_method(D_METHOD("set_talent4_in_row", "index", "value"), &CharacterSpec::set_talent0_in_row); + ClassDB::bind_method(D_METHOD("get_talent_row", "index"), &CharacterSpec::get_talent_row); + ClassDB::bind_method(D_METHOD("set_talent_row", "index", "row"), &CharacterSpec::set_talent_row); for (int i = 0; i < MAX_TALENT_ROWS; i++) { - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i) + "/talent0", PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent0_in_row", "get_talent0_in_row", i); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i) + "/talent1", PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent1_in_row", "get_talent1_in_row", i); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i) + "/talent2", PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent2_in_row", "get_talent2_in_row", i); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i) + "/talent3", PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent3_in_row", "get_talent3_in_row", i); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i) + "/talent4", PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent4_in_row", "get_talent4_in_row", i); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "TalentRowData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_row", "get_talent_row", i); } - ClassDB::bind_method(D_METHOD("get_talent_row"), &CharacterSpec::get_talent_row); + ClassDB::bind_method(D_METHOD("get_talent", "row_index", "index"), &CharacterSpec::get_talent); + + BIND_CONSTANT(MAX_TALENT_ROWS); } diff --git a/data/character_spec.h b/data/character_spec.h index 48bf2c3..291f2e5 100644 --- a/data/character_spec.h +++ b/data/character_spec.h @@ -19,33 +19,22 @@ public: void set_spec_name(String value); Ref get_talent_row(int index) const; + void set_talent_row(const int index, const Ref row); - Ref get_talent0_in_row(int index) const; - void set_talent0_in_row(int index, Ref talent); - - Ref get_talent1_in_row(int index) const; - void set_talent1_in_row(int index, Ref talent); - - Ref get_talent2_in_row(int index) const; - void set_talent2_in_row(int index, Ref talent); - - Ref get_talent3_in_row(int index) const; - void set_talent3_in_row(int index, Ref talent); - - Ref get_talent4_in_row(int index) const; - void set_talent4_in_row(int index, Ref talent); + Ref get_talent(const int row_index, const int index) const; CharacterSpec(); ~CharacterSpec(); +public: + enum { + MAX_TALENT_ROWS = 10, + }; + protected: static void _bind_methods(); private: - enum { - MAX_TALENT_ROWS = 10, - }; - int _spec_id; String _spec_name; Ref _rows[MAX_TALENT_ROWS]; diff --git a/data/data_manager.cpp b/data/data_manager.cpp index 9836a08..6b5c1e5 100644 --- a/data/data_manager.cpp +++ b/data/data_manager.cpp @@ -4,6 +4,7 @@ #include "character_class.h" #include "craft_data_attribute.h" #include "spell.h" +#include "talent.h" #include "mob_data.h" #include "player_character_data.h" @@ -129,6 +130,41 @@ int DataManager::get_aura_count() { return _auras.size(); } +//Talents +void DataManager::add_talent(Ref talent) { + ERR_FAIL_COND(!talent.is_valid()); + + _talents.push_back(talent); + _talent_map.set(talent->get_id(), talent); +} + +String DataManager::get_talents_folder() { + return _talents_folder; +} +void DataManager::set_talents_folder(String folder) { + _talents_folder = folder; +} +Vector > *DataManager::get_talents() { + return &_talents; +} + +Ref DataManager::get_talent(int talent_id) { + ERR_FAIL_COND_V(!_talent_map.has(talent_id), Ref(NULL)); + + return _talent_map.get(talent_id); +} + +Ref DataManager::get_talent_index(int index) { + ERR_FAIL_INDEX_V(index, _talents.size(), Ref(NULL)); + + return _talents.get(index); +} + +int DataManager::get_talent_count() { + return _talents.size(); +} + +//Craft Data void DataManager::add_craft_data(Ref cda) { ERR_FAIL_COND(!cda.is_valid()); @@ -267,6 +303,7 @@ int DataManager::get_player_character_data_count() { void DataManager::load_all() { load_spells(); load_auras(); + load_talents(); load_characters(); load_craft_datas(); load_item_templates(); @@ -352,6 +389,45 @@ void DataManager::load_auras() { } } +void DataManager::load_talents() { + _Directory dir; + + ERR_FAIL_COND(_talents_folder.ends_with("/")); + + if (dir.open(_talents_folder) == OK) { + + dir.list_dir_begin(); + + String filename = dir.get_next(); + + while (filename != "") { + if (!dir.current_is_dir()) { + String path = _talents_folder + "/" + filename; + + _ResourceLoader *rl = _ResourceLoader::get_singleton(); + + Ref resl = rl->load_interactive(path, "Aura"); + + resl->wait(); + + Ref s = resl->get_resource(); + + ERR_CONTINUE(!s.is_valid()); + + Ref talent = s; + + ERR_CONTINUE(!talent.is_valid()); + + add_talent(talent); + } + + filename = dir.get_next(); + } + } else { + print_error("An error occurred when trying to access the path."); + } +} + void DataManager::load_characters() { _Directory dir; @@ -565,6 +641,12 @@ void DataManager::list_auras() { } } +void DataManager::list_talents() { + for (int i = 0; i < _talents.size(); ++i) { + print_error(itos(i) + ": " + _talents.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()); @@ -624,6 +706,16 @@ void DataManager::_bind_methods() { ClassDB::bind_method(D_METHOD("get_aura_index", "index"), &DataManager::get_aura_index); ClassDB::bind_method(D_METHOD("get_aura_count"), &DataManager::get_aura_count); + //Talent + ClassDB::bind_method(D_METHOD("get_talents_folder"), &DataManager::get_talents_folder); + ClassDB::bind_method(D_METHOD("set_talents_folder", "folder"), &DataManager::set_talents_folder); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "talents_folder"), "set_talents_folder", "get_talents_folder"); + + ClassDB::bind_method(D_METHOD("add_talent", "spell"), &DataManager::add_talent); + ClassDB::bind_method(D_METHOD("get_talent", "id"), &DataManager::get_talent); + ClassDB::bind_method(D_METHOD("get_talent_index", "index"), &DataManager::get_talent_index); + ClassDB::bind_method(D_METHOD("get_talent_count"), &DataManager::get_talent_count); + //Craft Data ClassDB::bind_method(D_METHOD("get_craft_data_folder"), &DataManager::get_craft_data_folder); ClassDB::bind_method(D_METHOD("set_craft_data_folder", "folder"), &DataManager::set_craft_data_folder); @@ -668,6 +760,7 @@ void DataManager::_bind_methods() { 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_auras"), &DataManager::load_auras); + ClassDB::bind_method(D_METHOD("load_talents"), &DataManager::load_talents); ClassDB::bind_method(D_METHOD("load_characters"), &DataManager::load_characters); ClassDB::bind_method(D_METHOD("load_craft_datas"), &DataManager::load_craft_datas); ClassDB::bind_method(D_METHOD("load_item_templates"), &DataManager::load_item_templates); @@ -678,6 +771,7 @@ void DataManager::_bind_methods() { ClassDB::bind_method(D_METHOD("list_characters"), &DataManager::list_characters); ClassDB::bind_method(D_METHOD("list_spells"), &DataManager::list_spells); ClassDB::bind_method(D_METHOD("list_auras"), &DataManager::list_auras); + ClassDB::bind_method(D_METHOD("list_talents"), &DataManager::list_talents); ClassDB::bind_method(D_METHOD("list_craft_data"), &DataManager::list_craft_data); ClassDB::bind_method(D_METHOD("list_item_templates"), &DataManager::list_item_templates); ClassDB::bind_method(D_METHOD("list_mob_datas"), &DataManager::list_mob_datas); @@ -701,6 +795,9 @@ DataManager::~DataManager() { _auras.clear(); _aura_map.clear(); + + _talents.clear(); + _talent_map.clear(); _craft_datas.clear(); _craft_data_map.clear(); diff --git a/data/data_manager.h b/data/data_manager.h index 9bcfdc7..632e7a6 100644 --- a/data/data_manager.h +++ b/data/data_manager.h @@ -15,6 +15,7 @@ class Aura; class Spell; +class Talent; class CharacterClass; class CraftDataAttribute; class ItemTemplate; @@ -51,6 +52,14 @@ public: int get_aura_count(); void add_aura(Ref aura); + String get_talents_folder(); + void set_talents_folder(String folder); + Vector > *get_talents(); + Ref get_talent(int talent_id); + Ref get_talent_index(int index); + int get_talent_count(); + void add_talent(Ref talent); + String get_craft_data_folder(); void set_craft_data_folder(String folder); Vector > *get_craft_datas(); @@ -86,6 +95,7 @@ public: void load_all(); void load_spells(); void load_auras(); + void load_talents(); void load_characters(); void load_craft_datas(); void load_item_templates(); @@ -95,6 +105,7 @@ public: void list_characters(); void list_spells(); void list_auras(); + void list_talents(); void list_craft_data(); void list_item_templates(); void list_mob_datas(); @@ -123,6 +134,10 @@ private: Vector > _auras; HashMap > _aura_map; + String _talents_folder; + Vector > _talents; + HashMap > _talent_map; + String _craft_data_folder; Vector > _craft_datas; HashMap > _craft_data_map; diff --git a/data/spell.cpp b/data/spell.cpp index 12e97f3..0fad71f 100644 --- a/data/spell.cpp +++ b/data/spell.cpp @@ -138,10 +138,10 @@ void Spell::set_required_item(int value) { _required_item = value; } -EntityEnums::PlayerResourceTypes Spell::get_cost_type() { +int Spell::get_cost_type() { return _cost_type; } -void Spell::set_cost_type(EntityEnums::PlayerResourceTypes value) { +void Spell::set_cost_type(int value) { _cost_type = value; } @@ -152,10 +152,10 @@ void Spell::set_cost_resource(int value) { _cost_resource = value; } -EntityEnums::PlayerResourceTypes Spell::get_give_resource_type() { +int Spell::get_give_resource_type() { return _give_resource_type; } -void Spell::set_give_resource_type(EntityEnums::PlayerResourceTypes value) { +void Spell::set_give_resource_type(int value) { _give_resource_type = value; } @@ -1041,7 +1041,7 @@ void Spell::_bind_methods() { ClassDB::bind_method(D_METHOD("get_cost_type"), &Spell::get_cost_type); ClassDB::bind_method(D_METHOD("set_cost_type", "value"), &Spell::set_cost_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "cost_type", PROPERTY_HINT_ENUM, "None, Rage"), "set_cost_type", "get_cost_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "cost_type"), "set_cost_type", "get_cost_type"); ClassDB::bind_method(D_METHOD("get_cost_resource"), &Spell::get_cost_resource); ClassDB::bind_method(D_METHOD("set_cost_resource", "value"), &Spell::set_cost_resource); @@ -1050,7 +1050,7 @@ void Spell::_bind_methods() { ADD_GROUP("Gives", "give"); ClassDB::bind_method(D_METHOD("get_give_resource_type"), &Spell::get_give_resource_type); ClassDB::bind_method(D_METHOD("set_give_resource_type", "value"), &Spell::set_give_resource_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "give_resource_type", PROPERTY_HINT_ENUM, "None, Rage"), "set_give_resource_type", "get_give_resource_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "give_resource_type"), "set_give_resource_type", "get_give_resource_type"); ClassDB::bind_method(D_METHOD("get_give_resource"), &Spell::get_give_resource); ClassDB::bind_method(D_METHOD("set_give_resource", "value"), &Spell::set_give_resource); diff --git a/data/spell.h b/data/spell.h index 4aa6a1a..8a25a69 100644 --- a/data/spell.h +++ b/data/spell.h @@ -127,14 +127,14 @@ public: int get_required_item(); void set_required_item(int value); - EntityEnums::PlayerResourceTypes get_cost_type(); - void set_cost_type(EntityEnums::PlayerResourceTypes value); + int get_cost_type(); + void set_cost_type(int value); int get_cost_resource(); void set_cost_resource(int value); - EntityEnums::PlayerResourceTypes get_give_resource_type(); - void set_give_resource_type(EntityEnums::PlayerResourceTypes value); + int get_give_resource_type(); + void set_give_resource_type(int value); int get_give_resource(); void set_give_resource(int value); @@ -392,9 +392,9 @@ private: int _item_cost; int _craft_material_cost; int _required_item; - EntityEnums::PlayerResourceTypes _cost_type; + int _cost_type; int _cost_resource; - EntityEnums::PlayerResourceTypes _give_resource_type; + int _give_resource_type; int _give_resource; bool _has_global_cooldown; bool _is_local_spell; diff --git a/data/talent.cpp b/data/talent.cpp index b705fcd..785bb77 100644 --- a/data/talent.cpp +++ b/data/talent.cpp @@ -1,187 +1,28 @@ #include "talent.h" -int Talent::get_id(){ - return _id; +Ref Talent::get_next_rank() const { + return _next_rank; +} +void Talent::set_next_rank(const Ref rank) { + _next_rank = rank; } -void Talent::set_id(int value) -{ - _id = value; +Talent::Talent() { + set_aura_type(SpellEnums::AURA_TYPE_TALENT); + set_hide(true); } - -Ref Talent::get_rank_data(int index) -{ - return _ranks[index]; +Talent::~Talent() { + _next_rank.unref(); + _aura.unref(); } -String Talent::get_talent_name() -{ - return _talent_name; -} - -void Talent::set_talent_name(String value) -{ - _talent_name = value; -} - -String Talent::get_description() -{ - return _description; -} - -void Talent::set_description(String value) -{ - _description = value; -} - - -int Talent::get_max_rank() -{ - return _max_rank; -} - -void Talent::set_max_rank(int value) -{ - _max_rank = value; -} - -Stat::StatId Talent::get_talent_stat_attribute_stat(int index) const { - ERR_FAIL_INDEX_V(index, MAX_RANKS, Stat::STAT_ID_NONE); - - return _ranks[index]->get_stat(); -} -void Talent::set_talent_stat_attribute_stat(int index, const Stat::StatId value) { - ERR_FAIL_INDEX(index, MAX_RANKS); - - _ranks[index]->set_stat(value); -} - -float Talent::get_talent_stat_attribute_base_mod(int index) const { - ERR_FAIL_INDEX_V(index, MAX_RANKS, 0); - - return _ranks[index]->get_base_mod(); -} -void Talent::set_talent_stat_attribute_base_mod(int index, float value) { - ERR_FAIL_INDEX(index, MAX_RANKS); - - _ranks[index]->set_base_mod(value); -} - -float Talent::get_talent_stat_attribute_bonus_mod(int index) const { - ERR_FAIL_INDEX_V(index, MAX_RANKS, 0); - - return _ranks[index]->get_bonus_mod(); -} - -void Talent::set_talent_stat_attribute_bonus_mod(int index, float value) { - ERR_FAIL_INDEX(index, MAX_RANKS); - - _ranks[index]->set_bonus_mod(value); -} - -float Talent::get_talent_stat_attribute_percent_mod(int index) const { - ERR_FAIL_INDEX_V(index, MAX_RANKS, 0); - - return _ranks[index]->get_percent_mod(); -} - -void Talent::set_talent_stat_attribute_percent_mod(int index, float value) { - ERR_FAIL_INDEX(index, MAX_RANKS); - - _ranks[index]->set_percent_mod(value); -} - -Ref Talent::get_talent_aura(int index) const { - ERR_FAIL_INDEX_V(index, MAX_RANKS, 0); - - return _ranks[index]->get_aura(); -} - -void Talent::set_talent_aura(int index, Ref value) { - ERR_FAIL_INDEX(index, MAX_RANKS); - - _ranks[index]->set_aura(value); -} - -Talent::Talent() -{ - for (int i = 0; i < MAX_RANKS; ++i) - { - _ranks[i] = Ref(memnew(TalentRankData())); - } - - _id = 0; - _talent_name = ""; - _description = ""; - - _max_rank = 0; -} - -Talent::~Talent() -{ -} - -void Talent::_validate_property(PropertyInfo &property) const { - - String prop = property.name; - if (prop.begins_with("TalentRank_")) { - int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int(); - if (frame >= _max_rank) { - property.usage = 0; - } - } -} - - void Talent::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_id"), &Talent::get_id); - ClassDB::bind_method(D_METHOD("set_id", "value"), &Talent::set_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); + ClassDB::bind_method(D_METHOD("get_next_rank"), &Talent::get_next_rank); + ClassDB::bind_method(D_METHOD("set_next_rank", "next_rank"), &Talent::set_next_rank); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_rank", PROPERTY_HINT_RESOURCE_TYPE, "Talent"), "set_next_rank", "get_next_rank"); - ClassDB::bind_method(D_METHOD("get_talent_name"), &Talent::get_talent_name); - ClassDB::bind_method(D_METHOD("set_talent_name", "value"), &Talent::set_talent_name); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "talent_name"), "set_talent_name", "get_talent_name"); - - ClassDB::bind_method(D_METHOD("get_description"), &Talent::get_description); - ClassDB::bind_method(D_METHOD("set_description", "value"), &Talent::set_description); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "description"), "set_description", "get_description"); - - //// Ranks //// - ADD_GROUP("Rank", "rank"); - ClassDB::bind_method(D_METHOD("get_max_rank"), &Talent::get_max_rank); - ClassDB::bind_method(D_METHOD("set_max_rank", "value"), &Talent::set_max_rank); - - ClassDB::bind_method(D_METHOD("get_talent_stat_attribute_stat", "index"), &Talent::get_talent_stat_attribute_stat); - ClassDB::bind_method(D_METHOD("set_talent_stat_attribute_stat", "index", "value"), &Talent::set_talent_stat_attribute_stat); - - ClassDB::bind_method(D_METHOD("get_talent_stat_attribute_base_mod", "index"), &Talent::get_talent_stat_attribute_base_mod); - ClassDB::bind_method(D_METHOD("set_talent_stat_attribute_base_mod", "index", "value"), &Talent::set_talent_stat_attribute_base_mod); - - ClassDB::bind_method(D_METHOD("get_talent_stat_attribute_bonus_mod", "index"), &Talent::get_talent_stat_attribute_bonus_mod); - ClassDB::bind_method(D_METHOD("set_talent_stat_attribute_bonus_mod", "index", "value"), &Talent::set_talent_stat_attribute_bonus_mod); - - ClassDB::bind_method(D_METHOD("get_talent_stat_attribute_percent_mod", "index"), &Talent::get_talent_stat_attribute_percent_mod); - ClassDB::bind_method(D_METHOD("set_talent_stat_attribute_percent_mod", "index", "value"), &Talent::set_talent_stat_attribute_percent_mod); - - ClassDB::bind_method(D_METHOD("get_talent_aura", "index"), &Talent::get_talent_aura); - ClassDB::bind_method(D_METHOD("set_talent_aura", "index", "value"), &Talent::set_talent_aura); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "max_rank", PROPERTY_HINT_RANGE, "0," + itos(MAX_RANKS), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_max_rank", "get_max_rank"); - - for (int i = 0; i < MAX_RANKS; ++i) { - ADD_PROPERTYI(PropertyInfo(Variant::INT, "TalentRank_" + itos(i) + "/stat", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_stat_attribute_stat", "get_talent_stat_attribute_stat", i); - - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "TalentRank_" + itos(i) + "/base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_stat_attribute_base_mod", "get_talent_stat_attribute_base_mod", i); - - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "TalentRank_" + itos(i) + "/bonus_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_stat_attribute_bonus_mod", "get_talent_stat_attribute_bonus_mod", i); - - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "TalentRank_" + itos(i) + "/percent_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_stat_attribute_percent_mod", "get_talent_stat_attribute_percent_mod", i); - - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "TalentRank_" + itos(i) + "/aura", PROPERTY_HINT_RESOURCE_TYPE, "Aura", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_aura", "get_talent_aura", i); - } - - ClassDB::bind_method(D_METHOD("get_rank_data", "index"), &Talent::get_rank_data); - - BIND_CONSTANT(MAX_RANKS); + ClassDB::bind_method(D_METHOD("get_apply_aura"), &Talent::get_apply_aura); + ClassDB::bind_method(D_METHOD("set_apply_aura", "value"), &Talent::set_apply_aura); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "apply_aura", PROPERTY_HINT_RESOURCE_TYPE, "Aura"), "set_apply_aura", "get_apply_aura"); } diff --git a/data/talent.h b/data/talent.h index 73aef4d..75978fa 100644 --- a/data/talent.h +++ b/data/talent.h @@ -4,64 +4,28 @@ #include "core/resource.h" #include "core/ustring.h" -#include "../entities/stats/stat.h" #include "aura.h" -#include "talent_rank_data.h" -class TalentRankData; -class Aura; - -class Talent : public Resource { - GDCLASS(Talent, Resource); +class Talent : public Aura { + GDCLASS(Talent, Aura); public: - int get_id(); - void set_id(int value); + Ref get_next_rank() const; + void set_next_rank(const Ref rank); - String get_talent_name(); - void set_talent_name(String value); - - String get_description(); - void set_description(String value); - - Ref get_rank_data(int index); - - int get_max_rank(); - void set_max_rank(int value); - - Stat::StatId get_talent_stat_attribute_stat(int index) const; - void set_talent_stat_attribute_stat(int index, const Stat::StatId value); - - float get_talent_stat_attribute_base_mod(int index) const; - void set_talent_stat_attribute_base_mod(int index, float value); - - float get_talent_stat_attribute_bonus_mod(int index) const; - void set_talent_stat_attribute_bonus_mod(int index, float value); - - float get_talent_stat_attribute_percent_mod(int index) const; - void set_talent_stat_attribute_percent_mod(int index, float value); - - Ref get_talent_aura(int index) const; - void set_talent_aura(int index, Ref value); + Ref get_apply_aura() const { return _aura; } + void set_apply_aura(Ref aura) { _aura = Ref(aura); } Talent(); ~Talent(); protected: static void _bind_methods(); - void _validate_property(PropertyInfo &property) const; private: - enum { - MAX_RANKS = 5, - }; + Ref _next_rank; - int _id; - String _talent_name; - String _description; - - int _max_rank; - Ref _ranks[MAX_RANKS]; + Ref _aura; }; #endif diff --git a/data/talent_rank_data.cpp b/data/talent_rank_data.cpp deleted file mode 100644 index 95d613e..0000000 --- a/data/talent_rank_data.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "talent_rank_data.h" diff --git a/data/talent_rank_data.h b/data/talent_rank_data.h deleted file mode 100644 index 24013a1..0000000 --- a/data/talent_rank_data.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef TALENT_RANK_DATA_H -#define TALENT_RANK_DATA_H - -#include "core/ustring.h" -#include "core/reference.h" - -#include "../entities/stats/stat.h" -#include "aura.h" - -class Aura; - -class TalentRankData : public Reference -{ - GDCLASS(TalentRankData, Reference); - -public: - Stat::StatId get_stat() const { return _stat; } - void set_stat(Stat::StatId value) { _stat = value; } - - float get_base_mod() const { return _base_mod; } - void set_base_mod(float value) { _base_mod = value; } - - float get_bonus_mod() const { return _bonus_mod; } - void set_bonus_mod(float value) { _bonus_mod = value; } - - float get_percent_mod() const { return _percent_mod; } - void set_percent_mod(float value) { _percent_mod = value; } - - Ref get_aura() const { return _aura; } - void set_aura (Ref aura) { _aura = Ref(aura); } - - TalentRankData() { - _stat = Stat::STAT_ID_NONE; - _base_mod = 0; - _bonus_mod = 0; - _percent_mod = 0; - } - - ~TalentRankData() { - } - -protected: - static void _bind_methods() { - ClassDB::bind_method(D_METHOD("get_stat"), &TalentRankData::get_stat); - ClassDB::bind_method(D_METHOD("set_stat", "value"), &TalentRankData::set_stat); - ADD_PROPERTY(PropertyInfo(Variant::INT, "stat", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING), "set_stat", "get_stat"); - - ClassDB::bind_method(D_METHOD("get_base_mod"), &TalentRankData::get_base_mod); - ClassDB::bind_method(D_METHOD("set_base_mod", "value"), &TalentRankData::set_base_mod); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_mod"), "set_base_mod", "get_base_mod"); - - ClassDB::bind_method(D_METHOD("get_bonus_mod"), &TalentRankData::get_bonus_mod); - ClassDB::bind_method(D_METHOD("set_bonus_mod", "value"), &TalentRankData::set_bonus_mod); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus_mod"), "set_bonus_mod", "get_bonus_mod"); - - ClassDB::bind_method(D_METHOD("get_percent_mod"), &TalentRankData::get_percent_mod); - ClassDB::bind_method(D_METHOD("set_percent_mod", "value"), &TalentRankData::set_percent_mod); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_mod"), "set_percent_mod", "get_percent_mod"); - - ClassDB::bind_method(D_METHOD("get_aura"), &TalentRankData::get_aura); - ClassDB::bind_method(D_METHOD("set_aura", "value"), &TalentRankData::set_aura); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "aura", PROPERTY_HINT_RESOURCE_TYPE, "Aura"), "set_aura", "get_aura"); - } - -private: - Stat::StatId _stat; - float _base_mod; - float _bonus_mod; - float _percent_mod; - Ref_aura; - -}; - -#endif diff --git a/data/talent_row_data.cpp b/data/talent_row_data.cpp index b579703..7b617f4 100644 --- a/data/talent_row_data.cpp +++ b/data/talent_row_data.cpp @@ -1,74 +1,32 @@ #include "talent_row_data.h" Ref TalentRowData::get_talent(int index) const { + ERR_FAIL_INDEX_V(index, MAX_TALENTS_IN_ROW, Ref(NULL)); + return _talents[index]; } void TalentRowData::set_talent(int index, Ref talent) { + ERR_FAIL_INDEX(index, MAX_TALENTS_IN_ROW); + _talents[index] = Ref(talent); } -Ref TalentRowData::get_talent0() const { - return _talents[0]; +TalentRowData::TalentRowData() { } - -void TalentRowData::set_talent0(Ref talent) { - _talents[0] = Ref(talent); -} - -Ref TalentRowData::get_talent1() const { - return _talents[1]; -} - -void TalentRowData::set_talent1(Ref talent) { - _talents[1] = Ref(talent); -} - -Ref TalentRowData::get_talent2() const { - return _talents[2]; -} - -void TalentRowData::set_talent2(Ref talent) { - _talents[2] = Ref(talent); -} - -Ref TalentRowData::get_talent3() const { - return _talents[3]; -} - -void TalentRowData::set_talent3(Ref talent) { - _talents[3] = Ref(talent); -} - -Ref TalentRowData::get_talent4() const { - return _talents[4]; -} - -void TalentRowData::set_talent4(Ref talent) { - _talents[4] = Ref(talent); +TalentRowData::~TalentRowData() { + for (int i = 0; i < MAX_TALENTS_IN_ROW; ++i) { + _talents[i].unref(); + } } void TalentRowData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_talent", "index"), &TalentRowData::get_talent); ClassDB::bind_method(D_METHOD("set_talent", "index", "value"), &TalentRowData::set_talent); - ClassDB::bind_method(D_METHOD("get_talent0"), &TalentRowData::get_talent0); - ClassDB::bind_method(D_METHOD("set_talent0", "value"), &TalentRowData::set_talent0); + for (int i = 0; i < MAX_TALENTS_IN_ROW; ++i) { + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Talent_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent", "get_talent", i); + } - ClassDB::bind_method(D_METHOD("get_talent1"), &TalentRowData::get_talent1); - ClassDB::bind_method(D_METHOD("set_talent1", "value"), &TalentRowData::set_talent1); - - ClassDB::bind_method(D_METHOD("get_talent2"), &TalentRowData::get_talent2); - ClassDB::bind_method(D_METHOD("set_talent2", "value"), &TalentRowData::set_talent2); - - ClassDB::bind_method(D_METHOD("get_talent3"), &TalentRowData::get_talent3); - ClassDB::bind_method(D_METHOD("set_talent3", "value"), &TalentRowData::set_talent3); - - ClassDB::bind_method(D_METHOD("get_talent4"), &TalentRowData::get_talent4); - ClassDB::bind_method(D_METHOD("set_talent4", "value"), &TalentRowData::set_talent4); - - - //for (int i = 0; i < MAX_TALENTS_IN_ROW; i++) { - // ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i) + "/talent" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Talent", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent", "get_talent", i); - //} + BIND_CONSTANT(MAX_TALENTS_IN_ROW); } diff --git a/data/talent_row_data.h b/data/talent_row_data.h index e9532ee..6b64722 100644 --- a/data/talent_row_data.h +++ b/data/talent_row_data.h @@ -8,42 +8,25 @@ class Talent; -class TalentRowData : public Reference { - GDCLASS(TalentRowData, Reference); +class TalentRowData : public Resource { + GDCLASS(TalentRowData, Resource); public: Ref get_talent(int index) const; void set_talent(int index, Ref talent); - Ref get_talent0() const; - void set_talent0(Ref talent); + TalentRowData(); + ~TalentRowData(); - Ref get_talent1() const; - void set_talent1(Ref talent); - - Ref get_talent2() const; - void set_talent2(Ref talent); - - Ref get_talent3() const; - void set_talent3(Ref talent); - - Ref get_talent4() const; - void set_talent4(Ref talent); - - TalentRowData() { - for (int i = 0; i < MAX_TALENTS_IN_ROW; ++i) { - _talents[i] = Ref(NULL); - } - } +public: + enum { + MAX_TALENTS_IN_ROW = 5, + }; protected: static void _bind_methods(); private: - enum { - MAX_TALENTS_IN_ROW = 5, - }; - Ref _talents[MAX_TALENTS_IN_ROW]; }; diff --git a/entities/entity.cpp b/entities/entity.cpp index cff0616..930c68d 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -3,6 +3,7 @@ #include "../data/aura.h" #include "../data/spell.h" #include "../entities/auras/aura_data.h" +#include "../infos/spell_cast_info.h" #include "../pipelines/spell_damage_info.h" #include "../pipelines/spell_heal_info.h" @@ -160,6 +161,7 @@ void Entity::sets_character_class(Ref value) { _s_character_class = value; if (value.is_valid()) { + value->setup_resources(this); sinitialize_stats(); sets_character_class_id(value->get_id()); } @@ -217,7 +219,7 @@ Entity::Entity() { _s_active_category_cooldowns = 0; _c_active_category_cooldowns = 0; - + _s_entity_type = EntityEnums::EntityType::ENITIY_TYPE_NONE; _c_entity_type = EntityEnums::EntityType::ENITIY_TYPE_NONE; @@ -225,7 +227,12 @@ Entity::Entity() { _c_target = NULL; for (int i = 0; i < Stat::STAT_ID_TOTAL_STATS; ++i) { - _stats[i] = Ref(memnew(Stat(static_cast(i)))); + Ref s = Ref(memnew(Stat(static_cast(i)))); + + s->connect("s_changed", this, "ons_stat_changed"); + s->connect("c_changed", this, "onc_stat_changed"); + + _stats[i] = s; } get_stat_enum(Stat::STAT_ID_HEALTH)->set_base(10000); @@ -407,7 +414,6 @@ void Entity::sinitialize_stats() { cc->get_stat_data()->get_stat_for_stat(get_melee_damage()); cc->get_stat_data()->get_stat_for_stat(get_spell_damage()); - for (int i = 0; i < CharacterClass::MAX_AURAS; ++i) { Ref a = cc->get_aura(i); @@ -445,11 +451,11 @@ bool Entity::gets_global_cooldown() { void Entity::sstart_global_cooldown(float value) { _s_gcd = value; - + void son_gcd_started(); - + emit_signal("sgcd_started", _s_gcd); - + SEND_RPC(rpc("cstart_global_cooldown", value), cstart_global_cooldown(value)); } @@ -457,7 +463,7 @@ void Entity::cstart_global_cooldown(float value) { _c_gcd = value; void con_gcd_started(); - + emit_signal("cgcd_started", _c_gcd); } @@ -532,11 +538,10 @@ void Entity::set_stat_enum(Stat::StatId stat_id, Ref entry) { _stats[stat_id] = Ref(entry); } - void Entity::sdie() { //serverside - son_death(); + son_death(); //send an event to client SEND_RPC(rpc("cdie"), cdie()); @@ -547,8 +552,19 @@ void Entity::sdie() { void Entity::cdie() { con_death(); - - emit_signal("cdied", this); + + emit_signal("cdied", this); +} + +void Entity::ons_stat_changed(Ref stat) { + for (int i = 0; i < _s_resources.size(); ++i) { + _s_resources.get(i)->ons_stat_changed(stat); + } +} +void Entity::onc_stat_changed(Ref stat) { + for (int i = 0; i < _c_resources.size(); ++i) { + _c_resources.get(i)->onc_stat_changed(stat); + } } //// Resources //// @@ -558,10 +574,25 @@ Ref Entity::gets_resource(int index) { return _s_resources.get(index); } +Ref Entity::gets_resource_type(int type) { + for (int i = 0; i < _s_resources.size(); ++i) { + Ref r = _s_resources.get(i); + + if (r->get_resource_type() == type) { + return r; + } + } + + return Ref(NULL); +} void Entity::adds_resource(Ref resource) { ERR_FAIL_COND(!resource.is_valid()); + resource->ons_added(this); _s_resources.push_back(resource); + + //temporary + addc_resource(resource); } int Entity::gets_resource_count() { return _s_resources.size(); @@ -572,14 +603,31 @@ void Entity::removes_resource(int index) { _s_resources.remove(index); } +void Entity::clears_resource() { + _s_resources.clear(); +} + Ref Entity::getc_resource(int index) { ERR_FAIL_INDEX_V(index, _c_resources.size(), Ref()); return _c_resources.get(index); } +Ref Entity::getc_resource_type(int type) { + for (int i = 0; i < _c_resources.size(); ++i) { + Ref r = _c_resources.get(i); + + if (r->get_resource_type() == type) { + return r; + } + } + + return Ref(NULL); +} void Entity::addc_resource(Ref resource) { ERR_FAIL_COND(!resource.is_valid()); + resource->onc_added(this); + _c_resources.push_back(resource); } int Entity::getc_resource_count() { @@ -590,6 +638,9 @@ void Entity::removec_resource(int index) { _c_resources.remove(index); } +void Entity::clearc_resource() { + _s_resources.clear(); +} void Entity::stake_damage(Ref info) { ERR_FAIL_COND(!info.is_valid()); @@ -615,12 +666,12 @@ void Entity::stake_damage(Ref info) { } get_health()->sets_current(h); - + son_damage_dealt(info); - + //signal emit_signal("son_damage_received", this, info); - + //send an event to client SEND_RPC(rpc("con_damage_dealt", info), con_damage_dealt(info)); @@ -641,7 +692,7 @@ void Entity::sdeal_damage_to(Ref info) { sapply_passives_damage_deal(info); info->get_receiver()->stake_damage(info); son_dealt_damage(info); - + //send an event to client SEND_RPC(rpc("con_dealt_damage", info), con_dealt_damage(info)); @@ -737,13 +788,13 @@ void Entity::creceive_mana_changed(int amount) { void Entity::son_before_aura_applied(Ref data) { ERR_FAIL_COND(!data.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_after_aura_applied(data); - } - - if (has_method("_son_before_aura_applied")) + if (_s_character_class.is_valid()) { + _s_character_class->son_after_aura_applied(data); + } + + if (has_method("_son_before_aura_applied")) call("_son_before_aura_applied", data); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -754,13 +805,13 @@ void Entity::son_before_aura_applied(Ref data) { void Entity::son_after_aura_applied(Ref data) { ERR_FAIL_COND(!data.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_after_aura_applied(data); - } - - if (has_method("_son_after_aura_applied")) + if (_s_character_class.is_valid()) { + _s_character_class->son_after_aura_applied(data); + } + + if (has_method("_son_after_aura_applied")) call("_son_after_aura_applied", data); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -797,12 +848,12 @@ void Entity::update_auras(float delta) { void Entity::son_before_cast(Ref info) { ERR_FAIL_COND(!info.is_valid()); - - if (_s_character_class.is_valid()) { - _s_character_class->son_before_cast(info); - } - - if (has_method("_son_before_cast")) + + if (_s_character_class.is_valid()) { + _s_character_class->son_before_cast(info); + } + + if (has_method("_son_before_cast")) call("_son_before_cast", info); for (int i = 0; i < _s_auras.size(); ++i) { @@ -815,13 +866,13 @@ void Entity::son_before_cast(Ref info) { void Entity::son_before_cast_target(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_after_aura_applied(info); - } - - if (has_method("_son_before_cast_target")) + if (_s_character_class.is_valid()) { + _s_character_class->son_after_aura_applied(info); + } + + if (has_method("_son_before_cast_target")) call("_son_before_cast_target", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -831,14 +882,14 @@ void Entity::son_before_cast_target(Ref info) { void Entity::son_hit(Ref info) { ERR_FAIL_COND(!info.is_valid()); - - if (_s_character_class.is_valid()) { - _s_character_class->son_hit(info); - } - - if (has_method("_son_hit")) + + if (_s_character_class.is_valid()) { + _s_character_class->son_hit(info); + } + + if (has_method("_son_hit")) call("_son_hit", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -849,13 +900,13 @@ void Entity::son_hit(Ref info) { void Entity::son_before_damage(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_before_damage(info); - } - - if (has_method("_son_before_damage")) + if (_s_character_class.is_valid()) { + _s_character_class->son_before_damage(info); + } + + if (has_method("_son_before_damage")) call("_son_before_damage", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -866,13 +917,13 @@ void Entity::son_before_damage(Ref info) { void Entity::son_damage_receive(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_damage_receive(info); - } - - if (has_method("_son_damage_receive")) + if (_s_character_class.is_valid()) { + _s_character_class->son_damage_receive(info); + } + + if (has_method("_son_damage_receive")) call("_son_damage_receive", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -883,13 +934,13 @@ void Entity::son_damage_receive(Ref info) { void Entity::son_dealt_damage(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_dealt_damage(info); - } - - if (has_method("_son_dealt_damage")) + if (_s_character_class.is_valid()) { + _s_character_class->son_dealt_damage(info); + } + + if (has_method("_son_dealt_damage")) call("_son_dealt_damage", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -900,13 +951,13 @@ void Entity::son_dealt_damage(Ref info) { void Entity::son_damage_dealt(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_damage_dealt(info); - } - - if (has_method("_son_damage_dealt")) + if (_s_character_class.is_valid()) { + _s_character_class->son_damage_dealt(info); + } + + if (has_method("_son_damage_dealt")) call("_son_damage_dealt", info); - + //serverside for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -918,13 +969,13 @@ void Entity::son_damage_dealt(Ref info) { void Entity::son_before_heal(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_before_heal(info); - } - - if (has_method("_son_before_heal")) + if (_s_character_class.is_valid()) { + _s_character_class->son_before_heal(info); + } + + if (has_method("_son_before_heal")) call("_son_before_heal", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -935,13 +986,13 @@ void Entity::son_before_heal(Ref info) { void Entity::son_heal_receive(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_heal_receive(info); - } - - if (has_method("_son_heal_receive")) + if (_s_character_class.is_valid()) { + _s_character_class->son_heal_receive(info); + } + + if (has_method("_son_heal_receive")) call("_son_heal_receive", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -952,13 +1003,13 @@ void Entity::son_heal_receive(Ref info) { void Entity::son_dealt_heal(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_dealt_heal(info); - } - - if (has_method("_son_dealt_heal")) + if (_s_character_class.is_valid()) { + _s_character_class->son_dealt_heal(info); + } + + if (has_method("_son_dealt_heal")) call("_son_dealt_heal", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -969,13 +1020,13 @@ void Entity::son_dealt_heal(Ref info) { void Entity::son_heal_dealt(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_heal_dealt(info); - } - - if (has_method("_son_heal_dealt")) + if (_s_character_class.is_valid()) { + _s_character_class->son_heal_dealt(info); + } + + if (has_method("_son_heal_dealt")) call("_son_heal_dealt", info); - + //serverside for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1026,14 +1077,14 @@ void Entity::sapply_passives_heal_deal(Ref info) { void Entity::son_cast_finished(Ref info) { ERR_FAIL_COND(!info.is_valid()); - - if (_s_character_class.is_valid()) { - _s_character_class->son_cast_finished(info); - } - - if (has_method("_son_cast_finished")) + + if (_s_character_class.is_valid()) { + _s_character_class->son_cast_finished(info); + } + + if (has_method("_son_cast_finished")) call("_son_cast_finished", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1044,13 +1095,13 @@ void Entity::son_cast_finished(Ref info) { void Entity::son_cast_started(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_cast_started(info); - } - - if (has_method("_son_cast_started")) + if (_s_character_class.is_valid()) { + _s_character_class->son_cast_started(info); + } + + if (has_method("_son_cast_started")) call("_son_cast_started", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1061,13 +1112,13 @@ void Entity::son_cast_started(Ref info) { void Entity::son_cast_failed(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_cast_failed(info); - } - - if (has_method("_son_cast_failed")) + if (_s_character_class.is_valid()) { + _s_character_class->son_cast_failed(info); + } + + if (has_method("_son_cast_failed")) call("_son_cast_failed", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1078,13 +1129,13 @@ void Entity::son_cast_failed(Ref info) { void Entity::son_cast_finished_target(Ref info) { ERR_FAIL_COND(!info.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_cast_finished_target(info); - } - - if (has_method("_son_cast_finished_target")) + if (_s_character_class.is_valid()) { + _s_character_class->son_cast_finished_target(info); + } + + if (has_method("_son_cast_finished_target")) call("_son_cast_finished_target", info); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1093,16 +1144,16 @@ void Entity::son_cast_finished_target(Ref info) { } void Entity::son_death() { - if (_s_character_class.is_valid()) { - _s_character_class->son_death(this); - } - + if (_s_character_class.is_valid()) { + _s_character_class->son_death(this); + } + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); ad->get_aura()->son_death(ad); } - + if (has_method("_son_death")) call("_son_death"); } @@ -1110,13 +1161,13 @@ void Entity::son_death() { void Entity::son_cooldown_added(Ref cooldown) { ERR_FAIL_COND(!cooldown.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_cooldown_added(cooldown); - } - - if (has_method("_son_cooldown_added")) + if (_s_character_class.is_valid()) { + _s_character_class->son_cooldown_added(cooldown); + } + + if (has_method("_son_cooldown_added")) call("_son_cooldown_added", cooldown); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1126,30 +1177,30 @@ void Entity::son_cooldown_added(Ref cooldown) { void Entity::son_cooldown_removed(Ref cooldown) { ERR_FAIL_COND(!cooldown.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_cooldown_removed(cooldown); - } - - if (has_method("_son_cooldown_removed")) + if (_s_character_class.is_valid()) { + _s_character_class->son_cooldown_removed(cooldown); + } + + if (has_method("_son_cooldown_removed")) call("_son_cooldown_removed", cooldown); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); ad->get_aura()->son_cooldown_removed(ad, cooldown); } } - + void Entity::son_category_cooldown_added(Ref category_cooldown) { ERR_FAIL_COND(!category_cooldown.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_category_cooldown_added(category_cooldown); - } - - if (has_method("_son_category_cooldown_added")) + if (_s_character_class.is_valid()) { + _s_character_class->son_category_cooldown_added(category_cooldown); + } + + if (has_method("_son_category_cooldown_added")) call("_son_category_cooldown_added", category_cooldown); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1159,13 +1210,13 @@ void Entity::son_category_cooldown_added(Ref category_cooldown void Entity::son_category_cooldown_removed(Ref category_cooldown) { ERR_FAIL_COND(!category_cooldown.is_valid()); - if (_s_character_class.is_valid()) { - _s_character_class->son_category_cooldown_removed(category_cooldown); - } - - if (has_method("_son_category_cooldown_removed")) + if (_s_character_class.is_valid()) { + _s_character_class->son_category_cooldown_removed(category_cooldown); + } + + if (has_method("_son_category_cooldown_removed")) call("_son_category_cooldown_removed", category_cooldown); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1174,13 +1225,13 @@ void Entity::son_category_cooldown_removed(Ref category_cooldo } void Entity::son_gcd_started() { - if (_s_character_class.is_valid()) { - _s_character_class->son_gcd_started(this, _s_gcd); - } - - if (has_method("_son_gcd_started")) + if (_s_character_class.is_valid()) { + _s_character_class->son_gcd_started(this, _s_gcd); + } + + if (has_method("_son_gcd_started")) call("_son_gcd_started", _s_gcd); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1189,12 +1240,12 @@ void Entity::son_gcd_started() { } void Entity::son_gcd_finished() { if (_s_character_class.is_valid()) { - _s_character_class->son_gcd_finished(this); - } - - if (has_method("_son_gcd_finished")) + _s_character_class->son_gcd_finished(this); + } + + if (has_method("_son_gcd_finished")) call("_son_gcd_finished"); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1203,12 +1254,12 @@ void Entity::son_gcd_finished() { } void Entity::con_gcd_started() { if (_s_character_class.is_valid()) { - _s_character_class->con_gcd_started(this, _c_gcd); - } - - if (has_method("_con_gcd_started")) + _s_character_class->con_gcd_started(this, _c_gcd); + } + + if (has_method("_con_gcd_started")) call("_con_gcd_started", _c_gcd); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1217,12 +1268,12 @@ void Entity::con_gcd_started() { } void Entity::con_gcd_finished() { if (_s_character_class.is_valid()) { - _s_character_class->con_gcd_finished(this); - } - - if (has_method("_con_gcd_finished")) + _s_character_class->con_gcd_finished(this); + } + + if (has_method("_con_gcd_finished")) call("_con_gcd_finished"); - + for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -1374,15 +1425,15 @@ void Entity::cremove_aura(Ref aura) { } if (removed) { - if (_s_character_class.is_valid()) { - _s_character_class->con_aura_removed(aura); - } - - if (has_method("_con_aura_removed")) - call("_con_aura_removed", aura); - - emit_signal("caura_removed", a); - } + if (_s_character_class.is_valid()) { + _s_character_class->con_aura_removed(aura); + } + + if (has_method("_con_aura_removed")) + call("_con_aura_removed", aura); + + emit_signal("caura_removed", a); + } } void Entity::cremove_aura_exact(Ref aura) { @@ -1394,14 +1445,13 @@ void Entity::cremove_aura_exact(Ref aura) { break; } } - + if (_s_character_class.is_valid()) { - _s_character_class->con_aura_removed(aura); - } - - if (has_method("_con_aura_removed")) + _s_character_class->con_aura_removed(aura); + } + + if (has_method("_con_aura_removed")) call("_con_aura_removed", aura); - emit_signal("caura_removed", aura); } @@ -1417,13 +1467,12 @@ void Entity::cremove_aura_dispelled(Ref aura) { } if (_s_character_class.is_valid()) { - _s_character_class->con_aura_removed(aura); - } - - if (has_method("_con_aura_removed")) + _s_character_class->con_aura_removed(aura); + } + + if (has_method("_con_aura_removed")) call("_con_aura_removed", aura); - - + emit_signal("caura_removed_dispelled", aura); } @@ -1431,9 +1480,8 @@ void Entity::caura_refreshed(Ref aura) { ERR_EXPLAIN("NYI"); ERR_FAIL(); - ERR_FAIL_COND(!aura.is_valid()); - + emit_signal("caura_refreshed", aura); } @@ -1446,12 +1494,12 @@ void Entity::cremove_aura_expired(Ref aura) { break; } } - + if (_s_character_class.is_valid()) { - _s_character_class->con_aura_removed(aura); - } - - if (has_method("_con_aura_removed")) + _s_character_class->con_aura_removed(aura); + } + + if (has_method("_con_aura_removed")) call("_con_aura_removed", aura); emit_signal("caura_removed_expired", aura); @@ -1470,12 +1518,12 @@ Ref Entity::sget_aura(int index) { Ref Entity::sget_aura_by(Entity *caster, int aura_id) { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); - + if (ad->get_aura_id() == aura_id && ad->get_caster() == caster) { return ad; } } - + return Ref(NULL); } Ref Entity::sget_aura_by_bind(Node *caster, int aura_id) { @@ -1503,222 +1551,222 @@ Ref Entity::cget_aura(int index) { } void Entity::moved() { - if (has_method("_moved")) + if (has_method("_moved")) call("_moved"); } void Entity::con_cast_failed(Ref info) { ERR_FAIL_COND(!info.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_cast_failed(info); - } - + _c_character_class->con_cast_failed(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_cast_failed(ad, info); } - + if (has_method("_con_cast_failed")) call("_con_cast_failed"); } void Entity::con_cast_started(Ref info) { ERR_FAIL_COND(!info.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_cast_started(info); - } - + _c_character_class->con_cast_started(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_cast_started(ad, info); } - + if (has_method("_con_cast_started")) call("_con_cast_started"); } void Entity::con_cast_state_changed(Ref info) { ERR_FAIL_COND(!info.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_cast_state_changed(info); - } - + _c_character_class->con_cast_state_changed(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_cast_state_changed(ad, info); } - + if (has_method("_con_cast_state_changed")) call("_con_cast_state_changed"); } void Entity::con_cast_finished(Ref info) { ERR_FAIL_COND(!info.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_cast_finished(info); - } - + _c_character_class->con_cast_finished(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_cast_finished(ad, info); } - + if (has_method("_con_cast_finished")) call("_con_cast_finished"); } void Entity::con_spell_cast_success(Ref info) { ERR_FAIL_COND(!info.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_spell_cast_success(info); - } - + _c_character_class->con_spell_cast_success(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_spell_cast_success(ad, info); } - + if (has_method("_con_spell_cast_success")) call("_con_spell_cast_success"); } void Entity::con_death() { - if (_c_character_class.is_valid()) { - _c_character_class->con_death(this); - } - + if (_c_character_class.is_valid()) { + _c_character_class->con_death(this); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_death(ad); } - + if (has_method("_con_death")) call("_con_death"); } void Entity::con_cooldown_added(Ref cooldown) { ERR_FAIL_COND(!cooldown.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_cooldown_added(cooldown); - } - + _c_character_class->con_cooldown_added(cooldown); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_cooldown_added(ad, cooldown); } - + if (has_method("_con_cooldown_added")) call("_con_cooldown_added"); } void Entity::con_cooldown_removed(Ref cooldown) { ERR_FAIL_COND(!cooldown.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_cooldown_removed(cooldown); - } - + _c_character_class->con_cooldown_removed(cooldown); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_cooldown_removed(ad, cooldown); } - + if (has_method("_con_cooldown_removed")) call("_con_cooldown_removed"); } void Entity::con_category_cooldown_added(Ref category_cooldown) { ERR_FAIL_COND(!category_cooldown.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_category_cooldown_added(category_cooldown); - } - + _c_character_class->con_category_cooldown_added(category_cooldown); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_category_cooldown_added(ad, category_cooldown); } - + if (has_method("_con_category_cooldown_added")) call("_con_category_cooldown_added"); } void Entity::con_category_cooldown_removed(Ref category_cooldown) { ERR_FAIL_COND(!category_cooldown.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_category_cooldown_removed(category_cooldown); - } - + _c_character_class->con_category_cooldown_removed(category_cooldown); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_category_cooldown_removed(ad, category_cooldown); } - + if (has_method("_con_category_cooldown_removed")) call("_con_category_cooldown_removed"); } void Entity::con_aura_added(Ref data) { ERR_FAIL_COND(!data.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_aura_added(data); - } - + _c_character_class->con_aura_added(data); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_aura_added(data); } - + if (has_method("_con_aura_added")) call("_con_aura_added"); } void Entity::con_aura_removed(Ref data) { ERR_FAIL_COND(!data.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_aura_removed(data); - } - + _c_character_class->con_aura_removed(data); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_aura_removed(data); } - + if (has_method("_con_aura_removed")) call("_con_aura_removed"); } void Entity::con_aura_refresh(Ref data) { ERR_FAIL_COND(!data.is_valid()); - + if (_c_character_class.is_valid()) { - _c_character_class->con_aura_refresh(data); - } - + _c_character_class->con_aura_refresh(data); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_aura_refresh(data); } - + if (has_method("_con_aura_refresh")) call("_con_aura_refresh"); } @@ -1727,15 +1775,15 @@ void Entity::con_damage_dealt(Ref info) { ERR_FAIL_COND(!info.is_valid()); if (_c_character_class.is_valid()) { - _c_character_class->con_damage_dealt(info); - } - + _c_character_class->con_damage_dealt(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_damage_dealt(ad, info); } - + if (has_method("_con_damage_dealt")) call("_con_damage_dealt", info); @@ -1747,15 +1795,15 @@ void Entity::con_dealt_damage(Ref info) { ERR_FAIL_COND(!info.is_valid()); if (_c_character_class.is_valid()) { - _c_character_class->con_dealt_damage(info); - } - + _c_character_class->con_dealt_damage(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_dealt_damage(ad, info); } - + if (has_method("_con_dealt_damage")) call("_con_dealt_damage", info); @@ -1767,15 +1815,15 @@ void Entity::con_heal_dealt(Ref info) { ERR_FAIL_COND(!info.is_valid()); if (_c_character_class.is_valid()) { - _c_character_class->con_heal_dealt(info); - } - + _c_character_class->con_heal_dealt(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_heal_dealt(ad, info); } - + if (has_method("_con_heal_dealt")) call("_con_heal_dealt", info); @@ -1787,15 +1835,15 @@ void Entity::con_dealt_heal(Ref info) { ERR_FAIL_COND(!info.is_valid()); if (_c_character_class.is_valid()) { - _c_character_class->con_dealt_heal(info); - } - + _c_character_class->con_dealt_heal(info); + } + for (int i = 0; i < _c_auras.size(); ++i) { Ref ad = _c_auras.get(i); ad->get_aura()->con_dealt_heal(ad, info); } - + if (has_method("_con_dealt_heal")) call("_con_dealt_heal", info); @@ -1803,7 +1851,6 @@ void Entity::con_dealt_heal(Ref info) { emit_signal("con_dealt_heal", this, info); } - //// Casting System //// void Entity::sstart_casting(Ref info) { @@ -1925,48 +1972,48 @@ void Entity::adds_cooldown(int spell_id, float value) { Ref cd = _s_cooldown_map.get(spell_id); cd->set_remaining(value); - - son_cooldown_added(cd); - + + son_cooldown_added(cd); + emit_signal("scooldown_added", cd); - + SEND_RPC(rpc("addc_cooldown", spell_id, value), addc_cooldown(spell_id, value)); - + return; } Ref cd; cd.instance(); - - cd->set_spell_id(spell_id); - cd->set_remaining(value); + + cd->set_spell_id(spell_id); + cd->set_remaining(value); _s_cooldown_map.set(spell_id, cd); _s_cooldowns.push_back(cd); son_cooldown_added(cd); - + emit_signal("scooldown_added", cd); SEND_RPC(rpc("addc_cooldown", spell_id, value), addc_cooldown(spell_id, value)); } void Entity::removes_cooldown(int spell_id) { Ref cd; - + if (_s_cooldown_map.has(spell_id)) { _s_cooldown_map.erase(spell_id); } - + for (int i = 0; i < _s_cooldowns.size(); ++i) { if (_s_cooldowns.get(i)->get_spell_id() == spell_id) { cd = _s_cooldowns.get(i); - + _s_cooldowns.remove(i); - + break; } } - + son_cooldown_removed(cd); emit_signal("scooldown_removed", cd); @@ -1997,30 +2044,30 @@ void Entity::addc_cooldown(int spell_id, float value) { Ref cd = _c_cooldown_map.get(spell_id); cd->set_remaining(value); - - con_cooldown_added(cd); - + + con_cooldown_added(cd); + emit_signal("ccooldown_added", cd); - + return; } Ref cd; cd.instance(); - cd->set_spell_id(spell_id); - cd->set_remaining(value); - + cd->set_spell_id(spell_id); + cd->set_remaining(value); + _c_cooldown_map.set(spell_id, cd); _c_cooldowns.push_back(cd); - + con_cooldown_added(cd); emit_signal("ccooldown_added", cd); } void Entity::removec_cooldown(int spell_id) { Ref cd; - + if (_c_cooldown_map.has(spell_id)) { _c_cooldown_map.erase(spell_id); } @@ -2032,10 +2079,10 @@ void Entity::removec_cooldown(int spell_id) { break; } } - + if (!cd.is_valid()) - cd.instance(); - + cd.instance(); + con_cooldown_removed(cd); emit_signal("ccooldown_removed", cd); @@ -2075,12 +2122,12 @@ void Entity::adds_category_cooldown(int category_id, float value) { if (cc->get_category_id() == category_id) { cc->set_remaining(value); - son_category_cooldown_added(cc); - + son_category_cooldown_added(cc); + emit_signal("scategory_cooldown_added", cc); - - SEND_RPC(rpc("addc_category_cooldown", category_id, value), addc_category_cooldown(category_id, value)); - + + SEND_RPC(rpc("addc_category_cooldown", category_id, value), addc_category_cooldown(category_id, value)); + return; } } @@ -2088,47 +2135,47 @@ void Entity::adds_category_cooldown(int category_id, float value) { Ref cc; cc.instance(); - + cc->set_category_id(category_id); cc->set_remaining(value); _s_category_cooldowns.push_back(cc); _s_active_category_cooldowns |= category_id; - - son_category_cooldown_added(cc); - emit_signal("scategory_cooldown_added", cc); - + son_category_cooldown_added(cc); + + emit_signal("scategory_cooldown_added", cc); + SEND_RPC(rpc("addc_category_cooldown", category_id, value), addc_category_cooldown(category_id, value)); } void Entity::removes_category_cooldown(int category_id) { - Ref cc; - + Ref cc; + for (int i = 0; i < _s_category_cooldowns.size(); ++i) { if (_s_category_cooldowns.get(i)->get_category_id() == category_id) { - cc = _s_category_cooldowns.get(i); + cc = _s_category_cooldowns.get(i); _s_category_cooldowns.remove(i); break; } } - + if (!cc.is_valid()) - return; - + return; + _s_active_category_cooldowns ^= category_id; - son_category_cooldown_removed(cc); - + son_category_cooldown_removed(cc); + emit_signal("scategory_cooldown_removed", cc); SEND_RPC(rpc("removec_category_cooldown", category_id), removec_category_cooldown(category_id)); } Ref Entity::gets_category_cooldown(int category_id) { ERR_FAIL_COND_V(!(category_id & _s_active_category_cooldowns), Ref()); - + Ref cc; - + for (int i = 0; i < _s_category_cooldowns.size(); ++i) { cc = _s_category_cooldowns.get(i); @@ -2136,7 +2183,7 @@ Ref Entity::gets_category_cooldown(int category_id) { return cc; } } - + return cc; } Ref Entity::gets_category_cooldown_index(int index) { @@ -2158,56 +2205,56 @@ void Entity::addc_category_cooldown(int category_id, float value) { if (cc->get_category_id() == category_id) { cc->set_remaining(value); - - con_category_cooldown_added(cc); - + + con_category_cooldown_added(cc); + emit_signal("ccategory_cooldown_added", cc); return; } } } - + Ref cc; cc.instance(); - + cc->set_category_id(category_id); cc->set_remaining(value); _c_category_cooldowns.push_back(cc); _c_active_category_cooldowns |= category_id; - - con_category_cooldown_added(cc); - + + con_category_cooldown_added(cc); + emit_signal("ccategory_cooldown_added", cc); } void Entity::removec_category_cooldown(int category_id) { - Ref cc; - + Ref cc; + for (int i = 0; i < _c_category_cooldowns.size(); ++i) { if (_c_category_cooldowns.get(i)->get_category_id() == category_id) { - cc = _c_category_cooldowns.get(i); - - _c_category_cooldowns.remove(i); - + cc = _c_category_cooldowns.get(i); + + _c_category_cooldowns.remove(i); + break; } } - + if (!cc.is_valid()) - return; - + return; + _c_active_category_cooldowns ^= category_id; - - con_category_cooldown_removed(cc); + + con_category_cooldown_removed(cc); emit_signal("ccategory_cooldown_removed", cc); } Ref Entity::getc_category_cooldown(int category_id) { ERR_FAIL_COND_V(!(category_id & _c_active_category_cooldowns), Ref()); - + Ref cc; - + for (int i = 0; i < _c_category_cooldowns.size(); ++i) { cc = _c_category_cooldowns.get(i); @@ -2215,7 +2262,7 @@ Ref Entity::getc_category_cooldown(int category_id) { return cc; } } - + return cc; } Ref Entity::getc_category_cooldown_index(int index) { @@ -2227,7 +2274,6 @@ int Entity::getc_category_cooldown_count() { return _c_category_cooldowns.size(); } - //// Casting System //// bool Entity::sis_casting() { @@ -2307,6 +2353,11 @@ Entity *Entity::gets_target() { void Entity::sets_target(Node *p_target) { if (p_target == NULL) { _s_target = NULL; + + for (int i = 0; i < _s_resources.size(); ++i) { + _s_resources.get(i)->ons_target_changed(_s_target); + } + emit_signal("starget_changed", _s_target); setc_target(p_target); return; @@ -2320,6 +2371,10 @@ void Entity::sets_target(Node *p_target) { _s_target = e; + for (int i = 0; i < _s_resources.size(); ++i) { + _s_resources.get(i)->ons_target_changed(_s_target); + } + emit_signal("starget_changed", _s_target); if (is_inside_tree() && !get_tree()->has_network_peer()) { @@ -2334,6 +2389,10 @@ void Entity::setc_target(Node *p_target) { if (p_target == NULL) { _c_target = NULL; + for (int i = 0; i < _c_resources.size(); ++i) { + _c_resources.get(i)->onc_target_changed(_c_target); + } + emit_signal("ctarget_changed", _c_target); return; @@ -2347,6 +2406,10 @@ void Entity::setc_target(Node *p_target) { _c_target = e; + for (int i = 0; i < _c_resources.size(); ++i) { + _c_resources.get(i)->onc_target_changed(_c_target); + } + emit_signal("ctarget_changed", _c_target); } @@ -2388,8 +2451,8 @@ void Entity::creceive_rank(int talentID, int rank) { }*/ } -PlayerTalent *Entity::sget_talent(int id, bool create) { - /* +//PlayerTalent *Entity::sget_talent(int id, bool create) { +/* for (int i = 0; i < sTalents->Count; i += 1) { if (sTalents->GetData(i)->TalentID == id) { return sTalents->GetData(i); @@ -2402,11 +2465,11 @@ PlayerTalent *Entity::sget_talent(int id, bool create) { } return null;*/ - return NULL; -} +// return NULL; +//} -PlayerTalent *Entity::cget_talent(int id, bool create) { - /* +//PlayerTalent *Entity::cget_talent(int id, bool create) { +/* for (int i = 0; i < cTalents->Count; i += 1) { if (cTalents->GetData(i)->TalentID == id) { return cTalents->GetData(i); @@ -2419,8 +2482,8 @@ PlayerTalent *Entity::cget_talent(int id, bool create) { } return null;*/ - return NULL; -} +// return NULL; +//} //// Inventory //// @@ -2455,7 +2518,6 @@ void Entity::setc_target_bag(const Ref bag) { _c_target_bag = bag; } - bool Entity::stry_to_add_item(int itemId, int count) { return false; } @@ -2624,7 +2686,6 @@ void Entity::update(float delta) { if (_s_gcd <= 0) { _s_gcd = 0; - void son_gcd_finished(); emit_signal("sgcd_finished"); @@ -2636,7 +2697,7 @@ void Entity::update(float delta) { if (_c_gcd <= 0) { _c_gcd = 0; - + void con_gcd_finished(); emit_signal("cgcd_finished"); @@ -2646,25 +2707,25 @@ void Entity::update(float delta) { for (int i = 0; i < _c_cooldowns.size(); ++i) { Ref cd = _c_cooldowns.get(i); - cd->update(delta); - -// if (cd->update(delta)) { -// removec_cooldown(cd->get_spell_id()); -// --i; -// } + cd->update(delta); + + // if (cd->update(delta)) { + // removec_cooldown(cd->get_spell_id()); + // --i; + // } } for (int i = 0; i < _c_category_cooldowns.size(); ++i) { Ref cd = _c_category_cooldowns.get(i); - cd->update(delta); - -// if (cd->update(delta)) { -// removec_category_cooldown(cd->get_category_id()); -// --i; -// } + cd->update(delta); + + // if (cd->update(delta)) { + // removec_category_cooldown(cd->get_category_id()); + // --i; + // } } - + for (int i = 0; i < _s_cooldowns.size(); ++i) { Ref cd = _s_cooldowns.get(i); @@ -2685,6 +2746,14 @@ void Entity::update(float delta) { update_auras(delta); + for (int i = 0; i < _s_resources.size(); ++i) { + Ref er = _s_resources.get(i); + + if (er->get_should_process()) { + er->process(delta); + } + } + if (_s_spell_cast_info.is_valid() && _s_spell_cast_info->get_is_casting()) { if (_s_spell_cast_info->update_cast_time(delta)) { sfinish_cast(); @@ -2732,33 +2801,30 @@ void Entity::_notification(int p_what) { } } -void Entity::_bind_methods() { +void Entity::_bind_methods() { //Signals - ADD_SIGNAL(MethodInfo("starget_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - ADD_SIGNAL(MethodInfo("ctarget_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + ADD_SIGNAL(MethodInfo("starget_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + ADD_SIGNAL(MethodInfo("ctarget_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - ADD_SIGNAL(MethodInfo("son_damage_received", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); - ADD_SIGNAL(MethodInfo("con_damage_received", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); + ADD_SIGNAL(MethodInfo("son_damage_received", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); + ADD_SIGNAL(MethodInfo("con_damage_received", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); - ADD_SIGNAL(MethodInfo("con_damage_dealt", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); - ADD_SIGNAL(MethodInfo("con_dealt_damage", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); + ADD_SIGNAL(MethodInfo("con_damage_dealt", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); + ADD_SIGNAL(MethodInfo("con_dealt_damage", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); - ADD_SIGNAL(MethodInfo("son_heal_received", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); - ADD_SIGNAL(MethodInfo("con_heal_received", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); + ADD_SIGNAL(MethodInfo("son_heal_received", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); + ADD_SIGNAL(MethodInfo("con_heal_received", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); - ADD_SIGNAL(MethodInfo("con_dealt_heal", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); - - ADD_SIGNAL(MethodInfo("con_heal_dealt", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); - - - + ADD_SIGNAL(MethodInfo("con_dealt_heal", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); - ADD_SIGNAL(MethodInfo("scharacter_class_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - ADD_SIGNAL(MethodInfo("ccharacter_class_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + ADD_SIGNAL(MethodInfo("con_heal_dealt", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); + + ADD_SIGNAL(MethodInfo("scharacter_class_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + ADD_SIGNAL(MethodInfo("ccharacter_class_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + + ADD_SIGNAL(MethodInfo("sdied", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + ADD_SIGNAL(MethodInfo("cdied", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - ADD_SIGNAL(MethodInfo("sdied", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - ADD_SIGNAL(MethodInfo("cdied", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - //SpellCastSignals ADD_SIGNAL(MethodInfo("scast_started", PropertyInfo(Variant::OBJECT, "spell_cast_info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); ADD_SIGNAL(MethodInfo("scast_failed", PropertyInfo(Variant::OBJECT, "spell_cast_info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -2784,9 +2850,12 @@ void Entity::_bind_methods() { ADD_SIGNAL(MethodInfo("caura_removed_dispelled", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); ADD_SIGNAL(MethodInfo("caura_removed_expired", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); //ADD_SIGNAL(MethodInfo("caura_refreshed", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); - - ClassDB::bind_method(D_METHOD("sdie"), &Entity::sdie); - ClassDB::bind_method(D_METHOD("cdie"), &Entity::cdie); + + ClassDB::bind_method(D_METHOD("sdie"), &Entity::sdie); + ClassDB::bind_method(D_METHOD("cdie"), &Entity::cdie); + + ClassDB::bind_method(D_METHOD("ons_stat_changed", "stat"), &Entity::ons_stat_changed); + ClassDB::bind_method(D_METHOD("onc_stat_changed", "stat"), &Entity::onc_stat_changed); //EventHandlers BIND_VMETHOD(MethodInfo("_son_before_cast", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -2810,12 +2879,12 @@ void Entity::_bind_methods() { BIND_VMETHOD(MethodInfo("_son_before_aura_applied", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); BIND_VMETHOD(MethodInfo("_son_after_aura_applied", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); - - BIND_VMETHOD(MethodInfo("_son_death")); - + + BIND_VMETHOD(MethodInfo("_son_death")); + BIND_VMETHOD(MethodInfo("_son_gcd_started", PropertyInfo(Variant::REAL, "gcd"))); BIND_VMETHOD(MethodInfo("_son_gcd_finished")); - + ClassDB::bind_method(D_METHOD("son_before_aura_applied", "data"), &Entity::son_before_aura_applied); ClassDB::bind_method(D_METHOD("son_after_aura_applied", "data"), &Entity::son_after_aura_applied); @@ -2836,63 +2905,63 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("son_cast_finished", "info"), &Entity::son_cast_finished); ClassDB::bind_method(D_METHOD("son_cast_started", "info"), &Entity::son_cast_started); ClassDB::bind_method(D_METHOD("son_cast_failed", "info"), &Entity::son_cast_failed); - - ClassDB::bind_method(D_METHOD("son_death"), &Entity::son_death); - + + ClassDB::bind_method(D_METHOD("son_death"), &Entity::son_death); + ClassDB::bind_method(D_METHOD("son_gcd_started"), &Entity::son_gcd_started); ClassDB::bind_method(D_METHOD("son_gcd_finished"), &Entity::son_gcd_finished); - + //Clientside EventHandlers BIND_VMETHOD(MethodInfo("_con_cast_failed", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_started", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_state_changed", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_finished", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_spell_cast_success", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); - + BIND_VMETHOD(MethodInfo("_con_death")); - + BIND_VMETHOD(MethodInfo("con_cooldown_added", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "Cooldown"))); BIND_VMETHOD(MethodInfo("con_cooldown_removed", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "Cooldown"))); BIND_VMETHOD(MethodInfo("con_category_cooldown_added", PropertyInfo(Variant::OBJECT, "category_cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); BIND_VMETHOD(MethodInfo("con_category_cooldown_removed", PropertyInfo(Variant::OBJECT, "category_cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); - + BIND_VMETHOD(MethodInfo("_con_aura_added", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); BIND_VMETHOD(MethodInfo("_con_aura_removed", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); BIND_VMETHOD(MethodInfo("_con_aura_refresh", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); - + BIND_VMETHOD(MethodInfo("_con_damage_dealt", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); BIND_VMETHOD(MethodInfo("_con_dealt_damage", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellDamageInfo"))); BIND_VMETHOD(MethodInfo("_con_heal_dealt", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); BIND_VMETHOD(MethodInfo("_con_dealt_heal", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellHealInfo"))); - + BIND_VMETHOD(MethodInfo("_con_gcd_started", PropertyInfo(Variant::REAL, "gcd"))); BIND_VMETHOD(MethodInfo("_con_gcd_finished")); - + ClassDB::bind_method(D_METHOD("con_cast_failed", "info"), &Entity::con_cast_failed); ClassDB::bind_method(D_METHOD("con_cast_started", "info"), &Entity::con_cast_started); ClassDB::bind_method(D_METHOD("con_cast_state_changed", "info"), &Entity::con_cast_state_changed); ClassDB::bind_method(D_METHOD("con_cast_finished", "info"), &Entity::con_cast_finished); ClassDB::bind_method(D_METHOD("con_spell_cast_success", "info"), &Entity::con_spell_cast_success); - + ClassDB::bind_method(D_METHOD("con_death"), &Entity::con_death); - + ClassDB::bind_method(D_METHOD("con_cooldown_added", "cooldown"), &Entity::con_cooldown_added); ClassDB::bind_method(D_METHOD("con_cooldown_removed", "cooldown"), &Entity::con_cooldown_removed); ClassDB::bind_method(D_METHOD("con_category_cooldown_added", "category_cooldown"), &Entity::con_category_cooldown_added); ClassDB::bind_method(D_METHOD("con_category_cooldown_removed", "category_cooldown"), &Entity::con_category_cooldown_removed); - + ClassDB::bind_method(D_METHOD("con_aura_added", "data"), &Entity::con_aura_added); ClassDB::bind_method(D_METHOD("con_aura_removed", "data"), &Entity::con_aura_removed); ClassDB::bind_method(D_METHOD("con_aura_refresh", "data"), &Entity::con_aura_refresh); - + ClassDB::bind_method(D_METHOD("con_damage_dealt", "info"), &Entity::con_damage_dealt); ClassDB::bind_method(D_METHOD("con_dealt_damage", "info"), &Entity::con_dealt_damage); ClassDB::bind_method(D_METHOD("con_heal_dealt", "info"), &Entity::con_heal_dealt); ClassDB::bind_method(D_METHOD("con_dealt_heal", "info"), &Entity::con_dealt_heal); - + ClassDB::bind_method(D_METHOD("con_gcd_started"), &Entity::con_gcd_started); ClassDB::bind_method(D_METHOD("con_gcd_finished"), &Entity::con_gcd_finished); - + //Modifiers/Requesters ClassDB::bind_method(D_METHOD("sapply_passives_damage_receive", "data"), &Entity::sapply_passives_damage_receive); ClassDB::bind_method(D_METHOD("sapply_passives_damage_deal", "data"), &Entity::sapply_passives_damage_deal); @@ -2929,13 +2998,13 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("sget_aura_count"), &Entity::sget_aura_count); ClassDB::bind_method(D_METHOD("sget_aura", "index"), &Entity::sget_aura); ClassDB::bind_method(D_METHOD("sget_aura_by", "caster", "aura_id"), &Entity::sget_aura_by_bind); - + ClassDB::bind_method(D_METHOD("cget_aura_count"), &Entity::cget_aura_count); ClassDB::bind_method(D_METHOD("cget_aura", "index"), &Entity::cget_aura); //Hooks ClassDB::bind_method(D_METHOD("moved"), &Entity::moved); - + BIND_VMETHOD(MethodInfo("_moved")); //Properties @@ -3020,14 +3089,18 @@ void Entity::_bind_methods() { //Resources ClassDB::bind_method(D_METHOD("gets_resource", "index"), &Entity::gets_resource); + ClassDB::bind_method(D_METHOD("gets_resource_type", "type"), &Entity::gets_resource_type); ClassDB::bind_method(D_METHOD("adds_resource", "palyer_resource"), &Entity::adds_resource); ClassDB::bind_method(D_METHOD("gets_resource_count"), &Entity::gets_resource_count); ClassDB::bind_method(D_METHOD("removes_resource", "index"), &Entity::removes_resource); + ClassDB::bind_method(D_METHOD("clears_resource"), &Entity::clears_resource); ClassDB::bind_method(D_METHOD("getc_resource", "index"), &Entity::getc_resource); + ClassDB::bind_method(D_METHOD("getc_resource_type", "type"), &Entity::getc_resource_type); ClassDB::bind_method(D_METHOD("addc_resource", "palyer_resource"), &Entity::addc_resource); ClassDB::bind_method(D_METHOD("getc_resource_count"), &Entity::getc_resource_count); ClassDB::bind_method(D_METHOD("removec_resource", "index"), &Entity::removec_resource); + ClassDB::bind_method(D_METHOD("clearc_resource"), &Entity::clearc_resource); //GCD ADD_SIGNAL(MethodInfo("sgcd_started", PropertyInfo(Variant::REAL, "value"))); @@ -3100,9 +3173,9 @@ void Entity::_bind_methods() { //Category Cooldowns ADD_SIGNAL(MethodInfo("scategory_cooldown_added", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); - ADD_SIGNAL(MethodInfo("scategory_cooldown_removed", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); + ADD_SIGNAL(MethodInfo("scategory_cooldown_removed", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); ADD_SIGNAL(MethodInfo("ccategory_cooldown_added", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); - ADD_SIGNAL(MethodInfo("ccategory_cooldown_removed", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); + ADD_SIGNAL(MethodInfo("ccategory_cooldown_removed", PropertyInfo(Variant::OBJECT, "cooldown", PROPERTY_HINT_RESOURCE_TYPE, "CategoryCooldown"))); ClassDB::bind_method(D_METHOD("hass_category_cooldown", "category_id"), &Entity::hass_category_cooldown); ClassDB::bind_method(D_METHOD("adds_category_cooldown", "category_id", "value"), &Entity::adds_category_cooldown); @@ -3142,19 +3215,18 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("gets_bag"), &Entity::gets_bag); ClassDB::bind_method(D_METHOD("getc_bag"), &Entity::getc_bag); - + ClassDB::bind_method(D_METHOD("sets_bag", "bag"), &Entity::sets_bag); ClassDB::bind_method(D_METHOD("setc_bag", "bag"), &Entity::setc_bag); - + ClassDB::bind_method(D_METHOD("gets_target_bag"), &Entity::gets_target_bag); ClassDB::bind_method(D_METHOD("sets_target_bag", "bag"), &Entity::sets_target_bag); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "starget_bag", PROPERTY_HINT_RESOURCE_TYPE, "Bag"), "sets_target_bag", "gets_target_bag"); - + ClassDB::bind_method(D_METHOD("getc_target_bag"), &Entity::getc_target_bag); ClassDB::bind_method(D_METHOD("setc_target_bag", "bag"), &Entity::setc_target_bag); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ctarget_bag", PROPERTY_HINT_RESOURCE_TYPE, "Bag"), "setc_target_bag", "getc_target_bag"); - + BIND_ENUM_CONSTANT(BACKPACK_SIZE); BIND_ENUM_CONSTANT(MAX_BAG_SLOTS); } - diff --git a/entities/entity.h b/entities/entity.h index b3f7bd0..3d440c7 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -19,7 +19,6 @@ #include "core/ustring.h" #include "core/vector.h" #include "../data/item_instance.h" -#include "player_talent.h" #include "entity_resource.h" @@ -30,8 +29,6 @@ #include "../entity_enums.h" -#include "../infos/spell_cast_info.h" - #include "../skeleton/character_skeleton.h" #include "../utility/entity_create_info.h" @@ -225,17 +222,24 @@ public: void sdie(); void cdie(); + void ons_stat_changed(Ref stat); + void onc_stat_changed(Ref stat); + //// Resources //// Ref gets_resource(int index); + Ref gets_resource_type(int type); void adds_resource(Ref resource); int gets_resource_count(); void removes_resource(int index); + void clears_resource(); Ref getc_resource(int index); + Ref getc_resource_type(int type); void addc_resource(Ref resource); int getc_resource_count(); void removec_resource(int index); + void clearc_resource(); //GCD bool getc_has_global_cooldown(); @@ -455,8 +459,8 @@ public: void sreceive_rank_increase(int talentID); void sreceive_rank_decrease(int talentID); void creceive_rank(int talentID, int rank); - PlayerTalent *sget_talent(int id, bool create = false); - PlayerTalent *cget_talent(int id, bool create = false); + //PlayerTalent *sget_talent(int id, bool create = false); + //PlayerTalent *cget_talent(int id, bool create = false); //// Inventory //// @@ -629,8 +633,8 @@ private: //// TalentComponent //// - Vector > _s_talents; - Vector > _c_talents; + //Vector > _s_talents; + //Vector > _c_talents; //// Inventory //// diff --git a/entities/entity_resource.cpp b/entities/entity_resource.cpp index 57f1c76..cb57a54 100644 --- a/entities/entity_resource.cpp +++ b/entities/entity_resource.cpp @@ -1,5 +1,8 @@ #include "entity_resource.h" +#include "entity.h" +#include "stats/stat.h" + bool EntityResource::get_dirty() { return _dirty; } @@ -14,26 +17,113 @@ void EntityResource::set_should_process(bool value) { _should_process = value; } -void EntityResource::process(float delta) { - ERR_FAIL_COND(!has_method("_process")); +int EntityResource::get_resource_type() { + return _type; +} +void EntityResource::set_resource_type(int value) { + _type = value; - call("_process"); + emit_signal("changed", Ref(this)); +} + +int EntityResource::get_current() { + return _current; +} +void EntityResource::set_current(int value) { + _current = value; + + emit_signal("changed", Ref(this)); +} + +int EntityResource::get_max() { + return _max; +} +void EntityResource::set_max(int value) { + _max = value; + + emit_signal("changed", Ref(this)); +} + +Entity *EntityResource::get_owner() { + return _owner; +} +void EntityResource::set_owner(Entity *value) { + _owner = value; +} +void EntityResource::set_owner_bind(Node *owner) { + if (!owner) { + return; + } + + Entity *e = cast_to(owner); + + if (!e) { + return; + } + + _owner = e; +} + +void EntityResource::ons_added(Entity *owner) { + _owner = owner; + + if (has_method("_ons_added")) + call("_ons_added", owner); +} +void EntityResource::onc_added(Entity *owner) { + _owner = owner; + + if (has_method("_onc_added")) + call("_onc_added", owner); +} + +void EntityResource::ons_stat_changed(Ref stat) { + if (has_method("_ons_stat_changed")) + call("_ons_stat_changed", stat); +} +void EntityResource::onc_stat_changed(Ref stat) { + if (has_method("_onc_stat_changed")) + call("_onc_stat_changed", stat); +} + +void EntityResource::ons_target_changed(Entity *entity) { + if (has_method("_ons_target_changed")) + call("_ons_target_changed", entity); +} +void EntityResource::onc_target_changed(Entity *entity) { + if (has_method("_ons_target_changed")) + call("_ons_target_changed", entity); +} + +void EntityResource::process(float delta) { + call("_process", delta); +} + +void EntityResource::_process(float delta) { +} + +String EntityResource::gets_update_string() { + if (has_method("_gets_update_string")) + return call("_gets_update_string"); + + return ""; +} +void EntityResource::receivec_update_string(String str) { + if (has_method("_receivec_update_string")) + call("_receivec_update_string", str); } EntityResource::EntityResource() { _dirty = false; _should_process = has_method("_process"); + + _type = 0; + _current = 0; + _max = 0; } void EntityResource::_bind_methods() { - ADD_SIGNAL(MethodInfo("starget_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - ADD_SIGNAL(MethodInfo("ctarget_changed", PropertyInfo(Variant::OBJECT, "Entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - - BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta"))); - - ClassDB::bind_method(D_METHOD("process", "delta"), &EntityResource::process); - ClassDB::bind_method(D_METHOD("get_dirty"), &EntityResource::get_dirty); ClassDB::bind_method(D_METHOD("set_dirty", "value"), &EntityResource::set_dirty); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dirty"), "set_dirty", "get_dirty"); @@ -41,4 +131,36 @@ void EntityResource::_bind_methods() { ClassDB::bind_method(D_METHOD("get_should_process"), &EntityResource::get_should_process); ClassDB::bind_method(D_METHOD("set_should_process", "value"), &EntityResource::set_should_process); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "should_process"), "set_should_process", "get_should_process"); + + ClassDB::bind_method(D_METHOD("get_resource_type"), &EntityResource::get_resource_type); + ClassDB::bind_method(D_METHOD("set_resource_type", "value"), &EntityResource::set_resource_type); + ADD_PROPERTY(PropertyInfo(Variant::INT, "resource_type"), "set_resource_type", "get_resource_type"); + + ClassDB::bind_method(D_METHOD("get_current"), &EntityResource::get_current); + ClassDB::bind_method(D_METHOD("set_current", "value"), &EntityResource::set_current); + ADD_PROPERTY(PropertyInfo(Variant::INT, "current"), "set_current", "get_current"); + + ClassDB::bind_method(D_METHOD("get_max"), &EntityResource::get_max); + ClassDB::bind_method(D_METHOD("set_max", "value"), &EntityResource::set_max); + ADD_PROPERTY(PropertyInfo(Variant::INT, "max"), "set_max", "get_max"); + + ClassDB::bind_method(D_METHOD("get_owner"), &EntityResource::get_owner); + ClassDB::bind_method(D_METHOD("set_owner", "value"), &EntityResource::set_owner_bind); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), "set_owner", "get_owner"); + + BIND_VMETHOD(MethodInfo("_ons_stat_changed", PropertyInfo(Variant::OBJECT, "stat", PROPERTY_HINT_RESOURCE_TYPE, "Stat"))); + BIND_VMETHOD(MethodInfo("_onc_stat_changed", PropertyInfo(Variant::OBJECT, "stat", PROPERTY_HINT_RESOURCE_TYPE, "Stat"))); + + BIND_VMETHOD(MethodInfo("_ons_target_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + BIND_VMETHOD(MethodInfo("_onc_target_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + + BIND_VMETHOD(MethodInfo("_ons_added", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + BIND_VMETHOD(MethodInfo("_onc_added", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + + BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta"))); + + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, "str"), "_gets_update_string")); + BIND_VMETHOD(MethodInfo("_receivec_update_string", PropertyInfo(Variant::STRING, "str"))); + + ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); } diff --git a/entities/entity_resource.h b/entities/entity_resource.h index 64f0251..e972b4f 100644 --- a/entities/entity_resource.h +++ b/entities/entity_resource.h @@ -3,6 +3,9 @@ #include "core/reference.h" +class Stat; +class Entity; + class EntityResource : public Reference { GDCLASS(EntityResource, Reference); @@ -13,7 +16,33 @@ public: bool get_should_process(); void set_should_process(bool value); + int get_resource_type(); + void set_resource_type(int value); + + int get_current(); + void set_current(int value); + + int get_max(); + void set_max(int value); + + Entity *get_owner(); + void set_owner(Entity *entity); + void set_owner_bind(Node *owner); + + void ons_added(Entity *owner); + void onc_added(Entity *owner); + + void ons_stat_changed(Ref stat); + void onc_stat_changed(Ref stat); + + void ons_target_changed(Entity *target); + void onc_target_changed(Entity *target); + void process(float delta); + void _process(float delta); + + String gets_update_string(); + void receivec_update_string(String str); EntityResource(); @@ -21,8 +50,12 @@ protected: static void _bind_methods(); private: + Entity *_owner; bool _dirty; bool _should_process; + int _type; + int _current; + int _max; }; #endif diff --git a/entities/player_talent.cpp b/entities/player_talent.cpp deleted file mode 100644 index a096e6a..0000000 --- a/entities/player_talent.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "player_talent.h" - -int PlayerTalent::get_talent_id() { - return _talent_id; -} - -void PlayerTalent::set_talent_id(int value) { - _talent_id = value; -} - -int PlayerTalent::get_rank() { - return _rank; -} - -void PlayerTalent::set_rank(int value) { - _rank = value; -} - -PlayerTalent::PlayerTalent() { - _rank = (int)(0); - _talent_id = (int)(0); -} - -PlayerTalent::PlayerTalent(int talentID) { - set_talent_id(talentID); -} - -void PlayerTalent::_bind_methods() { - -} diff --git a/entities/player_talent.h b/entities/player_talent.h deleted file mode 100644 index aed1e2d..0000000 --- a/entities/player_talent.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef PLAYER_TALENT_H -#define PLAYER_TALENT_H - -#include "core/reference.h" - -class PlayerTalent : public Reference { - GDCLASS(PlayerTalent, Reference); - -public: - int get_talent_id(); - void set_talent_id(int value); - int get_rank(); - void set_rank(int value); - PlayerTalent(); - PlayerTalent(int talentID); - -protected: - static void _bind_methods(); - -private: - int _talent_id; - int _rank; -}; - -#endif diff --git a/entities/stats/stat.cpp b/entities/stats/stat.cpp index f4cdad9..715e1ce 100644 --- a/entities/stats/stat.cpp +++ b/entities/stats/stat.cpp @@ -1,8 +1,8 @@ #include "stat.h" -const String Stat::STAT_BINDING_STRING = "Health, Speed, Mana, GCD, Haste, Agility, Strength, Stamina, Intellect, Luck, Haste Rating, Resilience, Armor, Attack Power, Spell Power, Melee Crit, Melee Crit bonus, Spell Crit, Spell Crit Bonus, Block, Parry, Damage Reduction, Melee Damage Reduction, Spell Damage Reduction, Damage Taken, Heal Taken, Melee Damage, Spell Damage, Holy Resist, Shadow Resist, Nature Resist, Fire Resist, Frost Resist, Lightning Resist, Chaos Resist, Silence Resist, Fear Resist, None"; +const String Stat::STAT_BINDING_STRING = "Health,Speed,Mana,GCD,Haste,Agility,Strength,Stamina,Intellect,Luck,Haste Rating,Resilience,Armor,Attack Power,Spell Power,Melee Crit,Melee Crit bonus,Spell Crit,Spell Crit Bonus,Block,Parry,Damage Reduction,Melee Damage Reduction,Spell Damage Reduction,Damage Taken,Heal Taken,Melee Damage,Spell Damage,Holy Resist,Shadow Resist,Nature Resist,Fire Resist,Frost Resist,Lightning Resist,Chaos Resist,Silence Resist,Fear Resist,None"; -const String Stat::MODIFIER_APPLY_TYPE_BINDING_STRING = "Standard, Only min modifier, Only Max modifier"; +const String Stat::MODIFIER_APPLY_TYPE_BINDING_STRING = "Standard,Only min modifier,Only Max modifier"; Stat::Stat() { _id = Stat::STAT_ID_NONE; @@ -197,9 +197,9 @@ void Stat::apply_modifier(Ref modifier) { } recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); - // emit_signal("s_changed", this); + // emit_signal("s_changed", Ref(this)); } void Stat::de_apply_modifier(Ref modifier) { @@ -233,10 +233,10 @@ void Stat::de_apply_modifier(Ref modifier) { } recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); - // emit_signal("s_changed", this); + // emit_signal("s_changed", Ref(this)); } void Stat::re_apply_modifiers() { @@ -255,10 +255,10 @@ void Stat::re_apply_modifiers() { } recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); - // emit_signal("s_changed", this); + // emit_signal("s_changed", Ref(this)); } void Stat::re_apply_modifier_not_negative_stacking_percents() { @@ -296,10 +296,10 @@ void Stat::re_apply_modifier_not_negative_stacking_percents() { } recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); - // emit_signal("s_changed", this); + // emit_signal("s_changed", Ref(this)); } //Stat @@ -311,7 +311,7 @@ float Stat::gets_current() { void Stat::sets_current(float value) { _s_current = value; - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -322,7 +322,7 @@ float Stat::gets_max() { void Stat::sets_max(float value) { _s_max = value; - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -333,7 +333,7 @@ float Stat::getc_current() { void Stat::setc_current(float value) { _c_current = value; - emit_signal("c_changed", this); + emit_signal("c_changed", Ref(this)); } float Stat::getc_max() { @@ -343,7 +343,7 @@ float Stat::getc_max() { void Stat::setc_max(float value) { _s_current = value; - emit_signal("c_changed", this); + emit_signal("c_changed", Ref(this)); } float Stat::get_base() { @@ -354,7 +354,7 @@ void Stat::set_base(float value) { _base = value; recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -366,7 +366,7 @@ void Stat::set_bonus(float value) { _bonus = value; recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -378,7 +378,7 @@ void Stat::set_percent(float value) { _percent = value; recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -389,7 +389,7 @@ void Stat::reset_values() { _dirty = true; - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -411,7 +411,7 @@ void Stat::send() { _c_current = _s_current; _c_max = _s_max; - emit_signal("c_changed", this); + emit_signal("c_changed", Ref(this)); } @@ -426,7 +426,7 @@ bool Stat::isc_current_zero() { void Stat::set_to_max() { _s_current = _s_max; - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -437,7 +437,7 @@ void Stat::set_values(float base, float bonus, float percent) { recalculate(); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -451,7 +451,7 @@ void Stat::set_from_stat(Ref other) { _percent = other->_percent; set_dirty(true); - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -465,7 +465,7 @@ void Stat::set(float current, float max, float base, float bonus, float percent) _percent = percent; _dirty = true; - emit_signal("s_changed", this); + emit_signal("s_changed", Ref(this)); send(); } @@ -475,6 +475,7 @@ void Stat::_bind_methods() { ClassDB::bind_method(D_METHOD("get_id"), &Stat::get_id); ClassDB::bind_method(D_METHOD("set_id", "id"), &Stat::set_id); + //ADD_PROPERTY(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_ENUM, STAT_BINDING_STRING), "set_id", "get_id"); ClassDB::bind_method(D_METHOD("get_stat_modifier_type"), &Stat::get_stat_modifier_type); ClassDB::bind_method(D_METHOD("set_stat_modifier_type", "value"), &Stat::set_stat_modifier_type); diff --git a/entity_enums.cpp b/entity_enums.cpp index dda3f7c..d9f4625 100644 --- a/entity_enums.cpp +++ b/entity_enums.cpp @@ -6,3 +6,87 @@ const String EntityEnums::BINDING_STRING_ENTITY_STATE_TYPES = "None,Stun,Root,Fr const String EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS = "Root,Pelvis,Spine,Spine 1,Spine 2,Neck,Head,Left Clavicle,Left upper Arm,Left Forearm,Left Hand,Left Thumb Base,Left Thumb End,Left Fingers Base,Left Fingers End,Right Clavicle,Right upper Arm,Right Forearm,Right Hand,Right Thumb Base,Right Thumb End,Right Fingers Base,Right Fingers End,Left Thigh,Left Calf,Left Foot,Right Thigh,Right Calf,Right Foot"; const String EntityEnums::BINDING_STRING_AI_STATES = "Off,Rest,Patrol,Follow Path,Regenerate,Attack"; +const int EntityEnums::PLAYER_RESOURCE_TYPES_RAGE = 0; +const int EntityEnums::PLAYER_RESOURCE_TYPES_MANA = 1; +const int EntityEnums::PLAYER_RESOURCE_TYPES_ENERGY = 2; +const int EntityEnums::PLAYER_RESOURCE_TYPES_TIME_ANOMALY = 3; + +void EntityEnums::_bind_methods() { + BIND_CONSTANT(PLAYER_RESOURCE_TYPES_RAGE); + BIND_CONSTANT(PLAYER_RESOURCE_TYPES_MANA); + BIND_CONSTANT(PLAYER_RESOURCE_TYPES_ENERGY); + BIND_CONSTANT(PLAYER_RESOURCE_TYPES_TIME_ANOMALY); + + BIND_ENUM_CONSTANT(ENITIY_TYPE_NONE); + BIND_ENUM_CONSTANT(ENITIY_TYPE_PLAYER); + BIND_ENUM_CONSTANT(ENITIY_TYPE_AI); + BIND_ENUM_CONSTANT(ENITIY_TYPE_MOB); + + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_NONE); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_STUN); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_ROOT); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_FROZEN); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_SILENCED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_DISORIENTED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_FEARED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_BURNING); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_COLD); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_CURSED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_PACIFIED); + + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_NONE); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_STUN); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_ROOT); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_FROZEN); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_SILENCED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_DISORIENTED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_FEARED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_BURNING); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_COLD); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_CURSED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_PACIFIED); + BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_MAX); + + BIND_ENUM_CONSTANT(SKELETON_POINT_ROOT); + BIND_ENUM_CONSTANT(SKELETON_POINT_PELVIS); + BIND_ENUM_CONSTANT(SKELETON_POINT_SPINE); + BIND_ENUM_CONSTANT(SKELETON_POINT_SPINE_1); + BIND_ENUM_CONSTANT(SKELETON_POINT_SPINE_2); + BIND_ENUM_CONSTANT(SKELETON_POINT_NECK); + BIND_ENUM_CONSTANT(SKELETON_POINT_HEAD); + + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_CLAVICLE); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_UPPER_ARM); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FOREARM); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_HAND); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_THUMB_BASE); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_THUMB_END); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FINGERS_BASE); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FINGERS_END); + + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_CLAVICLE); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_UPPER_ARM); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FOREARM); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_HAND); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_THUMB_BASE); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_THUMB_END); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FINGERS_BASE); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FINGERS_END); + + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_THIGH); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_CALF); + BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FOOT); + + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_THIGH); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_CALF); + BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FOOT); + + BIND_ENUM_CONSTANT(SKELETON_POINTS_MAX); + + BIND_ENUM_CONSTANT(AI_STATE_OFF); + BIND_ENUM_CONSTANT(AI_STATE_REST); + BIND_ENUM_CONSTANT(AI_STATE_PATROL); + BIND_ENUM_CONSTANT(AI_STATE_FOLLOW_PATH); + BIND_ENUM_CONSTANT(AI_STATE_REGENERATE); + BIND_ENUM_CONSTANT(AI_STATE_ATTACK); +} diff --git a/entity_enums.h b/entity_enums.h index 9edbb93..6091cca 100644 --- a/entity_enums.h +++ b/entity_enums.h @@ -14,13 +14,10 @@ public: static const String BINDING_STRING_CHARCATER_SKELETON_POINTS; static const String BINDING_STRING_AI_STATES; - enum PlayerResourceTypes { - PLAYER_RESOURCE_TYPES_NONE, - PLAYER_RESOURCE_TYPES_RAGE, - PLAYER_RESOURCE_TYPES_MANA, - PLAYER_RESOURCE_TYPES_ENERGY, - PLAYER_RESOURCE_TYPES_TIME_ANOMALY, - }; + static const int PLAYER_RESOURCE_TYPES_RAGE; + static const int PLAYER_RESOURCE_TYPES_MANA; + static const int PLAYER_RESOURCE_TYPES_ENERGY; + static const int PLAYER_RESOURCE_TYPES_TIME_ANOMALY; enum EntityType { ENITIY_TYPE_NONE, @@ -136,91 +133,10 @@ public: EntityEnums() {} protected: - static void _bind_methods() { - BIND_ENUM_CONSTANT(PLAYER_RESOURCE_TYPES_NONE); - BIND_ENUM_CONSTANT(PLAYER_RESOURCE_TYPES_RAGE); - BIND_ENUM_CONSTANT(PLAYER_RESOURCE_TYPES_MANA); - BIND_ENUM_CONSTANT(PLAYER_RESOURCE_TYPES_ENERGY); - BIND_ENUM_CONSTANT(PLAYER_RESOURCE_TYPES_TIME_ANOMALY); - - BIND_ENUM_CONSTANT(ENITIY_TYPE_NONE); - BIND_ENUM_CONSTANT(ENITIY_TYPE_PLAYER); - BIND_ENUM_CONSTANT(ENITIY_TYPE_AI); - BIND_ENUM_CONSTANT(ENITIY_TYPE_MOB); - - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_NONE); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_STUN); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_ROOT); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_FROZEN); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_SILENCED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_DISORIENTED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_FEARED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_BURNING); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_COLD); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_CURSED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_FLAG_PACIFIED); - - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_NONE); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_STUN); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_ROOT); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_FROZEN); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_SILENCED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_DISORIENTED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_FEARED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_BURNING); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_COLD); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_CURSED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_PACIFIED); - BIND_ENUM_CONSTANT(ENTITY_STATE_TYPE_INDEX_MAX); - - BIND_ENUM_CONSTANT(SKELETON_POINT_ROOT); - BIND_ENUM_CONSTANT(SKELETON_POINT_PELVIS); - BIND_ENUM_CONSTANT(SKELETON_POINT_SPINE); - BIND_ENUM_CONSTANT(SKELETON_POINT_SPINE_1); - BIND_ENUM_CONSTANT(SKELETON_POINT_SPINE_2); - BIND_ENUM_CONSTANT(SKELETON_POINT_NECK); - BIND_ENUM_CONSTANT(SKELETON_POINT_HEAD); - - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_CLAVICLE); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_UPPER_ARM); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FOREARM); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_HAND); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_THUMB_BASE); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_THUMB_END); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FINGERS_BASE); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FINGERS_END); - - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_CLAVICLE); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_UPPER_ARM); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FOREARM); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_HAND); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_THUMB_BASE); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_THUMB_END); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FINGERS_BASE); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FINGERS_END); - - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_THIGH); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_CALF); - BIND_ENUM_CONSTANT(SKELETON_POINT_LEFT_FOOT); - - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_THIGH); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_CALF); - BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FOOT); - - BIND_ENUM_CONSTANT(SKELETON_POINTS_MAX); - - - BIND_ENUM_CONSTANT(AI_STATE_OFF); - BIND_ENUM_CONSTANT(AI_STATE_REST); - BIND_ENUM_CONSTANT(AI_STATE_PATROL); - BIND_ENUM_CONSTANT(AI_STATE_FOLLOW_PATH); - BIND_ENUM_CONSTANT(AI_STATE_REGENERATE); - BIND_ENUM_CONSTANT(AI_STATE_ATTACK); - } + static void _bind_methods(); }; VARIANT_ENUM_CAST(EntityEnums::EntityType); -VARIANT_ENUM_CAST(EntityEnums::PlayerResourceTypes); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeFlags); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeIndexes); VARIANT_ENUM_CAST(EntityEnums::CharacterSkeletonPoints); diff --git a/register_types.cpp b/register_types.cpp index 94067c5..d1681b6 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -9,7 +9,6 @@ #include "data/character_class.h" #include "data/talent.h" #include "data/talent_row_data.h" -#include "data/talent_rank_data.h" #include "data/character_spec.h" #include "data/xp_data.h" #include "data/item_stat_modifier.h" @@ -23,7 +22,6 @@ #include "entities/stats/stat.h" #include "entities/stats/stat_modifier.h" #include "entities/stats/stat_data.h" -#include "entities/player_talent.h" #include "inventory/bag.h" #include "data/craft_data_attribute_helper.h" @@ -96,7 +94,6 @@ void register_entity_spell_system_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); @@ -110,7 +107,6 @@ void register_entity_spell_system_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); diff --git a/spell_enums.cpp b/spell_enums.cpp index 788f6dc..b0024de 100644 --- a/spell_enums.cpp +++ b/spell_enums.cpp @@ -4,4 +4,4 @@ const String SpellEnums::BINDING_STRING_SPELL_TYPES = "Melee,Holy,Shadow,Nature, const String SpellEnums::BINDING_STRING_DIMINISHING_RETURN_CATEGORIES = "None,Root,Stun"; const String SpellEnums::BINDING_STRING_TRIGGER_EVENTS = "None,S On Before Damage,S On Damage Receive,S On Hit,S On Damage Dealt,S Aura Remove,S Aura Dispell,S On Before Aura Applied,S On After Aura Applied,C On Aura Added,C On Aura Removed,C On Aura Refreshed"; const String SpellEnums::BINDING_STRING_DAMAGE_TYPES = "Melee,Holy,Shadow,Nature,Fire,Frost,Lightning,Chaos"; -const String SpellEnums::BINDING_STRING_AURA_TYPES = "None,Magic,Poison,Physical,Curse,Bleed"; +const String SpellEnums::BINDING_STRING_AURA_TYPES = "None,Magic,Poison,Physical,Curse,Bleed,Talent"; diff --git a/spell_enums.h b/spell_enums.h index 6eefec4..78f7896 100644 --- a/spell_enums.h +++ b/spell_enums.h @@ -65,6 +65,7 @@ public: AURA_TYPE_PHYSICAL = 3, AURA_TYPE_CURSE = 4, AURA_TYPE_BLEED = 5, + AURA_TYPE_TALENT = 6, }; SpellEnums() {} @@ -114,6 +115,7 @@ protected: BIND_ENUM_CONSTANT(AURA_TYPE_PHYSICAL); BIND_ENUM_CONSTANT(AURA_TYPE_CURSE); BIND_ENUM_CONSTANT(AURA_TYPE_BLEED); + BIND_ENUM_CONSTANT(AURA_TYPE_TALENT); } };