mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Now resource paths are used instead of ids for save files. (They are converted back on load - ids are better for networking) This makes remapping resource ids possible, which makes creating modules (and later mods into zips or pcks) simple.
This commit is contained in:
parent
246f8178eb
commit
089c854c9e
@ -33,10 +33,10 @@ Ref<ItemTemplate> ItemInstance::get_item_template() {
|
||||
void ItemInstance::set_item_template(const Ref<ItemTemplate> &value) {
|
||||
_item_template = value;
|
||||
|
||||
_item_template_id = 0;
|
||||
_item_template_path = "";
|
||||
|
||||
if (value.is_valid())
|
||||
_item_template_id = value->get_id();
|
||||
_item_template_path = value->get_path();
|
||||
}
|
||||
|
||||
Ref<ItemStatModifier> ItemInstance::get_item_stat_modifier(const int index) {
|
||||
@ -94,7 +94,7 @@ void ItemInstance::from_dict(const Dictionary &dict) {
|
||||
Dictionary ItemInstance::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["item_id"] = _item_template->get_id();
|
||||
dict["item_path"] = _item_template->get_path();
|
||||
|
||||
dict["stack_size"] = _stack_size;
|
||||
|
||||
@ -111,10 +111,10 @@ Dictionary ItemInstance::_to_dict() {
|
||||
void ItemInstance::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_item_template_id = dict.get("item_id", 0);
|
||||
_item_template_path = dict.get("item_path", 0);
|
||||
|
||||
if (ESS::get_instance() != NULL) {
|
||||
_item_template = ESS::get_instance()->get_resource_db()->get_item_template(_item_template_id);
|
||||
_item_template = ESS::get_instance()->get_resource_db()->get_item_template_path(_item_template_path);
|
||||
}
|
||||
|
||||
_stack_size = dict.get("stack_size", 0);
|
||||
@ -133,7 +133,6 @@ void ItemInstance::_from_dict(const Dictionary &dict) {
|
||||
|
||||
ItemInstance::ItemInstance() {
|
||||
_stack_size = 1;
|
||||
_item_template_id = 0;
|
||||
_charges = -1;
|
||||
}
|
||||
ItemInstance::~ItemInstance() {
|
||||
|
@ -68,7 +68,7 @@ protected:
|
||||
|
||||
private:
|
||||
Ref<ItemTemplate> _item_template;
|
||||
int _item_template_id;
|
||||
StringName _item_template_path;
|
||||
|
||||
int _stack_size;
|
||||
int _charges;
|
||||
|
@ -43,6 +43,15 @@ void SpeciesInstance::set_species_id(int value) {
|
||||
_species = ESS::get_instance()->get_resource_db()->get_entity_species_data(_id);
|
||||
}
|
||||
|
||||
StringName SpeciesInstance::get_species_path() const {
|
||||
return _path;
|
||||
}
|
||||
void SpeciesInstance::set_species_path(const StringName &value) {
|
||||
_path = value;
|
||||
|
||||
_species = ESS::get_instance()->get_resource_db()->get_entity_species_data_path(_path);
|
||||
}
|
||||
|
||||
Ref<EntitySpeciesData> SpeciesInstance::get_species() {
|
||||
return _species;
|
||||
}
|
||||
@ -50,9 +59,9 @@ void SpeciesInstance::set_species(const Ref<EntitySpeciesData> &value) {
|
||||
_species = value;
|
||||
|
||||
if (_species.is_valid()) {
|
||||
_id = _species->get_id();
|
||||
_path = _species->get_path();
|
||||
} else {
|
||||
_id = 0;
|
||||
_path = "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +104,7 @@ Dictionary SpeciesInstance::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["id"] = _id;
|
||||
dict["species_id"] = _species_id;
|
||||
dict["species_path"] = _path;
|
||||
dict["skin_color_index"] = _skin_color_index;
|
||||
dict["hair_style_index"] = _hair_style_index;
|
||||
dict["_hair_color_index"] = _hair_color_index;
|
||||
@ -107,7 +116,7 @@ void SpeciesInstance::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_id = dict.get("id", 0);
|
||||
set_species_id(dict.get("species_id", 0));
|
||||
set_species_path(dict.get("species_path", ""));
|
||||
_skin_color_index = dict.get("skin_color_index", 0);
|
||||
_hair_style_index = dict.get("hair_style_index", 0);
|
||||
_hair_color_index = dict.get("hair_color_index", 0);
|
||||
@ -115,7 +124,6 @@ void SpeciesInstance::_from_dict(const Dictionary &dict) {
|
||||
}
|
||||
|
||||
SpeciesInstance::SpeciesInstance() {
|
||||
_id = 0;
|
||||
_species_id = 0;
|
||||
_skin_color_index = 0;
|
||||
_hair_style_index = 0;
|
||||
|
@ -39,6 +39,9 @@ public:
|
||||
int get_species_id() const;
|
||||
void set_species_id(const int value);
|
||||
|
||||
StringName get_species_path() const;
|
||||
void set_species_path(const StringName &value);
|
||||
|
||||
Ref<EntitySpeciesData> get_species();
|
||||
void set_species(const Ref<EntitySpeciesData> &value);
|
||||
|
||||
@ -68,6 +71,7 @@ protected:
|
||||
|
||||
private:
|
||||
int _id;
|
||||
StringName _path;
|
||||
int _species_id;
|
||||
Ref<EntitySpeciesData> _species;
|
||||
int _skin_color_index;
|
||||
|
@ -56,6 +56,10 @@ void ESSResourceDB::add_entity_resource(Ref<EntityResourceData> cls) {
|
||||
_entity_resources_path_to_id.set(cls->get_path(), cls->get_id());
|
||||
}
|
||||
|
||||
Ref<EntityResourceData> ESSResourceDB::get_entity_resource_path(const StringName &path) {
|
||||
return get_entity_resource(entity_resource_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_entity_skill(Ref<EntitySkillData> cls) {
|
||||
if (!cls.is_valid())
|
||||
return;
|
||||
@ -64,6 +68,10 @@ void ESSResourceDB::add_entity_skill(Ref<EntitySkillData> cls) {
|
||||
_entity_skill_path_to_id.set(cls->get_path(), cls->get_id());
|
||||
}
|
||||
|
||||
Ref<EntitySkillData> ESSResourceDB::get_entity_skill_path(const StringName &path) {
|
||||
return get_entity_skill(entity_skill_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_entity_data(Ref<EntityData> cls) {
|
||||
if (!cls.is_valid())
|
||||
return;
|
||||
@ -72,6 +80,10 @@ void ESSResourceDB::add_entity_data(Ref<EntityData> cls) {
|
||||
_entity_data_path_to_id.set(cls->get_path(), cls->get_id());
|
||||
}
|
||||
|
||||
Ref<EntityData> ESSResourceDB::get_entity_data_path(const StringName &path) {
|
||||
return get_entity_data(entity_data_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_spell(Ref<Spell> spell) {
|
||||
if (!spell.is_valid())
|
||||
return;
|
||||
@ -80,6 +92,10 @@ void ESSResourceDB::add_spell(Ref<Spell> spell) {
|
||||
_spell_path_to_id.set(spell->get_path(), spell->get_id());
|
||||
}
|
||||
|
||||
Ref<Spell> ESSResourceDB::get_spell_path(const StringName &path) {
|
||||
return get_spell(spell_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_aura(Ref<Aura> aura) {
|
||||
if (!aura.is_valid())
|
||||
return;
|
||||
@ -88,6 +104,10 @@ void ESSResourceDB::add_aura(Ref<Aura> aura) {
|
||||
_aura_path_to_id.set(aura->get_path(), aura->get_id());
|
||||
}
|
||||
|
||||
Ref<Aura> ESSResourceDB::get_aura_path(const StringName &path) {
|
||||
return get_aura(aura_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_craft_recipe(Ref<CraftRecipe> cda) {
|
||||
if (!cda.is_valid())
|
||||
return;
|
||||
@ -96,6 +116,10 @@ void ESSResourceDB::add_craft_recipe(Ref<CraftRecipe> cda) {
|
||||
_craft_recipe_path_to_id.set(cda->get_path(), cda->get_id());
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> ESSResourceDB::get_craft_recipe_path(const StringName &path) {
|
||||
return get_craft_recipe(craft_recipe_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_item_template(Ref<ItemTemplate> cda) {
|
||||
if (!cda.is_valid())
|
||||
return;
|
||||
@ -104,6 +128,10 @@ void ESSResourceDB::add_item_template(Ref<ItemTemplate> cda) {
|
||||
_item_template_path_to_id.set(cda->get_path(), cda->get_id());
|
||||
}
|
||||
|
||||
Ref<ItemTemplate> ESSResourceDB::get_item_template_path(const StringName &path) {
|
||||
return get_item_template(item_template_path_to_id(path));
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_entity_species_data(Ref<EntitySpeciesData> cda) {
|
||||
if (!cda.is_valid())
|
||||
return;
|
||||
@ -112,6 +140,10 @@ void ESSResourceDB::add_entity_species_data(Ref<EntitySpeciesData> cda) {
|
||||
_entity_species_path_to_id.set(cda->get_path(), cda->get_id());
|
||||
}
|
||||
|
||||
Ref<EntitySpeciesData> ESSResourceDB::get_entity_species_data_path(const StringName &path) {
|
||||
return get_entity_species_data(entity_species_path_to_id(path));
|
||||
}
|
||||
|
||||
StringName ESSResourceDB::entity_resource_id_to_path(const int id) const {
|
||||
ERR_FAIL_COND_V(!_entity_resources_id_to_path.has(id), StringName());
|
||||
|
||||
@ -300,6 +332,8 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resource_count"), &ESSResourceDB::get_entity_resource_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resources"), &ESSResourceDB::get_entity_resources);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_resources", "recipe"), &ESSResourceDB::set_entity_resources);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resource_path", "path"), &ESSResourceDB::get_entity_resource_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_resource_id_to_path", "id"), &ESSResourceDB::entity_resource_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_resource_path_to_id", "path"), &ESSResourceDB::entity_resource_path_to_id);
|
||||
|
||||
@ -310,6 +344,8 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill_count"), &ESSResourceDB::get_entity_skill_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skills"), &ESSResourceDB::get_entity_skills);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_skills", "recipe"), &ESSResourceDB::set_entity_skills);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill_path", "path"), &ESSResourceDB::get_entity_skill_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_skill_id_to_path", "id"), &ESSResourceDB::entity_skill_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_skill_path_to_id", "path"), &ESSResourceDB::entity_skill_path_to_id);
|
||||
|
||||
@ -320,6 +356,8 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &ESSResourceDB::get_entity_data_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_datas"), &ESSResourceDB::get_entity_datas);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_datas", "recipe"), &ESSResourceDB::set_entity_skills);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_path", "path"), &ESSResourceDB::get_entity_data_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_data_id_to_path", "id"), &ESSResourceDB::entity_data_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_data_path_to_id", "path"), &ESSResourceDB::entity_data_path_to_id);
|
||||
|
||||
@ -330,6 +368,8 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_spell_count"), &ESSResourceDB::get_spell_count);
|
||||
ClassDB::bind_method(D_METHOD("get_spells"), &ESSResourceDB::get_spells);
|
||||
ClassDB::bind_method(D_METHOD("set_spells", "recipe"), &ESSResourceDB::set_spells);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_spell_path", "path"), &ESSResourceDB::get_spell_path);
|
||||
ClassDB::bind_method(D_METHOD("spell_id_to_path", "id"), &ESSResourceDB::spell_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("spell_path_to_id", "path"), &ESSResourceDB::spell_path_to_id);
|
||||
|
||||
@ -340,6 +380,8 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_aura_count"), &ESSResourceDB::get_aura_count);
|
||||
ClassDB::bind_method(D_METHOD("get_auras"), &ESSResourceDB::get_auras);
|
||||
ClassDB::bind_method(D_METHOD("set_auras", "recipe"), &ESSResourceDB::set_auras);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_aura_path", "path"), &ESSResourceDB::get_aura_path);
|
||||
ClassDB::bind_method(D_METHOD("aura_id_to_path", "id"), &ESSResourceDB::aura_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("aura_path_to_id", "path"), &ESSResourceDB::aura_path_to_id);
|
||||
|
||||
@ -350,6 +392,8 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe_count"), &ESSResourceDB::get_craft_recipe_count);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipes"), &ESSResourceDB::get_craft_recipes);
|
||||
ClassDB::bind_method(D_METHOD("set_craft_recipes", "recipe"), &ESSResourceDB::set_craft_recipes);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe_path", "path"), &ESSResourceDB::get_craft_recipe_path);
|
||||
ClassDB::bind_method(D_METHOD("craft_recipe_id_to_path", "id"), &ESSResourceDB::craft_recipe_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("craft_recipe_path_to_id", "path"), &ESSResourceDB::craft_recipe_path_to_id);
|
||||
|
||||
@ -360,16 +404,20 @@ void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_item_template_count"), &ESSResourceDB::get_item_template_count);
|
||||
ClassDB::bind_method(D_METHOD("get_item_templates"), &ESSResourceDB::get_item_templates);
|
||||
ClassDB::bind_method(D_METHOD("set_item_templates", "recipe"), &ESSResourceDB::set_item_templates);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_template_path", "path"), &ESSResourceDB::get_item_template_path);
|
||||
ClassDB::bind_method(D_METHOD("item_template_id_to_path", "id"), &ESSResourceDB::item_template_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("item_template_path_to_id", "path"), &ESSResourceDB::item_template_path_to_id);
|
||||
|
||||
//Player Character Data
|
||||
//Entity Species
|
||||
ClassDB::bind_method(D_METHOD("add_entity_species_data", "pcd"), &ESSResourceDB::add_entity_species_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data", "pcd_id"), &ESSResourceDB::get_entity_species_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data_index", "index"), &ESSResourceDB::get_entity_species_data_index);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data_count"), &ESSResourceDB::get_entity_species_data_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_datas"), &ESSResourceDB::get_entity_species_datas);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_species_datas", "recipe"), &ESSResourceDB::set_entity_species_datas);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data_path", "path"), &ESSResourceDB::get_entity_species_data_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_species_id_to_path", "id"), &ESSResourceDB::entity_species_id_to_path);
|
||||
ClassDB::bind_method(D_METHOD("entity_species_path_to_id", "path"), &ESSResourceDB::entity_species_path_to_id);
|
||||
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
virtual void add_entity_resource(Ref<EntityResourceData> cls);
|
||||
virtual Vector<Variant> get_entity_resources() const = 0;
|
||||
virtual void set_entity_resources(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<EntityResourceData> 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;
|
||||
|
||||
@ -74,6 +76,8 @@ public:
|
||||
virtual void add_entity_skill(Ref<EntitySkillData> cls);
|
||||
virtual Vector<Variant> get_entity_skills() const = 0;
|
||||
virtual void set_entity_skills(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<EntitySkillData> get_entity_skill_path(const StringName &path);
|
||||
StringName entity_skill_id_to_path(const int id) const;
|
||||
int entity_skill_path_to_id(const StringName &path) const;
|
||||
|
||||
@ -83,6 +87,8 @@ public:
|
||||
virtual void add_entity_data(Ref<EntityData> cls);
|
||||
virtual Vector<Variant> get_entity_datas() const = 0;
|
||||
virtual void set_entity_datas(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<EntityData> get_entity_data_path(const StringName &path);
|
||||
StringName entity_data_id_to_path(const int id) const;
|
||||
int entity_data_path_to_id(const StringName &path) const;
|
||||
|
||||
@ -92,6 +98,8 @@ public:
|
||||
virtual void add_spell(Ref<Spell> spell);
|
||||
virtual Vector<Variant> get_spells() const = 0;
|
||||
virtual void set_spells(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<Spell> get_spell_path(const StringName &path);
|
||||
StringName spell_id_to_path(const int id) const;
|
||||
int spell_path_to_id(const StringName &path) const;
|
||||
|
||||
@ -101,6 +109,8 @@ public:
|
||||
virtual void add_aura(Ref<Aura> aura);
|
||||
virtual Vector<Variant> get_auras() const = 0;
|
||||
virtual void set_auras(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<Aura> get_aura_path(const StringName &path);
|
||||
StringName aura_id_to_path(const int id) const;
|
||||
int aura_path_to_id(const StringName &path) const;
|
||||
|
||||
@ -110,6 +120,8 @@ public:
|
||||
virtual void add_craft_recipe(Ref<CraftRecipe> aura);
|
||||
virtual Vector<Variant> get_craft_recipes() const = 0;
|
||||
virtual void set_craft_recipes(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<CraftRecipe> get_craft_recipe_path(const StringName &path);
|
||||
StringName craft_recipe_id_to_path(const int id) const;
|
||||
int craft_recipe_path_to_id(const StringName &path) const;
|
||||
|
||||
@ -119,6 +131,8 @@ public:
|
||||
virtual int get_item_template_count() = 0;
|
||||
virtual Vector<Variant> get_item_templates() const = 0;
|
||||
virtual void set_item_templates(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<ItemTemplate> get_item_template_path(const StringName &path);
|
||||
StringName item_template_id_to_path(const int id) const;
|
||||
int item_template_path_to_id(const StringName &path) const;
|
||||
|
||||
@ -128,6 +142,8 @@ public:
|
||||
virtual int get_entity_species_data_count() = 0;
|
||||
virtual Vector<Variant> get_entity_species_datas() const = 0;
|
||||
virtual void set_entity_species_datas(const Vector<Variant> &data) = 0;
|
||||
|
||||
Ref<EntitySpeciesData> get_entity_species_data_path(const StringName &path);
|
||||
StringName entity_species_id_to_path(const int id) const;
|
||||
int entity_species_path_to_id(const StringName &path) const;
|
||||
|
||||
|
@ -165,6 +165,11 @@ Ref<Aura> AuraData::get_aura() {
|
||||
|
||||
void AuraData::set_aura(Ref<Aura> aura) {
|
||||
_aura = aura;
|
||||
|
||||
if (aura.is_valid())
|
||||
_aura_path = aura->get_path();
|
||||
else
|
||||
_aura_path = "";
|
||||
}
|
||||
|
||||
int AuraData::get_damage() {
|
||||
@ -283,6 +288,7 @@ Dictionary AuraData::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["aura_id"] = _aura_id;
|
||||
dict["aura_path"] = _aura_path;
|
||||
dict["remaining_time"] = _remaining_time;
|
||||
dict["caster_path"] = _caster_path;
|
||||
|
||||
@ -304,21 +310,19 @@ Dictionary AuraData::_to_dict() {
|
||||
}
|
||||
void AuraData::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
ERR_FAIL_COND(!ESS::get_instance()->get_resource_db().is_valid());
|
||||
|
||||
_aura_id = dict.get("aura_id", 0);
|
||||
_aura_path = dict.get("aura_path", "");
|
||||
_remaining_time = dict.get("remaining_time", 0);
|
||||
_caster_path = dict.get("caster_path", NodePath());
|
||||
|
||||
_spell_scale = dict.get("spell_scale", 0);
|
||||
|
||||
_aura_group = dict.get("aura_group", 0);
|
||||
int aura_id = dict.get("aura_id", 0);
|
||||
//int aura_id = dict.get("aura_id", 0);
|
||||
|
||||
Ref<Aura> aura = ESS::get_instance()->get_resource_db()->get_aura(aura_id);
|
||||
|
||||
if (aura.is_valid()) {
|
||||
_aura = aura;
|
||||
}
|
||||
_aura = ESS::get_instance()->get_resource_db()->get_aura_path(_aura_path);
|
||||
|
||||
_is_timed = dict.get("is_timed", true);
|
||||
_damage = dict.get("damage", 0);
|
||||
|
@ -111,6 +111,7 @@ protected:
|
||||
private:
|
||||
Entity *_owner;
|
||||
int _aura_id;
|
||||
StringName _aura_path;
|
||||
float _remaining_time;
|
||||
Entity *_caster;
|
||||
NodePath _caster_path;
|
||||
|
@ -380,6 +380,13 @@ void Entity::setc_entity_data_id(int value) {
|
||||
}
|
||||
}
|
||||
|
||||
StringName Entity::gets_entity_data_path() {
|
||||
return _s_entity_data_path;
|
||||
}
|
||||
void Entity::sets_entity_data_path(const StringName &value) {
|
||||
_s_entity_data_path = value;
|
||||
}
|
||||
|
||||
Ref<EntityData> Entity::gets_entity_data() {
|
||||
return _s_entity_data;
|
||||
}
|
||||
@ -973,9 +980,9 @@ Dictionary Entity::_to_dict() {
|
||||
dict["seed"] = _s_seed;
|
||||
|
||||
if (_s_entity_data.is_valid())
|
||||
dict["entity_data_id"] = _s_entity_data->get_id();
|
||||
dict["entity_data_path"] = _s_entity_data->get_path();
|
||||
else
|
||||
dict["entity_data_id"] = 0;
|
||||
dict["entity_data_path"] = _s_entity_data_path;
|
||||
|
||||
//dict["send_flag"] = _s_send_flag;
|
||||
dict["entity_name"] = _s_entity_name;
|
||||
@ -1096,7 +1103,7 @@ Dictionary Entity::_to_dict() {
|
||||
Dictionary known_recipes;
|
||||
|
||||
for (int i = 0; i < _s_craft_recipes.size(); ++i) {
|
||||
known_recipes[i] = _s_craft_recipes.get(i)->get_id();
|
||||
known_recipes[i] = _s_craft_recipes.get(i)->get_path();
|
||||
}
|
||||
|
||||
dict["known_recipes"] = known_recipes;
|
||||
@ -1109,7 +1116,7 @@ Dictionary Entity::_to_dict() {
|
||||
Dictionary known_spells;
|
||||
|
||||
for (int i = 0; i < _s_spells.size(); ++i) {
|
||||
known_spells[i] = _s_spells.get(i)->get_id();
|
||||
known_spells[i] = _s_spells.get(i)->get_path();
|
||||
}
|
||||
|
||||
dict["known_spells"] = known_spells;
|
||||
@ -1199,9 +1206,9 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
for (int i = 0; i < rd.size(); ++i) {
|
||||
Dictionary ird = rd.get(String::num(i), Dictionary());
|
||||
|
||||
int data_id = ird.get("data_id", 0);
|
||||
StringName data_path = ird.get("data_path", "");
|
||||
|
||||
Ref<EntityResourceData> resd = ESS::get_instance()->get_resource_db()->get_entity_resource(data_id);
|
||||
Ref<EntityResourceData> resd = ESS::get_instance()->get_resource_db()->get_entity_resource_path(data_path);
|
||||
|
||||
ERR_CONTINUE(!resd.is_valid());
|
||||
|
||||
@ -1329,10 +1336,10 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
Dictionary known_recipes = dict.get("known_recipes", Dictionary());
|
||||
|
||||
for (int i = 0; i < known_recipes.size(); ++i) {
|
||||
int crid = known_recipes.get(String::num(i), 0);
|
||||
StringName crn = known_recipes.get(String::num(i), "");
|
||||
|
||||
if (ESS::get_instance() != NULL) {
|
||||
Ref<CraftRecipe> cr = ESS::get_instance()->get_resource_db()->get_craft_recipe(crid);
|
||||
Ref<CraftRecipe> cr = ESS::get_instance()->get_resource_db()->get_craft_recipe_path(crn);
|
||||
|
||||
if (cr.is_valid()) {
|
||||
adds_craft_recipe(cr);
|
||||
@ -1348,10 +1355,10 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
Dictionary known_spells = dict.get("known_spells", Dictionary());
|
||||
|
||||
for (int i = 0; i < known_spells.size(); ++i) {
|
||||
int spell_id = known_spells.get(String::num(i), 0);
|
||||
StringName spell_path = known_spells.get(String::num(i), "");
|
||||
|
||||
if (ESS::get_instance() != NULL) {
|
||||
Ref<Spell> sp = ESS::get_instance()->get_resource_db()->get_spell(spell_id);
|
||||
Ref<Spell> sp = ESS::get_instance()->get_resource_db()->get_spell_path(spell_path);
|
||||
|
||||
if (sp.is_valid()) {
|
||||
_s_spells.push_back(sp);
|
||||
@ -1396,13 +1403,13 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
_actionbar_locked = dict.get("actionbar_locked", false);
|
||||
//_action_bar_profile->from_dict(dict.get("actionbar_profile", Dictionary()));
|
||||
|
||||
int edi = dict.get("entity_data_id", 0);
|
||||
StringName edp = dict.get("entity_data_path", "");
|
||||
|
||||
if (ESS::get_instance() != NULL) {
|
||||
sets_entity_data(ESS::get_instance()->get_resource_db()->get_entity_data(edi));
|
||||
sets_entity_data(ESS::get_instance()->get_resource_db()->get_entity_data_path(edp));
|
||||
}
|
||||
|
||||
sets_entity_data_id(edi);
|
||||
sets_entity_data_path(edp);
|
||||
}
|
||||
|
||||
////// Stat System //////
|
||||
@ -2084,7 +2091,7 @@ Ref<EntityResource> Entity::gets_resource_id(int id) {
|
||||
for (int i = 0; i < _s_resources.size(); ++i) {
|
||||
Ref<EntityResource> r = _s_resources.get(i);
|
||||
|
||||
if (r->get_data_id() == id) {
|
||||
if (r->get_resource_data()->get_id() == id) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@ -2177,7 +2184,7 @@ Ref<EntityResource> Entity::getc_resource_id(int id) {
|
||||
for (int i = 0; i < _c_resources.size(); ++i) {
|
||||
Ref<EntityResource> r = _c_resources.get(i);
|
||||
|
||||
if (r->get_data_id() == id) {
|
||||
if (r->get_resource_data()->get_id() == id) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,13 @@ SOFTWARE.
|
||||
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#include "core/io/json.h"
|
||||
#include "../data/entities/xp_data.h"
|
||||
#include "../data/items/craft_recipe.h"
|
||||
#include "../data/items/item_instance.h"
|
||||
#include "../data/spells/spell.h"
|
||||
#include "./data/entity_data.h"
|
||||
#include "core/hash_map.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/object.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/vector.h"
|
||||
@ -299,6 +299,12 @@ public:
|
||||
int getc_entity_data_id();
|
||||
void setc_entity_data_id(int value);
|
||||
|
||||
StringName gets_entity_data_path();
|
||||
void sets_entity_data_path(const StringName &value);
|
||||
|
||||
StringName getc_entity_data_path();
|
||||
void setc_entity_data_path(const StringName &value);
|
||||
|
||||
EntityEnums::AIStates gets_ai_state() const;
|
||||
void sets_ai_state(EntityEnums::AIStates state);
|
||||
|
||||
@ -1026,6 +1032,8 @@ private:
|
||||
int _s_class_id;
|
||||
int _c_class_id;
|
||||
|
||||
StringName _s_entity_data_path;
|
||||
|
||||
int _s_entity_player_type;
|
||||
int _c_entity_player_type;
|
||||
|
||||
|
@ -48,16 +48,20 @@ Ref<EntityResourceData> EntityResource::get_resource_data() {
|
||||
void EntityResource::set_resource_data(const Ref<EntityResourceData> &value) {
|
||||
_data = value;
|
||||
|
||||
if (value.is_valid()) {
|
||||
_data_path = value->get_path();
|
||||
}
|
||||
|
||||
_dirty = true;
|
||||
|
||||
emit_signal("changed", Ref<EntityResource>(this));
|
||||
}
|
||||
|
||||
int EntityResource::get_data_id() const {
|
||||
return _data_id;
|
||||
StringName EntityResource::get_data_path() const {
|
||||
return _data_path;
|
||||
}
|
||||
void EntityResource::set_data_id(const int value) {
|
||||
_data_id = value;
|
||||
void EntityResource::set_data_path(const StringName &value) {
|
||||
_data_path = value;
|
||||
|
||||
_dirty = true;
|
||||
|
||||
@ -162,7 +166,7 @@ void EntityResource::receivec_update_string(const String str) {
|
||||
}
|
||||
|
||||
void EntityResource::resolve_references() {
|
||||
set_resource_data(ESS::get_instance()->get_resource_db()->get_entity_resource(_data_id));
|
||||
set_resource_data(ESS::get_instance()->get_resource_db()->get_entity_resource_path(_data_path));
|
||||
}
|
||||
|
||||
Dictionary EntityResource::to_dict() {
|
||||
@ -178,7 +182,9 @@ Dictionary EntityResource::_to_dict() {
|
||||
dict["dirty"] = _dirty;
|
||||
dict["should_process"] = _should_process;
|
||||
|
||||
dict["data_id"] = _data_id;
|
||||
//dict["data_id"] = _data_id;
|
||||
dict["data_path"] = _data_path;
|
||||
|
||||
dict["current"] = _current;
|
||||
|
||||
dict["max"] = _max;
|
||||
@ -187,10 +193,15 @@ Dictionary EntityResource::_to_dict() {
|
||||
}
|
||||
void EntityResource::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
ERR_FAIL_COND(!ESS::get_instance()->get_resource_db().is_valid());
|
||||
|
||||
_dirty = dict.get("dirty", false);
|
||||
_should_process = dict.get("should_process", false);
|
||||
_data_id = dict.get("data_id", 0);
|
||||
|
||||
_data_path = dict.get("data_path", "");
|
||||
//_data_id = ESS::get_instance()->get_resource_db()->entity_data_path_to_id(_data_path);
|
||||
|
||||
//_data_id = dict.get("data_id", 0);
|
||||
_current = dict.get("current", 0);
|
||||
_max = dict.get("max", 0);
|
||||
}
|
||||
@ -201,7 +212,6 @@ EntityResource::EntityResource() {
|
||||
|
||||
_should_process = has_method("_process");
|
||||
|
||||
_data_id = 0;
|
||||
_current = 0;
|
||||
_max = 0;
|
||||
}
|
||||
@ -223,9 +233,9 @@ void EntityResource::_bind_methods() {
|
||||
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_id"), &EntityResource::get_data_id);
|
||||
ClassDB::bind_method(D_METHOD("set_data_id", "value"), &EntityResource::set_data_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "data_id"), "set_data_id", "get_data_id");
|
||||
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::INT, "data_path"), "set_data_path", "get_data_path");
|
||||
|
||||
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);
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
Ref<EntityResourceData> get_resource_data();
|
||||
void set_resource_data(const Ref<EntityResourceData> &value);
|
||||
|
||||
int get_data_id() const;
|
||||
void set_data_id(const int 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);
|
||||
@ -96,7 +96,7 @@ private:
|
||||
bool _should_process;
|
||||
|
||||
Ref<EntityResourceData> _data;
|
||||
int _data_id;
|
||||
StringName _data_path;
|
||||
|
||||
int _current;
|
||||
int _max;
|
||||
|
@ -31,10 +31,13 @@ Ref<EntitySkillData> EntitySkill::get_skill() {
|
||||
void EntitySkill::set_skill(Ref<EntitySkillData> value) {
|
||||
_skill = value;
|
||||
|
||||
if (_skill.is_valid())
|
||||
if (_skill.is_valid()) {
|
||||
_skill_id = _skill->get_id();
|
||||
else
|
||||
_skill_path = _skill->get_path();
|
||||
} else {
|
||||
_skill_id = 0;
|
||||
_skill_path = "";
|
||||
}
|
||||
|
||||
emit_signal("skill_changed", Ref<EntitySkill>(this));
|
||||
}
|
||||
@ -90,6 +93,7 @@ Dictionary EntitySkill::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["skill_id"] = _skill_id;
|
||||
dict["skill_path"] = _skill_path;
|
||||
dict["current"] = _current;
|
||||
dict["max"] = _max;
|
||||
dict["disabled"] = _disabled;
|
||||
@ -100,6 +104,7 @@ void EntitySkill::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_skill_id = dict.get("skill_id", 0);
|
||||
_skill_path = dict.get("skill_path", "");
|
||||
_current = dict.get("current", 0);
|
||||
_max = dict.get("max", 0);
|
||||
_disabled = dict.get("disabled", true);
|
||||
|
@ -60,6 +60,7 @@ protected:
|
||||
private:
|
||||
Ref<EntitySkillData> _skill;
|
||||
int _skill_id;
|
||||
StringName _skill_path;
|
||||
int _current;
|
||||
int _max;
|
||||
bool _disabled;
|
||||
|
@ -22,6 +22,9 @@ SOFTWARE.
|
||||
|
||||
#include "cooldown.h"
|
||||
|
||||
#include "../database/ess_resource_db.h"
|
||||
#include "../singletons/ess.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
@ -66,15 +69,19 @@ void Cooldown::from_dict(const Dictionary &dict) {
|
||||
Dictionary Cooldown::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["spell_id"] = _spell_id;
|
||||
//dict["spell_id"] = _spell_id;
|
||||
dict["spell_path"] = ESS::get_instance()->get_resource_db()->spell_id_to_path(_spell_id);
|
||||
dict["remaining"] = _remaining;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void Cooldown::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
ERR_FAIL_COND(!ESS::get_instance()->get_resource_db().is_valid());
|
||||
|
||||
_spell_id = dict.get("spell_id", 0);
|
||||
StringName spell_path = dict.get("spell_path", "");
|
||||
//_spell_id = dict.get("spell_id", 0);
|
||||
_spell_id = ESS::get_instance()->get_resource_db()->spell_path_to_id(spell_path);
|
||||
_remaining = dict.get("remaining", 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user