2020-01-31 19:34:47 +01:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
#include "ess.h"
|
2019-04-20 14:02:55 +02:00
|
|
|
|
2020-04-14 16:46:24 +02:00
|
|
|
#include "../database/ess_resource_db.h"
|
2020-04-18 14:31:36 +02:00
|
|
|
#include "../spawners/ess_entity_spawner.h"
|
2020-04-14 16:46:24 +02:00
|
|
|
#include "../utility/entity_create_info.h"
|
2019-04-20 14:02:55 +02:00
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
ESS *ESS::instance;
|
2019-04-20 14:02:55 +02:00
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
ESS *ESS::get_instance() {
|
2019-05-30 00:26:02 +02:00
|
|
|
return instance;
|
2019-04-20 14:02:55 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_use_spell_points() const {
|
2020-02-21 11:56:57 +01:00
|
|
|
return _use_spell_points;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_use_spell_points(const bool value) {
|
2020-02-21 11:56:57 +01:00
|
|
|
_use_spell_points = value;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_scale_spells_by_default() const {
|
2020-03-10 13:24:14 +01:00
|
|
|
return _scale_spells_by_default;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_scale_spells_by_default(const bool value) {
|
2020-03-10 13:24:14 +01:00
|
|
|
_scale_spells_by_default = value;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_automatic_load() const {
|
2020-02-03 13:01:17 +01:00
|
|
|
return _automatic_load;
|
2020-02-02 02:44:37 +01:00
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_automatic_load(const bool load) {
|
2020-02-03 13:01:17 +01:00
|
|
|
_automatic_load = load;
|
2019-05-30 00:26:02 +02:00
|
|
|
}
|
2019-04-20 14:02:55 +02:00
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_use_class_xp() const {
|
2020-03-17 22:35:29 +01:00
|
|
|
return _use_class_xp;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_use_class_xp(const bool value) {
|
2020-03-17 22:35:29 +01:00
|
|
|
_use_class_xp = value;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_automatic_class_levelups() const {
|
2020-03-17 22:35:29 +01:00
|
|
|
return _automatic_class_levelups;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_automatic_class_levelups(const bool value) {
|
2020-03-17 22:35:29 +01:00
|
|
|
_automatic_class_levelups = value;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_use_global_class_level() const {
|
2020-03-17 22:35:29 +01:00
|
|
|
return _use_global_class_level;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_use_global_class_level(const bool value) {
|
2020-03-17 22:35:29 +01:00
|
|
|
_use_global_class_level = value;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_allow_class_spell_learning() const {
|
2020-03-20 03:29:36 +01:00
|
|
|
return _allow_class_spell_learning;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_allow_class_spell_learning(const bool value) {
|
2020-03-20 03:29:36 +01:00
|
|
|
_allow_class_spell_learning = value;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
bool ESS::get_allow_class_recipe_learning() const {
|
2020-03-20 03:29:36 +01:00
|
|
|
return _allow_class_recipe_learning;
|
|
|
|
}
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::set_allow_class_recipe_learning(const bool value) {
|
2020-03-20 03:29:36 +01:00
|
|
|
_allow_class_recipe_learning = value;
|
|
|
|
}
|
|
|
|
|
2020-05-19 02:19:23 +02:00
|
|
|
int ESS::get_max_character_level() const {
|
|
|
|
return _max_character_level;
|
|
|
|
}
|
|
|
|
void ESS::set_max_character_level(const int value) {
|
|
|
|
_max_character_level = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ESS::get_max_class_level() const {
|
|
|
|
return _max_class_level;
|
|
|
|
}
|
|
|
|
void ESS::set_max_class_level(const int value) {
|
|
|
|
_max_class_level = value;
|
|
|
|
}
|
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
Ref<ESSResourceDB> ESS::get_resource_db() {
|
|
|
|
return _ess_resource_db;
|
|
|
|
}
|
|
|
|
void ESS::set_resource_db(const Ref<ESSResourceDB> &resource_db) {
|
|
|
|
_ess_resource_db = resource_db;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<ESSEntitySpawner> ESS::get_entity_spawner() {
|
|
|
|
return _ess_entity_spawner;
|
|
|
|
}
|
|
|
|
void ESS::set_entity_spawner(const Ref<ESSEntitySpawner> &spawner) {
|
|
|
|
_ess_entity_spawner = spawner;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
String ESS::get_resource_db_path() {
|
2020-04-14 16:46:24 +02:00
|
|
|
return _ess_resource_db_path;
|
2019-10-13 15:21:28 +02:00
|
|
|
}
|
2020-04-18 14:31:36 +02:00
|
|
|
void ESS::set_resource_db_path(const String &path) {
|
2020-04-14 16:46:24 +02:00
|
|
|
_ess_resource_db_path = path;
|
2019-09-12 15:05:42 +02:00
|
|
|
}
|
2020-04-18 14:31:36 +02:00
|
|
|
|
|
|
|
String ESS::get_entity_spawner_path() {
|
|
|
|
return _ess_entity_spawner_path;
|
|
|
|
}
|
|
|
|
void ESS::set_entity_spawner_path(const String &path) {
|
|
|
|
_ess_entity_spawner_path = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ESS::request_entity_spawn(Ref<EntityCreateInfo> info) {
|
|
|
|
if (_ess_entity_spawner.is_valid())
|
|
|
|
_ess_entity_spawner->request_entity_spawn(info);
|
|
|
|
}
|
|
|
|
void ESS::request_entity_spawn_deferred(Ref<EntityCreateInfo> info) {
|
|
|
|
if (_ess_entity_spawner.is_valid())
|
|
|
|
_ess_entity_spawner->request_entity_spawn_deferred(info);
|
2019-05-04 20:19:54 +02:00
|
|
|
}
|
2020-04-14 14:15:38 +02:00
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
void ESS::load_resource_db() {
|
2019-09-12 15:05:42 +02:00
|
|
|
_Directory dir;
|
|
|
|
|
2020-04-14 16:46:24 +02:00
|
|
|
ERR_FAIL_COND(_ess_resource_db_path == "");
|
2019-09-12 15:05:42 +02:00
|
|
|
|
2020-04-14 16:46:24 +02:00
|
|
|
Ref<ESSResourceDB> d = load_resource(_ess_resource_db_path, "ESSResourceDB");
|
2019-09-12 15:05:42 +02:00
|
|
|
|
|
|
|
ERR_FAIL_COND(!d.is_valid());
|
|
|
|
|
2020-04-14 16:46:24 +02:00
|
|
|
_ess_resource_db = d;
|
2020-02-03 16:13:42 +01:00
|
|
|
}
|
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
void ESS::load_entity_spawner() {
|
|
|
|
_Directory dir;
|
|
|
|
|
|
|
|
ERR_FAIL_COND(_ess_entity_spawner_path == "");
|
|
|
|
|
|
|
|
Ref<ESSEntitySpawner> d = load_resource(_ess_entity_spawner_path, "ESSEntitySpawner");
|
|
|
|
|
|
|
|
ERR_FAIL_COND(!d.is_valid());
|
|
|
|
|
|
|
|
_ess_entity_spawner = d;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
Ref<Resource> ESS::load_resource(const String &path, const String &type_hint) {
|
2020-04-14 00:26:27 +02:00
|
|
|
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
|
|
|
|
|
|
|
#if VERSION_MAJOR < 4
|
|
|
|
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
|
|
|
|
|
|
|
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
|
|
|
|
|
|
|
resl->wait();
|
|
|
|
|
|
|
|
return resl->get_resource();
|
|
|
|
#else
|
|
|
|
return rl->load(path, type_hint);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
void ESS::load_all() {
|
|
|
|
load_resource_db();
|
|
|
|
load_entity_spawner();
|
|
|
|
|
|
|
|
_ess_resource_db->initialize();
|
2020-02-02 02:44:37 +01:00
|
|
|
}
|
2020-04-18 14:31:36 +02:00
|
|
|
|
|
|
|
void ESS::setup(const Ref<ESSResourceDB> &resource_db, const Ref<ESSEntitySpawner> &entity_spawner) {
|
|
|
|
_ess_resource_db = resource_db;
|
|
|
|
_ess_entity_spawner = entity_spawner;
|
2020-02-16 16:17:19 +01:00
|
|
|
}
|
2020-02-02 02:44:37 +01:00
|
|
|
|
2020-04-25 14:38:52 +02:00
|
|
|
//Stats
|
|
|
|
void ESS::stat_set_string(const String &stat_enum_string) {
|
|
|
|
_stat_enum_string = stat_enum_string;
|
|
|
|
|
|
|
|
_stat_id_to_name.clear();
|
|
|
|
_stat_name_to_id.clear();
|
|
|
|
|
2020-04-25 18:51:37 +02:00
|
|
|
_stat_id_to_property.clear();
|
|
|
|
_stat_property_to_id.clear();
|
|
|
|
|
2020-04-25 14:38:52 +02:00
|
|
|
int slicec = stat_enum_string.get_slice_count(",");
|
|
|
|
_stat_id_to_name.resize(slicec);
|
2020-04-25 18:51:37 +02:00
|
|
|
_stat_id_to_property.resize(slicec);
|
2020-04-25 14:38:52 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < slicec; ++i) {
|
2020-04-25 18:51:37 +02:00
|
|
|
String slice = stat_enum_string.get_slicec(',', i);
|
|
|
|
StringName s = StringName(slice);
|
2020-04-25 14:38:52 +02:00
|
|
|
|
|
|
|
_stat_id_to_name.set(i, s);
|
|
|
|
_stat_name_to_id.set(s, i);
|
2020-04-25 18:51:37 +02:00
|
|
|
|
|
|
|
String st = slice;
|
|
|
|
st = st.to_lower();
|
|
|
|
st = st.replace(" ", "_");
|
|
|
|
StringName stp = StringName(st);
|
|
|
|
|
|
|
|
_stat_id_to_property.set(i, stp);
|
|
|
|
_stat_property_to_id.set(stp, i);
|
2020-04-25 14:38:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
String ESS::stat_get_string() const {
|
|
|
|
return _stat_enum_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ESS::stat_get_id(const StringName &name) const {
|
|
|
|
ERR_FAIL_COND_V(!_stat_name_to_id.has(name), 0);
|
|
|
|
|
|
|
|
return _stat_name_to_id[name];
|
|
|
|
}
|
|
|
|
StringName ESS::stat_get_name(const int id) const {
|
|
|
|
ERR_FAIL_INDEX_V(id, _stat_id_to_name.size(), StringName());
|
|
|
|
|
|
|
|
return _stat_id_to_name[id];
|
|
|
|
}
|
2020-04-25 18:51:37 +02:00
|
|
|
|
|
|
|
int ESS::stat_get_property_id(const StringName &name) const {
|
|
|
|
ERR_FAIL_COND_V(!_stat_property_to_id.has(name), 0);
|
|
|
|
|
|
|
|
return _stat_property_to_id[name];
|
|
|
|
}
|
|
|
|
StringName ESS::stat_get_property_name(const int id) const {
|
|
|
|
ERR_FAIL_INDEX_V(id, _stat_id_to_property.size(), StringName());
|
|
|
|
|
|
|
|
return _stat_id_to_property[id];
|
|
|
|
}
|
2020-04-25 19:02:17 +02:00
|
|
|
bool ESS::stat_is_property(const StringName &name) const {
|
|
|
|
return _stat_property_to_id.has(name);
|
|
|
|
}
|
2020-04-25 18:51:37 +02:00
|
|
|
|
2020-04-25 14:38:52 +02:00
|
|
|
int ESS::stat_get_count() const {
|
|
|
|
return _stat_id_to_name.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
PoolStringArray ESS::stats_get() const {
|
|
|
|
PoolStringArray arr;
|
|
|
|
arr.resize(_stat_id_to_name.size());
|
|
|
|
|
|
|
|
for (int i = 0; i < _stat_id_to_name.size(); ++i) {
|
|
|
|
arr.set(i, _stat_id_to_name[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ESS::stats_set(const PoolStringArray &array) {
|
|
|
|
_stat_enum_string = "";
|
|
|
|
|
|
|
|
_stat_id_to_name.clear();
|
|
|
|
_stat_name_to_id.clear();
|
|
|
|
|
2020-04-25 18:51:37 +02:00
|
|
|
_stat_id_to_property.clear();
|
|
|
|
_stat_property_to_id.clear();
|
|
|
|
|
2020-04-25 14:38:52 +02:00
|
|
|
_stat_id_to_name.resize(array.size());
|
2020-04-25 18:51:37 +02:00
|
|
|
_stat_id_to_property.resize(array.size());
|
2020-04-25 14:38:52 +02:00
|
|
|
|
|
|
|
if (array.size() > 0)
|
|
|
|
_stat_enum_string += array[0];
|
|
|
|
|
|
|
|
for (int i = 0; i < array.size(); ++i) {
|
|
|
|
StringName s = StringName(array[i]);
|
|
|
|
|
|
|
|
_stat_id_to_name.set(i, s);
|
|
|
|
_stat_name_to_id.set(s, i);
|
|
|
|
|
2020-04-25 18:51:37 +02:00
|
|
|
String st = array[i];
|
|
|
|
st = st.to_lower();
|
|
|
|
st = st.replace(" ", "_");
|
|
|
|
StringName stp = StringName(st);
|
|
|
|
|
|
|
|
_stat_id_to_property.set(i, stp);
|
|
|
|
_stat_property_to_id.set(stp, i);
|
|
|
|
|
2020-04-25 14:38:52 +02:00
|
|
|
_stat_enum_string += ",";
|
|
|
|
_stat_enum_string += array[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int ESS::stat_get_main_stat_count() const {
|
|
|
|
return _stat_main_stat_count;
|
|
|
|
}
|
|
|
|
void ESS::stat_set_main_stat_count(const int index) {
|
|
|
|
_stat_main_stat_count = index;
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-10 13:24:14 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_spell_points"), "set_use_spell_points", "get_use_spell_points");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-10 13:24:14 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scale_spells_by_default"), "set_scale_spells_by_default", "get_scale_spells_by_default");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-10 13:24:14 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-17 22:35:29 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_class_levelups"), "set_automatic_class_levelups", "get_automatic_class_levelups");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-17 22:35:29 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_class_xp"), "set_use_class_xp", "get_use_class_xp");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-17 22:35:29 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_global_class_level"), "set_use_global_class_level", "get_use_global_class_level");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-20 03:29:36 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_class_spell_learning"), "set_allow_class_spell_learning", "get_allow_class_spell_learning");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-03-20 03:29:36 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_class_recipe_learning"), "set_allow_class_recipe_learning", "get_allow_class_recipe_learning");
|
|
|
|
|
2020-05-19 02:19:23 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_max_character_level"), &ESS::get_max_character_level);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_max_character_level", "value"), &ESS::set_max_character_level);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_character_level"), "set_max_character_level", "get_max_character_level");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_max_class_level"), &ESS::get_max_class_level);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_max_class_level", "value"), &ESS::set_max_class_level);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_class_level"), "set_max_class_level", "get_max_class_level");
|
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_resource_db"), &ESS::get_resource_db);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_resource_db"), &ESS::set_resource_db);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "resource_db", PROPERTY_HINT_RESOURCE_TYPE, "ESSResourceDB"), "set_resource_db", "get_resource_db");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_entity_spawner"), &ESS::get_entity_spawner);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_entity_spawner"), &ESS::set_entity_spawner);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "entity_spawner", PROPERTY_HINT_RESOURCE_TYPE, "ESSEntitySpawner"), "set_entity_spawner", "get_entity_spawner");
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-04-14 16:46:24 +02:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_db_path"), "set_resource_db_path", "get_resource_db_path");
|
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_entity_spawner_path"), &ESS::get_entity_spawner_path);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_entity_spawner_path", "path"), &ESS::set_entity_spawner_path);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "entity_spawner_path"), "set_entity_spawner_path", "get_entity_spawner_path");
|
2020-02-03 16:13:42 +01:00
|
|
|
|
2019-09-12 15:05:42 +02:00
|
|
|
//load
|
2020-04-14 16:55:21 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("load_resource_db"), &ESS::load_resource_db);
|
2020-04-18 20:33:55 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("load_entity_spawner"), &ESS::load_entity_spawner);
|
2020-02-02 02:44:37 +01:00
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &ESS::load_resource, DEFVAL(""));
|
2020-04-14 00:26:27 +02:00
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
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);
|
2020-04-18 14:31:36 +02:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("load_all"), &ESS::load_all);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("setup", "resource_db", "entity_spawner"), &ESS::setup);
|
2020-04-25 14:38:52 +02:00
|
|
|
|
|
|
|
//Stats
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_string"), &ESS::stat_get_string);
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_set_string", "stat_enum_string"), &ESS::stat_set_string);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "stat_string"), "stat_set_string", "stat_get_string");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_id", "name"), &ESS::stat_get_id);
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_name", "id"), &ESS::stat_get_name);
|
2020-04-25 18:51:37 +02:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_property_id", "name"), &ESS::stat_get_property_id);
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_property_name", "id"), &ESS::stat_get_property_name);
|
2020-04-25 19:02:17 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("stat_is_property", "name"), &ESS::stat_is_property);
|
2020-04-25 18:51:37 +02:00
|
|
|
|
2020-04-25 14:38:52 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_count"), &ESS::stat_get_count);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("stats_get"), &ESS::stats_get);
|
|
|
|
ClassDB::bind_method(D_METHOD("stats_set", "array"), &ESS::stats_set);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "stats"), "stats_set", "stats_get");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_get_main_stat_count"), &ESS::stat_get_main_stat_count);
|
|
|
|
ClassDB::bind_method(D_METHOD("stat_set_main_stat_count", "index"), &ESS::stat_set_main_stat_count);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "main_stat_count"), "stat_set_main_stat_count", "stat_get_main_stat_count");
|
2019-04-20 14:02:55 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
ESS::ESS() {
|
2019-05-30 00:26:02 +02:00
|
|
|
instance = this;
|
2019-04-20 14:02:55 +02:00
|
|
|
|
2020-02-21 11:56:57 +01:00
|
|
|
_use_spell_points = GLOBAL_DEF("ess/spells/use_spell_points", false);
|
2020-03-10 13:24:14 +01:00
|
|
|
_scale_spells_by_default = GLOBAL_DEF("ess/spells/scale_spells_by_default", false);
|
2020-03-20 03:29:36 +01:00
|
|
|
_allow_class_spell_learning = GLOBAL_DEF("ess/spells/allow_class_spell_learning", false);
|
|
|
|
_allow_class_recipe_learning = GLOBAL_DEF("ess/spells/allow_class_recipe_learning", false);
|
2020-03-17 22:35:29 +01:00
|
|
|
|
|
|
|
_use_class_xp = GLOBAL_DEF("ess/level/use_class_xp", false);
|
|
|
|
_automatic_class_levelups = GLOBAL_DEF("ess/level/automatic_class_levelups", false);
|
|
|
|
_use_global_class_level = GLOBAL_DEF("ess/level/use_global_class_level", false);
|
|
|
|
|
2020-05-19 02:19:23 +02:00
|
|
|
_max_character_level = GLOBAL_DEF("ess/level/max_character_level", 20);
|
|
|
|
_max_class_level = GLOBAL_DEF("ess/level/max_class_level", 40);
|
|
|
|
|
2020-02-01 15:38:46 +01:00
|
|
|
_automatic_load = GLOBAL_DEF("ess/data/automatic_load", false);
|
2020-02-01 11:17:24 +01:00
|
|
|
|
2020-04-14 16:46:24 +02:00
|
|
|
_ess_resource_db_path = GLOBAL_DEF("ess/data/ess_resource_db_path", "");
|
2020-04-18 14:31:36 +02:00
|
|
|
_ess_entity_spawner_path = GLOBAL_DEF("ess/data/ess_entity_spawner_path", "");
|
2020-02-01 11:17:24 +01:00
|
|
|
|
2020-04-25 19:23:02 +02:00
|
|
|
stat_set_string(GLOBAL_DEF("ess/enums/stats", "Agility,Strength,Stamina,Intellect,Spirit,Health,Speed,Global Cooldown,Haste"));
|
|
|
|
_stat_main_stat_count = GLOBAL_DEF("ess/enums/main_stat_count", 5);
|
2020-04-25 14:38:52 +02:00
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
if (!Engine::get_singleton()->is_editor_hint() && _automatic_load) {
|
2020-02-01 15:38:46 +01:00
|
|
|
call_deferred("load_all");
|
|
|
|
}
|
2019-04-20 14:02:55 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 16:55:21 +02:00
|
|
|
ESS::~ESS() {
|
2019-05-30 00:26:02 +02:00
|
|
|
instance = NULL;
|
|
|
|
|
2020-04-14 16:46:24 +02:00
|
|
|
_ess_resource_db.unref();
|
2020-04-18 14:31:36 +02:00
|
|
|
_ess_entity_spawner.unref();
|
2020-04-25 14:38:52 +02:00
|
|
|
|
|
|
|
_stat_id_to_name.clear();
|
|
|
|
_stat_name_to_id.clear();
|
2020-04-25 18:51:37 +02:00
|
|
|
|
|
|
|
_stat_id_to_property.clear();
|
|
|
|
_stat_property_to_id.clear();
|
2019-04-20 14:02:55 +02:00
|
|
|
}
|