Rename the EntityDataManager singleton to just simply ESS.

This commit is contained in:
Relintai 2020-04-14 16:55:21 +02:00
parent 3cb26816d2
commit 4935de4c5f
18 changed files with 135 additions and 135 deletions

View File

@ -53,10 +53,10 @@ For example this way it is easy to make chests attack the player, or make spell
Since spawning (= creating) entities is entirely dependant on the type of game you are making, ESS cannot do
everything for you. It will set up stats, equipment etc, but there is no way to set up positions for example.
In lieu of this EntityDataManager has a signal that you should hook into from a class, and using that hook
In lieu of this ESS has a signal that you should hook into from a class, and using that hook
you can set up your entities however you like.
EntityDataManager also contains the method to request the system to spawn an Entity.
ESS also contains the method to request the system to spawn an Entity.
#### EntityCreateInfo

2
SCsub
View File

@ -116,7 +116,7 @@ sources = [
"profiles/player_profile.cpp",
"singletons/profile_manager.cpp",
"singletons/entity_data_manager.cpp",
"singletons/ess.cpp",
"database/ess_resource_db.cpp",

View File

@ -13,7 +13,7 @@ def get_doc_classes():
"CharacterAtlasEntry",
"CharacterAtlas",
"EntityDataManager",
"ESS",
"AuraGroup",
"AuraStatAttribute",
@ -99,7 +99,7 @@ def get_doc_classes():
"SpellFollowProjectile3D",
"EntityDataManager",
"ESS",
"EntityEnums",
"ItemEnums",

View File

@ -23,7 +23,7 @@ SOFTWARE.
#include "aura.h"
#include "../../entities/resources/entity_resource_cost_data.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
#include "core/version.h"
@ -328,7 +328,7 @@ Aura::Aura() {
_is_debuff = false;
_hide = false;
_rank = 0;
_scale_with_level = EntityDataManager::get_instance()->get_scale_spells_by_default();
_scale_with_level = ESS::get_instance()->get_scale_spells_by_default();
_damage_enabled = false;
_damage_type = 0;

View File

@ -25,7 +25,7 @@ SOFTWARE.
#include "item_template.h"
#include "../../database/ess_resource_db.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
Ref<ItemTemplate> ItemInstance::get_item_template() {
return _item_template;
@ -113,8 +113,8 @@ 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_resource_db()->get_item_template(_item_template_id);
if (ESS::get_instance() != NULL) {
_item_template = ESS::get_instance()->get_resource_db()->get_item_template(_item_template_id);
}
_stack_size = dict.get("stack_size", 0);

View File

@ -23,7 +23,7 @@ SOFTWARE.
#include "species_instance.h"
#include "../../database/ess_resource_db.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
#include "entity_species_data.h"
@ -40,7 +40,7 @@ int SpeciesInstance::get_species_id() const {
void SpeciesInstance::set_species_id(int value) {
_id = value;
_species = EntityDataManager::get_instance()->get_resource_db()->get_entity_species_data(_id);
_species = ESS::get_instance()->get_resource_db()->get_entity_species_data(_id);
}
Ref<EntitySpeciesData> SpeciesInstance::get_species() {

View File

@ -29,7 +29,7 @@ SOFTWARE.
#include "../../entities/auras/aura_data.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
#include "../../pipelines/spell_damage_info.h"
#include "../../pipelines/spell_heal_info.h"
@ -864,7 +864,7 @@ Spell::Spell() {
_level = 1;
_rank = 0;
_scale_with_level = EntityDataManager::get_instance()->get_scale_spells_by_default();
_scale_with_level = ESS::get_instance()->get_scale_spells_by_default();
_global_cooldown_enabled = true;
_is_local_spell = false;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EntityDataManager" inherits="Object" version="3.2">
<class name="ESS" inherits="Object" version="3.2">
<brief_description>
The EntityDataManager singleton.
The ESS singleton.
</brief_description>
<description>
Gives easy access to entity and spell related data, providing easy lookups.

View File

@ -24,7 +24,7 @@ SOFTWARE.
#include "../../data/auras/aura.h"
#include "../../database/ess_resource_db.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
#include "../entity.h"
#include "core/version.h"
@ -314,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_resource_db()->get_aura(aura_id);
Ref<Aura> aura = ESS::get_instance()->get_resource_db()->get_aura(aura_id);
if (aura.is_valid()) {
_aura = aura;

View File

@ -23,7 +23,7 @@ SOFTWARE.
#include "entity.h"
#include "../database/ess_resource_db.h"
#include "../singletons/entity_data_manager.h"
#include "../singletons/ess.h"
#include "../singletons/profile_manager.h"
#include "../data/auras/aura.h"
@ -375,8 +375,8 @@ void Entity::setc_entity_data_id(int value) {
return;
}
if (EntityDataManager::get_instance() != NULL) {
setc_entity_data(EntityDataManager::get_instance()->get_resource_db()->get_entity_data(_c_class_id));
if (ESS::get_instance() != NULL) {
setc_entity_data(ESS::get_instance()->get_resource_db()->get_entity_data(_c_class_id));
}
}
@ -510,7 +510,7 @@ void Entity::_setup(Ref<EntityCreateInfo> info) {
}
if (gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY) {
if (EntityDataManager::get_instance()->get_use_global_class_level()) {
if (ESS::get_instance()->get_use_global_class_level()) {
Ref<ClassProfile> cp = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(gets_entity_data()->get_id());
if (cp.is_valid()) {
@ -638,7 +638,7 @@ void Entity::_setup(Ref<EntityCreateInfo> info) {
sets_class_xp(info->get_class_xp());
sets_character_xp(info->get_character_xp());
if (EntityDataManager::get_instance()->get_allow_class_spell_learning()) {
if (ESS::get_instance()->get_allow_class_spell_learning()) {
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_id());
if (class_profile.is_valid() && class_profile->has_custom_data("spells")) {
@ -650,7 +650,7 @@ void Entity::_setup(Ref<EntityCreateInfo> info) {
}
}
if (EntityDataManager::get_instance()->get_allow_class_recipe_learning()) {
if (ESS::get_instance()->get_allow_class_recipe_learning()) {
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_id());
if (class_profile.is_valid() && class_profile->has_custom_data("recipes")) {
@ -1103,7 +1103,7 @@ Dictionary Entity::_to_dict() {
//// Known Spells ////
if (EntityDataManager::get_instance()->get_use_spell_points())
if (ESS::get_instance()->get_use_spell_points())
dict["free_spell_points"] = _s_free_spell_points;
Dictionary known_spells;
@ -1143,7 +1143,7 @@ void Entity::_from_dict(const Dictionary &dict) {
sets_gender(static_cast<EntityEnums::EntityGender>(static_cast<int>(dict.get("gender", 0))));
if (EntityDataManager::get_instance()->get_use_global_class_level()) {
if (ESS::get_instance()->get_use_global_class_level()) {
_s_class_level = (dict.get("class_level", 0));
_s_class_xp = (dict.get("class_xp", 0));
} else {
@ -1201,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_resource_db()->get_entity_resource(data_id);
Ref<EntityResourceData> resd = ESS::get_instance()->get_resource_db()->get_entity_resource(data_id);
ERR_CONTINUE(!resd.is_valid());
@ -1331,8 +1331,8 @@ void Entity::_from_dict(const Dictionary &dict) {
for (int i = 0; i < known_recipes.size(); ++i) {
int crid = known_recipes.get(String::num(i), 0);
if (EntityDataManager::get_instance() != NULL) {
Ref<CraftRecipe> cr = EntityDataManager::get_instance()->get_resource_db()->get_craft_recipe(crid);
if (ESS::get_instance() != NULL) {
Ref<CraftRecipe> cr = ESS::get_instance()->get_resource_db()->get_craft_recipe(crid);
if (cr.is_valid()) {
adds_craft_recipe(cr);
@ -1342,7 +1342,7 @@ void Entity::_from_dict(const Dictionary &dict) {
//// Known Spells ////
if (EntityDataManager::get_instance()->get_use_spell_points())
if (ESS::get_instance()->get_use_spell_points())
sets_free_spell_points(dict.get("free_spell_points", 0));
Dictionary known_spells = dict.get("known_spells", Dictionary());
@ -1350,8 +1350,8 @@ void Entity::_from_dict(const Dictionary &dict) {
for (int i = 0; i < known_spells.size(); ++i) {
int spell_id = known_spells.get(String::num(i), 0);
if (EntityDataManager::get_instance() != NULL) {
Ref<Spell> sp = EntityDataManager::get_instance()->get_resource_db()->get_spell(spell_id);
if (ESS::get_instance() != NULL) {
Ref<Spell> sp = ESS::get_instance()->get_resource_db()->get_spell(spell_id);
if (sp.is_valid()) {
_s_spells.push_back(sp);
@ -1398,8 +1398,8 @@ 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_resource_db()->get_entity_data(edi));
if (ESS::get_instance() != NULL) {
sets_entity_data(ESS::get_instance()->get_resource_db()->get_entity_data(edi));
}
sets_entity_data_id(edi);
@ -1533,18 +1533,18 @@ void Entity::adds_craft_recipe(Ref<CraftRecipe> craft_recipe) {
ORPC(addc_craft_recipe_id, craft_recipe->get_id());
}
void Entity::adds_craft_recipe_id(int id) {
ERR_FAIL_COND(!EntityDataManager::get_instance());
ERR_FAIL_COND(!ESS::get_instance());
if (hass_craft_recipe_id(id))
return;
Ref<CraftRecipe> craft_recipe = EntityDataManager::get_instance()->get_resource_db()->get_craft_recipe(id);
Ref<CraftRecipe> craft_recipe = ESS::get_instance()->get_resource_db()->get_craft_recipe(id);
ERR_FAIL_COND(!craft_recipe.is_valid());
_s_craft_recipes.push_back(craft_recipe);
if (EntityDataManager::get_instance()->get_allow_class_recipe_learning() && (_s_entity_player_type == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY)) {
if (ESS::get_instance()->get_allow_class_recipe_learning() && (_s_entity_player_type == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY)) {
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_id());
if (class_profile->has_custom_data("recipes")) {
@ -1653,12 +1653,12 @@ void Entity::addc_craft_recipe(Ref<CraftRecipe> craft_recipe) {
emit_signal("ccraft_recipe_added", this, craft_recipe);
}
void Entity::addc_craft_recipe_id(int id) {
ERR_FAIL_COND(!EntityDataManager::get_instance());
ERR_FAIL_COND(!ESS::get_instance());
if (hasc_craft_recipe_id(id))
return;
Ref<CraftRecipe> craft_recipe = EntityDataManager::get_instance()->get_resource_db()->get_craft_recipe(id);
Ref<CraftRecipe> craft_recipe = ESS::get_instance()->get_resource_db()->get_craft_recipe(id);
ERR_FAIL_COND(!craft_recipe.is_valid());
@ -2155,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_resource_db()->get_entity_resource(data_id);
Ref<EntityResourceData> resd = ESS::get_instance()->get_resource_db()->get_entity_resource(data_id);
ERR_FAIL_COND(!resd.is_valid());
@ -2599,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_resource_db()->get_item_template(item_id);
Ref<ItemTemplate> it = ESS::get_instance()->get_resource_db()->get_item_template(item_id);
ERR_FAIL_COND(!it.is_valid());
@ -4532,7 +4532,7 @@ void Entity::adds_spell(Ref<Spell> spell) {
_s_spells.push_back(spell);
if (EntityDataManager::get_instance()->get_allow_class_spell_learning() && (_s_entity_player_type == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY)) {
if (ESS::get_instance()->get_allow_class_spell_learning() && (_s_entity_player_type == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY)) {
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_id());
if (class_profile->has_custom_data("spells")) {
@ -4564,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_resource_db()->get_spell(id);
Ref<Spell> spell = ESS::get_instance()->get_resource_db()->get_spell(id);
ERR_FAIL_COND(!spell.is_valid());
@ -4642,14 +4642,14 @@ int Entity::getc_spell_count() {
}
void Entity::addc_spell_rpc(int id) {
ERR_FAIL_COND(EntityDataManager::get_instance() == NULL);
ERR_FAIL_COND(ESS::get_instance() == NULL);
addc_spell(EntityDataManager::get_instance()->get_resource_db()->get_spell(id));
addc_spell(ESS::get_instance()->get_resource_db()->get_spell(id));
}
void Entity::removec_spell_rpc(int id) {
ERR_FAIL_COND(EntityDataManager::get_instance() == NULL);
ERR_FAIL_COND(ESS::get_instance() == NULL);
removec_spell(EntityDataManager::get_instance()->get_resource_db()->get_spell(id));
removec_spell(ESS::get_instance()->get_resource_db()->get_spell(id));
}
//Skills
@ -6339,9 +6339,9 @@ 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_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 (ESS::get_instance()->get_use_class_xp() && ESS::get_instance()->get_automatic_class_levelups()) {
if (ESS::get_instance()->get_resource_db()->get_xp_data()->can_class_level_up(gets_class_level())) {
int xpr = ESS::get_instance()->get_resource_db()->get_xp_data()->get_class_xp(gets_class_level());
if (xpr <= gets_class_xp()) {
sclass_levelup(1);
@ -6350,8 +6350,8 @@ void Entity::_son_xp_gained(int value) {
}
}
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 (ESS::get_instance()->get_resource_db()->get_xp_data()->can_character_level_up(gets_character_level())) {
int xpr = ESS::get_instance()->get_resource_db()->get_xp_data()->get_character_xp(gets_character_level());
if (xpr <= gets_character_xp()) {
scharacter_levelup(1);
@ -6380,8 +6380,8 @@ void Entity::_son_character_level_up(int level) {
sm->set_base_mod(sm->get_base_mod() + st);
}
if (!EntityDataManager::get_instance()->get_use_class_xp()) {
if (EntityDataManager::get_instance()->get_use_spell_points())
if (!ESS::get_instance()->get_use_class_xp()) {
if (ESS::get_instance()->get_use_spell_points())
sets_free_spell_points(gets_free_spell_points() + ecd->get_spell_points_per_level() * level);
sets_free_talent_points(gets_free_talent_points() + level);
@ -6397,7 +6397,7 @@ void Entity::_son_class_level_up(int level) {
if (!ecd.is_valid())
return;
if (EntityDataManager::get_instance()->get_use_spell_points())
if (ESS::get_instance()->get_use_spell_points())
sets_free_spell_points(gets_free_spell_points() + ecd->get_spell_points_per_level() * level);
sets_free_talent_points(gets_free_talent_points() + level);
@ -6473,7 +6473,7 @@ void Entity::_son_death() {
}
void Entity::_slearn_spell(int id) {
if (EntityDataManager::get_instance()->get_use_spell_points()) {
if (ESS::get_instance()->get_use_spell_points()) {
ERR_FAIL_COND(gets_free_spell_points() <= 0);
}
@ -6498,7 +6498,7 @@ void Entity::_slearn_spell(int id) {
adds_spell(sp);
if (EntityDataManager::get_instance()->get_use_spell_points())
if (ESS::get_instance()->get_use_spell_points())
sets_free_spell_points(_s_free_spell_points - 1);
return;

View File

@ -23,7 +23,7 @@ SOFTWARE.
#include "entity_resource.h"
#include "../../database/ess_resource_db.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
#include "../entity.h"
#include "../stats/stat.h"
#include "entity_resource_data.h"
@ -162,7 +162,7 @@ void EntityResource::receivec_update_string(const String str) {
}
void EntityResource::resolve_references() {
set_resource_data(EntityDataManager::get_instance()->get_resource_db()->get_entity_resource(_data_id));
set_resource_data(ESS::get_instance()->get_resource_db()->get_entity_resource(_data_id));
}
Dictionary EntityResource::to_dict() {

View File

@ -23,7 +23,7 @@ SOFTWARE.
#include "entity_skill.h"
#include "../../database/ess_resource_db.h"
#include "../../singletons/entity_data_manager.h"
#include "../../singletons/ess.h"
Ref<EntitySkillData> EntitySkill::get_skill() {
return _skill;
@ -45,8 +45,8 @@ int EntitySkill::get_skill_id() {
void EntitySkill::set_skill_id(int value) {
_skill_id = value;
if (EntityDataManager::get_instance() != NULL) {
_skill = EntityDataManager::get_instance()->get_resource_db()->get_entity_skill(_skill_id);
if (ESS::get_instance() != NULL) {
_skill = ESS::get_instance()->get_resource_db()->get_entity_skill(_skill_id);
}
emit_signal("skill_changed", Ref<EntitySkill>(this));

View File

@ -27,7 +27,7 @@ SOFTWARE.
#include "../data/spells/spell.h"
#include "../database/ess_resource_db.h"
#include "../entities/entity.h"
#include "../singletons/entity_data_manager.h"
#include "../singletons/ess.h"
#include "core/version.h"
@ -181,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_resource_db()->get_spell(_spell_id);
Ref<Spell> spell = ESS::get_instance()->get_resource_db()->get_spell(_spell_id);
if (spell.is_valid()) {
_spell = spell;

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include "../data/spells/spell.h"
#include "../database/ess_resource_db.h"
#include "../entities/entity.h"
#include "../singletons/entity_data_manager.h"
#include "../singletons/ess.h"
#include "core/version.h"
@ -176,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_resource_db()->get_spell(_damage_source_id);
_damage_source = ESS::get_instance()->get_resource_db()->get_spell(_damage_source_id);
} else if (_damage_source_type == DAMAGE_SOURCE_AURA) {
_damage_source = EntityDataManager::get_instance()->get_resource_db()->get_aura(_damage_source_id);
_damage_source = ESS::get_instance()->get_resource_db()->get_aura(_damage_source_id);
}
}

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include "../data/spells/spell.h"
#include "../database/ess_resource_db.h"
#include "../entities/entity.h"
#include "../singletons/entity_data_manager.h"
#include "../singletons/ess.h"
#include "core/version.h"
@ -172,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_resource_db()->get_spell(_heal_source_id);
_heal_source = ESS::get_instance()->get_resource_db()->get_spell(_heal_source_id);
} else if (_heal_source_type == HEAL_SOURCE_AURA) {
_heal_source = EntityDataManager::get_instance()->get_resource_db()->get_aura(_heal_source_id);
_heal_source = ESS::get_instance()->get_resource_db()->get_aura(_heal_source_id);
}
}

View File

@ -25,7 +25,7 @@ SOFTWARE.
#include "entity_enums.h"
#include "item_enums.h"
#include "singletons/entity_data_manager.h"
#include "singletons/ess.h"
#include "data/auras/aura.h"
#include "data/auras/aura_group.h"
@ -137,7 +137,7 @@ SOFTWARE.
#include "database/ess_resource_db.cpp"
static EntityDataManager *entity_data_manager = NULL;
static ESS *entity_data_manager = NULL;
static ProfileManager *profile_manager = NULL;
void register_entity_spell_system_types() {
@ -267,9 +267,9 @@ void register_entity_spell_system_types() {
ClassDB::register_class<ProfileManager>();
entity_data_manager = memnew(EntityDataManager);
ClassDB::register_class<EntityDataManager>();
Engine::get_singleton()->add_singleton(Engine::Singleton("EntityDataManager", EntityDataManager::get_instance()));
entity_data_manager = memnew(ESS);
ClassDB::register_class<ESS>();
Engine::get_singleton()->add_singleton(Engine::Singleton("ESS", ESS::get_instance()));
profile_manager = memnew(ProfileManager);
ClassDB::register_class<ProfileManager>();

View File

@ -20,84 +20,84 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "entity_data_manager.h"
#include "ess.h"
#include "../database/ess_resource_db.h"
#include "../utility/entity_create_info.h"
EntityDataManager *EntityDataManager::instance;
ESS *ESS::instance;
EntityDataManager *EntityDataManager::get_instance() {
ESS *ESS::get_instance() {
return instance;
}
bool EntityDataManager::get_use_spell_points() const {
bool ESS::get_use_spell_points() const {
return _use_spell_points;
}
void EntityDataManager::set_use_spell_points(const bool value) {
void ESS::set_use_spell_points(const bool value) {
_use_spell_points = value;
}
bool EntityDataManager::get_scale_spells_by_default() const {
bool ESS::get_scale_spells_by_default() const {
return _scale_spells_by_default;
}
void EntityDataManager::set_scale_spells_by_default(const bool value) {
void ESS::set_scale_spells_by_default(const bool value) {
_scale_spells_by_default = value;
}
bool EntityDataManager::get_automatic_load() const {
bool ESS::get_automatic_load() const {
return _automatic_load;
}
void EntityDataManager::set_automatic_load(const bool load) {
void ESS::set_automatic_load(const bool load) {
_automatic_load = load;
}
bool EntityDataManager::get_use_class_xp() const {
bool ESS::get_use_class_xp() const {
return _use_class_xp;
}
void EntityDataManager::set_use_class_xp(const bool value) {
void ESS::set_use_class_xp(const bool value) {
_use_class_xp = value;
}
bool EntityDataManager::get_automatic_class_levelups() const {
bool ESS::get_automatic_class_levelups() const {
return _automatic_class_levelups;
}
void EntityDataManager::set_automatic_class_levelups(const bool value) {
void ESS::set_automatic_class_levelups(const bool value) {
_automatic_class_levelups = value;
}
bool EntityDataManager::get_use_global_class_level() const {
bool ESS::get_use_global_class_level() const {
return _use_global_class_level;
}
void EntityDataManager::set_use_global_class_level(const bool value) {
void ESS::set_use_global_class_level(const bool value) {
_use_global_class_level = value;
}
bool EntityDataManager::get_allow_class_spell_learning() const {
bool ESS::get_allow_class_spell_learning() const {
return _allow_class_spell_learning;
}
void EntityDataManager::set_allow_class_spell_learning(const bool value) {
void ESS::set_allow_class_spell_learning(const bool value) {
_allow_class_spell_learning = value;
}
bool EntityDataManager::get_allow_class_recipe_learning() const {
bool ESS::get_allow_class_recipe_learning() const {
return _allow_class_recipe_learning;
}
void EntityDataManager::set_allow_class_recipe_learning(const bool value) {
void ESS::set_allow_class_recipe_learning(const bool value) {
_allow_class_recipe_learning = value;
}
String EntityDataManager::get_resource_db_path() {
String ESS::get_resource_db_path() {
return _ess_resource_db_path;
}
void EntityDataManager::set_resource_db_path(String path) {
void ESS::set_resource_db_path(String path) {
_ess_resource_db_path = path;
}
Ref<ESSResourceDB> EntityDataManager::get_resource_db() {
Ref<ESSResourceDB> ESS::get_resource_db() {
return _ess_resource_db;
}
void EntityDataManager::load_resource_db() {
void ESS::load_resource_db() {
_Directory dir;
ERR_FAIL_COND(_ess_resource_db_path == "");
@ -109,7 +109,7 @@ void EntityDataManager::load_resource_db() {
_ess_resource_db = d;
}
Ref<Resource> EntityDataManager::load_resource(const String &path, const String &type_hint) {
Ref<Resource> ESS::load_resource(const String &path, const String &type_hint) {
_ResourceLoader *rl = _ResourceLoader::get_singleton();
#if VERSION_MAJOR < 4
@ -125,65 +125,65 @@ Ref<Resource> EntityDataManager::load_resource(const String &path, const String
#endif
}
void EntityDataManager::request_entity_spawn(const Ref<EntityCreateInfo> &info) {
void ESS::request_entity_spawn(const Ref<EntityCreateInfo> &info) {
emit_signal("on_entity_spawn_requested", info);
}
void EntityDataManager::request_entity_spawn_deferred(const Ref<EntityCreateInfo> &info) {
void ESS::request_entity_spawn_deferred(const Ref<EntityCreateInfo> &info) {
call_deferred("emit_signal", "on_entity_spawn_requested", info);
}
void EntityDataManager::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_use_spell_points"), &EntityDataManager::get_use_spell_points);
ClassDB::bind_method(D_METHOD("set_use_spell_points", "value"), &EntityDataManager::set_use_spell_points);
void ESS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_use_spell_points"), &ESS::get_use_spell_points);
ClassDB::bind_method(D_METHOD("set_use_spell_points", "value"), &ESS::set_use_spell_points);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_spell_points"), "set_use_spell_points", "get_use_spell_points");
ClassDB::bind_method(D_METHOD("get_scale_spells_by_default"), &EntityDataManager::get_scale_spells_by_default);
ClassDB::bind_method(D_METHOD("set_scale_spells_by_default", "value"), &EntityDataManager::set_scale_spells_by_default);
ClassDB::bind_method(D_METHOD("get_scale_spells_by_default"), &ESS::get_scale_spells_by_default);
ClassDB::bind_method(D_METHOD("set_scale_spells_by_default", "value"), &ESS::set_scale_spells_by_default);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scale_spells_by_default"), "set_scale_spells_by_default", "get_scale_spells_by_default");
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);
ClassDB::bind_method(D_METHOD("get_automatic_load"), &ESS::get_automatic_load);
ClassDB::bind_method(D_METHOD("set_automatic_load", "load"), &ESS::set_automatic_load);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load");
ClassDB::bind_method(D_METHOD("get_automatic_class_levelups"), &EntityDataManager::get_automatic_class_levelups);
ClassDB::bind_method(D_METHOD("set_automatic_class_levelups", "load"), &EntityDataManager::set_automatic_class_levelups);
ClassDB::bind_method(D_METHOD("get_automatic_class_levelups"), &ESS::get_automatic_class_levelups);
ClassDB::bind_method(D_METHOD("set_automatic_class_levelups", "load"), &ESS::set_automatic_class_levelups);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_class_levelups"), "set_automatic_class_levelups", "get_automatic_class_levelups");
ClassDB::bind_method(D_METHOD("get_use_class_xp"), &EntityDataManager::get_use_class_xp);
ClassDB::bind_method(D_METHOD("set_use_class_xp", "value"), &EntityDataManager::set_use_class_xp);
ClassDB::bind_method(D_METHOD("get_use_class_xp"), &ESS::get_use_class_xp);
ClassDB::bind_method(D_METHOD("set_use_class_xp", "value"), &ESS::set_use_class_xp);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_class_xp"), "set_use_class_xp", "get_use_class_xp");
ClassDB::bind_method(D_METHOD("get_use_global_class_level"), &EntityDataManager::get_use_global_class_level);
ClassDB::bind_method(D_METHOD("set_use_global_class_level", "value"), &EntityDataManager::set_use_global_class_level);
ClassDB::bind_method(D_METHOD("get_use_global_class_level"), &ESS::get_use_global_class_level);
ClassDB::bind_method(D_METHOD("set_use_global_class_level", "value"), &ESS::set_use_global_class_level);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_global_class_level"), "set_use_global_class_level", "get_use_global_class_level");
ClassDB::bind_method(D_METHOD("get_allow_class_spell_learning"), &EntityDataManager::get_allow_class_spell_learning);
ClassDB::bind_method(D_METHOD("set_allow_class_spell_learning", "value"), &EntityDataManager::set_allow_class_spell_learning);
ClassDB::bind_method(D_METHOD("get_allow_class_spell_learning"), &ESS::get_allow_class_spell_learning);
ClassDB::bind_method(D_METHOD("set_allow_class_spell_learning", "value"), &ESS::set_allow_class_spell_learning);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_class_spell_learning"), "set_allow_class_spell_learning", "get_allow_class_spell_learning");
ClassDB::bind_method(D_METHOD("get_allow_class_recipe_learning"), &EntityDataManager::get_allow_class_recipe_learning);
ClassDB::bind_method(D_METHOD("set_allow_class_recipe_learning", "value"), &EntityDataManager::set_allow_class_recipe_learning);
ClassDB::bind_method(D_METHOD("get_allow_class_recipe_learning"), &ESS::get_allow_class_recipe_learning);
ClassDB::bind_method(D_METHOD("set_allow_class_recipe_learning", "value"), &ESS::set_allow_class_recipe_learning);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_class_recipe_learning"), "set_allow_class_recipe_learning", "get_allow_class_recipe_learning");
//XPData
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);
ClassDB::bind_method(D_METHOD("get_resource_db_path"), &ESS::get_resource_db_path);
ClassDB::bind_method(D_METHOD("set_resource_db_path", "path"), &ESS::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_resource_db"), &EntityDataManager::get_resource_db);
ClassDB::bind_method(D_METHOD("get_resource_db"), &ESS::get_resource_db);
//load
ClassDB::bind_method(D_METHOD("load_resource_db"), &EntityDataManager::load_resource_db);
ClassDB::bind_method(D_METHOD("load_resource_db"), &ESS::load_resource_db);
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &EntityDataManager::load_resource, DEFVAL(""));
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &ESS::load_resource, DEFVAL(""));
ADD_SIGNAL(MethodInfo("on_entity_spawn_requested", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "EntityCreateInfo")));
ClassDB::bind_method(D_METHOD("request_entity_spawn", "info"), &EntityDataManager::request_entity_spawn);
ClassDB::bind_method(D_METHOD("request_entity_spawn_deferred", "info"), &EntityDataManager::request_entity_spawn_deferred);
ClassDB::bind_method(D_METHOD("request_entity_spawn", "info"), &ESS::request_entity_spawn);
ClassDB::bind_method(D_METHOD("request_entity_spawn_deferred", "info"), &ESS::request_entity_spawn_deferred);
}
EntityDataManager::EntityDataManager() {
ESS::ESS() {
instance = this;
_use_spell_points = GLOBAL_DEF("ess/spells/use_spell_points", false);
@ -204,7 +204,7 @@ EntityDataManager::EntityDataManager() {
}
}
EntityDataManager::~EntityDataManager() {
ESS::~ESS() {
instance = NULL;
_ess_resource_db.unref();

View File

@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef ENTITY_DATA_MANAGER_H
#define ENTITY_DATA_MANAGER_H
#ifndef ESS_H
#define ESS_H
#include "core/object.h"
@ -36,11 +36,11 @@ SOFTWARE.
class ESSResourceDB;
class EntityCreateInfo;
class EntityDataManager : public Object {
GDCLASS(EntityDataManager, Object);
class ESS : public Object {
GDCLASS(ESS, Object);
public:
static EntityDataManager *get_instance();
static ESS *get_instance();
bool get_use_spell_points() const;
void set_use_spell_points(const bool value);
@ -78,8 +78,8 @@ public:
void request_entity_spawn(const Ref<EntityCreateInfo> &info);
void request_entity_spawn_deferred(const Ref<EntityCreateInfo> &info);
EntityDataManager();
~EntityDataManager();
ESS();
~ESS();
protected:
static void _bind_methods();
@ -89,7 +89,7 @@ private:
String _ess_resource_db_path;
Ref<ESSResourceDB> _ess_resource_db;
static EntityDataManager *instance;
static ESS *instance;
bool _use_spell_points;
bool _scale_spells_by_default;