Added locked property to Stat. Also fixed a bunch of smaller errors.

This commit is contained in:
Relintai 2019-09-11 18:18:20 +02:00
parent 7fbb0c4599
commit cfb2373fd1
4 changed files with 39 additions and 13 deletions

View File

@ -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<EntityCreateInfo> 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<EntityDataContainer> Entity::gets_data(int index) {
ERR_FAIL_INDEX_V(index, _s_data.size(),Ref<EntityDataContainer>());
ERR_FAIL_INDEX_V(index, _s_data.size(), Ref<EntityDataContainer>());
_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<EntityDataContainer> Entity::getc_data(int index) {
ERR_FAIL_INDEX_V(index, _c_data.size(),Ref<EntityDataContainer>());
_c_data.get(index);
return _c_data.get(index);
}
int Entity::getc_data_count() {
return _c_data.size();

View File

@ -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<Stat>(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");

View File

@ -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<Ref<StatModifier> > _modifiers;
bool _locked;
bool _dirty;
float _base;

View File

@ -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;