diff --git a/data/species/entity_species_data.cpp b/data/species/entity_species_data.cpp index dc62bf6..3a22268 100644 --- a/data/species/entity_species_data.cpp +++ b/data/species/entity_species_data.cpp @@ -34,10 +34,10 @@ void EntitySpeciesData::set_id(const int value) { _id = value; } -EntityEnums::EntityType EntitySpeciesData::get_type() const { +int EntitySpeciesData::get_type() const { return _type; } -void EntitySpeciesData::set_type(const EntityEnums::EntityType value) { +void EntitySpeciesData::set_type(const int value) { _type = value; } @@ -155,7 +155,7 @@ String EntitySpeciesData::generate_name(int seed) { EntitySpeciesData::EntitySpeciesData() { _id = 0; - _type = EntityEnums::ENITIY_TYPE_NONE; + _type = 0; } EntitySpeciesData::~EntitySpeciesData() { _model_data.unref(); @@ -164,6 +164,12 @@ EntitySpeciesData::~EntitySpeciesData() { _auras.clear(); } +void EntitySpeciesData::_validate_property(PropertyInfo &property) const { + if (property.name == "type") { + property.hint_string = ESS::get_instance()->entity_types_get(); + } +} + void EntitySpeciesData::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::STRING, "_generate_name", PropertyInfo(Variant::INT, "seed"))); @@ -175,7 +181,7 @@ void EntitySpeciesData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_type"), &EntitySpeciesData::get_type); ClassDB::bind_method(D_METHOD("set_type", "value"), &EntitySpeciesData::set_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_ENTITY_TYPES), "set_type", "get_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, ""), "set_type", "get_type"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_name", "get_name"); diff --git a/data/species/entity_species_data.h b/data/species/entity_species_data.h index 6ed4f68..aa6c94b 100644 --- a/data/species/entity_species_data.h +++ b/data/species/entity_species_data.h @@ -41,8 +41,8 @@ public: int get_id() const; void set_id(const int value); - EntityEnums::EntityType get_type() const; - void set_type(const EntityEnums::EntityType value); + int get_type() const; + void set_type(const int value); String get_text_description() const; void set_text_description(const String &value); @@ -78,11 +78,12 @@ public: ~EntitySpeciesData(); protected: + void _validate_property(PropertyInfo &property) const; static void _bind_methods(); private: int _id; - EntityEnums::EntityType _type; + int _type; String _text_description; Ref _model_data; diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index 9661017..2196b0c 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -53,10 +53,10 @@ void EntityData::set_inherits(const Ref &value) { _inherits = value; } -EntityEnums::EntityType EntityData::get_entity_type() const { +int EntityData::get_entity_type() const { return _entity_type; } -void EntityData::set_entity_type(const EntityEnums::EntityType value) { +void EntityData::set_entity_type(const int value) { _entity_type = value; } @@ -885,7 +885,7 @@ EntityData::EntityData() { _bag_size = 0; _is_playable = false; - _entity_type = EntityEnums::ENITIY_TYPE_NONE; + _entity_type = 0; _interaction_type = EntityEnums::ENITIY_INTERACTION_TYPE_NORMAL; _immunity_flags = 0; _entity_flags = 0; @@ -909,6 +909,12 @@ EntityData::~EntityData() { _craft_recipes.clear(); } +void EntityData::_validate_property(PropertyInfo &property) const { + if (property.name == "entity_type") { + property.hint_string = ESS::get_instance()->entity_types_get(); + } +} + void EntityData::_bind_methods() { //Interactions BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "can"), "_cans_interact", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); @@ -1038,7 +1044,7 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_entity_type"), &EntityData::get_entity_type); ClassDB::bind_method(D_METHOD("set_entity_type", "value"), &EntityData::set_entity_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_type", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_ENTITY_TYPES), "set_entity_type", "get_entity_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_type", PROPERTY_HINT_ENUM, ""), "set_entity_type", "get_entity_type"); ClassDB::bind_method(D_METHOD("get_entity_interaction_type"), &EntityData::get_entity_interaction_type); ClassDB::bind_method(D_METHOD("set_entity_interaction_type", "value"), &EntityData::set_entity_interaction_type); diff --git a/entities/data/entity_data.h b/entities/data/entity_data.h index 18e3ba6..13a020d 100644 --- a/entities/data/entity_data.h +++ b/entities/data/entity_data.h @@ -73,8 +73,8 @@ public: Ref get_inherits() const; void set_inherits(const Ref &value); - EntityEnums::EntityType get_entity_type() const; - void set_entity_type(const EntityEnums::EntityType value); + int get_entity_type() const; + void set_entity_type(const int value); EntityEnums::EntityInteractionType get_entity_interaction_type() const; void set_entity_interaction_type(const EntityEnums::EntityInteractionType value); @@ -231,6 +231,7 @@ public: ~EntityData(); protected: + void _validate_property(PropertyInfo &property) const; static void _bind_methods(); private: @@ -238,7 +239,7 @@ private: Ref _inherits; - EntityEnums::EntityType _entity_type; + int _entity_type; EntityEnums::EntityInteractionType _interaction_type; diff --git a/entities/entity.cpp b/entities/entity.cpp index e5f2cc6..9e530ec 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -183,19 +183,19 @@ void Entity::setc_entity_player_type(int value) { } //EntityType -EntityEnums::EntityType Entity::gets_entity_type() { +int Entity::gets_entity_type() { return _s_entity_type; } -void Entity::sets_entity_type(EntityEnums::EntityType value) { +void Entity::sets_entity_type(int value) { _s_entity_type = value; VRPC(setc_entity_type, value); } -EntityEnums::EntityType Entity::getc_entity_type() { +int Entity::getc_entity_type() { return _c_entity_type; } -void Entity::setc_entity_type(EntityEnums::EntityType value) { +void Entity::setc_entity_type(int value) { _c_entity_type = value; } @@ -1267,7 +1267,7 @@ Dictionary Entity::_to_dict() { void Entity::_from_dict(const Dictionary &dict) { ERR_FAIL_COND(dict.empty()); - sets_entity_type((EntityEnums::EntityType)((int)dict.get("type", 0))); + sets_entity_type((int)((int)dict.get("type", 0))); sets_gender(static_cast(static_cast(dict.get("gender", 0)))); @@ -1394,7 +1394,7 @@ void Entity::_from_dict(const Dictionary &dict) { //_c_auras.push_back(r); } - sets_entity_type((EntityEnums::EntityType)((int)dict.get("entity_type", 0))); + sets_entity_type((int)((int)dict.get("entity_type", 0))); sets_immunity_flags(dict.get("immunity_flags", 0)); sets_entity_flags(dict.get("entity_flags", 0)); EntityEnums::EntityController contr = static_cast(static_cast(dict.get("entity_controller", 0))); @@ -5809,8 +5809,8 @@ Entity::Entity() { _s_active_category_cooldowns = 0; _c_active_category_cooldowns = 0; - _s_entity_type = EntityEnums::ENITIY_TYPE_NONE; - _c_entity_type = EntityEnums::ENITIY_TYPE_NONE; + _s_entity_type = 0; + _c_entity_type = 0; _s_immunity_flags = 0; @@ -6401,7 +6401,7 @@ bool Entity::_set(const StringName &p_name, const Variant &p_value) { return true; /* - sets_entity_type((EntityEnums::EntityType)((int)dict.get("type", 0))); + sets_entity_type((int)((int)dict.get("type", 0))); sets_gender(static_cast(static_cast(dict.get("gender", 0)))); @@ -6501,7 +6501,7 @@ bool Entity::_set(const StringName &p_name, const Variant &p_value) { //_c_auras.push_back(r); } - sets_entity_type((EntityEnums::EntityType)((int)dict.get("entity_type", 0))); + sets_entity_type((int)((int)dict.get("entity_type", 0))); sets_immunity_flags(dict.get("immunity_flags", 0)); sets_entity_flags(dict.get("entity_flags", 0)); EntityEnums::EntityController contr = static_cast(static_cast(dict.get("entity_controller", 0))); @@ -6847,6 +6847,14 @@ void Entity::_get_property_list(List *p_list) const { } } +void Entity::_validate_property(PropertyInfo &property) const { + String name = property.name; + + if (name == "sentity_player_type" || name == "centity_player_type") { + property.hint_string = ESS::get_instance()->entity_types_get(); + } +} + void Entity::_bind_methods() { //Signals ADD_SIGNAL(MethodInfo("deserialized", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); @@ -7247,11 +7255,11 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("gets_entity_type"), &Entity::gets_entity_type); ClassDB::bind_method(D_METHOD("sets_entity_type", "value"), &Entity::sets_entity_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "sentity_type", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_ENTITY_TYPES), "sets_entity_type", "gets_entity_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sentity_type", PROPERTY_HINT_ENUM, ""), "sets_entity_type", "gets_entity_type"); ClassDB::bind_method(D_METHOD("getc_entity_type"), &Entity::getc_entity_type); ClassDB::bind_method(D_METHOD("setc_entity_type", "value"), &Entity::sets_entity_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "centity_type", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_ENTITY_TYPES, 0), "setc_entity_type", "getc_entity_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "centity_type", PROPERTY_HINT_ENUM, "", 0), "setc_entity_type", "getc_entity_type"); ClassDB::bind_method(D_METHOD("gets_ai_state"), &Entity::gets_ai_state); ClassDB::bind_method(D_METHOD("sets_ai_state", "value"), &Entity::sets_ai_state); diff --git a/entities/entity.h b/entities/entity.h index bfbd04f..c34ef94 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -268,11 +268,11 @@ public: void setc_entity_player_type(int value); //EntityType - EntityEnums::EntityType gets_entity_type(); - void sets_entity_type(EntityEnums::EntityType value); + int gets_entity_type(); + void sets_entity_type(int value); - EntityEnums::EntityType getc_entity_type(); - void setc_entity_type(EntityEnums::EntityType value); + int getc_entity_type(); + void setc_entity_type(int value); //Relations EntityEnums::EntityRelationType gets_relation_to_bind(Node *to); @@ -1047,6 +1047,7 @@ protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List *p_list) const; + void _validate_property(PropertyInfo &property) const; static void _bind_methods(); virtual void _notification(int p_what); @@ -1158,8 +1159,8 @@ private: Vector > _s_auras; Vector > _c_auras; - EntityEnums::EntityType _s_entity_type; - EntityEnums::EntityType _c_entity_type; + int _s_entity_type; + int _c_entity_type; int _s_immunity_flags; diff --git a/entity_enums.cpp b/entity_enums.cpp index 64bf007..9a951c5 100644 --- a/entity_enums.cpp +++ b/entity_enums.cpp @@ -23,7 +23,6 @@ SOFTWARE. #include "entity_enums.h" const String EntityEnums::BINDING_STRING_ENTITY_PLAYER_TYPES = "None,Player,Networked,AI,Display"; -const String EntityEnums::BINDING_STRING_ENTITY_TYPES = "None,Creature,Totem,Idol,Humanoid,Mechanical,Beast,Dragonkin,Elemental,Ghost,Energy,Anomaly,Demon,Object"; const String EntityEnums::BINDING_STRING_ENTITY_CONTOLLER = "None,Player,AI"; const String EntityEnums::BINDING_STRING_ENTITY_FLAGS = "Untargetable,Hidden,Interactable,Hostile"; const String EntityEnums::BINDING_STRING_ENTITY_STATE_TYPES = "None,Stun,Root,Frozen,Silenced,Disoriented,Feared,Burning,Cold,Cursed,Pacified"; @@ -44,21 +43,6 @@ void EntityEnums::_bind_methods() { BIND_ENUM_CONSTANT(ENTITY_PLAYER_TYPE_AI); BIND_ENUM_CONSTANT(ENTITY_PLAYER_TYPE_DISPLAY); - BIND_ENUM_CONSTANT(ENITIY_TYPE_NONE); - BIND_ENUM_CONSTANT(ENITIY_TYPE_CREATURE); - BIND_ENUM_CONSTANT(ENITIY_TYPE_TOTEM); - BIND_ENUM_CONSTANT(ENITIY_TYPE_IDOL); - BIND_ENUM_CONSTANT(ENITIY_TYPE_HUMANOID); - BIND_ENUM_CONSTANT(ENITIY_TYPE_MECHANICAL); - BIND_ENUM_CONSTANT(ENITIY_TYPE_BEAST); - BIND_ENUM_CONSTANT(ENITIY_TYPE_DRAGONKIN); - BIND_ENUM_CONSTANT(ENITIY_TYPE_ELEMENTAL); - BIND_ENUM_CONSTANT(ENITIY_TYPE_GHOST); - BIND_ENUM_CONSTANT(ENITIY_TYPE_ENERGY); - BIND_ENUM_CONSTANT(ENITIY_TYPE_ANOMALY); - BIND_ENUM_CONSTANT(ENITIY_TYPE_DEMON); - BIND_ENUM_CONSTANT(ENITIY_TYPE_OBJECT); - BIND_ENUM_CONSTANT(ENITIY_CONTROLLER_NONE); BIND_ENUM_CONSTANT(ENITIY_CONTROLLER_PLAYER); BIND_ENUM_CONSTANT(ENITIY_CONTROLLER_AI); diff --git a/entity_enums.h b/entity_enums.h index 5650047..ff90df7 100644 --- a/entity_enums.h +++ b/entity_enums.h @@ -31,7 +31,6 @@ class EntityEnums : public Object { public: static const String BINDING_STRING_ENTITY_PLAYER_TYPES; - static const String BINDING_STRING_ENTITY_TYPES; static const String BINDING_STRING_ENTITY_CONTOLLER; static const String BINDING_STRING_ENTITY_FLAGS; static const String BINDING_STRING_ENTITY_STATE_TYPES; @@ -54,23 +53,6 @@ public: ENTITY_PLAYER_TYPE_DISPLAY, }; - enum EntityType { - ENITIY_TYPE_NONE, - ENITIY_TYPE_CREATURE, - ENITIY_TYPE_TOTEM, - ENITIY_TYPE_IDOL, - ENITIY_TYPE_HUMANOID, - ENITIY_TYPE_MECHANICAL, - ENITIY_TYPE_BEAST, - ENITIY_TYPE_DRAGONKIN, - ENITIY_TYPE_ELEMENTAL, - ENITIY_TYPE_GHOST, - ENITIY_TYPE_ENERGY, - ENITIY_TYPE_ANOMALY, - ENITIY_TYPE_DEMON, - ENITIY_TYPE_OBJECT, - }; - enum EntityController { ENITIY_CONTROLLER_NONE, ENITIY_CONTROLLER_PLAYER, @@ -287,7 +269,6 @@ protected: }; VARIANT_ENUM_CAST(EntityEnums::EntityPlayerType); -VARIANT_ENUM_CAST(EntityEnums::EntityType); VARIANT_ENUM_CAST(EntityEnums::EntityController); VARIANT_ENUM_CAST(EntityEnums::EntityFlags); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeFlags);