diff --git a/entities/entity.cpp b/entities/entity.cpp index 8f5a2cc..e2c37b7 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -231,7 +231,10 @@ void Entity::_setup() { sets_entity_type(_s_entity_data->get_entity_type()); sets_immunity_flags(_s_entity_data->get_immunity_flags()); sets_entity_flags(_s_entity_data->get_entity_flags()); - sets_entity_controller(_s_entity_data->get_entity_controller()); + + if (_s_entity_controller == EntityEnums::ENITIY_CONTROLLER_NONE) + sets_entity_controller(_s_entity_data->get_entity_controller()); + sets_player_name(_s_entity_data->get_entity_name()); sets_money(_s_entity_data->get_money()); } @@ -456,8 +459,8 @@ void Entity::initialize(Ref info) { _s_player_name = info->get_player_name(); _c_player_name = info->get_player_name(); - sets_entity_type(info->get_entity_type()); - setc_entity_type(info->get_entity_type()); + sets_entity_controller(info->get_entity_controller()); + //setc_entity_controller(info->get_entity_type()); sets_level(info->get_level()); setc_level(info->get_level()); @@ -2708,9 +2711,9 @@ void Entity::removes_data(int index) { _s_data.remove(index); } Ref Entity::gets_data(int index) { - ERR_FAIL_INDEX_V(index, _s_data.size(),Ref()); + ERR_FAIL_INDEX_V(index, _s_data.size(), Ref()); - _s_data.get(index); + return _s_data.get(index); } int Entity::gets_data_count() { return _s_data.size(); @@ -2728,7 +2731,7 @@ void Entity::removec_data(int index) { Ref Entity::getc_data(int index) { ERR_FAIL_INDEX_V(index, _c_data.size(),Ref()); - _c_data.get(index); + return _c_data.get(index); } int Entity::getc_data_count() { return _c_data.size(); diff --git a/entities/stats/stat.cpp b/entities/stats/stat.cpp index 715e1ce..c073297 100644 --- a/entities/stats/stat.cpp +++ b/entities/stats/stat.cpp @@ -7,6 +7,7 @@ const String Stat::MODIFIER_APPLY_TYPE_BINDING_STRING = "Standard,Only min modif Stat::Stat() { _id = Stat::STAT_ID_NONE; + _locked = false; _base = (float)(0); _bonus = (float)(0); _percent = (float)(0); @@ -21,6 +22,7 @@ Stat::Stat() { Stat::Stat(Stat::StatId id) { _id = id; + _locked = false; _base = (float)(0); _bonus = (float)(0); _percent = (float)(0); @@ -35,6 +37,7 @@ Stat::Stat(Stat::StatId id) { Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type) { _id = id; + _locked = false; _base = (float)(0); _bonus = (float)(0); _percent = (float)(0); @@ -51,6 +54,7 @@ Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type) { Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type, float base, float bonus, float percent) { _id = id; + _locked = false; _base = (float)(0); _bonus = (float)(0); _percent = (float)(0); @@ -71,6 +75,7 @@ Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type, float bas Stat::Stat(Stat::StatId id, StatModifierApplyType modifier_apply_type, float base) { _id = id; + _locked = false; _base = (float)(0); _bonus = (float)(0); _percent = (float)(0); @@ -128,10 +133,16 @@ void Stat::set_stat_modifier_type(Stat::StatModifierApplyType value) { _modifier_apply_type = value; } +bool Stat::get_locked() { + return _locked; +} +void Stat::set_locked(bool value) { + _locked = value; +} + bool Stat::get_dirty() { return _dirty; } - void Stat::set_dirty(bool value) { _dirty = value; } @@ -309,6 +320,10 @@ float Stat::gets_current() { } void Stat::sets_current(float value) { + if (_locked) { + return; + } + _s_current = value; emit_signal("s_changed", Ref(this)); @@ -481,6 +496,10 @@ void Stat::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stat_modifier_type", "value"), &Stat::set_stat_modifier_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "stat_type", PROPERTY_HINT_ENUM, "Standard, Min Modifier, Max modifier"), "set_stat_modifier_type", "get_stat_modifier_type"); + 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"); diff --git a/entities/stats/stat.h b/entities/stats/stat.h index 10d6517..180f629 100644 --- a/entities/stats/stat.h +++ b/entities/stats/stat.h @@ -87,6 +87,9 @@ public: StatModifierApplyType get_stat_modifier_type(); void set_stat_modifier_type(StatModifierApplyType value); + bool get_locked(); + void set_locked(bool value); + bool get_dirty(); void set_dirty(bool value); @@ -143,6 +146,7 @@ private: Vector > _modifiers; + bool _locked; bool _dirty; float _base; diff --git a/utility/entity_create_info.h b/utility/entity_create_info.h index 8e5494d..47872ec 100644 --- a/utility/entity_create_info.h +++ b/utility/entity_create_info.h @@ -13,8 +13,8 @@ public: int get_guid() { return _guid; } void set_guid(int value) { _guid = value; } - EntityEnums::EntityType get_entity_type() { return _entity_type; } - void set_entity_type(EntityEnums::EntityType value) { _entity_type = value; } + EntityEnums::EntityController get_entity_controller() { return _entity_controller; } + void set_entity_controller(EntityEnums::EntityController value) { _entity_controller = value; } String get_player_name() { return _player_name; } void set_player_name(String value) { _player_name = value; } @@ -30,9 +30,9 @@ public: protected: static void _bind_methods() { - ClassDB::bind_method(D_METHOD("get_entity_type"), &EntityCreateInfo::get_entity_type); - ClassDB::bind_method(D_METHOD("set_entity_type", "value"), &EntityCreateInfo::set_entity_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_type", PROPERTY_HINT_ENUM, "None, Player, AI, Mob"), "set_entity_type", "get_entity_type"); + ClassDB::bind_method(D_METHOD("get_entity_controller"), &EntityCreateInfo::get_entity_controller); + ClassDB::bind_method(D_METHOD("set_entity_controller", "value"), &EntityCreateInfo::set_entity_controller); + ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_controller", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_ENTITY_CONTOLLER), "set_entity_controller", "get_entity_controller"); ClassDB::bind_method(D_METHOD("get_player_name"), &EntityCreateInfo::get_player_name); ClassDB::bind_method(D_METHOD("set_player_name", "value"), &EntityCreateInfo::set_player_name); @@ -53,7 +53,7 @@ protected: private: int _guid; - EntityEnums::EntityType _entity_type; + EntityEnums::EntityController _entity_controller; String _player_name; int _level; int _xp;