mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
Class profile now also uses resource paths instead of ids.
This commit is contained in:
parent
1893598fc3
commit
fa8f38fa5d
@ -518,7 +518,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 (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());
|
||||
Ref<ClassProfile> cp = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(gets_entity_data()->get_path());
|
||||
|
||||
if (cp.is_valid()) {
|
||||
int leveldiff = cp->get_level() - _s_class_level;
|
||||
@ -646,7 +646,7 @@ void Entity::_setup(Ref<EntityCreateInfo> info) {
|
||||
sets_character_xp(info->get_character_xp());
|
||||
|
||||
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());
|
||||
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path());
|
||||
|
||||
if (class_profile.is_valid() && class_profile->has_custom_data("spells")) {
|
||||
Vector<int> spells = class_profile->get_custom_data("spells");
|
||||
@ -658,7 +658,7 @@ void Entity::_setup(Ref<EntityCreateInfo> info) {
|
||||
}
|
||||
|
||||
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());
|
||||
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path());
|
||||
|
||||
if (class_profile.is_valid() && class_profile->has_custom_data("recipes")) {
|
||||
Vector<int> recipes = class_profile->get_custom_data("recipes");
|
||||
@ -942,7 +942,7 @@ int Entity::getc_pet_count() {
|
||||
//// Profiles ////
|
||||
|
||||
Ref<ClassProfile> Entity::get_class_profile() {
|
||||
return ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_class_id);
|
||||
return ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path());
|
||||
}
|
||||
|
||||
//// Serialization ////
|
||||
@ -1552,7 +1552,7 @@ void Entity::adds_craft_recipe_id(int id) {
|
||||
_s_craft_recipes.push_back(craft_recipe);
|
||||
|
||||
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());
|
||||
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path());
|
||||
|
||||
if (class_profile->has_custom_data("recipes")) {
|
||||
Vector<int> recipes = class_profile->get_custom_data("recipes");
|
||||
@ -4540,7 +4540,7 @@ void Entity::adds_spell(Ref<Spell> spell) {
|
||||
_s_spells.push_back(spell);
|
||||
|
||||
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());
|
||||
Ref<ClassProfile> class_profile = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(_s_entity_data->get_path());
|
||||
|
||||
if (class_profile->has_custom_data("spells")) {
|
||||
Vector<int> spells = class_profile->get_custom_data("spells");
|
||||
@ -5576,7 +5576,7 @@ void Entity::set_actionbar_locked(bool value) {
|
||||
}
|
||||
|
||||
Ref<ActionBarProfile> Entity::get_action_bar_profile() {
|
||||
Ref<ClassProfile> cp = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(gets_entity_data()->get_id());
|
||||
Ref<ClassProfile> cp = ProfileManager::get_instance()->getc_player_profile()->get_class_profile(gets_entity_data()->get_path());
|
||||
|
||||
if (cp.is_valid()) {
|
||||
set_actionbar_locked(cp->get_actionbar_locked());
|
||||
|
@ -22,33 +22,33 @@ SOFTWARE.
|
||||
|
||||
#include "class_profile.h"
|
||||
|
||||
int ClassProfile::get_class_id() {
|
||||
return _class_id;
|
||||
StringName ClassProfile::get_class_path() const {
|
||||
return _class_path;
|
||||
}
|
||||
|
||||
void ClassProfile::set_class_id(int value) {
|
||||
_class_id = value;
|
||||
void ClassProfile::set_class_path(const StringName &value) {
|
||||
_class_path = value;
|
||||
}
|
||||
|
||||
String ClassProfile::get_character_class_name() {
|
||||
String ClassProfile::get_character_class_name() const {
|
||||
return _character_class_name;
|
||||
}
|
||||
|
||||
void ClassProfile::set_character_class_name(String value) {
|
||||
void ClassProfile::set_character_class_name(const String &value) {
|
||||
_character_class_name = value;
|
||||
}
|
||||
|
||||
int ClassProfile::get_level() {
|
||||
int ClassProfile::get_level() const {
|
||||
return _level;
|
||||
}
|
||||
|
||||
void ClassProfile::set_level(int value) {
|
||||
void ClassProfile::set_level(const int value) {
|
||||
_level = value;
|
||||
|
||||
emit_change();
|
||||
}
|
||||
|
||||
int ClassProfile::get_xp() {
|
||||
int ClassProfile::get_xp() const {
|
||||
return _xp;
|
||||
}
|
||||
|
||||
@ -58,10 +58,10 @@ void ClassProfile::set_xp(int value) {
|
||||
emit_change();
|
||||
}
|
||||
|
||||
bool ClassProfile::get_actionbar_locked() {
|
||||
bool ClassProfile::get_actionbar_locked() const {
|
||||
return _actionbar_locked;
|
||||
}
|
||||
void ClassProfile::set_actionbar_locked(bool value) {
|
||||
void ClassProfile::set_actionbar_locked(const bool value) {
|
||||
_actionbar_locked = value;
|
||||
|
||||
emit_change();
|
||||
@ -112,7 +112,7 @@ Dictionary ClassProfile::to_dict() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["character_class_name"] = _character_class_name;
|
||||
dict["class_id"] = _class_id;
|
||||
dict["class_path"] = _class_path;
|
||||
dict["level"] = _level;
|
||||
dict["xp"] = _xp;
|
||||
dict["actionbar_locked"] = _actionbar_locked;
|
||||
@ -126,7 +126,7 @@ void ClassProfile::from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_character_class_name = dict.get("character_class_name", "");
|
||||
_class_id = dict.get("class_id", 0);
|
||||
_class_path = dict.get("class_path", "");
|
||||
_level = dict.get("level", 1);
|
||||
_xp = dict.get("xp", 0);
|
||||
_actionbar_locked = dict.get("actionbar_locked", false);
|
||||
@ -143,31 +143,30 @@ ClassProfile::ClassProfile() {
|
||||
_action_bar_profile->set_owner(this);
|
||||
_input_profile.instance();
|
||||
|
||||
_class_id = 0;
|
||||
_level = 1;
|
||||
_xp = 0;
|
||||
_actionbar_locked = false;
|
||||
}
|
||||
|
||||
ClassProfile::ClassProfile(int class_id) {
|
||||
ClassProfile::ClassProfile(const StringName &class_path) {
|
||||
_action_bar_profile.instance();
|
||||
_action_bar_profile->set_owner(this);
|
||||
_input_profile.instance();
|
||||
|
||||
_class_id = class_id;
|
||||
_class_path = class_path;
|
||||
_level = 1;
|
||||
_xp = 0;
|
||||
_actionbar_locked = false;
|
||||
}
|
||||
|
||||
ClassProfile::ClassProfile(String class_name, int class_id, int level, int xp, bool locked) {
|
||||
ClassProfile::ClassProfile(const String &class_name, const StringName &class_path, const int level, const int xp, const bool locked) {
|
||||
_action_bar_profile.instance();
|
||||
_action_bar_profile->set_owner(this);
|
||||
|
||||
_input_profile.instance();
|
||||
|
||||
_character_class_name = class_name;
|
||||
_class_id = class_id;
|
||||
_class_path = class_path;
|
||||
_level = level;
|
||||
_xp = xp;
|
||||
_actionbar_locked = true;
|
||||
@ -189,9 +188,9 @@ void ClassProfile::load_defaults() {
|
||||
void ClassProfile::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("changed"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_class_id"), &ClassProfile::get_class_id);
|
||||
ClassDB::bind_method(D_METHOD("set_class_id", "value"), &ClassProfile::set_class_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "class_id"), "set_class_id", "get_class_id");
|
||||
ClassDB::bind_method(D_METHOD("get_class_path"), &ClassProfile::get_class_path);
|
||||
ClassDB::bind_method(D_METHOD("set_class_path", "value"), &ClassProfile::set_class_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "class_path"), "set_class_path", "get_class_path");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_character_class_name"), &ClassProfile::get_character_class_name);
|
||||
ClassDB::bind_method(D_METHOD("set_character_class_name", "value"), &ClassProfile::set_character_class_name);
|
||||
|
@ -34,16 +34,21 @@ class ClassProfile : public Reference {
|
||||
GDCLASS(ClassProfile, Reference);
|
||||
|
||||
public:
|
||||
int get_class_id();
|
||||
void set_class_id(int value);
|
||||
String get_character_class_name();
|
||||
void set_character_class_name(String value);
|
||||
int get_level();
|
||||
void set_level(int value);
|
||||
int get_xp();
|
||||
void set_xp(int value);
|
||||
bool get_actionbar_locked();
|
||||
void set_actionbar_locked(bool value);
|
||||
StringName get_class_path() const;
|
||||
void set_class_path(const StringName &value);
|
||||
|
||||
String get_character_class_name() const;
|
||||
void set_character_class_name(const String &value);
|
||||
|
||||
int get_level() const;
|
||||
void set_level(const int value);
|
||||
|
||||
int get_xp() const;
|
||||
void set_xp(const int value);
|
||||
|
||||
bool get_actionbar_locked() const;
|
||||
void set_actionbar_locked(const bool value);
|
||||
|
||||
Ref<InputProfile> get_input_profile();
|
||||
Ref<ActionBarProfile> get_action_bar_profile();
|
||||
|
||||
@ -58,8 +63,8 @@ public:
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
ClassProfile();
|
||||
ClassProfile(int class_id);
|
||||
ClassProfile(String class_name, int class_id, int level, int xp, bool locked);
|
||||
ClassProfile(const StringName &class_path);
|
||||
ClassProfile(const String &class_name, const StringName &class_path, const int level, const int xp, const bool locked);
|
||||
~ClassProfile();
|
||||
|
||||
void load_defaults();
|
||||
@ -69,7 +74,7 @@ protected:
|
||||
|
||||
private:
|
||||
String _character_class_name;
|
||||
int _class_id;
|
||||
StringName _class_path;
|
||||
int _level;
|
||||
int _xp;
|
||||
bool _actionbar_locked;
|
||||
|
@ -103,14 +103,14 @@ Vector<Ref<ClassProfile> > &PlayerProfile::get_class_profiles() {
|
||||
return _class_profiles;
|
||||
}
|
||||
|
||||
Ref<ClassProfile> PlayerProfile::get_class_profile(const int class_id) {
|
||||
Ref<ClassProfile> PlayerProfile::get_class_profile(const StringName &class_path) {
|
||||
for (int i = 0; i < _class_profiles.size(); ++i) {
|
||||
if (_class_profiles.get(i)->get_class_id() == class_id) {
|
||||
if (_class_profiles.get(i)->get_class_path() == class_path) {
|
||||
return Ref<ClassProfile>(_class_profiles.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ClassProfile> class_profile = Ref<ClassProfile>(memnew(ClassProfile(class_id)));
|
||||
Ref<ClassProfile> class_profile = Ref<ClassProfile>(memnew(ClassProfile(class_path)));
|
||||
|
||||
class_profile->load_defaults();
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void remove_class_profile(const int index);
|
||||
|
||||
Vector<Ref<ClassProfile> > &get_class_profiles();
|
||||
Ref<ClassProfile> get_class_profile(const int class_id);
|
||||
Ref<ClassProfile> get_class_profile(const StringName &class_path);
|
||||
|
||||
Dictionary get_custom_data();
|
||||
void set_custom_data(const Dictionary &dict);
|
||||
|
Loading…
Reference in New Issue
Block a user