mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-22 17:18:12 +01:00
Basic bindings for WorldSpell, and WorldSpellData.
This commit is contained in:
parent
7f3b1eecdd
commit
94dbc91b88
772
entity_data_manager.cpp
Normal file
772
entity_data_manager.cpp
Normal file
@ -0,0 +1,772 @@
|
||||
#include "entity_data_manager.h"
|
||||
|
||||
#include "./entities/data/entity_data.h"
|
||||
#include "./data/aura.h"
|
||||
#include "./data/craft_recipe.h"
|
||||
#include "./data/spell.h"
|
||||
|
||||
EntityDataManager *EntityDataManager::instance;
|
||||
|
||||
EntityDataManager *EntityDataManager::get_instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
void EntityDataManager::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
if (get_automatic_load()) {
|
||||
load_all();
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_skill_for_armor_type(int index) {
|
||||
ERR_FAIL_INDEX_V(index, ItemEnums::ARMOR_TYPE_MAX, Ref<Aura>());
|
||||
|
||||
return _armor_type_skills[index];
|
||||
}
|
||||
void EntityDataManager::set_skill_for_armor_type(int index, Ref<Aura> aura) {
|
||||
ERR_FAIL_INDEX(index, ItemEnums::ARMOR_TYPE_MAX);
|
||||
|
||||
_armor_type_skills[index] = aura;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
String EntityDataManager::get_entity_datas_folder() {
|
||||
return _entity_datas_folder;
|
||||
}
|
||||
|
||||
void EntityDataManager::set_entity_datas_folder(String folder) {
|
||||
_entity_datas_folder = folder;
|
||||
}
|
||||
|
||||
Vector<Ref<EntityData> > *EntityDataManager::get_entity_datas() {
|
||||
return &_entity_datas;
|
||||
}
|
||||
|
||||
Ref<EntityData> EntityDataManager::get_entity_data(int class_id) {
|
||||
if (!_entity_data_map.has(class_id))
|
||||
return Ref<EntityData>(NULL);
|
||||
|
||||
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(Ref<EntityData> cls) {
|
||||
ERR_FAIL_COND(!cls.is_valid());
|
||||
|
||||
_entity_datas.push_back(cls);
|
||||
_entity_data_map.set(cls->get_id(), cls);
|
||||
}
|
||||
|
||||
String EntityDataManager::get_spells_folder() {
|
||||
return _spells_folder;
|
||||
}
|
||||
void EntityDataManager::set_spells_folder(String folder) {
|
||||
_spells_folder = folder;
|
||||
}
|
||||
Vector<Ref<Spell> > *EntityDataManager::get_spells() {
|
||||
return &_spells;
|
||||
}
|
||||
|
||||
Ref<Spell> EntityDataManager::get_spell(int spell_id) {
|
||||
ERR_FAIL_COND_V(!_spell_map.has(spell_id), Ref<Spell>(NULL));
|
||||
|
||||
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(Ref<Spell> spell) {
|
||||
ERR_FAIL_COND(!spell.is_valid());
|
||||
|
||||
_spells.push_back(spell);
|
||||
_spell_map.set(spell->get_id(), spell);
|
||||
}
|
||||
|
||||
void EntityDataManager::add_aura(Ref<Aura> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
_auras.push_back(aura);
|
||||
_aura_map.set(aura->get_id(), aura);
|
||||
}
|
||||
|
||||
String EntityDataManager::get_auras_folder() {
|
||||
return _auras_folder;
|
||||
}
|
||||
void EntityDataManager::set_auras_folder(String folder) {
|
||||
_auras_folder = folder;
|
||||
}
|
||||
Vector<Ref<Aura> > *EntityDataManager::get_auras() {
|
||||
return &_auras;
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_aura(int aura_id) {
|
||||
ERR_FAIL_COND_V(!_aura_map.has(aura_id), Ref<Aura>(NULL));
|
||||
|
||||
return _aura_map.get(aura_id);
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_aura_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _auras.size(), Ref<Aura>(NULL));
|
||||
|
||||
return _auras.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_aura_count() {
|
||||
return _auras.size();
|
||||
}
|
||||
|
||||
//Craft Data
|
||||
void EntityDataManager::add_craft_data(Ref<CraftRecipe> cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_craft_datas.push_back(cda);
|
||||
_craft_data_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
String EntityDataManager::get_craft_data_folder() {
|
||||
return _craft_data_folder;
|
||||
}
|
||||
void EntityDataManager::set_craft_data_folder(String folder) {
|
||||
_craft_data_folder = folder;
|
||||
}
|
||||
Vector<Ref<CraftRecipe> > *EntityDataManager::get_craft_datas() {
|
||||
return &_craft_datas;
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> EntityDataManager::get_craft_data(int craft_id) {
|
||||
ERR_FAIL_COND_V(!_craft_data_map.has(craft_id), Ref<CraftRecipe>(NULL));
|
||||
|
||||
return _craft_data_map.get(craft_id);
|
||||
}
|
||||
|
||||
Ref<CraftRecipe> EntityDataManager::get_craft_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _craft_datas.size(), Ref<CraftRecipe>(NULL));
|
||||
|
||||
return _craft_datas.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_craft_data_count() {
|
||||
return _craft_datas.size();
|
||||
}
|
||||
|
||||
String EntityDataManager::get_item_template_folder() {
|
||||
return _item_template_folder;
|
||||
}
|
||||
void EntityDataManager::set_item_template_folder(String folder) {
|
||||
_item_template_folder = folder;
|
||||
}
|
||||
Vector<Ref<ItemTemplate> > *EntityDataManager::get_item_templates() {
|
||||
return &_item_templates;
|
||||
}
|
||||
|
||||
void EntityDataManager::add_item_template(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(!_item_template_map.has(item_id), Ref<ItemTemplate>(NULL));
|
||||
|
||||
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>(NULL));
|
||||
|
||||
return _item_templates.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_item_template_count() {
|
||||
return _item_templates.size();
|
||||
}
|
||||
|
||||
String EntityDataManager::get_mob_data_folder() {
|
||||
return _mob_data_folder;
|
||||
}
|
||||
void EntityDataManager::set_mob_data_folder(String folder) {
|
||||
_mob_data_folder = folder;
|
||||
}
|
||||
Vector<Ref<EntityData> > *EntityDataManager::get_mob_datas() {
|
||||
return &_mob_datas;
|
||||
}
|
||||
|
||||
void EntityDataManager::add_mob_data(Ref<EntityData> cda) {
|
||||
ERR_FAIL_COND(!cda.is_valid());
|
||||
|
||||
_mob_datas.push_back(cda);
|
||||
_mob_data_map.set(cda->get_id(), cda);
|
||||
}
|
||||
|
||||
Ref<EntityData> EntityDataManager::get_mob_data(int item_id) {
|
||||
ERR_FAIL_COND_V(!_mob_data_map.has(item_id), Ref<EntityData>(NULL));
|
||||
|
||||
return _mob_data_map.get(item_id);
|
||||
}
|
||||
|
||||
Ref<EntityData> EntityDataManager::get_mob_data_index(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _mob_datas.size(), Ref<EntityData>(NULL));
|
||||
|
||||
return _mob_datas.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_mob_data_count() {
|
||||
return _mob_datas.size();
|
||||
}
|
||||
|
||||
String EntityDataManager::get_player_character_data_folder() {
|
||||
return _player_character_data_folder;
|
||||
}
|
||||
void EntityDataManager::set_player_character_data_folder(String folder) {
|
||||
_player_character_data_folder = folder;
|
||||
}
|
||||
Vector<Ref<EntityData> > *EntityDataManager::get_player_character_datas() {
|
||||
return &_player_character_datas;
|
||||
}
|
||||
|
||||
void EntityDataManager::add_player_character_data(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(!_player_character_data_map.has(item_id), Ref<EntityData>(NULL));
|
||||
|
||||
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>(NULL));
|
||||
|
||||
return _player_character_datas.get(index);
|
||||
}
|
||||
|
||||
int EntityDataManager::get_player_character_data_count() {
|
||||
return _player_character_datas.size();
|
||||
}
|
||||
|
||||
void EntityDataManager::load_all() {
|
||||
load_xp_data();
|
||||
load_spells();
|
||||
load_auras();
|
||||
load_characters();
|
||||
load_craft_datas();
|
||||
load_item_templates();
|
||||
load_mob_datas();
|
||||
load_player_character_datas();
|
||||
}
|
||||
|
||||
void EntityDataManager::load_xp_data() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_xp_data_path == "");
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(_xp_data_path, "XPData");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_FAIL_COND(!s.is_valid());
|
||||
|
||||
Ref<XPData> d = s;
|
||||
|
||||
ERR_FAIL_COND(!d.is_valid());
|
||||
|
||||
_xp_data = d;
|
||||
}
|
||||
|
||||
void EntityDataManager::load_spells() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_spells_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_spells_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _spells_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "Spell");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<Spell> spell = s;
|
||||
|
||||
ERR_CONTINUE(!spell.is_valid());
|
||||
|
||||
add_spell(spell);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_auras() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_auras_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_auras_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _auras_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "Aura");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<Aura> aura = s;
|
||||
|
||||
ERR_CONTINUE(!aura.is_valid());
|
||||
|
||||
add_aura(aura);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_characters() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_entity_datas_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_entity_datas_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _entity_datas_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "EntityData");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<EntityData> cls = s;
|
||||
|
||||
ERR_CONTINUE(!cls.is_valid());
|
||||
|
||||
add_entity_data(cls);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_craft_datas() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_craft_data_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_craft_data_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _craft_data_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "CraftRecipe");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<CraftRecipe> cda = s;
|
||||
|
||||
ERR_CONTINUE(!cda.is_valid());
|
||||
|
||||
add_craft_data(cda);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_item_templates() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_item_template_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_item_template_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _item_template_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "ItemTemplate");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<ItemTemplate> it = s;
|
||||
|
||||
ERR_CONTINUE(!it.is_valid());
|
||||
|
||||
add_item_template(it);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_mob_datas() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_mob_data_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_mob_data_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _mob_data_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "EntityData");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<EntityData> mob_data = s;
|
||||
|
||||
ERR_CONTINUE(!mob_data.is_valid());
|
||||
|
||||
add_mob_data(mob_data);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::load_player_character_datas() {
|
||||
_Directory dir;
|
||||
|
||||
ERR_FAIL_COND(_player_character_data_folder.ends_with("/"));
|
||||
|
||||
if (dir.open(_player_character_data_folder) == OK) {
|
||||
|
||||
dir.list_dir_begin();
|
||||
|
||||
String filename = dir.get_next();
|
||||
|
||||
while (filename != "") {
|
||||
if (!dir.current_is_dir()) {
|
||||
String path = _player_character_data_folder + "/" + filename;
|
||||
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, "EntityData");
|
||||
|
||||
resl->wait();
|
||||
|
||||
Ref<Resource> s = resl->get_resource();
|
||||
|
||||
ERR_CONTINUE(!s.is_valid());
|
||||
|
||||
Ref<EntityData> pcd = s;
|
||||
|
||||
ERR_CONTINUE(!pcd.is_valid());
|
||||
|
||||
add_player_character_data(pcd);
|
||||
}
|
||||
|
||||
filename = dir.get_next();
|
||||
}
|
||||
} else {
|
||||
print_error("An error occurred when trying to access the path.");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_characters() {
|
||||
for (int i = 0; i < _entity_datas.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _entity_datas.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_spells() {
|
||||
for (int i = 0; i < _spells.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _spells.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_auras() {
|
||||
for (int i = 0; i < _auras.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _auras.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_craft_data() {
|
||||
for (int i = 0; i < _craft_datas.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _craft_datas.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_item_templates() {
|
||||
for (int i = 0; i < _item_templates.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _item_templates.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_mob_datas() {
|
||||
for (int i = 0; i < _mob_datas.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _mob_datas.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::list_player_character_datas() {
|
||||
for (int i = 0; i < _player_character_datas.size(); ++i) {
|
||||
print_error(itos(i) + ": " + _player_character_datas.get(i)->get_name());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityDataManager::_bind_methods() {
|
||||
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);
|
||||
}
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_automatic_load"), &EntityDataManager::get_automatic_load);
|
||||
ClassDB::bind_method(D_METHOD("set_automatic_load", "load"), &EntityDataManager::set_automatic_load);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load");
|
||||
|
||||
//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_xp_data"), &EntityDataManager::get_xp_data);
|
||||
|
||||
//EntityData
|
||||
ClassDB::bind_method(D_METHOD("get_entity_datas_folder"), &EntityDataManager::get_entity_datas_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_entity_datas_folder", "folder"), &EntityDataManager::set_entity_datas_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "entity_datas_folder"), "set_entity_datas_folder", "get_entity_datas_folder");
|
||||
|
||||
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);
|
||||
|
||||
//Spell
|
||||
ClassDB::bind_method(D_METHOD("get_spells_folder"), &EntityDataManager::get_spells_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_spells_folder", "folder"), &EntityDataManager::set_spells_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "spells_folder"), "set_spells_folder", "get_spells_folder");
|
||||
|
||||
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);
|
||||
|
||||
//Aura
|
||||
ClassDB::bind_method(D_METHOD("get_auras_folder"), &EntityDataManager::get_auras_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_auras_folder", "folder"), &EntityDataManager::set_auras_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "auras_folder"), "set_auras_folder", "get_auras_folder");
|
||||
|
||||
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);
|
||||
|
||||
//Craft Data
|
||||
ClassDB::bind_method(D_METHOD("get_craft_data_folder"), &EntityDataManager::get_craft_data_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_craft_data_folder", "folder"), &EntityDataManager::set_craft_data_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "craft_data_folder"), "set_craft_data_folder", "get_craft_data_folder");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_craft_data", "craft_data"), &EntityDataManager::add_craft_data);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_data", "craft_data_id"), &EntityDataManager::get_craft_data);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_data_index", "index"), &EntityDataManager::get_craft_data_index);
|
||||
ClassDB::bind_method(D_METHOD("get_craft_data_count"), &EntityDataManager::get_craft_data_count);
|
||||
|
||||
//Item Templates
|
||||
ClassDB::bind_method(D_METHOD("get_item_template_folder"), &EntityDataManager::get_item_template_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_item_template_folder", "folder"), &EntityDataManager::set_item_template_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "item_template_folder"), "set_item_template_folder", "get_item_template_folder");
|
||||
|
||||
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);
|
||||
|
||||
//Mob Data
|
||||
ClassDB::bind_method(D_METHOD("get_mob_data_folder"), &EntityDataManager::get_mob_data_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_mob_data_folder", "folder"), &EntityDataManager::set_mob_data_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "mob_data_folder"), "set_mob_data_folder", "get_mob_data_folder");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_mob_data", "mob_data"), &EntityDataManager::add_mob_data);
|
||||
ClassDB::bind_method(D_METHOD("get_mob_data", "mob_data_id"), &EntityDataManager::get_mob_data);
|
||||
ClassDB::bind_method(D_METHOD("get_mob_data_index", "index"), &EntityDataManager::get_mob_data_index);
|
||||
ClassDB::bind_method(D_METHOD("get_mob_data_count"), &EntityDataManager::get_mob_data_count);
|
||||
|
||||
//Player Character Data
|
||||
ClassDB::bind_method(D_METHOD("get_player_character_data_folder"), &EntityDataManager::get_player_character_data_folder);
|
||||
ClassDB::bind_method(D_METHOD("set_player_character_data_folder", "folder"), &EntityDataManager::set_player_character_data_folder);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "player_character_data_folder"), "set_player_character_data_folder", "get_player_character_data_folder");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_player_character_data", "pcd"), &EntityDataManager::add_player_character_data);
|
||||
ClassDB::bind_method(D_METHOD("get_player_character_data", "pcd_id"), &EntityDataManager::get_player_character_data);
|
||||
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);
|
||||
|
||||
//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_spells"), &EntityDataManager::load_spells);
|
||||
ClassDB::bind_method(D_METHOD("load_auras"), &EntityDataManager::load_auras);
|
||||
ClassDB::bind_method(D_METHOD("load_characters"), &EntityDataManager::load_characters);
|
||||
ClassDB::bind_method(D_METHOD("load_craft_datas"), &EntityDataManager::load_craft_datas);
|
||||
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);
|
||||
|
||||
//tests
|
||||
ClassDB::bind_method(D_METHOD("list_characters"), &EntityDataManager::list_characters);
|
||||
ClassDB::bind_method(D_METHOD("list_spells"), &EntityDataManager::list_spells);
|
||||
ClassDB::bind_method(D_METHOD("list_auras"), &EntityDataManager::list_auras);
|
||||
ClassDB::bind_method(D_METHOD("list_craft_data"), &EntityDataManager::list_craft_data);
|
||||
ClassDB::bind_method(D_METHOD("list_item_templates"), &EntityDataManager::list_item_templates);
|
||||
ClassDB::bind_method(D_METHOD("list_mob_datas"), &EntityDataManager::list_mob_datas);
|
||||
ClassDB::bind_method(D_METHOD("list_player_character_datas"), &EntityDataManager::list_player_character_datas);
|
||||
}
|
||||
|
||||
EntityDataManager::EntityDataManager() {
|
||||
instance = this;
|
||||
|
||||
_automatic_load = true;
|
||||
}
|
||||
|
||||
EntityDataManager::~EntityDataManager() {
|
||||
instance = NULL;
|
||||
|
||||
_entity_datas.clear();
|
||||
_entity_data_map.clear();
|
||||
|
||||
_spells.clear();
|
||||
_spell_map.clear();
|
||||
|
||||
_auras.clear();
|
||||
_aura_map.clear();
|
||||
|
||||
_craft_datas.clear();
|
||||
_craft_data_map.clear();
|
||||
|
||||
_item_templates.clear();
|
||||
_item_template_map.clear();
|
||||
|
||||
_mob_datas.clear();
|
||||
_mob_data_map.clear();
|
||||
|
||||
_player_character_datas.clear();
|
||||
_player_character_data_map.clear();
|
||||
}
|
162
entity_data_manager.h
Normal file
162
entity_data_manager.h
Normal file
@ -0,0 +1,162 @@
|
||||
#ifndef ENTITY_DATA_MANAGER_H
|
||||
#define ENTITY_DATA_MANAGER_H
|
||||
|
||||
#include "core/array.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"
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#include "core/bind/core_bind.h"
|
||||
|
||||
#include "item_enums.h"
|
||||
|
||||
#include "./data/xp_data.h"
|
||||
|
||||
class Aura;
|
||||
class Spell;
|
||||
class EntityData;
|
||||
class CraftRecipe;
|
||||
class ItemTemplate;
|
||||
|
||||
class EntityDataManager : public Node {
|
||||
GDCLASS(EntityDataManager, Node);
|
||||
|
||||
public:
|
||||
static EntityDataManager *get_instance();
|
||||
|
||||
Ref<Aura> get_skill_for_armor_type(int index);
|
||||
void set_skill_for_armor_type(int index, Ref<Aura> aura);
|
||||
|
||||
String get_xp_data_path();
|
||||
void set_xp_data_path(String path);
|
||||
Ref<XPData> get_xp_data();
|
||||
|
||||
String get_entity_datas_folder();
|
||||
void set_entity_datas_folder(String folder);
|
||||
Vector<Ref<EntityData> > *get_entity_datas();
|
||||
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(Ref<EntityData> cls);
|
||||
|
||||
String get_spells_folder();
|
||||
void set_spells_folder(String folder);
|
||||
Vector<Ref<Spell> > *get_spells();
|
||||
Ref<Spell> get_spell(int spell_id);
|
||||
Ref<Spell> get_spell_index(int index);
|
||||
int get_spell_count();
|
||||
void add_spell(Ref<Spell> spell);
|
||||
|
||||
String get_auras_folder();
|
||||
void set_auras_folder(String folder);
|
||||
Vector<Ref<Aura> > *get_auras();
|
||||
Ref<Aura> get_aura(int aura_id);
|
||||
Ref<Aura> get_aura_index(int index);
|
||||
int get_aura_count();
|
||||
void add_aura(Ref<Aura> aura);
|
||||
|
||||
String get_craft_data_folder();
|
||||
void set_craft_data_folder(String folder);
|
||||
Vector<Ref<CraftRecipe> > *get_craft_datas();
|
||||
Ref<CraftRecipe> get_craft_data(int craft_id);
|
||||
Ref<CraftRecipe> get_craft_data_index(int index);
|
||||
int get_craft_data_count();
|
||||
void add_craft_data(Ref<CraftRecipe> aura);
|
||||
|
||||
String get_item_template_folder();
|
||||
void set_item_template_folder(String folder);
|
||||
Vector<Ref<ItemTemplate> > *get_item_templates();
|
||||
void add_item_template(Ref<ItemTemplate> aura);
|
||||
Ref<ItemTemplate> get_item_template(int item_id);
|
||||
Ref<ItemTemplate> get_item_template_index(int index);
|
||||
int get_item_template_count();
|
||||
|
||||
String get_mob_data_folder();
|
||||
void set_mob_data_folder(String folder);
|
||||
Vector<Ref<EntityData> > *get_mob_datas();
|
||||
void add_mob_data(Ref<EntityData> aura);
|
||||
Ref<EntityData> get_mob_data(int item_id);
|
||||
Ref<EntityData> get_mob_data_index(int index);
|
||||
int get_mob_data_count();
|
||||
|
||||
String get_player_character_data_folder();
|
||||
void set_player_character_data_folder(String folder);
|
||||
Vector<Ref<EntityData> > *get_player_character_datas();
|
||||
void add_player_character_data(Ref<EntityData> aura);
|
||||
Ref<EntityData> get_player_character_data(int item_id);
|
||||
Ref<EntityData> get_player_character_data_index(int index);
|
||||
int get_player_character_data_count();
|
||||
|
||||
void load_all();
|
||||
void load_xp_data();
|
||||
void load_spells();
|
||||
void load_auras();
|
||||
void load_characters();
|
||||
void load_craft_datas();
|
||||
void load_item_templates();
|
||||
void load_mob_datas();
|
||||
void load_player_character_datas();
|
||||
|
||||
void list_characters();
|
||||
void list_spells();
|
||||
void list_auras();
|
||||
void list_craft_data();
|
||||
void list_item_templates();
|
||||
void list_mob_datas();
|
||||
void list_player_character_datas();
|
||||
|
||||
bool get_automatic_load() { return _automatic_load; }
|
||||
void set_automatic_load(bool load) { _automatic_load = load; }
|
||||
|
||||
EntityDataManager();
|
||||
~EntityDataManager();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _notification(int p_what);
|
||||
|
||||
private:
|
||||
String _xp_data_path;
|
||||
Ref<XPData> _xp_data;
|
||||
|
||||
String _entity_datas_folder;
|
||||
Vector<Ref<EntityData> > _entity_datas;
|
||||
HashMap<int, Ref<EntityData> > _entity_data_map;
|
||||
|
||||
String _spells_folder;
|
||||
Vector<Ref<Spell> > _spells;
|
||||
HashMap<int, Ref<Spell> > _spell_map;
|
||||
|
||||
String _auras_folder;
|
||||
Vector<Ref<Aura> > _auras;
|
||||
HashMap<int, Ref<Aura> > _aura_map;
|
||||
|
||||
String _craft_data_folder;
|
||||
Vector<Ref<CraftRecipe> > _craft_datas;
|
||||
HashMap<int, Ref<CraftRecipe> > _craft_data_map;
|
||||
|
||||
String _item_template_folder;
|
||||
Vector<Ref<ItemTemplate> > _item_templates;
|
||||
HashMap<int, Ref<ItemTemplate> > _item_template_map;
|
||||
|
||||
String _mob_data_folder;
|
||||
Vector<Ref<EntityData> > _mob_datas;
|
||||
HashMap<int, Ref<EntityData> > _mob_data_map;
|
||||
|
||||
String _player_character_data_folder;
|
||||
Vector<Ref<EntityData> > _player_character_datas;
|
||||
HashMap<int, Ref<EntityData> > _player_character_data_map;
|
||||
|
||||
Ref<Aura> _armor_type_skills[ItemEnums::ARMOR_TYPE_MAX];
|
||||
|
||||
static EntityDataManager *instance;
|
||||
|
||||
bool _automatic_load;
|
||||
};
|
||||
|
||||
#endif
|
@ -6,3 +6,5 @@ const String SpellEnums::BINDING_STRING_DIMINISHING_RETURN_CATEGORIES = "None,Ro
|
||||
const String SpellEnums::BINDING_STRING_TRIGGER_EVENTS = "None,S On Before Damage,S On Damage Receive,S On Hit,S On Damage Dealt,S Aura Remove,S Aura Dispell,S On Before Aura Applied,S On After Aura Applied,C On Aura Added,C On Aura Removed,C On Aura Refreshed";
|
||||
const String SpellEnums::BINDING_STRING_DAMAGE_TYPES = "Melee,Holy,Shadow,Nature,Fire,Frost,Lightning,Chaos";
|
||||
const String SpellEnums::BINDING_STRING_AURA_TYPES = "None,Magic,Poison,Physical,Curse,Bleed,Talent,Skill";
|
||||
const String SpellEnums::BINDING_STRING_COLLIDER_TYPE = "None,Sphere,Box";
|
||||
const String SpellEnums::BINDING_STRING_TARGET_TYPE = "None,Node,Bone ID,Coords";
|
||||
|
@ -13,6 +13,8 @@ public:
|
||||
static const String BINDING_STRING_TRIGGER_EVENTS;
|
||||
static const String BINDING_STRING_DAMAGE_TYPES;
|
||||
static const String BINDING_STRING_AURA_TYPES;
|
||||
static const String BINDING_STRING_COLLIDER_TYPE;
|
||||
static const String BINDING_STRING_TARGET_TYPE;
|
||||
|
||||
enum DamageType {
|
||||
DAMAGE_TYPE_NONE = 0,
|
||||
@ -80,6 +82,19 @@ public:
|
||||
AURA_TYPE_SKILL = 7,
|
||||
};
|
||||
|
||||
enum ColliderType {
|
||||
COLLIDER_TYPE_NONE = 0,
|
||||
COLLIDER_TYPE_SPHERE,
|
||||
COLLIDER_TYPE_BOX
|
||||
};
|
||||
|
||||
enum TargetType {
|
||||
TARGET_TYPE_NONE = 0,
|
||||
TARGET_TYPE_NODE,
|
||||
TARGET_TYPE_BONE_ID,
|
||||
TARGET_TYPE_COORDS,
|
||||
};
|
||||
|
||||
SpellEnums() {}
|
||||
|
||||
protected:
|
||||
@ -137,6 +152,16 @@ protected:
|
||||
BIND_ENUM_CONSTANT(AURA_TYPE_BLEED);
|
||||
BIND_ENUM_CONSTANT(AURA_TYPE_TALENT);
|
||||
BIND_ENUM_CONSTANT(AURA_TYPE_SKILL);
|
||||
|
||||
|
||||
BIND_ENUM_CONSTANT(COLLIDER_TYPE_NONE);
|
||||
BIND_ENUM_CONSTANT(COLLIDER_TYPE_SPHERE);
|
||||
BIND_ENUM_CONSTANT(COLLIDER_TYPE_BOX);
|
||||
|
||||
BIND_ENUM_CONSTANT(TARGET_TYPE_NONE);
|
||||
BIND_ENUM_CONSTANT(TARGET_TYPE_NODE);
|
||||
BIND_ENUM_CONSTANT(TARGET_TYPE_BONE_ID);
|
||||
BIND_ENUM_CONSTANT(TARGET_TYPE_COORDS);
|
||||
}
|
||||
};
|
||||
|
||||
@ -146,5 +171,8 @@ VARIANT_ENUM_CAST(SpellEnums::DiminishingReturnCategory);
|
||||
VARIANT_ENUM_CAST(SpellEnums::TriggerEvents);
|
||||
VARIANT_ENUM_CAST(SpellEnums::DamageType);
|
||||
VARIANT_ENUM_CAST(SpellEnums::AuraType);
|
||||
VARIANT_ENUM_CAST(SpellEnums::ColliderType);
|
||||
VARIANT_ENUM_CAST(SpellEnums::TargetType);
|
||||
|
||||
|
||||
#endif
|
||||
|
11
spells/spell_projectile.cpp
Normal file
11
spells/spell_projectile.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "spell_projectile.h"
|
||||
|
||||
|
||||
SpellProjectile::SpellProjectile() {
|
||||
}
|
||||
|
||||
SpellProjectile::~SpellProjectile() {
|
||||
}
|
||||
|
||||
void SpellProjectile::_bind_methods() {
|
||||
}
|
28
spells/spell_projectile.h
Normal file
28
spells/spell_projectile.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef SPELL_PROJECTILE_H
|
||||
#define SPELL_PROJECTILE_H
|
||||
|
||||
#ifdef ENTITIES_2D
|
||||
#include "scene/2d/node_2d.h"
|
||||
#else
|
||||
#include "scene/3d/spatial.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENTITIES_2D
|
||||
class SpellProjectile : public Node2D {
|
||||
GDCLASS(SpellProjectile, Node2D);
|
||||
#else
|
||||
class SpellProjectile : public Spatial {
|
||||
GDCLASS(SpellProjectile, Spatial);
|
||||
#endif
|
||||
|
||||
public:
|
||||
SpellProjectile();
|
||||
~SpellProjectile();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
//private:
|
||||
};
|
||||
|
||||
#endif
|
10
spells/world_spell_effect.cpp
Normal file
10
spells/world_spell_effect.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "world_spell_effect.h"
|
||||
|
||||
WorldSpellEffect::WorldSpellEffect() {
|
||||
}
|
||||
|
||||
WorldSpellEffect::~WorldSpellEffect() {
|
||||
}
|
||||
|
||||
void WorldSpellEffect::_bind_methods() {
|
||||
}
|
19
spells/world_spell_effect.h
Normal file
19
spells/world_spell_effect.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef WORLD_SPELL_EFFECT_H
|
||||
#define WORLD_SPELL_EFFECT_H
|
||||
|
||||
#include "../entities/entity.h"
|
||||
|
||||
class WorldSpellEffect : public Entity {
|
||||
GDCLASS(WorldSpellEffect, Entity);
|
||||
|
||||
public:
|
||||
WorldSpellEffect();
|
||||
~WorldSpellEffect();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//private:
|
||||
};
|
||||
|
||||
#endif
|
@ -1,10 +1,168 @@
|
||||
#include "world_spell.h"
|
||||
|
||||
|
||||
int WorldSpell::get_data_id() {
|
||||
return _data_id;
|
||||
}
|
||||
void WorldSpell::set_data_id(int value) {
|
||||
_data_id = value;
|
||||
}
|
||||
|
||||
Ref<WorldSpellData> WorldSpell::get_data() {
|
||||
return _data;
|
||||
}
|
||||
void WorldSpell::set_data(Ref<WorldSpellData> value) {
|
||||
_data = value;
|
||||
}
|
||||
|
||||
SpellEnums::ColliderType WorldSpell::get_collider_type() {
|
||||
return _collider_type;
|
||||
}
|
||||
void WorldSpell::set_collider_type(SpellEnums::ColliderType value) {
|
||||
_collider_type = value;
|
||||
}
|
||||
|
||||
Vector3 WorldSpell::get_collider_box_extents() {
|
||||
return _collider_box_extents;
|
||||
}
|
||||
void WorldSpell::set_collider_box_extents(Vector3 value) {
|
||||
_collider_box_extents = value;
|
||||
}
|
||||
|
||||
float WorldSpell::get_collider_sphere_radius() {
|
||||
return _collider_sphere_radius;
|
||||
}
|
||||
void WorldSpell::set_collider_sphere_radius(float value) {
|
||||
_collider_sphere_radius = value;
|
||||
}
|
||||
|
||||
SpellEnums::TargetType WorldSpell::get_target_type() {
|
||||
return _target_type;
|
||||
}
|
||||
void WorldSpell::set_target_type(SpellEnums::TargetType value) {
|
||||
_target_type = value;
|
||||
}
|
||||
|
||||
int WorldSpell::get_target_bone_id() {
|
||||
return _target_bone_id;
|
||||
}
|
||||
void WorldSpell::set_target_bone_id(int value) {
|
||||
_target_bone_id = value;
|
||||
}
|
||||
|
||||
bool WorldSpell::get_move() {
|
||||
return _move;
|
||||
}
|
||||
void WorldSpell::set_move(bool value) {
|
||||
_move = value;
|
||||
}
|
||||
|
||||
float WorldSpell::get_movement_speed() {
|
||||
return _movement_speed;
|
||||
}
|
||||
void WorldSpell::set_movement_speed(float value) {
|
||||
_movement_speed = value;
|
||||
}
|
||||
|
||||
Vector3 WorldSpell::get_movement_dir() {
|
||||
return _movement_dir;
|
||||
}
|
||||
void WorldSpell::set_movement_dir(Vector3 value) {
|
||||
_movement_dir = value;
|
||||
}
|
||||
|
||||
float WorldSpell::get_max_dist() {
|
||||
return _max_dist;
|
||||
}
|
||||
void WorldSpell::set_max_dist(float value) {
|
||||
_max_dist = value;
|
||||
}
|
||||
|
||||
Ref<PackedScene> WorldSpell::get_effect() {
|
||||
return _effect;
|
||||
}
|
||||
void WorldSpell::set_effect(Ref<PackedScene> value) {
|
||||
_effect = value;
|
||||
}
|
||||
|
||||
Vector3 WorldSpell::get_effect_offset() {
|
||||
return _effect_offset;
|
||||
}
|
||||
void WorldSpell::set_effect_offset(Vector3 value) {
|
||||
_effect_offset = value;
|
||||
}
|
||||
|
||||
WorldSpell::WorldSpell() {
|
||||
_data_id = 0;
|
||||
|
||||
_collider_type = SpellEnums::COLLIDER_TYPE_NONE;
|
||||
|
||||
_collider_sphere_radius = 1;
|
||||
|
||||
_target_type = SpellEnums::TARGET_TYPE_NONE;
|
||||
_target_bone_id = 0;
|
||||
|
||||
_move = true;
|
||||
_movement_speed = 10;
|
||||
|
||||
_max_dist = 400;
|
||||
}
|
||||
|
||||
WorldSpell::~WorldSpell() {
|
||||
_data.unref();
|
||||
_effect.unref();
|
||||
}
|
||||
|
||||
void WorldSpell::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_data_id"), &WorldSpell::get_data_id);
|
||||
ClassDB::bind_method(D_METHOD("set_data_id", "value"), &WorldSpell::set_data_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "data_id"), "set_data_id", "get_data_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_data"), &WorldSpell::get_data);
|
||||
ClassDB::bind_method(D_METHOD("set_data", "value"), &WorldSpell::set_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "WorldSpellData"), "set_data", "get_data");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collider_type"), &WorldSpell::get_collider_type);
|
||||
ClassDB::bind_method(D_METHOD("set_collider_type", "value"), &WorldSpell::set_collider_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_type", PROPERTY_HINT_ENUM, SpellEnums::BINDING_STRING_COLLIDER_TYPE), "set_collider_type", "get_collider_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collider_box_extents"), &WorldSpell::get_collider_box_extents);
|
||||
ClassDB::bind_method(D_METHOD("set_collider_box_extents", "value"), &WorldSpell::set_collider_box_extents);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_box_extents"), "set_collider_box_extents", "get_collider_box_extents");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collider_sphere_radius"), &WorldSpell::get_collider_sphere_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_collider_sphere_radius", "value"), &WorldSpell::set_collider_sphere_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collider_sphere_radius"), "set_collider_sphere_radius", "get_collider_sphere_radius");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_type"), &WorldSpell::get_target_type);
|
||||
ClassDB::bind_method(D_METHOD("set_target_type", "value"), &WorldSpell::set_target_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_type", PROPERTY_HINT_ENUM, SpellEnums::BINDING_STRING_TARGET_TYPE), "set_target_type", "get_target_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_bone_id"), &WorldSpell::get_target_bone_id);
|
||||
ClassDB::bind_method(D_METHOD("set_target_bone_id", "value"), &WorldSpell::set_target_bone_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_bone_id"), "set_target_bone_id", "get_target_bone_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_move"), &WorldSpell::get_move);
|
||||
ClassDB::bind_method(D_METHOD("set_move", "value"), &WorldSpell::set_move);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "move"), "set_move", "get_move");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_movement_speed"), &WorldSpell::get_movement_speed);
|
||||
ClassDB::bind_method(D_METHOD("set_movement_speed", "value"), &WorldSpell::set_movement_speed);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "movement_speed"), "set_movement_speed", "get_movement_speed");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_movement_dir"), &WorldSpell::get_movement_dir);
|
||||
ClassDB::bind_method(D_METHOD("set_movement_dir", "value"), &WorldSpell::set_movement_dir);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "movement_dir"), "set_movement_dir", "get_movement_dir");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_max_dist"), &WorldSpell::get_max_dist);
|
||||
ClassDB::bind_method(D_METHOD("set_max_dist", "value"), &WorldSpell::set_max_dist);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_dist"), "set_max_dist", "get_max_dist");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_effect"), &WorldSpell::get_effect);
|
||||
ClassDB::bind_method(D_METHOD("set_effect", "value"), &WorldSpell::set_effect);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "effect", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_effect", "get_effect");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_effect_offset"), &WorldSpell::get_effect_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_effect_offset", "value"), &WorldSpell::set_effect_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "effect_offset"), "set_effect_offset", "get_effect_offset");
|
||||
}
|
||||
|
@ -7,8 +7,14 @@
|
||||
#include "scene/3d/spatial.h"
|
||||
#endif
|
||||
|
||||
#include "core/vector.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#include "../spell_enums.h"
|
||||
|
||||
#include "world_spell_data.h"
|
||||
|
||||
|
||||
#ifdef ENTITIES_2D
|
||||
class WorldSpell : public Node2D {
|
||||
GDCLASS(WorldSpell, Node2D);
|
||||
@ -18,6 +24,45 @@ class WorldSpell : public Spatial {
|
||||
#endif
|
||||
|
||||
public:
|
||||
int get_data_id();
|
||||
void set_data_id(int value);
|
||||
|
||||
Ref<WorldSpellData> get_data();
|
||||
void set_data(Ref<WorldSpellData> value);
|
||||
|
||||
SpellEnums::ColliderType get_collider_type();
|
||||
void set_collider_type(SpellEnums::ColliderType value);
|
||||
|
||||
Vector3 get_collider_box_extents();
|
||||
void set_collider_box_extents(Vector3 value);
|
||||
|
||||
float get_collider_sphere_radius();
|
||||
void set_collider_sphere_radius(float value);
|
||||
|
||||
SpellEnums::TargetType get_target_type();
|
||||
void set_target_type(SpellEnums::TargetType value);
|
||||
|
||||
int get_target_bone_id();
|
||||
void set_target_bone_id(int value);
|
||||
|
||||
bool get_move();
|
||||
void set_move(bool value);
|
||||
|
||||
float get_movement_speed();
|
||||
void set_movement_speed(float value);
|
||||
|
||||
Vector3 get_movement_dir();
|
||||
void set_movement_dir(Vector3 value);
|
||||
|
||||
float get_max_dist();
|
||||
void set_max_dist(float value);
|
||||
|
||||
Ref<PackedScene> get_effect();
|
||||
void set_effect(Ref<PackedScene> value);
|
||||
|
||||
Vector3 get_effect_offset();
|
||||
void set_effect_offset(Vector3 value);
|
||||
|
||||
WorldSpell();
|
||||
~WorldSpell();
|
||||
|
||||
@ -25,6 +70,24 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _data_id;
|
||||
Ref<WorldSpellData> _data;
|
||||
|
||||
SpellEnums::ColliderType _collider_type;
|
||||
Vector3 _collider_box_extents;
|
||||
float _collider_sphere_radius;
|
||||
|
||||
SpellEnums::TargetType _target_type;
|
||||
int _target_bone_id;
|
||||
|
||||
bool _move;
|
||||
float _movement_speed;
|
||||
Vector3 _movement_dir;
|
||||
|
||||
float _max_dist;
|
||||
|
||||
Ref<PackedScene> _effect;
|
||||
Vector3 _effect_offset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,11 +1,157 @@
|
||||
#include "world_spell_data.h"
|
||||
|
||||
int WorldSpellData::get_id() {
|
||||
return _id;
|
||||
}
|
||||
void WorldSpellData::set_id(int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
SpellEnums::ColliderType WorldSpellData::get_collider_type() {
|
||||
return _collider_type;
|
||||
}
|
||||
void WorldSpellData::set_collider_type(SpellEnums::ColliderType value) {
|
||||
_collider_type = value;
|
||||
}
|
||||
|
||||
Vector3 WorldSpellData::get_collider_box_extents() {
|
||||
return _collider_box_extents;
|
||||
}
|
||||
void WorldSpellData::set_collider_box_extents(Vector3 value) {
|
||||
_collider_box_extents = value;
|
||||
}
|
||||
|
||||
float WorldSpellData::get_collider_sphere_radius() {
|
||||
return _collider_sphere_radius;
|
||||
}
|
||||
void WorldSpellData::set_collider_sphere_radius(float value) {
|
||||
_collider_sphere_radius = value;
|
||||
}
|
||||
|
||||
SpellEnums::TargetType WorldSpellData::get_target_type() {
|
||||
return _target_type;
|
||||
}
|
||||
void WorldSpellData::set_target_type(SpellEnums::TargetType value) {
|
||||
_target_type = value;
|
||||
}
|
||||
|
||||
int WorldSpellData::get_target_bone_id() {
|
||||
return _target_bone_id;
|
||||
}
|
||||
void WorldSpellData::set_target_bone_id(int value) {
|
||||
_target_bone_id = value;
|
||||
}
|
||||
|
||||
bool WorldSpellData::get_move() {
|
||||
return _move;
|
||||
}
|
||||
void WorldSpellData::set_move(bool value) {
|
||||
_move = value;
|
||||
}
|
||||
|
||||
float WorldSpellData::get_movement_speed() {
|
||||
return _movement_speed;
|
||||
}
|
||||
void WorldSpellData::set_movement_speed(float value) {
|
||||
_movement_speed = value;
|
||||
}
|
||||
|
||||
Vector3 WorldSpellData::get_movement_dir() {
|
||||
return _movement_dir;
|
||||
}
|
||||
void WorldSpellData::set_movement_dir(Vector3 value) {
|
||||
_movement_dir = value;
|
||||
}
|
||||
|
||||
float WorldSpellData::get_max_dist() {
|
||||
return _max_dist;
|
||||
}
|
||||
void WorldSpellData::set_max_dist(float value) {
|
||||
_max_dist = value;
|
||||
}
|
||||
|
||||
Ref<PackedScene> WorldSpellData::get_effect() {
|
||||
return _effect;
|
||||
}
|
||||
void WorldSpellData::set_effect(Ref<PackedScene> value) {
|
||||
_effect = value;
|
||||
}
|
||||
|
||||
Vector3 WorldSpellData::get_effect_offset() {
|
||||
return _effect_offset;
|
||||
}
|
||||
void WorldSpellData::set_effect_offset(Vector3 value) {
|
||||
_effect_offset = value;
|
||||
}
|
||||
|
||||
WorldSpellData::WorldSpellData() {
|
||||
_id = 0;
|
||||
|
||||
_collider_type = SpellEnums::COLLIDER_TYPE_NONE;
|
||||
|
||||
_collider_sphere_radius = 1;
|
||||
|
||||
_target_type = SpellEnums::TARGET_TYPE_NONE;
|
||||
_target_bone_id = 0;
|
||||
|
||||
_move = true;
|
||||
_movement_speed = 10;
|
||||
|
||||
_max_dist = 400;
|
||||
}
|
||||
|
||||
WorldSpellData::~WorldSpellData() {
|
||||
_effect.unref();
|
||||
}
|
||||
|
||||
void WorldSpellData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &WorldSpellData::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "value"), &WorldSpellData::set_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_name", "get_name");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collider_type"), &WorldSpellData::get_collider_type);
|
||||
ClassDB::bind_method(D_METHOD("set_collider_type", "value"), &WorldSpellData::set_collider_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_type", PROPERTY_HINT_ENUM, SpellEnums::BINDING_STRING_COLLIDER_TYPE), "set_collider_type", "get_collider_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collider_box_extents"), &WorldSpellData::get_collider_box_extents);
|
||||
ClassDB::bind_method(D_METHOD("set_collider_box_extents", "value"), &WorldSpellData::set_collider_box_extents);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_box_extents"), "set_collider_box_extents", "get_collider_box_extents");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_collider_sphere_radius"), &WorldSpellData::get_collider_sphere_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_collider_sphere_radius", "value"), &WorldSpellData::set_collider_sphere_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collider_sphere_radius"), "set_collider_sphere_radius", "get_collider_sphere_radius");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_type"), &WorldSpellData::get_target_type);
|
||||
ClassDB::bind_method(D_METHOD("set_target_type", "value"), &WorldSpellData::set_target_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_type", PROPERTY_HINT_ENUM, SpellEnums::BINDING_STRING_TARGET_TYPE), "set_target_type", "get_target_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_target_bone_id"), &WorldSpellData::get_target_bone_id);
|
||||
ClassDB::bind_method(D_METHOD("set_target_bone_id", "value"), &WorldSpellData::set_target_bone_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_bone_id"), "set_target_bone_id", "get_target_bone_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_move"), &WorldSpellData::get_move);
|
||||
ClassDB::bind_method(D_METHOD("set_move", "value"), &WorldSpellData::set_move);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "move"), "set_move", "get_move");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_movement_speed"), &WorldSpellData::get_movement_speed);
|
||||
ClassDB::bind_method(D_METHOD("set_movement_speed", "value"), &WorldSpellData::set_movement_speed);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "movement_speed"), "set_movement_speed", "get_movement_speed");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_movement_dir"), &WorldSpellData::get_movement_dir);
|
||||
ClassDB::bind_method(D_METHOD("set_movement_dir", "value"), &WorldSpellData::set_movement_dir);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "movement_dir"), "set_movement_dir", "get_movement_dir");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_max_dist"), &WorldSpellData::get_max_dist);
|
||||
ClassDB::bind_method(D_METHOD("set_max_dist", "value"), &WorldSpellData::set_max_dist);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_dist"), "set_max_dist", "get_max_dist");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_effect"), &WorldSpellData::get_effect);
|
||||
ClassDB::bind_method(D_METHOD("set_effect", "value"), &WorldSpellData::set_effect);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "effect", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_effect", "get_effect");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_effect_offset"), &WorldSpellData::get_effect_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_effect_offset", "value"), &WorldSpellData::set_effect_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "effect_offset"), "set_effect_offset", "get_effect_offset");
|
||||
}
|
||||
|
@ -3,10 +3,51 @@
|
||||
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "core/vector.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#include "../spell_enums.h"
|
||||
|
||||
class WorldSpellData : public Resource {
|
||||
GDCLASS(WorldSpellData, Resource);
|
||||
|
||||
public:
|
||||
int get_id();
|
||||
void set_id(int value);
|
||||
|
||||
SpellEnums::ColliderType get_collider_type();
|
||||
void set_collider_type(SpellEnums::ColliderType value);
|
||||
|
||||
Vector3 get_collider_box_extents();
|
||||
void set_collider_box_extents(Vector3 value);
|
||||
|
||||
float get_collider_sphere_radius();
|
||||
void set_collider_sphere_radius(float value);
|
||||
|
||||
SpellEnums::TargetType get_target_type();
|
||||
void set_target_type(SpellEnums::TargetType value);
|
||||
|
||||
int get_target_bone_id();
|
||||
void set_target_bone_id(int value);
|
||||
|
||||
bool get_move();
|
||||
void set_move(bool value);
|
||||
|
||||
float get_movement_speed();
|
||||
void set_movement_speed(float value);
|
||||
|
||||
Vector3 get_movement_dir();
|
||||
void set_movement_dir(Vector3 value);
|
||||
|
||||
float get_max_dist();
|
||||
void set_max_dist(float value);
|
||||
|
||||
Ref<PackedScene> get_effect();
|
||||
void set_effect(Ref<PackedScene> value);
|
||||
|
||||
Vector3 get_effect_offset();
|
||||
void set_effect_offset(Vector3 value);
|
||||
|
||||
WorldSpellData();
|
||||
~WorldSpellData();
|
||||
|
||||
@ -14,6 +55,23 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _id;
|
||||
|
||||
SpellEnums::ColliderType _collider_type;
|
||||
Vector3 _collider_box_extents;
|
||||
float _collider_sphere_radius;
|
||||
|
||||
SpellEnums::TargetType _target_type;
|
||||
int _target_bone_id;
|
||||
|
||||
bool _move;
|
||||
float _movement_speed;
|
||||
Vector3 _movement_dir;
|
||||
|
||||
float _max_dist;
|
||||
|
||||
Ref<PackedScene> _effect;
|
||||
Vector3 _effect_offset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user