mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
Moved the data out from EntityDataManager into a new ESSResourceDB class (Resource). The DataManager now stores an instance of this new resource instead.
This commit is contained in:
parent
d8ea28e221
commit
3cb26816d2
2
SCsub
2
SCsub
@ -118,6 +118,8 @@ sources = [
|
||||
"singletons/profile_manager.cpp",
|
||||
"singletons/entity_data_manager.cpp",
|
||||
|
||||
"database/ess_resource_db.cpp",
|
||||
|
||||
"editor/ess_editor_plugin.cpp",
|
||||
]
|
||||
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
|
||||
#include "item_template.h"
|
||||
|
||||
#include "../../database/ess_resource_db.h"
|
||||
#include "../../singletons/entity_data_manager.h"
|
||||
|
||||
Ref<ItemTemplate> ItemInstance::get_item_template() {
|
||||
@ -113,7 +114,7 @@ void ItemInstance::_from_dict(const Dictionary &dict) {
|
||||
_item_template_id = dict.get("item_id", 0);
|
||||
|
||||
if (EntityDataManager::get_instance() != NULL) {
|
||||
_item_template = EntityDataManager::get_instance()->get_item_template(_item_template_id);
|
||||
_item_template = EntityDataManager::get_instance()->get_resource_db()->get_item_template(_item_template_id);
|
||||
}
|
||||
|
||||
_stack_size = dict.get("stack_size", 0);
|
||||
|
@ -22,6 +22,7 @@ SOFTWARE.
|
||||
|
||||
#include "species_instance.h"
|
||||
|
||||
#include "../../database/ess_resource_db.h"
|
||||
#include "../../singletons/entity_data_manager.h"
|
||||
|
||||
#include "entity_species_data.h"
|
||||
@ -39,7 +40,7 @@ int SpeciesInstance::get_species_id() const {
|
||||
void SpeciesInstance::set_species_id(int value) {
|
||||
_id = value;
|
||||
|
||||
_species = EntityDataManager::get_instance()->get_entity_species_data(_id);
|
||||
_species = EntityDataManager::get_instance()->get_resource_db()->get_entity_species_data(_id);
|
||||
}
|
||||
|
||||
Ref<EntitySpeciesData> SpeciesInstance::get_species() {
|
||||
|
668
database/ess_resource_db.cpp
Normal file
668
database/ess_resource_db.cpp
Normal file
@ -0,0 +1,668 @@
|
||||
/*
|
||||
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 "ess_resource_db.h"
|
||||
|
||||
#include "../data/auras/aura.h"
|
||||
#include "../data/items/craft_recipe.h"
|
||||
#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/skills/entity_skill_data.h"
|
||||
|
||||
bool ESSResourceDB::get_automatic_load() const {
|
||||
return _automatic_load;
|
||||
}
|
||||
void ESSResourceDB::set_automatic_load(const bool load) {
|
||||
_automatic_load = load;
|
||||
}
|
||||
|
||||
bool ESSResourceDB::get_load_folders() const {
|
||||
return _load_folders;
|
||||
}
|
||||
void ESSResourceDB::set_load_folders(const bool load) {
|
||||
_load_folders = load;
|
||||
}
|
||||
|
||||
Ref<Aura> ESSResourceDB::get_skill_for_armor_type(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, ItemEnums::ARMOR_TYPE_MAX, Ref<Aura>());
|
||||
|
||||
return _armor_type_skills[index];
|
||||
}
|
||||
void ESSResourceDB::set_skill_for_armor_type(const int index, const Ref<Aura> &aura) {
|
||||
ERR_FAIL_INDEX(index, ItemEnums::ARMOR_TYPE_MAX);
|
||||
|
||||
_armor_type_skills[index] = aura;
|
||||
}
|
||||
|
||||
String ESSResourceDB::get_xp_data_path() {
|
||||
return _xp_data_path;
|
||||
}
|
||||
void ESSResourceDB::set_xp_data_path(String path) {
|
||||
_xp_data_path = path;
|
||||
}
|
||||
Ref<XPData> ESSResourceDB::get_xp_data() {
|
||||
return _xp_data;
|
||||
}
|
||||
|
||||
PoolStringArray ESSResourceDB::get_folders() const {
|
||||
return _folders;
|
||||
}
|
||||
void ESSResourceDB::set_folders(const PoolStringArray &data) {
|
||||
_folders = data;
|
||||
}
|
||||
|
||||
Ref<EntityResourceData> ESSResourceDB::get_entity_resource(int class_id) {
|
||||
//ERR_FAIL_COND_V_MSG(!_entity_resource_map.has(class_id), Ref<EntityResourceData>(), "Could not find EntityResourceData! Id:" + String::num(class_id));
|
||||
|
||||
if (!_entity_resource_map.has(class_id)) {
|
||||
return Ref<EntityResourceData>();
|
||||
}
|
||||
|
||||
return _entity_resource_map.get(class_id);
|
||||
}
|
||||
Ref<EntityResourceData> ESSResourceDB::get_entity_resource_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref<EntityResourceData>(NULL));
|
||||
|
||||
return _entity_resources.get(index);
|
||||
}
|
||||
int ESSResourceDB::get_entity_resource_count() {
|
||||
return _entity_resources.size();
|
||||
}
|
||||
void ESSResourceDB::add_entity_resource(const Ref<EntityResourceData> &cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_resources.push_back(cls);
|
||||
_entity_resource_map.set(cls->get_id(), cls);
|
||||
}
|
||||
Vector<Variant> ESSResourceDB::get_entity_resources() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_resources.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_resources[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_resources[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_entity_resources(const Vector<Variant> &data) {
|
||||
_entity_resources.clear();
|
||||
_entity_resource_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntityResource> d = Ref<EntityResource>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_entity_resource(d);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EntitySkillData> ESSResourceDB::get_entity_skill(int class_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_entity_skill_map.has(class_id), Ref<EntitySkillData>(), "Could not find EntitySkillData! Id:" + String::num(class_id));
|
||||
|
||||
return _entity_skill_map.get(class_id);
|
||||
}
|
||||
Ref<EntitySkillData> ESSResourceDB::get_entity_skill_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_skills.size(), Ref<EntitySkillData>(NULL));
|
||||
|
||||
return _entity_skills.get(index);
|
||||
}
|
||||
int ESSResourceDB::get_entity_skill_count() {
|
||||
return _entity_skills.size();
|
||||
}
|
||||
void ESSResourceDB::add_entity_skill(const Ref<EntitySkillData> &cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_skills.push_back(cls);
|
||||
_entity_skill_map.set(cls->get_id(), cls);
|
||||
}
|
||||
Vector<Variant> ESSResourceDB::get_entity_skills() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_skills.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_skills[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_skills[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_entity_skills(const Vector<Variant> &data) {
|
||||
_entity_skills.clear();
|
||||
_entity_skill_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntitySkillData> d = Ref<EntitySkillData>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_entity_skill(d);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EntityData> ESSResourceDB::get_entity_data(int class_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_entity_data_map.has(class_id), Ref<EntityData>(), "Could not find EntityData! Id:" + String::num(class_id));
|
||||
|
||||
return _entity_data_map.get(class_id);
|
||||
}
|
||||
Ref<EntityData> ESSResourceDB::get_entity_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>(NULL));
|
||||
|
||||
return _entity_datas.get(index);
|
||||
}
|
||||
int ESSResourceDB::get_entity_data_count() {
|
||||
return _entity_datas.size();
|
||||
}
|
||||
void ESSResourceDB::add_entity_data(const Ref<EntityData> &cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_datas.push_back(cls);
|
||||
_entity_data_map.set(cls->get_id(), cls);
|
||||
}
|
||||
Vector<Variant> ESSResourceDB::get_entity_datas() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_datas.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_datas[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_datas[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_entity_datas(const Vector<Variant> &data) {
|
||||
_craft_recipes.clear();
|
||||
_craft_recipe_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntityResource> d = Ref<EntityResource>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_entity_data(d);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Spell> ESSResourceDB::get_spell(int spell_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_spell_map.has(spell_id), Ref<Spell>(), "Could not find Spell! Id:" + String::num(spell_id));
|
||||
|
||||
return _spell_map.get(spell_id);
|
||||
}
|
||||
|
||||
Ref<Spell> ESSResourceDB::get_spell_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _spells.size(), Ref<Spell>(NULL));
|
||||
|
||||
return _spells.get(index);
|
||||
}
|
||||
int ESSResourceDB::get_spell_count() {
|
||||
return _spells.size();
|
||||
}
|
||||
void ESSResourceDB::add_spell(const Ref<Spell> &spell) {
|
||||
ERR_FAIL_COND(!spell.is_valid());
|
||||
|
||||
_spells.push_back(spell);
|
||||
_spell_map.set(spell->get_id(), spell);
|
||||
}
|
||||
Vector<Variant> ESSResourceDB::get_spells() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _craft_recipes.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_craft_recipes[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_craft_recipes[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_spells(const Vector<Variant> &data) {
|
||||
_spells.clear();
|
||||
_spell_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<Spell> d = Ref<Spell>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_spell(d);
|
||||
}
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_aura(const Ref<Aura> &aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
_auras.push_back(aura);
|
||||
_aura_map.set(aura->get_id(), aura);
|
||||
}
|
||||
|
||||
Ref<Aura> ESSResourceDB::get_aura(int aura_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_aura_map.has(aura_id), Ref<Aura>(), "Could not find Aura! Id:" + String::num(aura_id));
|
||||
|
||||
return _aura_map.get(aura_id);
|
||||
}
|
||||
|
||||
Ref<Aura> ESSResourceDB::get_aura_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _auras.size(), Ref<Aura>());
|
||||
|
||||
return _auras.get(index);
|
||||
}
|
||||
|
||||
int ESSResourceDB::get_aura_count() {
|
||||
return _auras.size();
|
||||
}
|
||||
|
||||
Vector<Variant> ESSResourceDB::get_auras() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _auras.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_auras[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_auras[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_auras(const Vector<Variant> &data) {
|
||||
_auras.clear();
|
||||
_aura_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<Aura> d = Ref<Aura>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_aura(d);
|
||||
}
|
||||
}
|
||||
|
||||
//Craft Data
|
||||
void ESSResourceDB::add_craft_recipe(const Ref<CraftRecipe> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_craft_recipes.push_back(cda);
|
||||
_craft_recipe_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> ESSResourceDB::get_craft_recipe(int craft_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_craft_recipe_map.has(craft_id), Ref<CraftRecipe>(), "Could not find CraftRecipe! Id:" + String::num(craft_id));
|
||||
|
||||
return _craft_recipe_map.get(craft_id);
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> ESSResourceDB::get_craft_recipe_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _craft_recipes.size(), Ref<CraftRecipe>());
|
||||
|
||||
return _craft_recipes.get(index);
|
||||
}
|
||||
|
||||
int ESSResourceDB::get_craft_recipe_count() {
|
||||
return _craft_recipes.size();
|
||||
}
|
||||
|
||||
Vector<Variant> ESSResourceDB::get_craft_recipes() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _craft_recipes.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_craft_recipes[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_craft_recipes[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_craft_recipes(const Vector<Variant> &data) {
|
||||
_craft_recipes.clear();
|
||||
_craft_recipe_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<CraftRecipe> d = Ref<CraftRecipe>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_craft_recipe(d);
|
||||
}
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_item_template(const Ref<ItemTemplate> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_item_templates.push_back(cda);
|
||||
_item_template_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
Ref<ItemTemplate> ESSResourceDB::get_item_template(int item_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_item_template_map.has(item_id), Ref<ItemTemplate>(), "Could not find ItemTemplate! Id:" + String::num(item_id));
|
||||
|
||||
return _item_template_map.get(item_id);
|
||||
}
|
||||
|
||||
Ref<ItemTemplate> ESSResourceDB::get_item_template_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _item_templates.size(), Ref<ItemTemplate>());
|
||||
|
||||
return _item_templates.get(index);
|
||||
}
|
||||
|
||||
int ESSResourceDB::get_item_template_count() {
|
||||
return _item_templates.size();
|
||||
}
|
||||
Vector<Variant> ESSResourceDB::get_item_templates() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _item_templates.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_item_templates[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_item_templates[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_item_templates(const Vector<Variant> &data) {
|
||||
_item_templates.clear();
|
||||
_item_template_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<ItemTemplate> d = Ref<ItemTemplate>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_item_template(d);
|
||||
}
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_entity_species_data(const Ref<EntitySpeciesData> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_entity_species_datas.push_back(cda);
|
||||
_entity_species_data_map.set(cda->get_id(), cda);
|
||||
}
|
||||
Ref<EntitySpeciesData> ESSResourceDB::get_entity_species_data(int item_id) {
|
||||
if (!_entity_species_data_map.has(item_id))
|
||||
return Ref<EntitySpeciesData>();
|
||||
|
||||
return _entity_species_data_map.get(item_id);
|
||||
}
|
||||
Ref<EntitySpeciesData> ESSResourceDB::get_entity_species_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_species_datas.size(), Ref<EntitySpeciesData>());
|
||||
|
||||
return _entity_species_datas.get(index);
|
||||
}
|
||||
int ESSResourceDB::get_entity_species_data_count() {
|
||||
return _entity_species_datas.size();
|
||||
}
|
||||
Vector<Variant> ESSResourceDB::get_entity_species_datas() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_species_datas.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_species_datas[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_species_datas[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void ESSResourceDB::set_entity_species_datas(const Vector<Variant> &data) {
|
||||
_entity_species_datas.clear();
|
||||
_entity_species_data_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntitySpeciesData> d = Ref<EntitySpeciesData>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_item_template(d);
|
||||
}
|
||||
}
|
||||
|
||||
void ESSResourceDB::load_all() {
|
||||
load_xp_data();
|
||||
load_folders();
|
||||
}
|
||||
|
||||
void ESSResourceDB::load_xp_data() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_xp_data_path == "");
|
||||
|
||||
Ref<XPData> d = load_resource(_xp_data_path, "XPData");
|
||||
|
||||
ERR_FAIL_COND(!d.is_valid());
|
||||
|
||||
_xp_data = d;
|
||||
}
|
||||
|
||||
void ESSResourceDB::load_folders() {
|
||||
for (int i = 0; i < _folders.size(); ++i) {
|
||||
load_folder(_folders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ESSResourceDB::load_folder(const String &folder) {
|
||||
_Directory dir;
|
||||
|
||||
bool ew = folder.ends_with("/");
|
||||
|
||||
if (dir.open(folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename;
|
||||
|
||||
while (true) {
|
||||
filename = dir.get_next();
|
||||
|
||||
if (filename == "")
|
||||
break;
|
||||
|
||||
if (!dir.current_is_dir()) {
|
||||
String path;
|
||||
|
||||
if (ew)
|
||||
path = folder + filename;
|
||||
else
|
||||
path = folder + "/" + filename;
|
||||
|
||||
Ref<Resource> res = load_resource(path);
|
||||
|
||||
ERR_CONTINUE(!res.is_valid());
|
||||
|
||||
add_resource(res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void ESSResourceDB::add_resource(const Ref<Resource> &resource) {
|
||||
StringName cls = resource->get_class_name();
|
||||
|
||||
if (cls == "EntityResourceData") {
|
||||
add_entity_resource(resource);
|
||||
} else if (cls == "EntitySkillData") {
|
||||
add_entity_skill(resource);
|
||||
} else if (cls == "EntityData") {
|
||||
add_entity_data(resource);
|
||||
} else if (cls == "Spell") {
|
||||
add_spell(resource);
|
||||
} else if (cls == "Aura") {
|
||||
add_aura(resource);
|
||||
} else if (cls == "CraftRecipe") {
|
||||
add_craft_recipe(resource);
|
||||
} else if (cls == "ItemTemplate") {
|
||||
add_item_template(resource);
|
||||
} else if (cls == "EntitySpeciesData") {
|
||||
add_entity_species_data(resource);
|
||||
} else if (cls == "XPData") {
|
||||
_xp_data = resource;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Resource> ESSResourceDB::load_resource(const String &path, const String &type_hint) {
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
||||
|
||||
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
||||
|
||||
resl->wait();
|
||||
|
||||
return resl->get_resource();
|
||||
#else
|
||||
return rl->load(path, type_hint);
|
||||
#endif
|
||||
}
|
||||
|
||||
ESSResourceDB::ESSResourceDB() {
|
||||
_automatic_load = false;
|
||||
|
||||
_xp_data_path = "";
|
||||
|
||||
if (_automatic_load) {
|
||||
call_deferred("load_all");
|
||||
}
|
||||
}
|
||||
|
||||
ESSResourceDB::~ESSResourceDB() {
|
||||
_entity_resources.clear();
|
||||
_entity_resource_map.clear();
|
||||
|
||||
_entity_skills.clear();
|
||||
_entity_skill_map.clear();
|
||||
|
||||
_entity_datas.clear();
|
||||
_entity_data_map.clear();
|
||||
|
||||
_spells.clear();
|
||||
_spell_map.clear();
|
||||
|
||||
_auras.clear();
|
||||
_aura_map.clear();
|
||||
|
||||
_craft_recipes.clear();
|
||||
_craft_recipe_map.clear();
|
||||
|
||||
_item_templates.clear();
|
||||
_item_template_map.clear();
|
||||
|
||||
_entity_species_datas.clear();
|
||||
_entity_species_data_map.clear();
|
||||
}
|
||||
|
||||
void ESSResourceDB::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_automatic_load"), &ESSResourceDB::get_automatic_load);
|
||||
ClassDB::bind_method(D_METHOD("set_automatic_load", "load"), &ESSResourceDB::set_automatic_load);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_skill_for_armor_type", "index"), &ESSResourceDB::get_skill_for_armor_type);
|
||||
ClassDB::bind_method(D_METHOD("set_skill_for_armor_type", "index", "aura"), &ESSResourceDB::set_skill_for_armor_type);
|
||||
|
||||
for (int i = 0; i < ItemEnums::ARMOR_TYPE_MAX; ++i) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "skill_for_armor_type_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Aura"), "set_skill_for_armor_type", "get_skill_for_armor_type", i);
|
||||
}
|
||||
|
||||
//XPData
|
||||
ClassDB::bind_method(D_METHOD("get_xp_data_path"), &ESSResourceDB::get_xp_data_path);
|
||||
ClassDB::bind_method(D_METHOD("set_xp_data_path", "path"), &ESSResourceDB::set_xp_data_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "xp_data_path"), "set_xp_data_path", "get_xp_data_path");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_xp_data"), &ESSResourceDB::get_xp_data);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_folders"), &ESSResourceDB::get_folders);
|
||||
ClassDB::bind_method(D_METHOD("set_folders", "recipe"), &ESSResourceDB::set_folders);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "folders"), "set_folders", "get_folders");
|
||||
|
||||
//EntityResourceData
|
||||
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);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_resources", PROPERTY_HINT_NONE, "17/17:EntityResourceData", PROPERTY_USAGE_DEFAULT, "EntityResourceData"), "set_entity_resources", "get_entity_resources");
|
||||
|
||||
//EntitySkills
|
||||
ClassDB::bind_method(D_METHOD("add_entity_skill", "cls"), &ESSResourceDB::add_entity_skill);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill", "class_id"), &ESSResourceDB::get_entity_skill);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill_index", "index"), &ESSResourceDB::get_entity_skill_index);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_skills", PROPERTY_HINT_NONE, "17/17:EntitySkillData", PROPERTY_USAGE_DEFAULT, "EntitySkillData"), "set_entity_skills", "get_entity_skills");
|
||||
|
||||
//EntityData
|
||||
ClassDB::bind_method(D_METHOD("add_entity_data", "cls"), &ESSResourceDB::add_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data", "class_id"), &ESSResourceDB::get_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_index", "index"), &ESSResourceDB::get_entity_data_index);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas");
|
||||
|
||||
//Spell
|
||||
ClassDB::bind_method(D_METHOD("add_spell", "spell"), &ESSResourceDB::add_spell);
|
||||
ClassDB::bind_method(D_METHOD("get_spell", "spell_id"), &ESSResourceDB::get_spell);
|
||||
ClassDB::bind_method(D_METHOD("get_spell_index", "index"), &ESSResourceDB::get_spell_index);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "spells", PROPERTY_HINT_NONE, "17/17:Spell", PROPERTY_USAGE_DEFAULT, "Spell"), "set_spells", "get_spells");
|
||||
|
||||
//Aura
|
||||
ClassDB::bind_method(D_METHOD("add_aura", "spell"), &ESSResourceDB::add_aura);
|
||||
ClassDB::bind_method(D_METHOD("get_aura", "id"), &ESSResourceDB::get_aura);
|
||||
ClassDB::bind_method(D_METHOD("get_aura_index", "index"), &ESSResourceDB::get_aura_index);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "auras", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_auras", "get_auras");
|
||||
|
||||
//Craft Data
|
||||
ClassDB::bind_method(D_METHOD("add_craft_recipe", "craft_recipe"), &ESSResourceDB::add_craft_recipe);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe", "craft_recipe_id"), &ESSResourceDB::get_craft_recipe);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe_index", "index"), &ESSResourceDB::get_craft_recipe_index);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "craft_recipes", PROPERTY_HINT_NONE, "17/17:CraftRecipe", PROPERTY_USAGE_DEFAULT, "CraftRecipe"), "set_craft_recipes", "get_craft_recipes");
|
||||
|
||||
//Item Templates
|
||||
ClassDB::bind_method(D_METHOD("add_item_template", "item_template"), &ESSResourceDB::add_item_template);
|
||||
ClassDB::bind_method(D_METHOD("get_item_template", "item_template_id"), &ESSResourceDB::get_item_template);
|
||||
ClassDB::bind_method(D_METHOD("get_item_template_index", "index"), &ESSResourceDB::get_item_template_index);
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "item_templates", PROPERTY_HINT_NONE, "17/17:ItemTemplate", PROPERTY_USAGE_DEFAULT, "ItemTemplate"), "set_item_templates", "get_item_templates");
|
||||
|
||||
//Player Character Data
|
||||
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);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_species_datas", PROPERTY_HINT_NONE, "17/17:EntitySpeciesData", PROPERTY_USAGE_DEFAULT, "EntitySpeciesData"), "set_entity_species_datas", "get_entity_species_datas");
|
||||
|
||||
//load
|
||||
ClassDB::bind_method(D_METHOD("load_all"), &ESSResourceDB::load_all);
|
||||
ClassDB::bind_method(D_METHOD("load_xp_data"), &ESSResourceDB::load_xp_data);
|
||||
ClassDB::bind_method(D_METHOD("load_folders"), &ESSResourceDB::load_folders);
|
||||
ClassDB::bind_method(D_METHOD("load_folder", "folder"), &ESSResourceDB::load_folder);
|
||||
ClassDB::bind_method(D_METHOD("add_resource", "resource"), &ESSResourceDB::add_resource);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &ESSResourceDB::load_resource, DEFVAL(""));
|
||||
}
|
181
database/ess_resource_db.h
Normal file
181
database/ess_resource_db.h
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
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 ESS_RESOURCE_DB_H
|
||||
#define ESS_RESOURCE_DB_H
|
||||
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "core/array.h"
|
||||
#include "core/engine.h"
|
||||
#include "core/hash_map.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/variant.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "core/ustring.h"
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#include "core/bind/core_bind.h"
|
||||
|
||||
#include "../item_enums.h"
|
||||
|
||||
#include "../data/entities/xp_data.h"
|
||||
|
||||
class Aura;
|
||||
class Spell;
|
||||
class EntityData;
|
||||
class CraftRecipe;
|
||||
class ItemTemplate;
|
||||
class EntityResourceData;
|
||||
class EntitySkillData;
|
||||
class EntityCreateInfo;
|
||||
class SpellCastInfo;
|
||||
class EntitySpeciesData;
|
||||
|
||||
class ESSResourceDB : public Resource {
|
||||
GDCLASS(ESSResourceDB, Resource);
|
||||
|
||||
public:
|
||||
bool get_automatic_load() const;
|
||||
void set_automatic_load(const bool load);
|
||||
|
||||
bool get_load_folders() const;
|
||||
void set_load_folders(const bool load);
|
||||
|
||||
Ref<Aura> get_skill_for_armor_type(const int index);
|
||||
void set_skill_for_armor_type(const int index, const Ref<Aura> &aura);
|
||||
|
||||
String get_xp_data_path();
|
||||
void set_xp_data_path(String path);
|
||||
Ref<XPData> get_xp_data();
|
||||
|
||||
PoolStringArray get_folders() const;
|
||||
void set_folders(const PoolStringArray &folders);
|
||||
|
||||
Ref<EntityResourceData> get_entity_resource(int class_id);
|
||||
Ref<EntityResourceData> get_entity_resource_index(int index);
|
||||
int get_entity_resource_count();
|
||||
void add_entity_resource(const Ref<EntityResourceData> &cls);
|
||||
Vector<Variant> get_entity_resources() const;
|
||||
void set_entity_resources(const Vector<Variant> &data);
|
||||
|
||||
Ref<EntitySkillData> get_entity_skill(int class_id);
|
||||
Ref<EntitySkillData> get_entity_skill_index(int index);
|
||||
int get_entity_skill_count();
|
||||
void add_entity_skill(const Ref<EntitySkillData> &cls);
|
||||
Vector<Variant> get_entity_skills() const;
|
||||
void set_entity_skills(const Vector<Variant> &data);
|
||||
|
||||
Ref<EntityData> get_entity_data(int class_id);
|
||||
Ref<EntityData> get_entity_data_index(int index);
|
||||
int get_entity_data_count();
|
||||
void add_entity_data(const Ref<EntityData> &cls);
|
||||
Vector<Variant> get_entity_datas() const;
|
||||
void set_entity_datas(const Vector<Variant> &data);
|
||||
|
||||
Ref<Spell> get_spell(int spell_id);
|
||||
Ref<Spell> get_spell_index(int index);
|
||||
int get_spell_count();
|
||||
void add_spell(const Ref<Spell> &spell);
|
||||
Vector<Variant> get_spells() const;
|
||||
void set_spells(const Vector<Variant> &data);
|
||||
|
||||
Ref<Aura> get_aura(int aura_id);
|
||||
Ref<Aura> get_aura_index(int index);
|
||||
int get_aura_count();
|
||||
void add_aura(const Ref<Aura> &aura);
|
||||
Vector<Variant> get_auras() const;
|
||||
void set_auras(const Vector<Variant> &data);
|
||||
|
||||
Ref<CraftRecipe> get_craft_recipe(int craft_id);
|
||||
Ref<CraftRecipe> get_craft_recipe_index(int index);
|
||||
int get_craft_recipe_count();
|
||||
void add_craft_recipe(const Ref<CraftRecipe> &aura);
|
||||
Vector<Variant> get_craft_recipes() const;
|
||||
void set_craft_recipes(const Vector<Variant> &data);
|
||||
|
||||
void add_item_template(const Ref<ItemTemplate> &aura);
|
||||
Ref<ItemTemplate> get_item_template(int item_id);
|
||||
Ref<ItemTemplate> get_item_template_index(int index);
|
||||
int get_item_template_count();
|
||||
Vector<Variant> get_item_templates() const;
|
||||
void set_item_templates(const Vector<Variant> &data);
|
||||
|
||||
void add_entity_species_data(const Ref<EntitySpeciesData> &aura);
|
||||
Ref<EntitySpeciesData> get_entity_species_data(int item_id);
|
||||
Ref<EntitySpeciesData> get_entity_species_data_index(int index);
|
||||
int get_entity_species_data_count();
|
||||
Vector<Variant> get_entity_species_datas() const;
|
||||
void set_entity_species_datas(const Vector<Variant> &data);
|
||||
|
||||
void load_all();
|
||||
void load_xp_data();
|
||||
void load_folders();
|
||||
void load_folder(const String &folder);
|
||||
void add_resource(const Ref<Resource> &resource);
|
||||
|
||||
Ref<Resource> load_resource(const String &path, const String &type_hint = "");
|
||||
|
||||
ESSResourceDB();
|
||||
~ESSResourceDB();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
String _xp_data_path;
|
||||
Ref<XPData> _xp_data;
|
||||
|
||||
PoolStringArray _folders;
|
||||
|
||||
Vector<Ref<EntityResourceData> > _entity_resources;
|
||||
HashMap<int, Ref<EntityResourceData> > _entity_resource_map;
|
||||
|
||||
Vector<Ref<EntitySkillData> > _entity_skills;
|
||||
HashMap<int, Ref<EntitySkillData> > _entity_skill_map;
|
||||
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
HashMap<int, Ref<EntityData> > _entity_data_map;
|
||||
|
||||
Vector<Ref<Spell> > _spells;
|
||||
HashMap<int, Ref<Spell> > _spell_map;
|
||||
|
||||
Vector<Ref<Aura> > _auras;
|
||||
HashMap<int, Ref<Aura> > _aura_map;
|
||||
|
||||
Vector<Ref<CraftRecipe> > _craft_recipes;
|
||||
HashMap<int, Ref<CraftRecipe> > _craft_recipe_map;
|
||||
|
||||
Vector<Ref<ItemTemplate> > _item_templates;
|
||||
HashMap<int, Ref<ItemTemplate> > _item_template_map;
|
||||
|
||||
Vector<Ref<EntitySpeciesData> > _entity_species_datas;
|
||||
HashMap<int, Ref<EntitySpeciesData> > _entity_species_data_map;
|
||||
|
||||
Ref<Aura> _armor_type_skills[ItemEnums::ARMOR_TYPE_MAX];
|
||||
|
||||
bool _automatic_load;
|
||||
bool _load_folders;
|
||||
};
|
||||
|
||||
#endif
|
@ -23,6 +23,7 @@ SOFTWARE.
|
||||
#include "aura_data.h"
|
||||
|
||||
#include "../../data/auras/aura.h"
|
||||
#include "../../database/ess_resource_db.h"
|
||||
#include "../../singletons/entity_data_manager.h"
|
||||
#include "../entity.h"
|
||||
|
||||
@ -313,7 +314,7 @@ void AuraData::_from_dict(const Dictionary &dict) {
|
||||
_aura_group = dict.get("aura_group", 0);
|
||||
int aura_id = dict.get("aura_id", 0);
|
||||
|
||||
Ref<Aura> aura = EntityDataManager::get_instance()->get_aura(aura_id);
|
||||
Ref<Aura> aura = EntityDataManager::get_instance()->get_resource_db()->get_aura(aura_id);
|
||||
|
||||
if (aura.is_valid()) {
|
||||
_aura = aura;
|
||||
|
@ -22,6 +22,7 @@ SOFTWARE.
|
||||
|
||||
#include "entity.h"
|
||||
|
||||
#include "../database/ess_resource_db.h"
|
||||
#include "../singletons/entity_data_manager.h"
|
||||
#include "../singletons/profile_manager.h"
|
||||
|
||||
@ -375,7 +376,7 @@ void Entity::setc_entity_data_id(int value) {
|
||||
}
|
||||
|
||||
if (EntityDataManager::get_instance() != NULL) {
|
||||
setc_entity_data(EntityDataManager::get_instance()->get_entity_data(_c_class_id));
|
||||
setc_entity_data(EntityDataManager::get_instance()->get_resource_db()->get_entity_data(_c_class_id));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1200,7 +1201,7 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
|
||||
int data_id = ird.get("data_id", 0);
|
||||
|
||||
Ref<EntityResourceData> resd = EntityDataManager::get_instance()->get_entity_resource(data_id);
|
||||
Ref<EntityResourceData> resd = EntityDataManager::get_instance()->get_resource_db()->get_entity_resource(data_id);
|
||||
|
||||
ERR_CONTINUE(!resd.is_valid());
|
||||
|
||||
@ -1331,7 +1332,7 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
int crid = known_recipes.get(String::num(i), 0);
|
||||
|
||||
if (EntityDataManager::get_instance() != NULL) {
|
||||
Ref<CraftRecipe> cr = EntityDataManager::get_instance()->get_craft_recipe(crid);
|
||||
Ref<CraftRecipe> cr = EntityDataManager::get_instance()->get_resource_db()->get_craft_recipe(crid);
|
||||
|
||||
if (cr.is_valid()) {
|
||||
adds_craft_recipe(cr);
|
||||
@ -1350,7 +1351,7 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
int spell_id = known_spells.get(String::num(i), 0);
|
||||
|
||||
if (EntityDataManager::get_instance() != NULL) {
|
||||
Ref<Spell> sp = EntityDataManager::get_instance()->get_spell(spell_id);
|
||||
Ref<Spell> sp = EntityDataManager::get_instance()->get_resource_db()->get_spell(spell_id);
|
||||
|
||||
if (sp.is_valid()) {
|
||||
_s_spells.push_back(sp);
|
||||
@ -1398,7 +1399,7 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
int edi = dict.get("entity_data_id", 0);
|
||||
|
||||
if (EntityDataManager::get_instance() != NULL) {
|
||||
sets_entity_data(EntityDataManager::get_instance()->get_entity_data(edi));
|
||||
sets_entity_data(EntityDataManager::get_instance()->get_resource_db()->get_entity_data(edi));
|
||||
}
|
||||
|
||||
sets_entity_data_id(edi);
|
||||
@ -1537,7 +1538,7 @@ void Entity::adds_craft_recipe_id(int id) {
|
||||
if (hass_craft_recipe_id(id))
|
||||
return;
|
||||
|
||||
Ref<CraftRecipe> craft_recipe = EntityDataManager::get_instance()->get_craft_recipe(id);
|
||||
Ref<CraftRecipe> craft_recipe = EntityDataManager::get_instance()->get_resource_db()->get_craft_recipe(id);
|
||||
|
||||
ERR_FAIL_COND(!craft_recipe.is_valid());
|
||||
|
||||
@ -1657,7 +1658,7 @@ void Entity::addc_craft_recipe_id(int id) {
|
||||
if (hasc_craft_recipe_id(id))
|
||||
return;
|
||||
|
||||
Ref<CraftRecipe> craft_recipe = EntityDataManager::get_instance()->get_craft_recipe(id);
|
||||
Ref<CraftRecipe> craft_recipe = EntityDataManager::get_instance()->get_resource_db()->get_craft_recipe(id);
|
||||
|
||||
ERR_FAIL_COND(!craft_recipe.is_valid());
|
||||
|
||||
@ -2154,7 +2155,7 @@ void Entity::addc_resource_rpc(int index, String data) {
|
||||
|
||||
int data_id = dict.get("data_id", 0);
|
||||
|
||||
Ref<EntityResourceData> resd = EntityDataManager::get_instance()->get_entity_resource(data_id);
|
||||
Ref<EntityResourceData> resd = EntityDataManager::get_instance()->get_resource_db()->get_entity_resource(data_id);
|
||||
|
||||
ERR_FAIL_COND(!resd.is_valid());
|
||||
|
||||
@ -2598,7 +2599,7 @@ void Entity::crequest_use_item(int item_id) {
|
||||
RPCS(suse_item, item_id);
|
||||
}
|
||||
void Entity::_suse_item(int item_id) {
|
||||
Ref<ItemTemplate> it = EntityDataManager::get_instance()->get_item_template(item_id);
|
||||
Ref<ItemTemplate> it = EntityDataManager::get_instance()->get_resource_db()->get_item_template(item_id);
|
||||
|
||||
ERR_FAIL_COND(!it.is_valid());
|
||||
|
||||
@ -4563,7 +4564,7 @@ void Entity::adds_spell(Ref<Spell> spell) {
|
||||
ORPCOBJ(addc_spell_rpc, spell->get_id(), addc_spell, spell);
|
||||
}
|
||||
void Entity::adds_spell_id(int id) {
|
||||
Ref<Spell> spell = EntityDataManager::get_instance()->get_spell(id);
|
||||
Ref<Spell> spell = EntityDataManager::get_instance()->get_resource_db()->get_spell(id);
|
||||
|
||||
ERR_FAIL_COND(!spell.is_valid());
|
||||
|
||||
@ -4643,12 +4644,12 @@ int Entity::getc_spell_count() {
|
||||
void Entity::addc_spell_rpc(int id) {
|
||||
ERR_FAIL_COND(EntityDataManager::get_instance() == NULL);
|
||||
|
||||
addc_spell(EntityDataManager::get_instance()->get_spell(id));
|
||||
addc_spell(EntityDataManager::get_instance()->get_resource_db()->get_spell(id));
|
||||
}
|
||||
void Entity::removec_spell_rpc(int id) {
|
||||
ERR_FAIL_COND(EntityDataManager::get_instance() == NULL);
|
||||
|
||||
removec_spell(EntityDataManager::get_instance()->get_spell(id));
|
||||
removec_spell(EntityDataManager::get_instance()->get_resource_db()->get_spell(id));
|
||||
}
|
||||
|
||||
//Skills
|
||||
@ -6339,8 +6340,8 @@ void Entity::_scraft(int id) {
|
||||
|
||||
void Entity::_son_xp_gained(int value) {
|
||||
if (EntityDataManager::get_instance()->get_use_class_xp() && EntityDataManager::get_instance()->get_automatic_class_levelups()) {
|
||||
if (EntityDataManager::get_instance()->get_xp_data()->can_class_level_up(gets_class_level())) {
|
||||
int xpr = EntityDataManager::get_instance()->get_xp_data()->get_class_xp(gets_class_level());
|
||||
if (EntityDataManager::get_instance()->get_resource_db()->get_xp_data()->can_class_level_up(gets_class_level())) {
|
||||
int xpr = EntityDataManager::get_instance()->get_resource_db()->get_xp_data()->get_class_xp(gets_class_level());
|
||||
|
||||
if (xpr <= gets_class_xp()) {
|
||||
sclass_levelup(1);
|
||||
@ -6349,8 +6350,8 @@ void Entity::_son_xp_gained(int value) {
|
||||
}
|
||||
}
|
||||
|
||||
if (EntityDataManager::get_instance()->get_xp_data()->can_character_level_up(gets_character_level())) {
|
||||
int xpr = EntityDataManager::get_instance()->get_xp_data()->get_character_xp(gets_character_level());
|
||||
if (EntityDataManager::get_instance()->get_resource_db()->get_xp_data()->can_character_level_up(gets_character_level())) {
|
||||
int xpr = EntityDataManager::get_instance()->get_resource_db()->get_xp_data()->get_character_xp(gets_character_level());
|
||||
|
||||
if (xpr <= gets_character_xp()) {
|
||||
scharacter_levelup(1);
|
||||
|
@ -22,6 +22,7 @@ SOFTWARE.
|
||||
|
||||
#include "entity_resource.h"
|
||||
|
||||
#include "../../database/ess_resource_db.h"
|
||||
#include "../../singletons/entity_data_manager.h"
|
||||
#include "../entity.h"
|
||||
#include "../stats/stat.h"
|
||||
@ -161,7 +162,7 @@ void EntityResource::receivec_update_string(const String str) {
|
||||
}
|
||||
|
||||
void EntityResource::resolve_references() {
|
||||
set_resource_data(EntityDataManager::get_instance()->get_entity_resource(_data_id));
|
||||
set_resource_data(EntityDataManager::get_instance()->get_resource_db()->get_entity_resource(_data_id));
|
||||
}
|
||||
|
||||
Dictionary EntityResource::to_dict() {
|
||||
|
@ -22,6 +22,7 @@ SOFTWARE.
|
||||
|
||||
#include "entity_skill.h"
|
||||
|
||||
#include "../../database/ess_resource_db.h"
|
||||
#include "../../singletons/entity_data_manager.h"
|
||||
|
||||
Ref<EntitySkillData> EntitySkill::get_skill() {
|
||||
@ -45,7 +46,7 @@ void EntitySkill::set_skill_id(int value) {
|
||||
_skill_id = value;
|
||||
|
||||
if (EntityDataManager::get_instance() != NULL) {
|
||||
_skill = EntityDataManager::get_instance()->get_entity_skill(_skill_id);
|
||||
_skill = EntityDataManager::get_instance()->get_resource_db()->get_entity_skill(_skill_id);
|
||||
}
|
||||
|
||||
emit_signal("skill_changed", Ref<EntitySkill>(this));
|
||||
|
@ -25,6 +25,7 @@ SOFTWARE.
|
||||
#include "../data/items/item_instance.h"
|
||||
#include "../data/items/item_template.h"
|
||||
#include "../data/spells/spell.h"
|
||||
#include "../database/ess_resource_db.h"
|
||||
#include "../entities/entity.h"
|
||||
#include "../singletons/entity_data_manager.h"
|
||||
|
||||
@ -180,7 +181,7 @@ void SpellCastInfo::resolve_references(Node *owner) {
|
||||
_target = Object::cast_to<Entity>(owner->get_node_or_null(_target_path));
|
||||
}
|
||||
|
||||
Ref<Spell> spell = EntityDataManager::get_instance()->get_spell(_spell_id);
|
||||
Ref<Spell> spell = EntityDataManager::get_instance()->get_resource_db()->get_spell(_spell_id);
|
||||
|
||||
if (spell.is_valid()) {
|
||||
_spell = spell;
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
|
||||
#include "../data/auras/aura.h"
|
||||
#include "../data/spells/spell.h"
|
||||
#include "../database/ess_resource_db.h"
|
||||
#include "../entities/entity.h"
|
||||
#include "../singletons/entity_data_manager.h"
|
||||
|
||||
@ -175,9 +176,9 @@ void SpellDamageInfo::resolve_references(Node *owner) {
|
||||
_receiver = Object::cast_to<Entity>(owner->get_node_or_null(_receiver_path));
|
||||
|
||||
if (_damage_source_type == DAMAGE_SOURCE_SPELL) {
|
||||
_damage_source = EntityDataManager::get_instance()->get_spell(_damage_source_id);
|
||||
_damage_source = EntityDataManager::get_instance()->get_resource_db()->get_spell(_damage_source_id);
|
||||
} else if (_damage_source_type == DAMAGE_SOURCE_AURA) {
|
||||
_damage_source = EntityDataManager::get_instance()->get_aura(_damage_source_id);
|
||||
_damage_source = EntityDataManager::get_instance()->get_resource_db()->get_aura(_damage_source_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
|
||||
#include "../data/auras/aura.h"
|
||||
#include "../data/spells/spell.h"
|
||||
#include "../database/ess_resource_db.h"
|
||||
#include "../entities/entity.h"
|
||||
#include "../singletons/entity_data_manager.h"
|
||||
|
||||
@ -171,9 +172,9 @@ void SpellHealInfo::resolve_references(Node *owner) {
|
||||
_receiver = Object::cast_to<Entity>(owner->get_node_or_null(_receiver_path));
|
||||
|
||||
if (_heal_source_type == HEAL_SOURCE_SPELL) {
|
||||
_heal_source = EntityDataManager::get_instance()->get_spell(_heal_source_id);
|
||||
_heal_source = EntityDataManager::get_instance()->get_resource_db()->get_spell(_heal_source_id);
|
||||
} else if (_heal_source_type == HEAL_SOURCE_AURA) {
|
||||
_heal_source = EntityDataManager::get_instance()->get_aura(_heal_source_id);
|
||||
_heal_source = EntityDataManager::get_instance()->get_resource_db()->get_aura(_heal_source_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,8 @@ SOFTWARE.
|
||||
|
||||
#include "editor/ess_editor_plugin.h"
|
||||
|
||||
#include "database/ess_resource_db.cpp"
|
||||
|
||||
static EntityDataManager *entity_data_manager = NULL;
|
||||
static ProfileManager *profile_manager = NULL;
|
||||
|
||||
@ -248,6 +250,9 @@ void register_entity_spell_system_types() {
|
||||
|
||||
ClassDB::register_class<AIFormation>();
|
||||
|
||||
//Resources
|
||||
ClassDB::register_class<ESSResourceDB>();
|
||||
|
||||
//ProfileManager
|
||||
ClassDB::register_class<InputProfileModifier>();
|
||||
ClassDB::register_class<InputProfileModifierEntry>();
|
||||
|
@ -22,13 +22,8 @@ SOFTWARE.
|
||||
|
||||
#include "entity_data_manager.h"
|
||||
|
||||
#include "../data/auras/aura.h"
|
||||
#include "../data/items/craft_recipe.h"
|
||||
#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/skills/entity_skill_data.h"
|
||||
#include "../database/ess_resource_db.h"
|
||||
#include "../utility/entity_create_info.h"
|
||||
|
||||
EntityDataManager *EntityDataManager::instance;
|
||||
|
||||
@ -57,13 +52,6 @@ void EntityDataManager::set_automatic_load(const bool load) {
|
||||
_automatic_load = load;
|
||||
}
|
||||
|
||||
bool EntityDataManager::get_load_folders() const {
|
||||
return _load_folders;
|
||||
}
|
||||
void EntityDataManager::set_load_folders(const bool load) {
|
||||
_load_folders = load;
|
||||
}
|
||||
|
||||
bool EntityDataManager::get_use_class_xp() const {
|
||||
return _use_class_xp;
|
||||
}
|
||||
@ -99,463 +87,26 @@ void EntityDataManager::set_allow_class_recipe_learning(const bool value) {
|
||||
_allow_class_recipe_learning = value;
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_skill_for_armor_type(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, ItemEnums::ARMOR_TYPE_MAX, Ref<Aura>());
|
||||
|
||||
return _armor_type_skills[index];
|
||||
String EntityDataManager::get_resource_db_path() {
|
||||
return _ess_resource_db_path;
|
||||
}
|
||||
void EntityDataManager::set_skill_for_armor_type(const int index, const Ref<Aura> &aura) {
|
||||
ERR_FAIL_INDEX(index, ItemEnums::ARMOR_TYPE_MAX);
|
||||
|
||||
_armor_type_skills[index] = aura;
|
||||
void EntityDataManager::set_resource_db_path(String path) {
|
||||
_ess_resource_db_path = path;
|
||||
}
|
||||
Ref<ESSResourceDB> EntityDataManager::get_resource_db() {
|
||||
return _ess_resource_db;
|
||||
}
|
||||
|
||||
String EntityDataManager::get_xp_data_path() {
|
||||
return _xp_data_path;
|
||||
}
|
||||
void EntityDataManager::set_xp_data_path(String path) {
|
||||
_xp_data_path = path;
|
||||
}
|
||||
Ref<XPData> EntityDataManager::get_xp_data() {
|
||||
return _xp_data;
|
||||
}
|
||||
|
||||
Ref<EntityResourceData> EntityDataManager::get_entity_resource(int class_id) {
|
||||
//ERR_FAIL_COND_V_MSG(!_entity_resource_map.has(class_id), Ref<EntityResourceData>(), "Could not find EntityResourceData! Id:" + String::num(class_id));
|
||||
|
||||
if (!_entity_resource_map.has(class_id)) {
|
||||
return Ref<EntityResourceData>();
|
||||
}
|
||||
|
||||
return _entity_resource_map.get(class_id);
|
||||
}
|
||||
Ref<EntityResourceData> EntityDataManager::get_entity_resource_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_resources.size(), Ref<EntityResourceData>(NULL));
|
||||
|
||||
return _entity_resources.get(index);
|
||||
}
|
||||
int EntityDataManager::get_entity_resource_count() {
|
||||
return _entity_resources.size();
|
||||
}
|
||||
void EntityDataManager::add_entity_resource(const Ref<EntityResourceData> &cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_resources.push_back(cls);
|
||||
_entity_resource_map.set(cls->get_id(), cls);
|
||||
}
|
||||
Vector<Variant> EntityDataManager::get_entity_resources() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_resources.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_resources[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_resources[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_entity_resources(const Vector<Variant> &data) {
|
||||
_entity_resources.clear();
|
||||
_entity_resource_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntityResource> d = Ref<EntityResource>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_entity_resource(d);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EntitySkillData> EntityDataManager::get_entity_skill(int class_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_entity_skill_map.has(class_id), Ref<EntitySkillData>(), "Could not find EntitySkillData! Id:" + String::num(class_id));
|
||||
|
||||
return _entity_skill_map.get(class_id);
|
||||
}
|
||||
Ref<EntitySkillData> EntityDataManager::get_entity_skill_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_skills.size(), Ref<EntitySkillData>(NULL));
|
||||
|
||||
return _entity_skills.get(index);
|
||||
}
|
||||
int EntityDataManager::get_entity_skill_count() {
|
||||
return _entity_skills.size();
|
||||
}
|
||||
void EntityDataManager::add_entity_skill(const Ref<EntitySkillData> &cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_skills.push_back(cls);
|
||||
_entity_skill_map.set(cls->get_id(), cls);
|
||||
}
|
||||
Vector<Variant> EntityDataManager::get_entity_skills() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_skills.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_skills[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_skills[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_entity_skills(const Vector<Variant> &data) {
|
||||
_entity_skills.clear();
|
||||
_entity_skill_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntitySkillData> d = Ref<EntitySkillData>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_entity_skill(d);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EntityData> EntityDataManager::get_entity_data(int class_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_entity_data_map.has(class_id), Ref<EntityData>(), "Could not find EntityData! Id:" + String::num(class_id));
|
||||
|
||||
return _entity_data_map.get(class_id);
|
||||
}
|
||||
Ref<EntityData> EntityDataManager::get_entity_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>(NULL));
|
||||
|
||||
return _entity_datas.get(index);
|
||||
}
|
||||
int EntityDataManager::get_entity_data_count() {
|
||||
return _entity_datas.size();
|
||||
}
|
||||
void EntityDataManager::add_entity_data(const Ref<EntityData> &cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_datas.push_back(cls);
|
||||
_entity_data_map.set(cls->get_id(), cls);
|
||||
}
|
||||
Vector<Variant> EntityDataManager::get_entity_datas() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_datas.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_datas[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_datas[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_entity_datas(const Vector<Variant> &data) {
|
||||
_craft_recipes.clear();
|
||||
_craft_recipe_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntityResource> d = Ref<EntityResource>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_entity_data(d);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Spell> EntityDataManager::get_spell(int spell_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_spell_map.has(spell_id), Ref<Spell>(), "Could not find Spell! Id:" + String::num(spell_id));
|
||||
|
||||
return _spell_map.get(spell_id);
|
||||
}
|
||||
|
||||
Ref<Spell> EntityDataManager::get_spell_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _spells.size(), Ref<Spell>(NULL));
|
||||
|
||||
return _spells.get(index);
|
||||
}
|
||||
int EntityDataManager::get_spell_count() {
|
||||
return _spells.size();
|
||||
}
|
||||
void EntityDataManager::add_spell(const Ref<Spell> &spell) {
|
||||
ERR_FAIL_COND(!spell.is_valid());
|
||||
|
||||
_spells.push_back(spell);
|
||||
_spell_map.set(spell->get_id(), spell);
|
||||
}
|
||||
Vector<Variant> EntityDataManager::get_spells() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _craft_recipes.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_craft_recipes[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_craft_recipes[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_spells(const Vector<Variant> &data) {
|
||||
_spells.clear();
|
||||
_spell_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<Spell> d = Ref<Spell>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_spell(d);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::add_aura(const Ref<Aura> &aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
_auras.push_back(aura);
|
||||
_aura_map.set(aura->get_id(), aura);
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_aura(int aura_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_aura_map.has(aura_id), Ref<Aura>(), "Could not find Aura! Id:" + String::num(aura_id));
|
||||
|
||||
return _aura_map.get(aura_id);
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_aura_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _auras.size(), Ref<Aura>());
|
||||
|
||||
return _auras.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_aura_count() {
|
||||
return _auras.size();
|
||||
}
|
||||
|
||||
Vector<Variant> EntityDataManager::get_auras() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _auras.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_auras[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_auras[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_auras(const Vector<Variant> &data) {
|
||||
_auras.clear();
|
||||
_aura_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<Aura> d = Ref<Aura>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_aura(d);
|
||||
}
|
||||
}
|
||||
|
||||
//Craft Data
|
||||
void EntityDataManager::add_craft_recipe(const Ref<CraftRecipe> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_craft_recipes.push_back(cda);
|
||||
_craft_recipe_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> EntityDataManager::get_craft_recipe(int craft_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_craft_recipe_map.has(craft_id), Ref<CraftRecipe>(), "Could not find CraftRecipe! Id:" + String::num(craft_id));
|
||||
|
||||
return _craft_recipe_map.get(craft_id);
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> EntityDataManager::get_craft_recipe_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _craft_recipes.size(), Ref<CraftRecipe>());
|
||||
|
||||
return _craft_recipes.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_craft_recipe_count() {
|
||||
return _craft_recipes.size();
|
||||
}
|
||||
|
||||
Vector<Variant> EntityDataManager::get_craft_recipes() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _craft_recipes.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_craft_recipes[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_craft_recipes[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_craft_recipes(const Vector<Variant> &data) {
|
||||
_craft_recipes.clear();
|
||||
_craft_recipe_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<CraftRecipe> d = Ref<CraftRecipe>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_craft_recipe(d);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::add_item_template(const Ref<ItemTemplate> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_item_templates.push_back(cda);
|
||||
_item_template_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
Ref<ItemTemplate> EntityDataManager::get_item_template(int item_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_item_template_map.has(item_id), Ref<ItemTemplate>(), "Could not find ItemTemplate! Id:" + String::num(item_id));
|
||||
|
||||
return _item_template_map.get(item_id);
|
||||
}
|
||||
|
||||
Ref<ItemTemplate> EntityDataManager::get_item_template_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _item_templates.size(), Ref<ItemTemplate>());
|
||||
|
||||
return _item_templates.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_item_template_count() {
|
||||
return _item_templates.size();
|
||||
}
|
||||
Vector<Variant> EntityDataManager::get_item_templates() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _item_templates.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_item_templates[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_item_templates[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_item_templates(const Vector<Variant> &data) {
|
||||
_item_templates.clear();
|
||||
_item_template_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<ItemTemplate> d = Ref<ItemTemplate>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_item_template(d);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::add_entity_species_data(const Ref<EntitySpeciesData> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_entity_species_datas.push_back(cda);
|
||||
_entity_species_data_map.set(cda->get_id(), cda);
|
||||
}
|
||||
Ref<EntitySpeciesData> EntityDataManager::get_entity_species_data(int item_id) {
|
||||
if (!_entity_species_data_map.has(item_id))
|
||||
return Ref<EntitySpeciesData>();
|
||||
|
||||
return _entity_species_data_map.get(item_id);
|
||||
}
|
||||
Ref<EntitySpeciesData> EntityDataManager::get_entity_species_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _entity_species_datas.size(), Ref<EntitySpeciesData>());
|
||||
|
||||
return _entity_species_datas.get(index);
|
||||
}
|
||||
int EntityDataManager::get_entity_species_data_count() {
|
||||
return _entity_species_datas.size();
|
||||
}
|
||||
Vector<Variant> EntityDataManager::get_entity_species_datas() const {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _entity_species_datas.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_entity_species_datas[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_entity_species_datas[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void EntityDataManager::set_entity_species_datas(const Vector<Variant> &data) {
|
||||
_entity_species_datas.clear();
|
||||
_entity_species_data_map.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Ref<EntitySpeciesData> d = Ref<EntitySpeciesData>(data[i]);
|
||||
|
||||
ERR_CONTINUE(!d.is_valid());
|
||||
|
||||
add_item_template(d);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_all() {
|
||||
load_xp_data();
|
||||
load_folders();
|
||||
}
|
||||
|
||||
void EntityDataManager::load_xp_data() {
|
||||
void EntityDataManager::load_resource_db() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_xp_data_path == "");
|
||||
ERR_FAIL_COND(_ess_resource_db_path == "");
|
||||
|
||||
Ref<XPData> d = load_resource(_xp_data_path, "XPData");
|
||||
Ref<ESSResourceDB> d = load_resource(_ess_resource_db_path, "ESSResourceDB");
|
||||
|
||||
ERR_FAIL_COND(!d.is_valid());
|
||||
|
||||
_xp_data = d;
|
||||
}
|
||||
|
||||
void EntityDataManager::load_folders() {
|
||||
for (int i = 0; i < _folders.size(); ++i) {
|
||||
load_folder(_folders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_folder(const String &folder) {
|
||||
_Directory dir;
|
||||
|
||||
bool ew = folder.ends_with("/");
|
||||
|
||||
if (dir.open(folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename;
|
||||
|
||||
while (true) {
|
||||
filename = dir.get_next();
|
||||
|
||||
if (filename == "")
|
||||
break;
|
||||
|
||||
if (!dir.current_is_dir()) {
|
||||
String path;
|
||||
|
||||
if (ew)
|
||||
path = folder + filename;
|
||||
else
|
||||
path = folder + "/" + filename;
|
||||
|
||||
Ref<Resource> res = load_resource(path);
|
||||
|
||||
ERR_CONTINUE(!res.is_valid());
|
||||
|
||||
add_resource(res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::add_resource(const Ref<Resource> &resource) {
|
||||
StringName cls = resource->get_class_name();
|
||||
|
||||
if (cls == "EntityResourceData") {
|
||||
add_entity_resource(resource);
|
||||
} else if (cls == "EntitySkillData") {
|
||||
add_entity_skill(resource);
|
||||
} else if (cls == "EntityData") {
|
||||
add_entity_data(resource);
|
||||
} else if (cls == "Spell") {
|
||||
add_spell(resource);
|
||||
} else if (cls == "Aura") {
|
||||
add_aura(resource);
|
||||
} else if (cls == "CraftRecipe") {
|
||||
add_craft_recipe(resource);
|
||||
} else if (cls == "ItemTemplate") {
|
||||
add_item_template(resource);
|
||||
} else if (cls == "EntitySpeciesData") {
|
||||
add_entity_species_data(resource);
|
||||
} else if (cls == "XPData") {
|
||||
_xp_data = resource;
|
||||
}
|
||||
_ess_resource_db = d;
|
||||
}
|
||||
|
||||
Ref<Resource> EntityDataManager::load_resource(const String &path, const String &type_hint) {
|
||||
@ -614,98 +165,15 @@ void EntityDataManager::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_allow_class_recipe_learning", "value"), &EntityDataManager::set_allow_class_recipe_learning);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_class_recipe_learning"), "set_allow_class_recipe_learning", "get_allow_class_recipe_learning");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_skill_for_armor_type", "index"), &EntityDataManager::get_skill_for_armor_type);
|
||||
ClassDB::bind_method(D_METHOD("set_skill_for_armor_type", "index", "aura"), &EntityDataManager::set_skill_for_armor_type);
|
||||
|
||||
for (int i = 0; i < ItemEnums::ARMOR_TYPE_MAX; ++i) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "skill_for_armor_type_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Aura"), "set_skill_for_armor_type", "get_skill_for_armor_type", i);
|
||||
}
|
||||
|
||||
//XPData
|
||||
ClassDB::bind_method(D_METHOD("get_xp_data_path"), &EntityDataManager::get_xp_data_path);
|
||||
ClassDB::bind_method(D_METHOD("set_xp_data_path", "path"), &EntityDataManager::set_xp_data_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "xp_data_path"), "set_xp_data_path", "get_xp_data_path");
|
||||
ClassDB::bind_method(D_METHOD("get_resource_db_path"), &EntityDataManager::get_resource_db_path);
|
||||
ClassDB::bind_method(D_METHOD("set_resource_db_path", "path"), &EntityDataManager::set_resource_db_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_db_path"), "set_resource_db_path", "get_resource_db_path");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_xp_data"), &EntityDataManager::get_xp_data);
|
||||
|
||||
//EntityResourceData
|
||||
ClassDB::bind_method(D_METHOD("add_entity_resource", "cls"), &EntityDataManager::add_entity_resource);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resource", "class_id"), &EntityDataManager::get_entity_resource);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resource_index", "index"), &EntityDataManager::get_entity_resource_index);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resource_count"), &EntityDataManager::get_entity_resource_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_resources"), &EntityDataManager::get_entity_resources);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_resources", "recipe"), &EntityDataManager::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");
|
||||
|
||||
//EntitySkills
|
||||
ClassDB::bind_method(D_METHOD("add_entity_skill", "cls"), &EntityDataManager::add_entity_skill);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill", "class_id"), &EntityDataManager::get_entity_skill);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill_index", "index"), &EntityDataManager::get_entity_skill_index);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skill_count"), &EntityDataManager::get_entity_skill_count);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipes"), &EntityDataManager::get_craft_recipes);
|
||||
ClassDB::bind_method(D_METHOD("set_craft_recipes", "recipe"), &EntityDataManager::set_craft_recipes);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "craft_recipes", PROPERTY_HINT_NONE, "17/17:CraftRecipe", PROPERTY_USAGE_DEFAULT, "CraftRecipe"), "set_craft_recipes", "get_craft_recipes");
|
||||
|
||||
//EntityData
|
||||
ClassDB::bind_method(D_METHOD("add_entity_data", "cls"), &EntityDataManager::add_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data", "class_id"), &EntityDataManager::get_entity_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_index", "index"), &EntityDataManager::get_entity_data_index);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &EntityDataManager::get_entity_data_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_skills"), &EntityDataManager::get_entity_skills);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_skills", "recipe"), &EntityDataManager::set_entity_skills);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_skills", PROPERTY_HINT_NONE, "17/17:EntitySkillData", PROPERTY_USAGE_DEFAULT, "EntitySkillData"), "set_entity_skills", "get_entity_skills");
|
||||
|
||||
//Spell
|
||||
ClassDB::bind_method(D_METHOD("add_spell", "spell"), &EntityDataManager::add_spell);
|
||||
ClassDB::bind_method(D_METHOD("get_spell", "spell_id"), &EntityDataManager::get_spell);
|
||||
ClassDB::bind_method(D_METHOD("get_spell_index", "index"), &EntityDataManager::get_spell_index);
|
||||
ClassDB::bind_method(D_METHOD("get_spell_count"), &EntityDataManager::get_spell_count);
|
||||
ClassDB::bind_method(D_METHOD("get_spells"), &EntityDataManager::get_spells);
|
||||
ClassDB::bind_method(D_METHOD("set_spells", "recipe"), &EntityDataManager::set_spells);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "spells", PROPERTY_HINT_NONE, "17/17:Spell", PROPERTY_USAGE_DEFAULT, "Spell"), "set_spells", "get_spells");
|
||||
|
||||
//Aura
|
||||
ClassDB::bind_method(D_METHOD("add_aura", "spell"), &EntityDataManager::add_aura);
|
||||
ClassDB::bind_method(D_METHOD("get_aura", "id"), &EntityDataManager::get_aura);
|
||||
ClassDB::bind_method(D_METHOD("get_aura_index", "index"), &EntityDataManager::get_aura_index);
|
||||
ClassDB::bind_method(D_METHOD("get_aura_count"), &EntityDataManager::get_aura_count);
|
||||
ClassDB::bind_method(D_METHOD("get_auras"), &EntityDataManager::get_auras);
|
||||
ClassDB::bind_method(D_METHOD("set_auras", "recipe"), &EntityDataManager::set_auras);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "auras", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_auras", "get_auras");
|
||||
|
||||
//Craft Data
|
||||
ClassDB::bind_method(D_METHOD("add_craft_recipe", "craft_recipe"), &EntityDataManager::add_craft_recipe);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe", "craft_recipe_id"), &EntityDataManager::get_craft_recipe);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe_index", "index"), &EntityDataManager::get_craft_recipe_index);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipe_count"), &EntityDataManager::get_craft_recipe_count);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_recipes"), &EntityDataManager::get_craft_recipes);
|
||||
ClassDB::bind_method(D_METHOD("set_craft_recipes", "recipe"), &EntityDataManager::set_craft_recipes);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "craft_recipes", PROPERTY_HINT_NONE, "17/17:CraftRecipe", PROPERTY_USAGE_DEFAULT, "CraftRecipe"), "set_craft_recipes", "get_craft_recipes");
|
||||
|
||||
//Item Templates
|
||||
ClassDB::bind_method(D_METHOD("add_item_template", "item_template"), &EntityDataManager::add_item_template);
|
||||
ClassDB::bind_method(D_METHOD("get_item_template", "item_template_id"), &EntityDataManager::get_item_template);
|
||||
ClassDB::bind_method(D_METHOD("get_item_template_index", "index"), &EntityDataManager::get_item_template_index);
|
||||
ClassDB::bind_method(D_METHOD("get_item_template_count"), &EntityDataManager::get_item_template_count);
|
||||
ClassDB::bind_method(D_METHOD("get_item_templates"), &EntityDataManager::get_item_templates);
|
||||
ClassDB::bind_method(D_METHOD("set_item_templates", "recipe"), &EntityDataManager::set_item_templates);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "item_templates", PROPERTY_HINT_NONE, "17/17:ItemTemplate", PROPERTY_USAGE_DEFAULT, "ItemTemplate"), "set_item_templates", "get_item_templates");
|
||||
|
||||
//Player Character Data
|
||||
ClassDB::bind_method(D_METHOD("add_entity_species_data", "pcd"), &EntityDataManager::add_entity_species_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data", "pcd_id"), &EntityDataManager::get_entity_species_data);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data_index", "index"), &EntityDataManager::get_entity_species_data_index);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data_count"), &EntityDataManager::get_entity_species_data_count);
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_datas"), &EntityDataManager::get_entity_species_datas);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_species_datas", "recipe"), &EntityDataManager::set_entity_species_datas);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_species_datas", PROPERTY_HINT_NONE, "17/17:EntitySpeciesData", PROPERTY_USAGE_DEFAULT, "EntitySpeciesData"), "set_entity_species_datas", "get_entity_species_datas");
|
||||
ClassDB::bind_method(D_METHOD("get_resource_db"), &EntityDataManager::get_resource_db);
|
||||
|
||||
//load
|
||||
ClassDB::bind_method(D_METHOD("load_all"), &EntityDataManager::load_all);
|
||||
ClassDB::bind_method(D_METHOD("load_xp_data"), &EntityDataManager::load_xp_data);
|
||||
ClassDB::bind_method(D_METHOD("load_folders"), &EntityDataManager::load_folders);
|
||||
ClassDB::bind_method(D_METHOD("load_folder", "folder"), &EntityDataManager::load_folder);
|
||||
ClassDB::bind_method(D_METHOD("add_resource", "resource"), &EntityDataManager::add_resource);
|
||||
ClassDB::bind_method(D_METHOD("load_resource_db"), &EntityDataManager::load_resource_db);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &EntityDataManager::load_resource, DEFVAL(""));
|
||||
|
||||
@ -729,7 +197,7 @@ EntityDataManager::EntityDataManager() {
|
||||
|
||||
_automatic_load = GLOBAL_DEF("ess/data/automatic_load", false);
|
||||
|
||||
_xp_data_path = GLOBAL_DEF("ess/data/xp_data_path", "");
|
||||
_ess_resource_db_path = GLOBAL_DEF("ess/data/ess_resource_db_path", "");
|
||||
|
||||
if (_automatic_load) {
|
||||
call_deferred("load_all");
|
||||
@ -739,29 +207,5 @@ EntityDataManager::EntityDataManager() {
|
||||
EntityDataManager::~EntityDataManager() {
|
||||
instance = NULL;
|
||||
|
||||
_folders.clear();
|
||||
|
||||
_entity_resources.clear();
|
||||
_entity_resource_map.clear();
|
||||
|
||||
_entity_skills.clear();
|
||||
_entity_skill_map.clear();
|
||||
|
||||
_entity_datas.clear();
|
||||
_entity_data_map.clear();
|
||||
|
||||
_spells.clear();
|
||||
_spell_map.clear();
|
||||
|
||||
_auras.clear();
|
||||
_aura_map.clear();
|
||||
|
||||
_craft_recipes.clear();
|
||||
_craft_recipe_map.clear();
|
||||
|
||||
_item_templates.clear();
|
||||
_item_template_map.clear();
|
||||
|
||||
_entity_species_datas.clear();
|
||||
_entity_species_data_map.clear();
|
||||
_ess_resource_db.unref();
|
||||
}
|
||||
|
@ -25,12 +25,7 @@ SOFTWARE.
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
#include "core/array.h"
|
||||
#include "core/engine.h"
|
||||
#include "core/hash_map.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/variant.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "core/resource.h"
|
||||
#include "core/ustring.h"
|
||||
@ -38,20 +33,8 @@ SOFTWARE.
|
||||
|
||||
#include "core/bind/core_bind.h"
|
||||
|
||||
#include "../item_enums.h"
|
||||
|
||||
#include "../data/entities/xp_data.h"
|
||||
|
||||
class Aura;
|
||||
class Spell;
|
||||
class EntityData;
|
||||
class CraftRecipe;
|
||||
class ItemTemplate;
|
||||
class EntityResourceData;
|
||||
class EntitySkillData;
|
||||
class ESSResourceDB;
|
||||
class EntityCreateInfo;
|
||||
class SpellCastInfo;
|
||||
class EntitySpeciesData;
|
||||
|
||||
class EntityDataManager : public Object {
|
||||
GDCLASS(EntityDataManager, Object);
|
||||
@ -71,9 +54,6 @@ public:
|
||||
bool get_load_folders() const;
|
||||
void set_load_folders(const bool load);
|
||||
|
||||
bool get_use_resource_data() const;
|
||||
void set_use_resource_data(const bool load);
|
||||
|
||||
bool get_use_class_xp() const;
|
||||
void set_use_class_xp(const bool value);
|
||||
|
||||
@ -89,84 +69,12 @@ public:
|
||||
bool get_allow_class_recipe_learning() const;
|
||||
void set_allow_class_recipe_learning(const bool value);
|
||||
|
||||
Ref<Aura> get_skill_for_armor_type(const int index);
|
||||
void set_skill_for_armor_type(const int index, const Ref<Aura> &aura);
|
||||
|
||||
String get_resource_db_path();
|
||||
void set_resource_db_path(String path);
|
||||
Ref<Resource> get_resource_db();
|
||||
|
||||
String get_xp_data_path();
|
||||
void set_xp_data_path(String path);
|
||||
Ref<XPData> get_xp_data();
|
||||
|
||||
Ref<EntityResourceData> get_entity_resource(int class_id);
|
||||
Ref<EntityResourceData> get_entity_resource_index(int index);
|
||||
int get_entity_resource_count();
|
||||
void add_entity_resource(const Ref<EntityResourceData> &cls);
|
||||
Vector<Variant> get_entity_resources() const;
|
||||
void set_entity_resources(const Vector<Variant> &data);
|
||||
|
||||
Ref<EntitySkillData> get_entity_skill(int class_id);
|
||||
Ref<EntitySkillData> get_entity_skill_index(int index);
|
||||
int get_entity_skill_count();
|
||||
void add_entity_skill(const Ref<EntitySkillData> &cls);
|
||||
Vector<Variant> get_entity_skills() const;
|
||||
void set_entity_skills(const Vector<Variant> &data);
|
||||
|
||||
Ref<EntityData> get_entity_data(int class_id);
|
||||
Ref<EntityData> get_entity_data_index(int index);
|
||||
int get_entity_data_count();
|
||||
void add_entity_data(const Ref<EntityData> &cls);
|
||||
Vector<Variant> get_entity_datas() const;
|
||||
void set_entity_datas(const Vector<Variant> &data);
|
||||
|
||||
Ref<Spell> get_spell(int spell_id);
|
||||
Ref<Spell> get_spell_index(int index);
|
||||
int get_spell_count();
|
||||
void add_spell(const Ref<Spell> &spell);
|
||||
Vector<Variant> get_spells() const;
|
||||
void set_spells(const Vector<Variant> &data);
|
||||
|
||||
Ref<Aura> get_aura(int aura_id);
|
||||
Ref<Aura> get_aura_index(int index);
|
||||
int get_aura_count();
|
||||
void add_aura(const Ref<Aura> &aura);
|
||||
Vector<Variant> get_auras() const;
|
||||
void set_auras(const Vector<Variant> &data);
|
||||
|
||||
Ref<CraftRecipe> get_craft_recipe(int craft_id);
|
||||
Ref<CraftRecipe> get_craft_recipe_index(int index);
|
||||
int get_craft_recipe_count();
|
||||
void add_craft_recipe(const Ref<CraftRecipe> &aura);
|
||||
Vector<Variant> get_craft_recipes() const;
|
||||
void set_craft_recipes(const Vector<Variant> &data);
|
||||
|
||||
void add_item_template(const Ref<ItemTemplate> &aura);
|
||||
Ref<ItemTemplate> get_item_template(int item_id);
|
||||
Ref<ItemTemplate> get_item_template_index(int index);
|
||||
int get_item_template_count();
|
||||
Vector<Variant> get_item_templates() const;
|
||||
void set_item_templates(const Vector<Variant> &data);
|
||||
|
||||
void add_entity_species_data(const Ref<EntitySpeciesData> &aura);
|
||||
Ref<EntitySpeciesData> get_entity_species_data(int item_id);
|
||||
Ref<EntitySpeciesData> get_entity_species_data_index(int index);
|
||||
int get_entity_species_data_count();
|
||||
Vector<Variant> get_entity_species_datas() const;
|
||||
void set_entity_species_datas(const Vector<Variant> &data);
|
||||
|
||||
void load_all();
|
||||
void load_xp_data();
|
||||
void load_folders();
|
||||
void load_folder(const String &folder);
|
||||
void add_resource(const Ref<Resource> &resource);
|
||||
|
||||
Ref<ESSResourceDB> get_resource_db();
|
||||
void load_resource_db();
|
||||
Ref<Resource> load_resource(const String &path, const String &type_hint = "");
|
||||
|
||||
Vector<Variant> get_folders() const;
|
||||
void set_folders(const Vector<Variant> &folders);
|
||||
|
||||
void request_entity_spawn(const Ref<EntityCreateInfo> &info);
|
||||
void request_entity_spawn_deferred(const Ref<EntityCreateInfo> &info);
|
||||
|
||||
@ -177,46 +85,17 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
String _xp_data_path;
|
||||
Ref<XPData> _xp_data;
|
||||
|
||||
Vector<String> _folders;
|
||||
|
||||
Vector<Ref<EntityResourceData> > _entity_resources;
|
||||
HashMap<int, Ref<EntityResourceData> > _entity_resource_map;
|
||||
|
||||
Vector<Ref<EntitySkillData> > _entity_skills;
|
||||
HashMap<int, Ref<EntitySkillData> > _entity_skill_map;
|
||||
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
HashMap<int, Ref<EntityData> > _entity_data_map;
|
||||
|
||||
Vector<Ref<Spell> > _spells;
|
||||
HashMap<int, Ref<Spell> > _spell_map;
|
||||
|
||||
Vector<Ref<Aura> > _auras;
|
||||
HashMap<int, Ref<Aura> > _aura_map;
|
||||
|
||||
Vector<Ref<CraftRecipe> > _craft_recipes;
|
||||
HashMap<int, Ref<CraftRecipe> > _craft_recipe_map;
|
||||
|
||||
Vector<Ref<ItemTemplate> > _item_templates;
|
||||
HashMap<int, Ref<ItemTemplate> > _item_template_map;
|
||||
|
||||
Vector<Ref<EntitySpeciesData> > _entity_species_datas;
|
||||
HashMap<int, Ref<EntitySpeciesData> > _entity_species_data_map;
|
||||
|
||||
Ref<Aura> _armor_type_skills[ItemEnums::ARMOR_TYPE_MAX];
|
||||
bool _automatic_load;
|
||||
String _ess_resource_db_path;
|
||||
Ref<ESSResourceDB> _ess_resource_db;
|
||||
|
||||
static EntityDataManager *instance;
|
||||
|
||||
bool _use_spell_points;
|
||||
bool _scale_spells_by_default;
|
||||
bool _automatic_load;
|
||||
bool _load_folders;
|
||||
bool _use_class_xp;
|
||||
bool _automatic_class_levelups;
|
||||
bool _use_global_class_level;
|
||||
bool _use_class_xp;
|
||||
bool _allow_class_spell_learning;
|
||||
bool _allow_class_recipe_learning;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user