diff --git a/SCsub b/SCsub index c2ed41f..4b91b46 100644 --- a/SCsub +++ b/SCsub @@ -72,7 +72,6 @@ sources = [ "entities/auras/aura_data.cpp", "entities/entity.cpp", - "entities/resources/entity_resource_data.cpp", "entities/resources/entity_resource_cost_data.cpp", "entities/resources/entity_resource_cost_data_health.cpp", "entities/resources/entity_resource_cost_data_resource.cpp", diff --git a/config.py b/config.py index d7eb725..05247a6 100644 --- a/config.py +++ b/config.py @@ -45,7 +45,6 @@ def get_doc_classes(): "EntityResourceCostData", "EntityResourceCostDataHealth", "EntityResourceCostDataResource", - "EntityResourceData", "EntityResource", "EntityResourceHealth", "EntityResourceSpeed", diff --git a/database/ess_resource_db.cpp b/database/ess_resource_db.cpp index 4c2bf7e..b252aab 100644 --- a/database/ess_resource_db.cpp +++ b/database/ess_resource_db.cpp @@ -27,7 +27,7 @@ SOFTWARE. #include "../data/species/entity_species_data.h" #include "../data/spells/spell.h" #include "../entities/data/entity_data.h" -#include "../entities/resources/entity_resource_data.h" +#include "../entities/resources/entity_resource.h" #include "../entities/skills/entity_skill_data.h" Ref ESSResourceDB::get_skill_for_armor_type(const int index) { @@ -48,7 +48,7 @@ void ESSResourceDB::set_xp_data(const Ref &data) { _xp_data = data; } -void ESSResourceDB::add_entity_resource(Ref cls) { +void ESSResourceDB::add_entity_resource(Ref cls) { if (!cls.is_valid()) return; @@ -56,7 +56,7 @@ void ESSResourceDB::add_entity_resource(Ref cls) { _entity_resources_path_to_id.set(cls->get_path(), cls->get_id()); } -Ref ESSResourceDB::get_entity_resource_path(const StringName &path) { +Ref ESSResourceDB::get_entity_resource_path(const StringName &path) { return get_entity_resource(entity_resource_path_to_id(path)); } @@ -325,7 +325,7 @@ void ESSResourceDB::_bind_methods() { ClassDB::bind_method(D_METHOD("set_xp_data", "data"), &ESSResourceDB::set_xp_data); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "xp_data", PROPERTY_HINT_RESOURCE_TYPE, "XPData"), "set_xp_data", "get_xp_data"); - //EntityResourceData + //EntityResource ClassDB::bind_method(D_METHOD("add_entity_resource", "cls"), &ESSResourceDB::add_entity_resource); ClassDB::bind_method(D_METHOD("get_entity_resource", "class_id"), &ESSResourceDB::get_entity_resource); ClassDB::bind_method(D_METHOD("get_entity_resource_index", "index"), &ESSResourceDB::get_entity_resource_index); diff --git a/database/ess_resource_db.h b/database/ess_resource_db.h index f425c8a..ff8ab01 100644 --- a/database/ess_resource_db.h +++ b/database/ess_resource_db.h @@ -43,7 +43,7 @@ class Spell; class EntityData; class CraftRecipe; class ItemTemplate; -class EntityResourceData; +class EntityResource; class EntitySkillData; class EntityCreateInfo; class SpellCastInfo; @@ -59,14 +59,14 @@ public: Ref get_xp_data(); void set_xp_data(const Ref &data); - virtual Ref get_entity_resource(int class_id) = 0; - virtual Ref get_entity_resource_index(int index) = 0; + virtual Ref get_entity_resource(int class_id) = 0; + virtual Ref get_entity_resource_index(int index) = 0; virtual int get_entity_resource_count() = 0; - virtual void add_entity_resource(Ref cls); + virtual void add_entity_resource(Ref cls); virtual Vector get_entity_resources() const = 0; virtual void set_entity_resources(const Vector &data) = 0; - Ref get_entity_resource_path(const StringName &path); + Ref get_entity_resource_path(const StringName &path); StringName entity_resource_id_to_path(const int id) const; int entity_resource_path_to_id(const StringName &path) const; diff --git a/database/ess_resource_db_folders.cpp b/database/ess_resource_db_folders.cpp index 59f1821..4b36c0d 100644 --- a/database/ess_resource_db_folders.cpp +++ b/database/ess_resource_db_folders.cpp @@ -27,7 +27,7 @@ SOFTWARE. #include "../data/species/entity_species_data.h" #include "../data/spells/spell.h" #include "../entities/data/entity_data.h" -#include "../entities/resources/entity_resource_data.h" +#include "../entities/resources/entity_resource.h" #include "../entities/skills/entity_skill_data.h" bool ESSResourceDBFolders::get_automatic_load() const { @@ -125,7 +125,7 @@ void ESSResourceDBFolders::load_folder(const String &folder) { void ESSResourceDBFolders::add_resource(const Ref &resource) { StringName cls = resource->get_class_name(); - if (cls == "EntityResourceData") { + if (cls == "EntityResource") { add_entity_resource(resource); } else if (cls == "EntitySkillData") { add_entity_skill(resource); diff --git a/database/ess_resource_db_folders.h b/database/ess_resource_db_folders.h index da19dd2..d952363 100644 --- a/database/ess_resource_db_folders.h +++ b/database/ess_resource_db_folders.h @@ -48,7 +48,7 @@ class Spell; class EntityData; class CraftRecipe; class ItemTemplate; -class EntityResourceData; +class EntityResource; class EntitySkillData; class EntityCreateInfo; class SpellCastInfo; diff --git a/database/ess_resource_db_map.cpp b/database/ess_resource_db_map.cpp index 48ed3bf..f59b18b 100644 --- a/database/ess_resource_db_map.cpp +++ b/database/ess_resource_db_map.cpp @@ -27,27 +27,27 @@ SOFTWARE. #include "../data/species/entity_species_data.h" #include "../data/spells/spell.h" #include "../entities/data/entity_data.h" -#include "../entities/resources/entity_resource_data.h" +#include "../entities/resources/entity_resource.h" #include "../entities/skills/entity_skill_data.h" -Ref ESSResourceDBMap::get_entity_resource(int class_id) { - //ERR_FAIL_COND_V_MSG(!_entity_resource_map.has(class_id), Ref(), "Could not find EntityResourceData! Id:" + String::num(class_id)); +Ref ESSResourceDBMap::get_entity_resource(int class_id) { + //ERR_FAIL_COND_V_MSG(!_entity_resource_map.has(class_id), Ref(), "Could not find EntityResource! Id:" + String::num(class_id)); if (!_entity_resource_map.has(class_id)) { - return Ref(); + return Ref(); } return _entity_resource_map.get(class_id); } -Ref ESSResourceDBMap::get_entity_resource_index(int index) { - ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref(NULL)); +Ref ESSResourceDBMap::get_entity_resource_index(int index) { + ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref(NULL)); return _entity_resources.get(index); } int ESSResourceDBMap::get_entity_resource_count() { return _entity_resources.size(); } -void ESSResourceDBMap::add_entity_resource(Ref cls) { +void ESSResourceDBMap::add_entity_resource(Ref cls) { ERR_FAIL_COND(!cls.is_valid()); _entity_resources.push_back(cls); diff --git a/database/ess_resource_db_map.h b/database/ess_resource_db_map.h index 07dc706..6f3e988 100644 --- a/database/ess_resource_db_map.h +++ b/database/ess_resource_db_map.h @@ -48,7 +48,7 @@ class Spell; class EntityData; class CraftRecipe; class ItemTemplate; -class EntityResourceData; +class EntityResource; class EntitySkillData; class EntityCreateInfo; class SpellCastInfo; @@ -58,10 +58,10 @@ class ESSResourceDBMap : public ESSResourceDB { GDCLASS(ESSResourceDBMap, ESSResourceDB); public: - Ref get_entity_resource(int class_id); - Ref get_entity_resource_index(int index); + Ref get_entity_resource(int class_id); + Ref get_entity_resource_index(int index); int get_entity_resource_count(); - void add_entity_resource(Ref cls); + void add_entity_resource(Ref cls); Vector get_entity_resources() const; void set_entity_resources(const Vector &data); @@ -121,29 +121,29 @@ protected: static void _bind_methods(); private: - Vector> _entity_resources; - HashMap> _entity_resource_map; + Vector > _entity_resources; + HashMap > _entity_resource_map; - Vector> _entity_skills; - HashMap> _entity_skill_map; + Vector > _entity_skills; + HashMap > _entity_skill_map; - Vector> _entity_datas; - HashMap> _entity_data_map; + Vector > _entity_datas; + HashMap > _entity_data_map; - Vector> _spells; - HashMap> _spell_map; + Vector > _spells; + HashMap > _spell_map; - Vector> _auras; - HashMap> _aura_map; + Vector > _auras; + HashMap > _aura_map; - Vector> _craft_recipes; - HashMap> _craft_recipe_map; + Vector > _craft_recipes; + HashMap > _craft_recipe_map; - Vector> _item_templates; - HashMap> _item_template_map; + Vector > _item_templates; + HashMap > _item_template_map; - Vector> _entity_species_datas; - HashMap> _entity_species_data_map; + Vector > _entity_species_datas; + HashMap > _entity_species_data_map; }; #endif diff --git a/database/ess_resource_db_static.cpp b/database/ess_resource_db_static.cpp index 865a187..34fb7af 100644 --- a/database/ess_resource_db_static.cpp +++ b/database/ess_resource_db_static.cpp @@ -27,7 +27,7 @@ SOFTWARE. #include "../data/species/entity_species_data.h" #include "../data/spells/spell.h" #include "../entities/data/entity_data.h" -#include "../entities/resources/entity_resource_data.h" +#include "../entities/resources/entity_resource.h" #include "../entities/skills/entity_skill_data.h" bool ESSResourceDBStatic::get_remap_ids() const { @@ -37,21 +37,21 @@ void ESSResourceDBStatic::set_remap_ids(const bool value) { _remap_ids = value; } -Ref ESSResourceDBStatic::get_entity_resource(int id) { +Ref ESSResourceDBStatic::get_entity_resource(int id) { if (id < 0 || id >= _entity_resources.size()) - return Ref(); + return Ref(); return _entity_resources.get(id); } -Ref ESSResourceDBStatic::get_entity_resource_index(int index) { - ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref(NULL)); +Ref ESSResourceDBStatic::get_entity_resource_index(int index) { + ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref(NULL)); return _entity_resources.get(index); } int ESSResourceDBStatic::get_entity_resource_count() { return _entity_resources.size(); } -void ESSResourceDBStatic::add_entity_resource(Ref cls) { +void ESSResourceDBStatic::add_entity_resource(Ref cls) { if (_remap_ids && cls.is_valid()) cls->set_id(_entity_resources.size()); @@ -65,7 +65,7 @@ Vector ESSResourceDBStatic::get_entity_resources() const { void ESSResourceDBStatic::set_entity_resources(const Vector &data) { _entity_resources.clear(); for (int i = 0; i < data.size(); i++) { - Ref d = Ref(data[i]); + Ref d = Ref(data[i]); add_entity_resource(d); } @@ -353,7 +353,7 @@ void ESSResourceDBStatic::_bind_methods() { ClassDB::bind_method(D_METHOD("set_remap_ids", "value"), &ESSResourceDBStatic::set_remap_ids); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "remap_ids"), "set_remap_ids", "get_remap_ids"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_resources", PROPERTY_HINT_NONE, "17/17:EntityResourceData", PROPERTY_USAGE_DEFAULT, "EntityResourceData"), "set_entity_resources", "get_entity_resources"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_resources", PROPERTY_HINT_NONE, "17/17:EntityResource", PROPERTY_USAGE_DEFAULT, "EntityResource"), "set_entity_resources", "get_entity_resources"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_skills", PROPERTY_HINT_NONE, "17/17:EntitySkillData", PROPERTY_USAGE_DEFAULT, "EntitySkillData"), "set_entity_skills", "get_entity_skills"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "spells", PROPERTY_HINT_NONE, "17/17:Spell", PROPERTY_USAGE_DEFAULT, "Spell"), "set_spells", "get_spells"); diff --git a/database/ess_resource_db_static.h b/database/ess_resource_db_static.h index ad28d92..62514c2 100644 --- a/database/ess_resource_db_static.h +++ b/database/ess_resource_db_static.h @@ -38,7 +38,7 @@ class Spell; class EntityData; class CraftRecipe; class ItemTemplate; -class EntityResourceData; +class EntityResource; class EntitySkillData; class EntityCreateInfo; class SpellCastInfo; @@ -57,10 +57,10 @@ public: PoolStringArray get_folders() const; void set_folders(const PoolStringArray &folders); - Ref get_entity_resource(int class_id); - Ref get_entity_resource_index(int index); + Ref get_entity_resource(int class_id); + Ref get_entity_resource_index(int index); int get_entity_resource_count(); - void add_entity_resource(Ref cls); + void add_entity_resource(Ref cls); Vector get_entity_resources() const; void set_entity_resources(const Vector &data); @@ -124,14 +124,14 @@ protected: private: bool _remap_ids; - Vector> _entity_resources; - Vector> _entity_skills; - Vector> _entity_datas; - Vector> _spells; - Vector> _auras; - Vector> _craft_recipes; - Vector> _item_templates; - Vector> _entity_species_datas; + Vector > _entity_resources; + Vector > _entity_skills; + Vector > _entity_datas; + Vector > _spells; + Vector > _auras; + Vector > _craft_recipes; + Vector > _item_templates; + Vector > _entity_species_datas; }; #endif diff --git a/doc_classes/ESSResourceDB.xml b/doc_classes/ESSResourceDB.xml index 7e72711..4a19d37 100644 --- a/doc_classes/ESSResourceDB.xml +++ b/doc_classes/ESSResourceDB.xml @@ -40,7 +40,7 @@ - + @@ -296,7 +296,7 @@ - + @@ -310,7 +310,7 @@ - + @@ -318,7 +318,7 @@ - + diff --git a/doc_classes/EntityClassData.xml b/doc_classes/EntityClassData.xml index 92ea5dd..d653808 100644 --- a/doc_classes/EntityClassData.xml +++ b/doc_classes/EntityClassData.xml @@ -753,7 +753,7 @@ - + @@ -845,7 +845,7 @@ - + diff --git a/doc_classes/EntityResource.xml b/doc_classes/EntityResource.xml index a29f4c2..077fcfb 100644 --- a/doc_classes/EntityResource.xml +++ b/doc_classes/EntityResource.xml @@ -146,7 +146,7 @@ - + diff --git a/doc_classes/EntityResourceCostData.xml b/doc_classes/EntityResourceCostData.xml index c6e2fcc..f81b1a2 100644 --- a/doc_classes/EntityResourceCostData.xml +++ b/doc_classes/EntityResourceCostData.xml @@ -12,7 +12,7 @@ - + diff --git a/doc_classes/EntityResourceData.xml b/doc_classes/EntityResourceData.xml deleted file mode 100644 index 9353bb1..0000000 --- a/doc_classes/EntityResourceData.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - The data for an [Entity]'s resource. Resource in this context is things like mana. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/entities/data/entity_class_data.cpp b/entities/data/entity_class_data.cpp index 7f29390..e951df2 100644 --- a/entities/data/entity_class_data.cpp +++ b/entities/data/entity_class_data.cpp @@ -76,15 +76,15 @@ void EntityClassData::set_num_entity_resources(int value) { _entity_resources.resize(value); } -Ref EntityClassData::get_entity_resource(int index) const { - ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref()); +Ref EntityClassData::get_entity_resource(int index) const { + ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref()); return _entity_resources[index]; } -void EntityClassData::set_entity_resource(int index, Ref entity_resource) { +void EntityClassData::set_entity_resource(int index, Ref entity_resource) { ERR_FAIL_INDEX(index, _entity_resources.size()); - _entity_resources.set(index, Ref(entity_resource)); + _entity_resources.set(index, Ref(entity_resource)); } Vector EntityClassData::get_entity_resources() { @@ -93,7 +93,7 @@ Vector EntityClassData::get_entity_resources() { void EntityClassData::set_entity_resources(const Vector &entity_resources) { _entity_resources.clear(); for (int i = 0; i < entity_resources.size(); i++) { - Ref entity_resource = Ref(entity_resources[i]); + Ref entity_resource = Ref(entity_resources[i]); _entity_resources.push_back(entity_resource); } @@ -286,10 +286,12 @@ void EntityClassData::_setup_resources(Node *entity) { Entity *ent = Object::cast_to(entity); for (int i = 0; i < _entity_resources.size(); ++i) { - Ref res = _entity_resources.get(i); + Ref res = _entity_resources.get(i); if (res.is_valid()) { - ent->resource_adds(res->get_entity_resource_instance()); + Ref r = res->duplicate(false); + + ent->resource_adds(r); } } } @@ -341,7 +343,7 @@ void EntityClassData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entity_resources"), &EntityClassData::get_entity_resources); ClassDB::bind_method(D_METHOD("set_entity_resources", "entity_resources"), &EntityClassData::set_entity_resources); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_resources", PROPERTY_HINT_NONE, "17/17:EntityResourceData", PROPERTY_USAGE_DEFAULT, "EntityResourceData"), "set_entity_resources", "get_entity_resources"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_resources", PROPERTY_HINT_NONE, "17/17:EntityResource", PROPERTY_USAGE_DEFAULT, "EntityResource"), "set_entity_resources", "get_entity_resources"); ClassDB::bind_method(D_METHOD("_setup_resources", "entity"), &EntityClassData::_setup_resources); diff --git a/entities/data/entity_class_data.h b/entities/data/entity_class_data.h index 1b08b60..aabd973 100644 --- a/entities/data/entity_class_data.h +++ b/entities/data/entity_class_data.h @@ -38,7 +38,7 @@ SOFTWARE. #include "../../item_enums.h" -#include "../resources/entity_resource_data.h" +#include "../resources/entity_resource.h" class Aura; class Spell; @@ -72,8 +72,8 @@ public: int get_num_entity_resources(); void set_num_entity_resources(int value); - Ref get_entity_resource(int index) const; - void set_entity_resource(int index, Ref entity_resources); + Ref get_entity_resource(int index) const; + void set_entity_resource(int index, Ref entity_resources); Vector get_entity_resources(); void set_entity_resources(const Vector &entity_resourcess); @@ -152,7 +152,7 @@ private: EntityEnums::EntityClassPlaystyleType _playstyle_type; - Vector > _entity_resources; + Vector > _entity_resources; Vector > _specs; Vector > _spells; Vector > _start_spells; diff --git a/entities/entity.cpp b/entities/entity.cpp index 5e7da1d..f97b249 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -675,22 +675,6 @@ void Entity::_setup() { VRPCOBJ(aura_addc_rpc, JSON::print(ad->to_dict()), aura_addc, ad); } - for (int i = 0; i < _s_resources.size(); ++i) { - Ref res = _s_resources.get(i); - - ERR_CONTINUE(!res.is_valid()); - - res->resolve_references(); - } - - for (int i = 0; i < _c_resources.size(); ++i) { - Ref res = _c_resources.get(i); - - ERR_CONTINUE(!res.is_valid()); - - res->resolve_references(); - } - if (gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY) { if (ESS::get_singleton()->get_use_global_class_level()) { Ref cp = ProfileManager::get_singleton()->getc_player_profile()->get_class_profile(gets_entity_data()->get_path()); @@ -781,22 +765,6 @@ void Entity::_setup() { } } - for (int i = 0; i < _s_resources.size(); ++i) { - Ref res = _s_resources.get(i); - - ERR_CONTINUE(!res.is_valid()); - - res->resolve_references(); - } - - for (int i = 0; i < _c_resources.size(); ++i) { - Ref res = _c_resources.get(i); - - ERR_CONTINUE(!res.is_valid()); - - res->resolve_references(); - } - sets_ai(_s_entity_data->get_ai_instance()); if (!Engine::get_singleton()->is_editor_hint()) @@ -1412,11 +1380,11 @@ void Entity::_from_dict(const Dictionary &dict) { StringName data_path = ird.get("data_path", ""); - Ref resd = ESS::get_singleton()->get_resource_db()->get_entity_resource_path(data_path); + Ref resd = ESS::get_singleton()->get_resource_db()->get_entity_resource_path(data_path); ERR_CONTINUE(!resd.is_valid()); - Ref res = resd->get_entity_resource_instance(); + Ref res = resd->duplicate(true); ERR_CONTINUE(!res.is_valid()); @@ -2413,7 +2381,7 @@ Ref Entity::resource_gets_id(int id) { for (int i = EntityEnums::ENTITY_RESOURCE_INDEX_RESOURCES_BEGIN; i < _s_resources.size(); ++i) { Ref r = _s_resources.get(i); - if (r->get_resource_data()->get_id() == id) { + if (r->get_id() == id) { return r; } } @@ -2484,12 +2452,12 @@ void Entity::resource_addc_rpc(int index, String data) { int data_id = dict.get("data_id", 0); - Ref resd = ESS::get_singleton()->get_resource_db()->get_entity_resource(data_id); + Ref resd = ESS::get_singleton()->get_resource_db()->get_entity_resource(data_id); ERR_FAIL_COND(!resd.is_valid()); - - Ref res = resd->get_entity_resource_instance(); - + print_error("aaa"); + Ref res = resd->duplicate(true); + print_error("bbb"); ERR_FAIL_COND(!res.is_valid()); res->from_dict(dict); @@ -2506,7 +2474,7 @@ Ref Entity::resource_getc_id(int id) { for (int i = EntityEnums::ENTITY_RESOURCE_INDEX_RESOURCES_BEGIN; i < _c_resources.size(); ++i) { Ref r = _c_resources.get(i); - if (r->get_resource_data()->get_id() == id) { + if (r->get_id() == id) { return r; } } diff --git a/entities/resources/entity_resource.cpp b/entities/resources/entity_resource.cpp index 4d81aaa..d96801a 100644 --- a/entities/resources/entity_resource.cpp +++ b/entities/resources/entity_resource.cpp @@ -25,7 +25,20 @@ SOFTWARE. #include "../../database/ess_resource_db.h" #include "../../singletons/ess.h" #include "../entity.h" -#include "entity_resource_data.h" + +int EntityResource::get_id() const { + return _id; +} +void EntityResource::set_id(const int value) { + _id = value; +} + +String EntityResource::get_text_name() const { + return _text_name; +} +void EntityResource::set_text_name(const String value) { + _text_name = value; +} bool EntityResource::get_dirty() const { return _dirty; @@ -41,32 +54,6 @@ void EntityResource::set_should_process(const bool value) { _should_process = value; } -Ref EntityResource::get_resource_data() { - return _data; -} -void EntityResource::set_resource_data(const Ref &value) { - _data = value; - - if (value.is_valid()) { - _data_path = value->get_path(); - } - - _dirty = true; - - emit_signal("changed", Ref(this)); -} - -StringName EntityResource::get_data_path() const { - return _data_path; -} -void EntityResource::set_data_path(const StringName &value) { - _data_path = value; - - _dirty = true; - - emit_signal("changed", Ref(this)); -} - int EntityResource::get_current_value() const { return _current; } @@ -75,7 +62,7 @@ void EntityResource::set_current_value(const int value) { _dirty = true; - emit_signal("changed", Ref(this)); + //emit_signal("changed", Ref(this)); } int EntityResource::get_max_value() const { @@ -86,7 +73,7 @@ void EntityResource::set_max_value(const int value) { _dirty = true; - emit_signal("changed", Ref(this)); + //emit_signal("changed", Ref(this)); } Entity *EntityResource::get_owner() { @@ -164,10 +151,6 @@ void EntityResource::receivec_update_string(const String str) { call("_receivec_update_string", str); } -void EntityResource::resolve_references() { - set_resource_data(ESS::get_singleton()->get_resource_db()->get_entity_resource_path(_data_path)); -} - Dictionary EntityResource::to_dict() { return call("_to_dict"); } @@ -178,11 +161,13 @@ void EntityResource::from_dict(const Dictionary &dict) { Dictionary EntityResource::_to_dict() { Dictionary dict; + dict["data_path"] = ESS::get_singleton()->get_resource_db()->get_entity_resource(_id)->get_path(); + dict["dirty"] = _dirty; dict["should_process"] = _should_process; //dict["data_id"] = _data_id; - dict["data_path"] = _data_path; + //dict["data_path"] = _data_path; dict["current"] = _current; @@ -192,12 +177,11 @@ Dictionary EntityResource::_to_dict() { } void EntityResource::_from_dict(const Dictionary &dict) { ERR_FAIL_COND(dict.empty()); - ERR_FAIL_COND(!ESS::get_singleton()->get_resource_db().is_valid()); _dirty = dict.get("dirty", false); _should_process = dict.get("should_process", false); - _data_path = dict.get("data_path", ""); + //_data_path = dict.get("data_path", ""); //_data_id = ESS::get_singleton()->get_resource_db()->entity_data_path_to_id(_data_path); //_data_id = dict.get("data_id", 0); @@ -206,9 +190,13 @@ void EntityResource::_from_dict(const Dictionary &dict) { } EntityResource::EntityResource() { + _id = 0; + _server_side = false; _dirty = false; + _owner = NULL; + _should_process = has_method("_process"); _current = 0; @@ -216,25 +204,26 @@ EntityResource::EntityResource() { } EntityResource::~EntityResource() { - _data.unref(); + _owner = NULL; } void EntityResource::_bind_methods() { + + ClassDB::bind_method(D_METHOD("get_id"), &EntityResource::get_id); + ClassDB::bind_method(D_METHOD("set_id", "value"), &EntityResource::set_id); + ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); + + ClassDB::bind_method(D_METHOD("get_text_name"), &EntityResource::get_text_name); + ClassDB::bind_method(D_METHOD("set_text_name", "value"), &EntityResource::set_text_name); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_text_name", "get_text_name"); + 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"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dirty", PROPERTY_HINT_NONE, "", 0), "set_dirty", "get_dirty"); 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_data"), &EntityResource::get_resource_data); - ClassDB::bind_method(D_METHOD("set_resource_data", "value"), &EntityResource::set_resource_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityResourceData"), "set_resource_data", "get_resource_data"); - - ClassDB::bind_method(D_METHOD("get_data_path"), &EntityResource::get_data_path); - ClassDB::bind_method(D_METHOD("set_data_path", "value"), &EntityResource::set_data_path); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "data_path"), "set_data_path", "get_data_path"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "should_process", PROPERTY_HINT_NONE, "", 0), "set_should_process", "get_should_process"); ClassDB::bind_method(D_METHOD("get_current_value"), &EntityResource::get_current_value); ClassDB::bind_method(D_METHOD("set_current_value", "value"), &EntityResource::set_current_value); diff --git a/entities/resources/entity_resource.h b/entities/resources/entity_resource.h index fb0399f..210fdb0 100644 --- a/entities/resources/entity_resource.h +++ b/entities/resources/entity_resource.h @@ -26,24 +26,23 @@ SOFTWARE. #include "core/resource.h" class Entity; -class EntityResourceData; class EntityResource : public Resource { GDCLASS(EntityResource, Resource); public: + int get_id() const; + void set_id(const int value); + + String get_text_name() const; + void set_text_name(const String value); + bool get_dirty() const; void set_dirty(const bool value); bool get_should_process() const; void set_should_process(const bool value); - Ref get_resource_data(); - void set_resource_data(const Ref &value); - - StringName get_data_path() const; - void set_data_path(const StringName &value); - int get_current_value() const; void set_current_value(const int value); @@ -73,8 +72,6 @@ public: void receivec_update_full(const int current, const int max); void receivec_update_string(const String str); - virtual void resolve_references(); - Dictionary to_dict(); void from_dict(const Dictionary &dict); @@ -88,15 +85,15 @@ protected: static void _bind_methods(); private: + int _id; + String _text_name; + bool _server_side; Entity *_owner; bool _dirty; bool _should_process; - Ref _data; - StringName _data_path; - int _current; int _max; }; diff --git a/entities/resources/entity_resource_cost_data.h b/entities/resources/entity_resource_cost_data.h index ee30094..0716a38 100644 --- a/entities/resources/entity_resource_cost_data.h +++ b/entities/resources/entity_resource_cost_data.h @@ -25,8 +25,8 @@ SOFTWARE. #include "core/resource.h" +#include "entity_resource.h" #include "entity_resource_cost_data.h" -#include "entity_resource_data.h" class EntityResourceCostData : public Resource { GDCLASS(EntityResourceCostData, Resource); diff --git a/entities/resources/entity_resource_cost_data_health.h b/entities/resources/entity_resource_cost_data_health.h index 713f047..a223393 100644 --- a/entities/resources/entity_resource_cost_data_health.h +++ b/entities/resources/entity_resource_cost_data_health.h @@ -25,8 +25,8 @@ SOFTWARE. #include "core/resource.h" +#include "entity_resource.h" #include "entity_resource_cost_data.h" -#include "entity_resource_data.h" class EntityResourceCostDataHealth : public EntityResourceCostData { GDCLASS(EntityResourceCostDataHealth, EntityResourceCostData); diff --git a/entities/resources/entity_resource_cost_data_resource.cpp b/entities/resources/entity_resource_cost_data_resource.cpp index 50d24c0..b477ae2 100644 --- a/entities/resources/entity_resource_cost_data_resource.cpp +++ b/entities/resources/entity_resource_cost_data_resource.cpp @@ -22,10 +22,10 @@ SOFTWARE. #include "entity_resource_cost_data_resource.h" -Ref EntityResourceCostDataResource::get_entity_resource_data() { +Ref EntityResourceCostDataResource::get_entity_resource_data() { return _entity_resource_data; } -void EntityResourceCostDataResource::set_entity_resource_data(Ref data) { +void EntityResourceCostDataResource::set_entity_resource_data(Ref data) { _entity_resource_data = data; } @@ -35,5 +35,5 @@ EntityResourceCostDataResource::EntityResourceCostDataResource() { void EntityResourceCostDataResource::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entity_resource_data"), &EntityResourceCostDataResource::get_entity_resource_data); ClassDB::bind_method(D_METHOD("set_entity_resource_data", "value"), &EntityResourceCostDataResource::set_entity_resource_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "entity_resource_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityResourceData"), "set_entity_resource_data", "get_entity_resource_data"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "entity_resource_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"), "set_entity_resource_data", "get_entity_resource_data"); } diff --git a/entities/resources/entity_resource_cost_data_resource.h b/entities/resources/entity_resource_cost_data_resource.h index 0721a69..1473cd0 100644 --- a/entities/resources/entity_resource_cost_data_resource.h +++ b/entities/resources/entity_resource_cost_data_resource.h @@ -25,15 +25,15 @@ SOFTWARE. #include "core/resource.h" +#include "entity_resource.h" #include "entity_resource_cost_data.h" -#include "entity_resource_data.h" class EntityResourceCostDataResource : public EntityResourceCostData { GDCLASS(EntityResourceCostDataResource, EntityResourceCostData); public: - Ref get_entity_resource_data(); - void set_entity_resource_data(Ref data); + Ref get_entity_resource_data(); + void set_entity_resource_data(Ref data); EntityResourceCostDataResource(); @@ -41,7 +41,7 @@ protected: static void _bind_methods(); private: - Ref _entity_resource_data; + Ref _entity_resource_data; }; #endif diff --git a/entities/resources/entity_resource_data.cpp b/entities/resources/entity_resource_data.cpp deleted file mode 100644 index 3be6d48..0000000 --- a/entities/resources/entity_resource_data.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright (c) 2019-2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "entity_resource_data.h" - -#include "entity_resource.h" - -int EntityResourceData::get_id() const { - return _id; -} -void EntityResourceData::set_id(const int value) { - _id = value; -} - -String EntityResourceData::get_text_description() const { - return _text_description; -} -void EntityResourceData::set_text_description(const String value) { - _text_description = value; -} - -Ref EntityResourceData::get_entity_resource_instance() { - if (has_method("_get_entity_resource_instance")) { - return call("_get_entity_resource_instance"); - } - - return Ref(); -} - -EntityResourceData::EntityResourceData() { - _id = 0; -} - -void EntityResourceData::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_id"), &EntityResourceData::get_id); - ClassDB::bind_method(D_METHOD("set_id", "value"), &EntityResourceData::set_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); - - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "res", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"), "_get_entity_resource_instance")); - - ClassDB::bind_method(D_METHOD("get_entity_resource_instance"), &EntityResourceData::get_entity_resource_instance); - - ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_name", "get_name"); - - ClassDB::bind_method(D_METHOD("get_text_description"), &EntityResourceData::get_text_description); - ClassDB::bind_method(D_METHOD("set_text_description", "value"), &EntityResourceData::set_text_description); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_description", PROPERTY_HINT_MULTILINE_TEXT), "set_text_description", "get_text_description"); -} diff --git a/entities/resources/entity_resource_data.h b/entities/resources/entity_resource_data.h deleted file mode 100644 index 37f5b24..0000000 --- a/entities/resources/entity_resource_data.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2019-2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef ENTITY_RESOURCE_DATA_H -#define ENTITY_RESOURCE_DATA_H - -#include "core/resource.h" - -#include "core/ustring.h" - -class EntityResource; - -class EntityResourceData : public Resource { - GDCLASS(EntityResourceData, Resource); - -public: - int get_id() const; - void set_id(const int value); - - String get_text_description() const; - void set_text_description(const String value); - - Ref get_entity_resource_instance(); - - EntityResourceData(); - -protected: - static void _bind_methods(); - -private: - int _id; - String _text_description; -}; - -#endif diff --git a/entities/resources/entity_resource_health.cpp b/entities/resources/entity_resource_health.cpp index c41e1c6..15dd20e 100644 --- a/entities/resources/entity_resource_health.cpp +++ b/entities/resources/entity_resource_health.cpp @@ -25,7 +25,7 @@ SOFTWARE. #include "../../database/ess_resource_db.h" #include "../../singletons/ess.h" #include "../entity.h" -#include "entity_resource_data.h" +#include "entity_resource.h" void EntityResourceHealth::_init() { set_current_value(100); diff --git a/entities/resources/entity_resource_health.h b/entities/resources/entity_resource_health.h index 6467eb6..834b08e 100644 --- a/entities/resources/entity_resource_health.h +++ b/entities/resources/entity_resource_health.h @@ -26,7 +26,6 @@ SOFTWARE. #include "entity_resource.h" class Entity; -class EntityResourceData; class EntityResourceHealth : public EntityResource { GDCLASS(EntityResourceHealth, EntityResource); diff --git a/entities/resources/entity_resource_speed.cpp b/entities/resources/entity_resource_speed.cpp index f90d622..dceb5d2 100644 --- a/entities/resources/entity_resource_speed.cpp +++ b/entities/resources/entity_resource_speed.cpp @@ -25,7 +25,7 @@ SOFTWARE. #include "../../database/ess_resource_db.h" #include "../../singletons/ess.h" #include "../entity.h" -#include "entity_resource_data.h" +#include "entity_resource.h" void EntityResourceSpeed::_init() { set_current_value(base_value); diff --git a/entities/resources/entity_resource_speed.h b/entities/resources/entity_resource_speed.h index 60eb5c3..6cc634d 100644 --- a/entities/resources/entity_resource_speed.h +++ b/entities/resources/entity_resource_speed.h @@ -26,7 +26,6 @@ SOFTWARE. #include "entity_resource.h" class Entity; -class EntityResourceData; class EntityResourceSpeed : public EntityResource { GDCLASS(EntityResourceSpeed, EntityResource); diff --git a/register_types.cpp b/register_types.cpp index 60d0366..4578a2b 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -80,7 +80,6 @@ SOFTWARE. #include "entities/resources/entity_resource_cost_data.h" #include "entities/resources/entity_resource_cost_data_health.h" #include "entities/resources/entity_resource_cost_data_resource.h" -#include "entities/resources/entity_resource_data.h" #include "entities/resources/entity_resource_health.h" #include "entities/resources/entity_resource_speed.h" @@ -193,7 +192,6 @@ void register_entity_spell_system_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();