mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-05-09 22:41:39 +02:00
Added SpeciesInstance, it can store an entity's look setup (like hair index etc.). Also added SpeciesData loading/storing into EntityDataManager.
This commit is contained in:
parent
fceecac17c
commit
aee1e1f8cf
1
SCsub
1
SCsub
@ -32,6 +32,7 @@ sources = [
|
||||
"data/items/item_visual_entry.cpp",
|
||||
"data/species/entity_species_data.cpp",
|
||||
"data/species/species_model_data.cpp",
|
||||
"data/species/species_instance.cpp",
|
||||
|
||||
"data/spells/spell_cooldown_manipulation_data.cpp",
|
||||
"data/spells/spell.cpp",
|
||||
|
@ -25,31 +25,31 @@ SOFTWARE.
|
||||
#include "../auras/aura.h"
|
||||
#include "../spells/spell.h"
|
||||
|
||||
int EntitySpeciesData::get_id() {
|
||||
int EntitySpeciesData::get_id() const {
|
||||
return _id;
|
||||
}
|
||||
void EntitySpeciesData::set_id(int value) {
|
||||
void EntitySpeciesData::set_id(const int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
EntityEnums::EntityType EntitySpeciesData::get_type() {
|
||||
EntityEnums::EntityType EntitySpeciesData::get_type() const {
|
||||
return _type;
|
||||
}
|
||||
void EntitySpeciesData::set_type(EntityEnums::EntityType value) {
|
||||
void EntitySpeciesData::set_type(const EntityEnums::EntityType value) {
|
||||
_type = value;
|
||||
}
|
||||
|
||||
String EntitySpeciesData::get_text_description() {
|
||||
String EntitySpeciesData::get_text_description() const {
|
||||
return _text_description;
|
||||
}
|
||||
void EntitySpeciesData::set_text_description(String value) {
|
||||
void EntitySpeciesData::set_text_description(const String &value) {
|
||||
_text_description = value;
|
||||
}
|
||||
|
||||
Ref<SpeciesModelData> EntitySpeciesData::get_model_data() {
|
||||
return _model_data;
|
||||
}
|
||||
void EntitySpeciesData::set_model_data(Ref<SpeciesModelData> data) {
|
||||
void EntitySpeciesData::set_model_data(const Ref<SpeciesModelData> &data) {
|
||||
_model_data = data;
|
||||
}
|
||||
|
||||
@ -60,12 +60,12 @@ Ref<Spell> EntitySpeciesData::get_spell(const int index) const {
|
||||
|
||||
return _spells.get(index);
|
||||
}
|
||||
void EntitySpeciesData::set_spell(const int index, const Ref<Spell> spell) {
|
||||
void EntitySpeciesData::set_spell(const int index, const Ref<Spell> &spell) {
|
||||
ERR_FAIL_INDEX(index, _spells.size());
|
||||
|
||||
_spells.set(index, spell);
|
||||
}
|
||||
void EntitySpeciesData::add_spell(const Ref<Spell> spell) {
|
||||
void EntitySpeciesData::add_spell(const Ref<Spell> &spell) {
|
||||
_spells.push_back(spell);
|
||||
}
|
||||
void EntitySpeciesData::remove_spell(const int index) {
|
||||
@ -101,12 +101,12 @@ Ref<Aura> EntitySpeciesData::get_aura(const int index) const {
|
||||
|
||||
return _auras.get(index);
|
||||
}
|
||||
void EntitySpeciesData::set_aura(const int index, const Ref<Aura> aura) {
|
||||
void EntitySpeciesData::set_aura(const int index, const Ref<Aura> &aura) {
|
||||
ERR_FAIL_INDEX(index, _auras.size());
|
||||
|
||||
_auras.set(index, aura);
|
||||
}
|
||||
void EntitySpeciesData::add_aura(const Ref<Aura> aura) {
|
||||
void EntitySpeciesData::add_aura(const Ref<Aura> &aura) {
|
||||
_auras.push_back(aura);
|
||||
}
|
||||
void EntitySpeciesData::remove_aura(const int index) {
|
||||
|
@ -38,22 +38,22 @@ class EntitySpeciesData : public Resource {
|
||||
GDCLASS(EntitySpeciesData, Resource);
|
||||
|
||||
public:
|
||||
int get_id();
|
||||
void set_id(int value);
|
||||
int get_id() const;
|
||||
void set_id(const int value);
|
||||
|
||||
EntityEnums::EntityType get_type();
|
||||
void set_type(EntityEnums::EntityType value);
|
||||
EntityEnums::EntityType get_type() const;
|
||||
void set_type(const EntityEnums::EntityType value);
|
||||
|
||||
String get_text_description();
|
||||
void set_text_description(String value);
|
||||
String get_text_description() const;
|
||||
void set_text_description(const String &value);
|
||||
|
||||
Ref<SpeciesModelData> get_model_data();
|
||||
void set_model_data(Ref<SpeciesModelData> data);
|
||||
void set_model_data(const Ref<SpeciesModelData> &data);
|
||||
|
||||
//Spells
|
||||
Ref<Spell> get_spell(const int index) const;
|
||||
void set_spell(const int index, const Ref<Spell> spell);
|
||||
void add_spell(const Ref<Spell> spell);
|
||||
void set_spell(const int index, const Ref<Spell> &spell);
|
||||
void add_spell(const Ref<Spell> &spell);
|
||||
void remove_spell(const int index);
|
||||
|
||||
int get_spell_count() const;
|
||||
@ -63,8 +63,8 @@ public:
|
||||
|
||||
//Auras
|
||||
Ref<Aura> get_aura(const int index) const;
|
||||
void set_aura(const int index, const Ref<Aura> aura);
|
||||
void add_aura(const Ref<Aura> aura);
|
||||
void set_aura(const int index, const Ref<Aura> &aura);
|
||||
void add_aura(const Ref<Aura> &aura);
|
||||
void remove_aura(const int index);
|
||||
|
||||
int get_aura_count() const;
|
||||
|
166
data/species/species_instance.cpp
Normal file
166
data/species/species_instance.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
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 "species_instance.h"
|
||||
|
||||
#include "../../singletons/entity_data_manager.h"
|
||||
|
||||
#include "entity_species_data.h"
|
||||
|
||||
int SpeciesInstance::get_id() const {
|
||||
return _id;
|
||||
}
|
||||
void SpeciesInstance::set_id(const int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
int SpeciesInstance::get_species_id() const {
|
||||
return _species_id;
|
||||
}
|
||||
void SpeciesInstance::set_species_id(int value) {
|
||||
_id = value;
|
||||
|
||||
_species = EntityDataManager::get_instance()->get_entity_species_data(_id);
|
||||
}
|
||||
|
||||
Ref<EntitySpeciesData> SpeciesInstance::get_species() {
|
||||
return _species;
|
||||
}
|
||||
void SpeciesInstance::set_species(const Ref<EntitySpeciesData> &value) {
|
||||
_species = value;
|
||||
|
||||
if (_species.is_valid()) {
|
||||
_id = _species->get_id();
|
||||
} else {
|
||||
_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int SpeciesInstance::get_skin_color_index() const {
|
||||
return _skin_color_index;
|
||||
}
|
||||
void SpeciesInstance::set_skin_color_index(const int value) {
|
||||
_skin_color_index = value;
|
||||
}
|
||||
|
||||
int SpeciesInstance::get_hair_style_index() const {
|
||||
return _hair_style_index;
|
||||
}
|
||||
void SpeciesInstance::set_hair_style_index(const int value) {
|
||||
_hair_style_index = value;
|
||||
}
|
||||
|
||||
int SpeciesInstance::get_hair_color_index() const {
|
||||
return _hair_color_index;
|
||||
}
|
||||
void SpeciesInstance::set_hair_color_index(const int value) {
|
||||
_hair_color_index = value;
|
||||
}
|
||||
|
||||
int SpeciesInstance::get_head_index() const {
|
||||
return _head_index;
|
||||
}
|
||||
void SpeciesInstance::set_head_index(const int value) {
|
||||
_head_index = value;
|
||||
}
|
||||
|
||||
Dictionary SpeciesInstance::to_dict() {
|
||||
return call("_to_dict");
|
||||
}
|
||||
void SpeciesInstance::from_dict(const Dictionary &dict) {
|
||||
call("_from_dict", dict);
|
||||
}
|
||||
|
||||
Dictionary SpeciesInstance::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["id"] = _id;
|
||||
dict["species_id"] = _species_id;
|
||||
dict["skin_color_index"] = _skin_color_index;
|
||||
dict["hair_style_index"] = _hair_style_index;
|
||||
dict["_hair_color_index"] = _hair_color_index;
|
||||
dict["head_index"] = _head_index;
|
||||
|
||||
return dict;
|
||||
}
|
||||
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));
|
||||
_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);
|
||||
_head_index = dict.get("head_index", 0);
|
||||
}
|
||||
|
||||
SpeciesInstance::SpeciesInstance() {
|
||||
_id = 0;
|
||||
_species_id = 0;
|
||||
_skin_color_index = 0;
|
||||
_hair_style_index = 0;
|
||||
_hair_color_index = 0;
|
||||
_head_index = 0;
|
||||
}
|
||||
SpeciesInstance::~SpeciesInstance() {
|
||||
_species.unref();
|
||||
}
|
||||
|
||||
void SpeciesInstance::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &SpeciesInstance::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "value"), &SpeciesInstance::set_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_species_id"), &SpeciesInstance::get_species_id);
|
||||
ClassDB::bind_method(D_METHOD("set_species_id", "value"), &SpeciesInstance::set_species_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "species_id"), "set_species_id", "get_species_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_species"), &SpeciesInstance::get_species);
|
||||
ClassDB::bind_method(D_METHOD("set_species", "value"), &SpeciesInstance::set_species);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "species", PROPERTY_HINT_RESOURCE_TYPE, "EntitySpeciesData"), "set_species", "get_species");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_skin_color_index"), &SpeciesInstance::get_skin_color_index);
|
||||
ClassDB::bind_method(D_METHOD("set_skin_color_index", "value"), &SpeciesInstance::set_skin_color_index);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "skin_color_index"), "set_skin_color_index", "get_skin_color_index");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_hair_style_index"), &SpeciesInstance::get_hair_style_index);
|
||||
ClassDB::bind_method(D_METHOD("set_hair_style_index", "value"), &SpeciesInstance::set_hair_style_index);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "hair_style_index"), "set_hair_style_index", "get_hair_style_index");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_hair_color_index"), &SpeciesInstance::get_hair_color_index);
|
||||
ClassDB::bind_method(D_METHOD("set_hair_color_index", "value"), &SpeciesInstance::set_hair_color_index);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "hair_color_index"), "set_hair_color_index", "get_hair_color_index");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_head_index"), &SpeciesInstance::get_head_index);
|
||||
ClassDB::bind_method(D_METHOD("set_head_index", "value"), &SpeciesInstance::set_head_index);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "head_index"), "set_head_index", "get_head_index");
|
||||
|
||||
//Serialization
|
||||
BIND_VMETHOD(MethodInfo("_from_dict", PropertyInfo(Variant::DICTIONARY, "dict")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::DICTIONARY, "dict"), "_to_dict"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &SpeciesInstance::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &SpeciesInstance::to_dict);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_from_dict", "dict"), &SpeciesInstance::_from_dict);
|
||||
ClassDB::bind_method(D_METHOD("_to_dict"), &SpeciesInstance::_to_dict);
|
||||
}
|
79
data/species/species_instance.h
Normal file
79
data/species/species_instance.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
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 SPECIES_INSTANCE_H
|
||||
#define SPECIES_INSTANCE_H
|
||||
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "../items/item_visual_entry.h"
|
||||
|
||||
class EntitySpeciesData;
|
||||
|
||||
class SpeciesInstance : public Resource {
|
||||
GDCLASS(SpeciesInstance, Resource);
|
||||
|
||||
public:
|
||||
int get_id() const;
|
||||
void set_id(const int value);
|
||||
|
||||
int get_species_id() const;
|
||||
void set_species_id(const int value);
|
||||
|
||||
Ref<EntitySpeciesData> get_species();
|
||||
void set_species(const Ref<EntitySpeciesData> &value);
|
||||
|
||||
int get_skin_color_index() const;
|
||||
void set_skin_color_index(const int value);
|
||||
|
||||
int get_hair_style_index() const;
|
||||
void set_hair_style_index(const int value);
|
||||
|
||||
int get_hair_color_index() const;
|
||||
void set_hair_color_index(const int value);
|
||||
|
||||
int get_head_index() const;
|
||||
void set_head_index(const int value);
|
||||
|
||||
Dictionary to_dict();
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
Dictionary _to_dict();
|
||||
void _from_dict(const Dictionary &dict);
|
||||
|
||||
SpeciesInstance();
|
||||
~SpeciesInstance();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _id;
|
||||
int _species_id;
|
||||
Ref<EntitySpeciesData> _species;
|
||||
int _skin_color_index;
|
||||
int _hair_style_index;
|
||||
int _hair_color_index;
|
||||
int _head_index;
|
||||
};
|
||||
|
||||
#endif
|
@ -102,7 +102,9 @@ SOFTWARE.
|
||||
#include "skeleton/character_skeleton_3d.h"
|
||||
|
||||
#include "data/species/entity_species_data.h"
|
||||
#include "data/species/species_instance.h"
|
||||
#include "data/species/species_model_data.h"
|
||||
|
||||
#include "skeleton/skeleton_model_entry.h"
|
||||
|
||||
#include "utility/category_cooldown.h"
|
||||
@ -229,6 +231,8 @@ void register_entity_spell_system_types() {
|
||||
|
||||
ClassDB::register_class<EntitySpeciesData>();
|
||||
ClassDB::register_class<SpeciesModelData>();
|
||||
ClassDB::register_class<SpeciesInstance>();
|
||||
|
||||
ClassDB::register_class<SkeletonModelEntry>();
|
||||
|
||||
ClassDB::register_class<Cooldown>();
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
|
||||
#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"
|
||||
@ -359,30 +360,56 @@ void EntityDataManager::set_player_character_data_folder(String folder) {
|
||||
Vector<Ref<EntityData> > *EntityDataManager::get_player_character_datas() {
|
||||
return &_player_character_datas;
|
||||
}
|
||||
|
||||
void EntityDataManager::add_player_character_data(const Ref<EntityData> &cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_player_character_datas.push_back(cda);
|
||||
_player_character_data_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
Ref<EntityData> EntityDataManager::get_player_character_data(int item_id) {
|
||||
ERR_FAIL_COND_V_MSG(!_player_character_data_map.has(item_id), Ref<EntityData>(), "Could not find EntityData! Id:" + String::num(item_id));
|
||||
|
||||
return _player_character_data_map.get(item_id);
|
||||
}
|
||||
|
||||
Ref<EntityData> EntityDataManager::get_player_character_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _player_character_datas.size(), Ref<EntityData>());
|
||||
|
||||
return _player_character_datas.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_player_character_data_count() {
|
||||
return _player_character_datas.size();
|
||||
}
|
||||
|
||||
String EntityDataManager::get_entity_species_data_folder() {
|
||||
return _entity_species_data_folder;
|
||||
}
|
||||
void EntityDataManager::set_entity_species_data_folder(String folder) {
|
||||
_entity_species_data_folder = folder;
|
||||
}
|
||||
Vector<Ref<EntitySpeciesData> > *EntityDataManager::get_entity_species_datas() {
|
||||
return &_entity_species_datas;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
void EntityDataManager::load_all() {
|
||||
load_xp_data();
|
||||
load_entity_resources();
|
||||
@ -395,6 +422,7 @@ void EntityDataManager::load_all() {
|
||||
load_item_templates();
|
||||
load_mob_datas();
|
||||
load_player_character_datas();
|
||||
load_entity_species_datas();
|
||||
}
|
||||
|
||||
void EntityDataManager::load_xp_data() {
|
||||
@ -861,6 +889,50 @@ void EntityDataManager::load_player_character_datas() {
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_entity_species_datas() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_entity_species_data_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_entity_species_data_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename;
|
||||
|
||||
while (true) {
|
||||
filename = dir.get_next();
|
||||
|
||||
if (filename == "")
|
||||
break;
|
||||
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _entity_species_data_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "EntitySpeciesData");
|
||||
|
||||
ERR_CONTINUE(!resl.is_valid());
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<EntitySpeciesData> pcd = s;
|
||||
|
||||
ERR_CONTINUE(!pcd.is_valid());
|
||||
|
||||
add_entity_species_data(pcd);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::request_entity_spawn(const Ref<EntityCreateInfo> &info) {
|
||||
emit_signal("on_entity_spawn_requested", info);
|
||||
}
|
||||
@ -987,6 +1059,16 @@ void EntityDataManager::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_player_character_data_index", "index"), &EntityDataManager::get_player_character_data_index);
|
||||
ClassDB::bind_method(D_METHOD("get_player_character_data_count"), &EntityDataManager::get_player_character_data_count);
|
||||
|
||||
//Player Character Data
|
||||
ClassDB::bind_method(D_METHOD("get_entity_species_data_folder"), &EntityDataManager::get_entity_species_data_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_species_data_folder", "folder"), &EntityDataManager::set_entity_species_data_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "entity_species_data_folder"), "set_entity_species_data_folder", "get_entity_species_data_folder");
|
||||
|
||||
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);
|
||||
|
||||
//load
|
||||
ClassDB::bind_method(D_METHOD("load_all"), &EntityDataManager::load_all);
|
||||
ClassDB::bind_method(D_METHOD("load_entity_resources"), &EntityDataManager::load_entity_resources);
|
||||
@ -1000,6 +1082,7 @@ void EntityDataManager::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("load_item_templates"), &EntityDataManager::load_item_templates);
|
||||
ClassDB::bind_method(D_METHOD("load_mob_datas"), &EntityDataManager::load_mob_datas);
|
||||
ClassDB::bind_method(D_METHOD("load_player_character_datas"), &EntityDataManager::load_player_character_datas);
|
||||
ClassDB::bind_method(D_METHOD("load_entity_species_datas"), &EntityDataManager::load_entity_species_datas);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("on_entity_spawn_requested", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "EntityCreateInfo")));
|
||||
ADD_SIGNAL(MethodInfo("on_world_spell_spawn_requested", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "WorldSpellData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo")));
|
||||
@ -1024,6 +1107,7 @@ EntityDataManager::EntityDataManager() {
|
||||
_item_template_folder = GLOBAL_DEF("ess/data/item_template_folder", "");
|
||||
_mob_data_folder = GLOBAL_DEF("ess/data/mob_data_folder", "");
|
||||
_player_character_data_folder = GLOBAL_DEF("ess/data/player_character_data_folder", "");
|
||||
_entity_species_data_folder = GLOBAL_DEF("ess/data/entity_species_data_folder", "");
|
||||
|
||||
if (_automatic_load) {
|
||||
call_deferred("load_all");
|
||||
@ -1062,4 +1146,7 @@ EntityDataManager::~EntityDataManager() {
|
||||
|
||||
_player_character_datas.clear();
|
||||
_player_character_data_map.clear();
|
||||
|
||||
_entity_species_datas.clear();
|
||||
_entity_species_data_map.clear();
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class EntitySkillData;
|
||||
class EntityCreateInfo;
|
||||
class WorldSpellData;
|
||||
class SpellCastInfo;
|
||||
class EntitySpeciesData;
|
||||
|
||||
class EntityDataManager : public Object {
|
||||
GDCLASS(EntityDataManager, Object);
|
||||
@ -151,6 +152,14 @@ public:
|
||||
Ref<EntityData> get_player_character_data_index(int index);
|
||||
int get_player_character_data_count();
|
||||
|
||||
String get_entity_species_data_folder();
|
||||
void set_entity_species_data_folder(String folder);
|
||||
Vector<Ref<EntitySpeciesData> > *get_entity_species_datas();
|
||||
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();
|
||||
|
||||
void load_all();
|
||||
void load_entity_resources();
|
||||
void load_entity_skills();
|
||||
@ -163,6 +172,7 @@ public:
|
||||
void load_item_templates();
|
||||
void load_mob_datas();
|
||||
void load_player_character_datas();
|
||||
void load_entity_species_datas();
|
||||
|
||||
void request_entity_spawn(const Ref<EntityCreateInfo> &info);
|
||||
void request_world_spell_spawn(const Ref<WorldSpellData> &data, const Ref<SpellCastInfo> &info);
|
||||
@ -217,6 +227,10 @@ private:
|
||||
Vector<Ref<EntityData> > _player_character_datas;
|
||||
HashMap<int, Ref<EntityData> > _player_character_data_map;
|
||||
|
||||
String _entity_species_data_folder;
|
||||
Vector<Ref<EntitySpeciesData> > _entity_species_datas;
|
||||
HashMap<int, Ref<EntitySpeciesData> > _entity_species_data_map;
|
||||
|
||||
Ref<Aura> _armor_type_skills[ItemEnums::ARMOR_TYPE_MAX];
|
||||
|
||||
static EntityDataManager *instance;
|
||||
|
Loading…
Reference in New Issue
Block a user