mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
Stat simplification/rework - Part 1. Stats doesn't work yet! Removed StatModifier, and initial Stat api simplification/cleanup.
This commit is contained in:
parent
085890cd15
commit
58b318b9f4
1
SCsub
1
SCsub
@ -61,7 +61,6 @@ sources = [
|
||||
"skeleton/character_bones.cpp",
|
||||
|
||||
"entities/stats/stat.cpp",
|
||||
"entities/stats/stat_modifier.cpp",
|
||||
"entities/stats/stat_data.cpp",
|
||||
"entities/stats/stat_data_entry.cpp",
|
||||
"entities/stats/level_stat_data.cpp",
|
||||
|
@ -971,7 +971,9 @@ void Aura::_sapply(Ref<AuraApplyInfo> info) {
|
||||
Ref<AuraStatAttribute> stat_attribute = _aura_stat_attributes[i];
|
||||
|
||||
Ref<Stat> stat = info->get_target()->get_stat(stat_attribute->get_stat());
|
||||
stat->add_modifier(_id, stat_attribute->get_base_mod(), stat_attribute->get_bonus_mod(), stat_attribute->get_percent_mod());
|
||||
stat->mod_base(stat_attribute->get_base_mod());
|
||||
stat->mod_bonus(stat_attribute->get_bonus_mod());
|
||||
stat->mod_percent(stat_attribute->get_percent_mod());
|
||||
}
|
||||
|
||||
if (_add_states != 0) {
|
||||
@ -997,7 +999,9 @@ void Aura::_sdeapply(Ref<AuraData> data) {
|
||||
Ref<AuraStatAttribute> stat_attribute = _aura_stat_attributes[i];
|
||||
|
||||
Ref<Stat> stat = data->get_owner()->get_stat(stat_attribute->get_stat());
|
||||
stat->remove_modifier(_id);
|
||||
stat->mod_base(-stat_attribute->get_base_mod());
|
||||
stat->mod_bonus(-stat_attribute->get_bonus_mod());
|
||||
stat->mod_percent(-stat_attribute->get_percent_mod());
|
||||
}
|
||||
|
||||
if (_add_states != 0) {
|
||||
|
@ -40,7 +40,6 @@ SOFTWARE.
|
||||
#include "./resources/entity_resource_speed.h"
|
||||
#include "./skills/entity_skill.h"
|
||||
#include "./stats/stat.h"
|
||||
#include "./stats/stat_modifier.h"
|
||||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
@ -656,9 +655,7 @@ void Entity::_setup() {
|
||||
for (int i = 0; i < ESS::get_instance()->stat_get_count(); ++i) {
|
||||
Ref<Stat> s = _stats[i];
|
||||
|
||||
s->apply_modifiers();
|
||||
|
||||
s->setc_values(s->gets_current(), s->gets_max());
|
||||
s->setc_current(s->gets_current());
|
||||
s->set_dirty(false);
|
||||
}
|
||||
|
||||
@ -1876,24 +1873,17 @@ void Entity::notification_cstat_changed(Ref<Stat> stat) {
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::ssend_stat(int id, int ccurrent, int cmax) {
|
||||
void Entity::ssend_stat(int id, int ccurrent) {
|
||||
ERR_FAIL_INDEX(id, ESS::get_instance()->stat_get_count());
|
||||
|
||||
//TODO, mark stats that should be sent to all clients like health
|
||||
//if (id <= ESS::get_instance()->stat_get_main_stat_count()) {
|
||||
// VRPC(creceive_stat, id, ccurrent, cmax);
|
||||
// return;
|
||||
//}
|
||||
|
||||
VRPC(creceive_stat, id, ccurrent, cmax);
|
||||
|
||||
//ORPC(creceive_stat, id, ccurrent, cmax);
|
||||
//Only the owner needs access to stats
|
||||
ORPC(creceive_stat, id, ccurrent);
|
||||
}
|
||||
|
||||
void Entity::creceive_stat(int id, int ccurrent, int cmax) {
|
||||
void Entity::creceive_stat(int id, int ccurrent) {
|
||||
ERR_FAIL_INDEX(id, ESS::get_instance()->stat_get_count());
|
||||
|
||||
_stats.get(id)->setc_values(ccurrent, cmax);
|
||||
_stats.get(id)->setc_current(ccurrent);
|
||||
}
|
||||
|
||||
//// Equip Slots ////
|
||||
@ -2116,13 +2106,9 @@ void Entity::_equip_applys_item(Ref<ItemInstance> item) {
|
||||
|
||||
ERR_CONTINUE(!stat.is_valid());
|
||||
|
||||
Ref<StatModifier> sm = stat->get_modifier(0);
|
||||
|
||||
ERR_CONTINUE(!sm.is_valid());
|
||||
|
||||
sm->set_base_mod(sm->get_base_mod() + mod->get_base_mod());
|
||||
sm->set_bonus_mod(sm->get_bonus_mod() + mod->get_bonus_mod());
|
||||
sm->set_percent_mod(sm->get_percent_mod() + mod->get_percent_mod());
|
||||
stat->mod_base(mod->get_base_mod());
|
||||
stat->mod_bonus(mod->get_bonus_mod());
|
||||
stat->mod_percent(mod->get_percent_mod());
|
||||
}
|
||||
}
|
||||
void Entity::_equip_deapplys_item(Ref<ItemInstance> item) {
|
||||
@ -2142,13 +2128,9 @@ void Entity::_equip_deapplys_item(Ref<ItemInstance> item) {
|
||||
|
||||
ERR_CONTINUE(!stat.is_valid());
|
||||
|
||||
Ref<StatModifier> sm = stat->get_modifier(0);
|
||||
|
||||
ERR_CONTINUE(!sm.is_valid());
|
||||
|
||||
sm->set_base_mod(sm->get_base_mod() - mod->get_base_mod());
|
||||
sm->set_bonus_mod(sm->get_bonus_mod() - mod->get_bonus_mod());
|
||||
sm->set_percent_mod(sm->get_percent_mod() - mod->get_percent_mod());
|
||||
stat->mod_base(-mod->get_base_mod());
|
||||
stat->mod_bonus(-mod->get_bonus_mod());
|
||||
stat->mod_percent(-mod->get_percent_mod());
|
||||
}
|
||||
}
|
||||
|
||||
@ -5350,11 +5332,8 @@ void Entity::update(float delta) {
|
||||
for (int i = 0; i < ESS::get_instance()->stat_get_count(); ++i) {
|
||||
Ref<Stat> s = _stats[i];
|
||||
|
||||
if (s->get_dirty_mods())
|
||||
s->apply_modifiers();
|
||||
|
||||
if (s->get_dirty()) {
|
||||
ssend_stat(s->get_id(), s->gets_current(), s->gets_max());
|
||||
ssend_stat(s->get_id(), s->gets_current());
|
||||
|
||||
s->set_dirty(false);
|
||||
}
|
||||
@ -6068,8 +6047,7 @@ void Entity::_notification_scharacter_level_up(int level) {
|
||||
|
||||
Ref<Stat> stat = get_stat(i);
|
||||
|
||||
Ref<StatModifier> sm = stat->get_modifier(0);
|
||||
sm->set_base_mod(sm->get_base_mod() + st);
|
||||
stat->mod_base(st);
|
||||
}
|
||||
|
||||
if (!ESS::get_instance()->get_use_class_xp()) {
|
||||
@ -6284,15 +6262,7 @@ bool Entity::_set(const StringName &p_name, const Variant &p_value) {
|
||||
_stats.set(stat_id, stat);
|
||||
}
|
||||
|
||||
if (stat_prop_name == "public") {
|
||||
stat->set_public(p_value);
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "locked") {
|
||||
stat->set_locked(p_value);
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "base") {
|
||||
if (stat_prop_name == "base") {
|
||||
stat->set_base(p_value);
|
||||
|
||||
return true;
|
||||
@ -6308,45 +6278,6 @@ bool Entity::_set(const StringName &p_name, const Variant &p_value) {
|
||||
stat->sets_current(p_value);
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "smax") {
|
||||
stat->sets_max(p_value);
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "modifier") {
|
||||
int modifier_index = name.get_slicec('/', 3).to_int();
|
||||
String modifier_prop_name = name.get_slicec('/', 4);
|
||||
|
||||
if (stat->get_modifier_count() <= modifier_index) {
|
||||
stat->get_modifiers()->resize(modifier_index + 1);
|
||||
}
|
||||
|
||||
Ref<StatModifier> modifier = stat->get_modifier(modifier_index);
|
||||
|
||||
if (!modifier.is_valid()) {
|
||||
modifier.instance();
|
||||
modifier->set_owner(stat);
|
||||
stat->get_modifiers()->set(modifier_index, modifier);
|
||||
}
|
||||
|
||||
if (modifier_prop_name == "id") {
|
||||
modifier->set_id(p_value);
|
||||
|
||||
return true;
|
||||
} else if (modifier_prop_name == "base_mod") {
|
||||
modifier->set_base_mod(p_value);
|
||||
|
||||
return true;
|
||||
} else if (modifier_prop_name == "bonus_mod") {
|
||||
modifier->set_bonus_mod(p_value);
|
||||
|
||||
return true;
|
||||
} else if (modifier_prop_name == "percent_mod") {
|
||||
modifier->set_percent_mod(p_value);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -6622,15 +6553,7 @@ bool Entity::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
|
||||
Ref<Stat> stat = _stats[stat_id];
|
||||
|
||||
if (stat_prop_name == "public") {
|
||||
r_ret = stat->get_public();
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "locked") {
|
||||
r_ret = stat->get_locked();
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "base") {
|
||||
if (stat_prop_name == "base") {
|
||||
r_ret = stat->get_base();
|
||||
|
||||
return true;
|
||||
@ -6646,39 +6569,9 @@ bool Entity::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
r_ret = stat->gets_current();
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "smax") {
|
||||
r_ret = stat->gets_max();
|
||||
|
||||
return true;
|
||||
} else if (stat_prop_name == "modifier") {
|
||||
int modifier_index = name.get_slicec('/', 3).to_int();
|
||||
String modifier_prop_name = name.get_slicec('/', 4);
|
||||
|
||||
Ref<StatModifier> modifier = stat->get_modifier(modifier_index);
|
||||
|
||||
if (modifier_prop_name == "id") {
|
||||
r_ret = modifier->get_id();
|
||||
|
||||
return true;
|
||||
} else if (modifier_prop_name == "base_mod") {
|
||||
r_ret = modifier->get_base_mod();
|
||||
|
||||
return true;
|
||||
} else if (modifier_prop_name == "bonus_mod") {
|
||||
r_ret = modifier->get_bonus_mod();
|
||||
|
||||
return true;
|
||||
} else if (modifier_prop_name == "percent_mod") {
|
||||
r_ret = modifier->get_percent_mod();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -6842,24 +6735,9 @@ void Entity::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
if (!stat.is_valid())
|
||||
continue;
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, "stat/" + itos(i) + "/public", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, "stat/" + itos(i) + "/locked", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/base", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/percent", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/scurrent", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/smax", PROPERTY_HINT_NONE, "", property_usange));
|
||||
|
||||
for (int j = 0; j < stat->get_modifier_count(); ++j) {
|
||||
Ref<StatModifier> modifier = stat->get_modifier(j);
|
||||
|
||||
if (!modifier.is_valid())
|
||||
continue;
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "stat/" + itos(i) + "/modifier/" + itos(j) + "id", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/modifier/" + itos(j) + "base_mod", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/modifier/" + itos(j) + "bonus_mod", PROPERTY_HINT_NONE, "", property_usange));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "stat/" + itos(i) + "/modifier/" + itos(j) + "percent_mod", PROPERTY_HINT_NONE, "", property_usange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6923,8 +6801,8 @@ void Entity::_bind_methods() {
|
||||
|
||||
//binds
|
||||
|
||||
ClassDB::bind_method(D_METHOD("ssend_stat", "id", "ccurrent", "cmax"), &Entity::ssend_stat);
|
||||
ClassDB::bind_method(D_METHOD("creceive_stat", "id", "ccurrent", "cmax"), &Entity::creceive_stat);
|
||||
ClassDB::bind_method(D_METHOD("ssend_stat", "id", "ccurrent"), &Entity::ssend_stat);
|
||||
ClassDB::bind_method(D_METHOD("creceive_stat", "id", "ccurrent"), &Entity::creceive_stat);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("dies"), &Entity::dies);
|
||||
ClassDB::bind_method(D_METHOD("diec"), &Entity::diec);
|
||||
|
@ -62,20 +62,6 @@ void Stat::set_owner_bind(Node *value) {
|
||||
_owner = e;
|
||||
}
|
||||
|
||||
bool Stat::get_public() {
|
||||
return _public;
|
||||
}
|
||||
void Stat::set_public(bool value) {
|
||||
_public = value;
|
||||
}
|
||||
|
||||
bool Stat::get_locked() {
|
||||
return _locked;
|
||||
}
|
||||
void Stat::set_locked(bool value) {
|
||||
_locked = value;
|
||||
}
|
||||
|
||||
bool Stat::get_dirty() {
|
||||
return _dirty;
|
||||
}
|
||||
@ -83,18 +69,27 @@ void Stat::set_dirty(bool value) {
|
||||
_dirty = value;
|
||||
}
|
||||
|
||||
bool Stat::get_dirty_mods() {
|
||||
return _dirty_mods;
|
||||
}
|
||||
void Stat::set_dirty_mods(bool value) {
|
||||
_dirty_mods = value;
|
||||
}
|
||||
|
||||
float Stat::get_base() {
|
||||
return _base;
|
||||
}
|
||||
void Stat::set_base(float value) {
|
||||
_base = value;
|
||||
|
||||
refresh();
|
||||
}
|
||||
void Stat::mod_base(float value) {
|
||||
_base += value;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
float Stat::get_base_calculated() {
|
||||
return _base_calculated;
|
||||
}
|
||||
void Stat::set_base_calculated(float value) {
|
||||
_base_calculated = value;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
float Stat::get_bonus() {
|
||||
@ -102,6 +97,11 @@ float Stat::get_bonus() {
|
||||
}
|
||||
void Stat::set_bonus(float value) {
|
||||
_bonus = value;
|
||||
|
||||
refresh();
|
||||
}
|
||||
void Stat::mod_bonus(float value) {
|
||||
_bonus = value;
|
||||
}
|
||||
|
||||
float Stat::get_percent() {
|
||||
@ -109,28 +109,18 @@ float Stat::get_percent() {
|
||||
}
|
||||
void Stat::set_percent(float value) {
|
||||
_percent = value;
|
||||
|
||||
refresh();
|
||||
}
|
||||
void Stat::mod_percent(float value) {
|
||||
_percent = value;
|
||||
}
|
||||
|
||||
float Stat::gets_current() {
|
||||
return _s_current;
|
||||
}
|
||||
void Stat::sets_current(float value) {
|
||||
if (_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
_s_current = value;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
float Stat::gets_max() {
|
||||
return _s_max;
|
||||
}
|
||||
void Stat::sets_max(float value) {
|
||||
_s_max = value;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
float Stat::getc_current() {
|
||||
@ -142,162 +132,11 @@ void Stat::setc_current(float value) {
|
||||
_c_current = value;
|
||||
|
||||
_owner->notification_cstat_changed(Ref<Stat>(this));
|
||||
|
||||
emit_signal("c_changed", Ref<Stat>(this));
|
||||
}
|
||||
|
||||
float Stat::getc_max() {
|
||||
return _c_max;
|
||||
}
|
||||
void Stat::setc_max(float value) {
|
||||
ERR_FAIL_COND(_owner == NULL);
|
||||
|
||||
_s_current = value;
|
||||
|
||||
_owner->notification_cstat_changed(Ref<Stat>(this));
|
||||
|
||||
emit_signal("c_changed", Ref<Stat>(this));
|
||||
}
|
||||
|
||||
void Stat::setc_values(int ccurrent, int cmax) {
|
||||
ERR_FAIL_COND(_owner == NULL);
|
||||
|
||||
_c_current = ccurrent;
|
||||
_c_max = cmax;
|
||||
|
||||
_owner->notification_cstat_changed(Ref<Stat>(this));
|
||||
emit_signal("c_changed", Ref<Stat>(this));
|
||||
}
|
||||
|
||||
Vector<Ref<StatModifier> > *Stat::get_modifiers() {
|
||||
return &_modifiers;
|
||||
}
|
||||
|
||||
int Stat::get_modifier_count() {
|
||||
return _modifiers.size();
|
||||
}
|
||||
|
||||
void Stat::clear_modifiers() {
|
||||
_modifiers.clear();
|
||||
|
||||
_dirty = true;
|
||||
_dirty_mods = true;
|
||||
}
|
||||
|
||||
Ref<StatModifier> Stat::get_modifier(int index) {
|
||||
return _modifiers.get(index);
|
||||
}
|
||||
|
||||
Ref<StatModifier> Stat::add_modifier(int id, float base_mod, float bonus_mod, float percent_mod) {
|
||||
Ref<StatModifier> stat_modifier = Ref<StatModifier>(memnew(StatModifier(id, base_mod, bonus_mod, percent_mod, this)));
|
||||
|
||||
_modifiers.push_back(stat_modifier);
|
||||
|
||||
_dirty = true;
|
||||
_dirty_mods = true;
|
||||
|
||||
return stat_modifier;
|
||||
}
|
||||
|
||||
Ref<StatModifier> Stat::get_or_add_modifier(int id) {
|
||||
for (int i = 0; i < _modifiers.size(); ++i) {
|
||||
if (_modifiers.get(i)->get_id() == id) {
|
||||
return _modifiers.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<StatModifier> stat_modifier = Ref<StatModifier>(memnew(StatModifier(id, 0, 0, 0, this)));
|
||||
|
||||
_modifiers.push_back(stat_modifier);
|
||||
|
||||
return stat_modifier;
|
||||
}
|
||||
|
||||
void Stat::remove_modifier(int id) {
|
||||
for (int i = 0; i < _modifiers.size(); ++i) {
|
||||
if (_modifiers.get(i)->get_id() == id) {
|
||||
Ref<StatModifier> modifier = _modifiers.get(i);
|
||||
_modifiers.remove(i);
|
||||
|
||||
_dirty_mods = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Stat::remove_modifier_index(int index) {
|
||||
_modifiers.remove(index);
|
||||
}
|
||||
|
||||
void Stat::apply_modifiers() {
|
||||
#if VERSION_MAJOR < 4
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(_owner));
|
||||
#else
|
||||
ERR_FAIL_COND(_owner == NULL);
|
||||
#endif
|
||||
ERR_FAIL_COND(!_stat_data_entry.is_valid());
|
||||
|
||||
reset_values();
|
||||
|
||||
for (int i = 0; i < _modifiers.size(); ++i) {
|
||||
Ref<StatModifier> mod = _modifiers.get(i);
|
||||
|
||||
_base += mod->get_base_mod();
|
||||
_bonus += mod->get_bonus_mod();
|
||||
_percent += mod->get_percent_mod();
|
||||
}
|
||||
|
||||
refresh_currmax();
|
||||
_dirty_mods = false;
|
||||
|
||||
for (int i = 0; i < _stat_data_entry->get_mod_stat_count(); ++i) {
|
||||
Ref<Stat> stat = _owner->get_stat(_stat_data_entry->get_mod_stat_id(i));
|
||||
float multiplier = _stat_data_entry->get_mod_stat_multiplier(i);
|
||||
|
||||
ERR_FAIL_COND(!stat.is_valid());
|
||||
|
||||
Ref<StatModifier> sm = stat->get_or_add_modifier(-(static_cast<int>(_id) + 1));
|
||||
|
||||
sm->set_base_mod(_s_current + _s_current * multiplier);
|
||||
}
|
||||
|
||||
_owner->notification_sstat_changed(Ref<Stat>(this));
|
||||
emit_signal("s_changed", Ref<Stat>(this));
|
||||
}
|
||||
|
||||
void Stat::reset_values() {
|
||||
_percent = 0;
|
||||
_bonus = 0;
|
||||
_base = 0;
|
||||
|
||||
_dirty = true;
|
||||
_dirty_mods = true;
|
||||
}
|
||||
|
||||
void Stat::refresh_currmax() {
|
||||
//According to people on stack overflow this should be fine, because 0.0 has a unique representation
|
||||
float diff = _s_max == 0.0 ? 1.0 : _s_current / _s_max;
|
||||
|
||||
_s_max = (_base + _bonus) * (_percent / 100.0);
|
||||
|
||||
_s_current = _s_max * diff;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
bool Stat::iss_current_zero() {
|
||||
return (fabs(_s_current) < .000001);
|
||||
}
|
||||
|
||||
bool Stat::isc_current_zero() {
|
||||
return (fabs(_c_current) < .000001);
|
||||
}
|
||||
|
||||
void Stat::set_to_max() {
|
||||
ERR_FAIL_COND(_owner == NULL);
|
||||
|
||||
_s_current = _s_max;
|
||||
void Stat::refresh() {
|
||||
_s_current = (_base + _base_calculated + _bonus) * (_percent / 100.0);
|
||||
|
||||
_dirty = true;
|
||||
|
||||
@ -305,10 +144,6 @@ void Stat::set_to_max() {
|
||||
emit_signal("s_changed", Ref<Stat>(this));
|
||||
}
|
||||
|
||||
void Stat::modifier_changed(Ref<StatModifier> modifier) {
|
||||
_dirty_mods = true;
|
||||
}
|
||||
|
||||
Dictionary Stat::to_dict() {
|
||||
return call("_to_dict");
|
||||
}
|
||||
@ -321,25 +156,14 @@ Dictionary Stat::_to_dict() {
|
||||
|
||||
dict["id"] = _id;
|
||||
|
||||
dict["public"] = _public;
|
||||
dict["locked"] = _locked;
|
||||
dict["dirty"] = _dirty;
|
||||
dict["dirty_mods"] = _dirty_mods;
|
||||
|
||||
dict["base"] = _base;
|
||||
dict["base_calculated"] = _base_calculated;
|
||||
dict["bonus"] = _bonus;
|
||||
dict["percent"] = _percent;
|
||||
|
||||
dict["current"] = _s_current;
|
||||
dict["max"] = _s_max;
|
||||
|
||||
Dictionary modifiers;
|
||||
|
||||
for (int i = 0; i < _modifiers.size(); ++i) {
|
||||
modifiers[String::num(i)] = _modifiers.get(i)->to_dict();
|
||||
}
|
||||
|
||||
dict["modifiers"] = modifiers;
|
||||
|
||||
return dict;
|
||||
}
|
||||
@ -348,83 +172,50 @@ void Stat::_from_dict(const Dictionary &dict) {
|
||||
|
||||
_id = dict.get("id", 0);
|
||||
|
||||
_public = dict.get("public", false);
|
||||
_locked = dict.get("locked", false);
|
||||
_dirty = dict.get("dirty", false);
|
||||
_dirty_mods = dict.get("dirty_mods", false);
|
||||
|
||||
_base = dict.get("base", 0);
|
||||
_base_calculated = dict.get("base_calculated", 0);
|
||||
_bonus = dict.get("bonus", 0);
|
||||
_percent = dict.get("percent", 1);
|
||||
|
||||
_s_current = dict.get("current", 0);
|
||||
_s_max = dict.get("max", 0);
|
||||
|
||||
_c_current = _s_current;
|
||||
_c_max = _s_max;
|
||||
|
||||
_modifiers.clear();
|
||||
|
||||
Dictionary modifiers = dict.get("modifiers", Dictionary());
|
||||
|
||||
for (int i = 0; i < modifiers.size(); ++i) {
|
||||
Ref<StatModifier> sm;
|
||||
sm.instance();
|
||||
|
||||
sm->from_dict(modifiers.get(String::num(i), Dictionary()));
|
||||
sm->set_owner(this);
|
||||
|
||||
_modifiers.push_back(sm);
|
||||
}
|
||||
|
||||
_dirty = true;
|
||||
_dirty_mods = true;
|
||||
}
|
||||
|
||||
Stat::Stat() {
|
||||
_id = 0;
|
||||
_owner = NULL;
|
||||
|
||||
_public = false;
|
||||
_dirty_mods = false;
|
||||
|
||||
_locked = false;
|
||||
_dirty = true;
|
||||
|
||||
_base = 0;
|
||||
_base_calculated = 0;
|
||||
_bonus = 0;
|
||||
_percent = 0;
|
||||
|
||||
_s_current = 0;
|
||||
_s_max = 0;
|
||||
|
||||
_c_current = 0;
|
||||
_c_max = 0;
|
||||
}
|
||||
|
||||
Stat::Stat(int id, Entity *owner) {
|
||||
_id = id;
|
||||
_owner = owner;
|
||||
|
||||
_public = false;
|
||||
_dirty_mods = false;
|
||||
|
||||
_locked = false;
|
||||
_dirty = true;
|
||||
|
||||
_base = 0;
|
||||
_base_calculated = 0;
|
||||
_bonus = 0;
|
||||
_percent = 0;
|
||||
|
||||
_s_current = 0;
|
||||
_s_max = 0;
|
||||
|
||||
_c_current = 0;
|
||||
_c_max = 0;
|
||||
}
|
||||
|
||||
Stat::~Stat() {
|
||||
_modifiers.clear();
|
||||
_owner = NULL;
|
||||
_stat_data_entry.unref();
|
||||
}
|
||||
@ -451,70 +242,37 @@ void Stat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_owner", "value"), &Stat::set_owner_bind);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Entity", 0), "set_owner", "get_owner");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_public"), &Stat::get_public);
|
||||
ClassDB::bind_method(D_METHOD("set_public", "value"), &Stat::set_public);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "public"), "set_public", "get_public");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_locked"), &Stat::get_locked);
|
||||
ClassDB::bind_method(D_METHOD("set_locked", "value"), &Stat::set_locked);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "locked"), "set_locked", "get_locked");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_dirty"), &Stat::get_dirty);
|
||||
ClassDB::bind_method(D_METHOD("set_dirty", "value"), &Stat::set_dirty);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_dirty"), "set_dirty", "get_dirty");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_dirty_mods"), &Stat::get_dirty_mods);
|
||||
ClassDB::bind_method(D_METHOD("set_dirty_mods", "value"), &Stat::set_dirty_mods);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dirty_mods"), "set_dirty_mods", "get_dirty_mods");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base"), &Stat::get_base);
|
||||
ClassDB::bind_method(D_METHOD("set_base"), &Stat::set_base);
|
||||
ClassDB::bind_method(D_METHOD("set_base", "value"), &Stat::set_base);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base"), "set_base", "get_base");
|
||||
ClassDB::bind_method(D_METHOD("mod_base", "value"), &Stat::mod_base);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base_calculated"), &Stat::get_base_calculated);
|
||||
ClassDB::bind_method(D_METHOD("set_base_calculated", "value"), &Stat::set_base_calculated);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_calculated"), "set_base_calculated", "get_base_calculated");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bonus"), &Stat::get_bonus);
|
||||
ClassDB::bind_method(D_METHOD("set_bonus"), &Stat::set_bonus);
|
||||
ClassDB::bind_method(D_METHOD("set_bonus", "value"), &Stat::set_bonus);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus"), "set_bonus", "get_bonus");
|
||||
ClassDB::bind_method(D_METHOD("mod_bonus", "value"), &Stat::mod_bonus);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_percent"), &Stat::get_percent);
|
||||
ClassDB::bind_method(D_METHOD("set_percent"), &Stat::set_percent);
|
||||
ClassDB::bind_method(D_METHOD("set_percent", "value"), &Stat::set_percent);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent"), "set_percent", "get_percent");
|
||||
ClassDB::bind_method(D_METHOD("mod_percent", "value"), &Stat::mod_percent);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("gets_current"), &Stat::gets_current);
|
||||
ClassDB::bind_method(D_METHOD("sets_current", "value"), &Stat::sets_current);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scurrent"), "sets_current", "gets_current");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("gets_max"), &Stat::gets_max);
|
||||
ClassDB::bind_method(D_METHOD("sets_max"), &Stat::sets_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smax"), "sets_max", "gets_max");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("getc_max"), &Stat::getc_max);
|
||||
ClassDB::bind_method(D_METHOD("setc_max"), &Stat::setc_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cmax"), "setc_max", "getc_max");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("getc_current"), &Stat::getc_current);
|
||||
ClassDB::bind_method(D_METHOD("setc_current", "value"), &Stat::setc_current);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ccurrent"), "setc_current", "getc_current");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("setc_values", "ccurrent", "cmax"), &Stat::setc_values);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_modifier", "id", "base_mod", "bonus_mod", "percent_mod"), &Stat::add_modifier);
|
||||
ClassDB::bind_method(D_METHOD("get_or_add_modifier", "id"), &Stat::get_or_add_modifier);
|
||||
ClassDB::bind_method(D_METHOD("remove_modifier", "id"), &Stat::remove_modifier);
|
||||
ClassDB::bind_method(D_METHOD("remove_modifier_index", "index"), &Stat::remove_modifier_index);
|
||||
ClassDB::bind_method(D_METHOD("get_modifier_count"), &Stat::get_modifier_count);
|
||||
ClassDB::bind_method(D_METHOD("clear_modifiers"), &Stat::clear_modifiers);
|
||||
ClassDB::bind_method(D_METHOD("get_modifier", "index"), &Stat::get_modifier);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("apply_modifiers"), &Stat::apply_modifiers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("reset_values"), &Stat::reset_values);
|
||||
ClassDB::bind_method(D_METHOD("refresh_currmax"), &Stat::refresh_currmax);
|
||||
ClassDB::bind_method(D_METHOD("iss_current_zero"), &Stat::iss_current_zero);
|
||||
ClassDB::bind_method(D_METHOD("isc_current_zero"), &Stat::isc_current_zero);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_to_max"), &Stat::set_to_max);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("modifier_changed", "modifier"), &Stat::modifier_changed);
|
||||
ClassDB::bind_method(D_METHOD("refresh"), &Stat::refresh);
|
||||
|
||||
//Serialization
|
||||
BIND_VMETHOD(MethodInfo("_from_dict", PropertyInfo(Variant::DICTIONARY, "dict")));
|
||||
|
@ -28,8 +28,6 @@ SOFTWARE.
|
||||
#include "core/vector.h"
|
||||
#include "scene/resources/curve.h"
|
||||
|
||||
#include "stat_modifier.h"
|
||||
|
||||
class StatDataEntry;
|
||||
class Entity;
|
||||
|
||||
@ -50,58 +48,31 @@ public:
|
||||
void set_owner(Entity *value);
|
||||
void set_owner_bind(Node *value);
|
||||
|
||||
bool get_public();
|
||||
void set_public(bool value);
|
||||
|
||||
bool get_locked();
|
||||
void set_locked(bool value);
|
||||
|
||||
bool get_dirty();
|
||||
void set_dirty(bool value);
|
||||
|
||||
bool get_dirty_mods();
|
||||
void set_dirty_mods(bool value);
|
||||
|
||||
float get_base();
|
||||
void set_base(float value);
|
||||
void mod_base(float value);
|
||||
|
||||
float get_base_calculated();
|
||||
void set_base_calculated(float value);
|
||||
|
||||
float get_bonus();
|
||||
void set_bonus(float value);
|
||||
void mod_bonus(float value);
|
||||
|
||||
float get_percent();
|
||||
void set_percent(float value);
|
||||
void mod_percent(float value);
|
||||
|
||||
float gets_current();
|
||||
void sets_current(float value);
|
||||
float gets_max();
|
||||
void sets_max(float value);
|
||||
|
||||
float getc_current();
|
||||
void setc_current(float value);
|
||||
float getc_max();
|
||||
void setc_max(float value);
|
||||
|
||||
void setc_values(int ccurrent, int cmax);
|
||||
|
||||
Vector<Ref<StatModifier> > *get_modifiers();
|
||||
Ref<StatModifier> add_modifier(int id, float base_mod, float bonus_mod, float percent_mod);
|
||||
Ref<StatModifier> get_or_add_modifier(int id);
|
||||
void remove_modifier(int id);
|
||||
void remove_modifier_index(int index);
|
||||
int get_modifier_count();
|
||||
void clear_modifiers();
|
||||
Ref<StatModifier> get_modifier(int index);
|
||||
|
||||
void apply_modifiers();
|
||||
|
||||
void reset_values();
|
||||
void refresh_currmax();
|
||||
bool iss_current_zero();
|
||||
bool isc_current_zero();
|
||||
|
||||
void set_to_max();
|
||||
|
||||
void modifier_changed(Ref<StatModifier> modifier);
|
||||
void refresh();
|
||||
|
||||
Dictionary to_dict();
|
||||
void from_dict(const Dictionary &dict);
|
||||
@ -120,22 +91,16 @@ protected:
|
||||
private:
|
||||
int _id;
|
||||
|
||||
Vector<Ref<StatModifier> > _modifiers;
|
||||
|
||||
bool _public;
|
||||
bool _locked;
|
||||
bool _dirty;
|
||||
bool _dirty_mods;
|
||||
|
||||
float _base;
|
||||
float _base_calculated;
|
||||
float _bonus;
|
||||
float _percent;
|
||||
|
||||
float _s_current;
|
||||
float _s_max;
|
||||
|
||||
float _c_current;
|
||||
float _c_max;
|
||||
|
||||
Entity *_owner;
|
||||
Ref<StatDataEntry> _stat_data_entry;
|
||||
|
@ -71,9 +71,7 @@ void StatDataEntry::set_mod_stat_multiplier(int index, float value) {
|
||||
}
|
||||
|
||||
void StatDataEntry::get_stats_for_stat(Ref<Stat> stat) {
|
||||
stat->clear_modifiers();
|
||||
|
||||
stat->add_modifier(0, get_base(), 0, 0);
|
||||
stat->mod_base(get_base());
|
||||
stat->set_stat_data_entry(Ref<StatDataEntry>(this));
|
||||
}
|
||||
|
||||
|
@ -1,150 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "stat_modifier.h"
|
||||
|
||||
#include "stat.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define REAL FLOAT
|
||||
#endif
|
||||
|
||||
Ref<Stat> StatModifier::get_owner() {
|
||||
return Ref<Stat>(_owner);
|
||||
}
|
||||
void StatModifier::set_owner(Ref<Stat> stat) {
|
||||
_owner = stat.ptr();
|
||||
}
|
||||
|
||||
int StatModifier::get_id() {
|
||||
return _id;
|
||||
}
|
||||
void StatModifier::set_id(int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
float StatModifier::get_base_mod() {
|
||||
return _base_mod;
|
||||
}
|
||||
void StatModifier::set_base_mod(float value) {
|
||||
_base_mod = value;
|
||||
|
||||
if (_owner) {
|
||||
_owner->modifier_changed(Ref<StatModifier>(this));
|
||||
}
|
||||
}
|
||||
|
||||
float StatModifier::get_bonus_mod() {
|
||||
return _bonus_mod;
|
||||
}
|
||||
void StatModifier::set_bonus_mod(float value) {
|
||||
_bonus_mod = value;
|
||||
|
||||
if (_owner) {
|
||||
_owner->modifier_changed(Ref<StatModifier>(this));
|
||||
}
|
||||
}
|
||||
|
||||
float StatModifier::get_percent_mod() {
|
||||
return _percent_mod;
|
||||
}
|
||||
void StatModifier::set_percent_mod(float value) {
|
||||
_percent_mod = value;
|
||||
|
||||
if (_owner) {
|
||||
_owner->modifier_changed(Ref<StatModifier>(this));
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary StatModifier::to_dict() {
|
||||
return call("_to_dict");
|
||||
}
|
||||
void StatModifier::from_dict(const Dictionary &dict) {
|
||||
call("_from_dict", dict);
|
||||
}
|
||||
|
||||
Dictionary StatModifier::_to_dict() {
|
||||
Dictionary dict;
|
||||
|
||||
dict["id"] = _id;
|
||||
dict["base_mod"] = _base_mod;
|
||||
dict["bonus_mod"] = _bonus_mod;
|
||||
dict["percent_mod"] = _percent_mod;
|
||||
|
||||
return dict;
|
||||
}
|
||||
void StatModifier::_from_dict(const Dictionary &dict) {
|
||||
ERR_FAIL_COND(dict.empty());
|
||||
|
||||
_id = dict.get("id", 0);
|
||||
_base_mod = dict.get("base_mod", 0);
|
||||
_bonus_mod = dict.get("bonus_mod", 0);
|
||||
_percent_mod = dict.get("percent_mod", 0);
|
||||
}
|
||||
|
||||
StatModifier::StatModifier() {
|
||||
_id = 0;
|
||||
_base_mod = 0;
|
||||
_bonus_mod = 0;
|
||||
_percent_mod = 0;
|
||||
|
||||
_owner = NULL;
|
||||
}
|
||||
|
||||
StatModifier::StatModifier(int i, float base_mod, float bonus_mod, float percent_mod, Stat *owner) {
|
||||
_id = i;
|
||||
_base_mod = base_mod;
|
||||
_bonus_mod = bonus_mod;
|
||||
_percent_mod = percent_mod;
|
||||
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
void StatModifier::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &StatModifier::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "value"), &StatModifier::set_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base_mod"), &StatModifier::get_base_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_base_mod", "value"), &StatModifier::set_base_mod);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_mod"), "set_base_mod", "get_base_mod");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bonus_mod"), &StatModifier::get_bonus_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_bonus_mod", "value"), &StatModifier::set_bonus_mod);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus_mod"), "set_bonus_mod", "get_bonus_mod");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_percent_mod"), &StatModifier::get_percent_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_percent_mod", "value"), &StatModifier::set_percent_mod);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_mod"), "set_percent_mod", "get_percent_mod");
|
||||
|
||||
//Serialization
|
||||
BIND_VMETHOD(MethodInfo("_from_dict", PropertyInfo(Variant::DICTIONARY, "dict")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::DICTIONARY, "dict"), "_to_dict"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("from_dict", "dict"), &StatModifier::from_dict);
|
||||
ClassDB::bind_method(D_METHOD("to_dict"), &StatModifier::to_dict);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_from_dict", "dict"), &StatModifier::_from_dict);
|
||||
ClassDB::bind_method(D_METHOD("_to_dict"), &StatModifier::_to_dict);
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef STAT_MODIFIER_H
|
||||
#define STAT_MODIFIER_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class Stat;
|
||||
|
||||
class StatModifier : public Reference {
|
||||
GDCLASS(StatModifier, Reference);
|
||||
|
||||
public:
|
||||
StatModifier();
|
||||
|
||||
StatModifier(int i, float base_mod, float bonus_mod, float percent_mod, Stat *owner);
|
||||
|
||||
Ref<Stat> get_owner();
|
||||
void set_owner(Ref<Stat> stat);
|
||||
|
||||
int get_id();
|
||||
void set_id(int value);
|
||||
|
||||
float get_base_mod();
|
||||
void set_base_mod(float value);
|
||||
|
||||
float get_bonus_mod();
|
||||
void set_bonus_mod(float value);
|
||||
|
||||
float get_percent_mod();
|
||||
void set_percent_mod(float value);
|
||||
|
||||
Dictionary to_dict();
|
||||
void from_dict(const Dictionary &dict);
|
||||
|
||||
Dictionary _to_dict();
|
||||
void _from_dict(const Dictionary &dict);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _id;
|
||||
float _base_mod;
|
||||
float _bonus_mod;
|
||||
float _percent_mod;
|
||||
|
||||
Stat *_owner;
|
||||
};
|
||||
|
||||
#endif
|
@ -70,7 +70,6 @@ SOFTWARE.
|
||||
#include "entities/stats/stat.h"
|
||||
#include "entities/stats/stat_data.h"
|
||||
#include "entities/stats/stat_data_entry.h"
|
||||
#include "entities/stats/stat_modifier.h"
|
||||
|
||||
#include "inventory/bag.h"
|
||||
//#include "inventory/inventory.h"
|
||||
@ -197,7 +196,6 @@ void register_entity_spell_system_types() {
|
||||
//entity data
|
||||
ClassDB::register_class<EntityEnums>();
|
||||
|
||||
ClassDB::register_class<StatModifier>();
|
||||
ClassDB::register_class<Stat>();
|
||||
ClassDB::register_class<StatDataEntry>();
|
||||
ClassDB::register_class<StatData>();
|
||||
|
Loading…
Reference in New Issue
Block a user