diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index bdd160e..d283efc 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -21,6 +21,34 @@ void EntityData::set_inherits(Ref value) { _inherits = value; } +EntityEnums::EntityType EntityData::get_entity_type() { + return _entity_type; +} +void EntityData::set_entity_type(EntityEnums::EntityType value) { + _entity_type = value; +} + +int EntityData::get_immunity_flags() { + return _immunity_flags; +} +void EntityData::set_immunity_flags(int value) { + _immunity_flags = value; +} + +int EntityData::get_entity_flags() { + return _entity_flags; +} +void EntityData::set_entity_flags(int value) { + _entity_flags = value; +} + +EntityEnums::EntityController EntityData::get_entity_controller() { + return _entity_controller; +} +void EntityData::set_entity_controller(EntityEnums::EntityController value) { + _entity_controller = value; +} + String EntityData::get_entity_name() { return _entity_name; } @@ -933,6 +961,14 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_id"), &EntityData::get_id); ClassDB::bind_method(D_METHOD("set_id", "value"), &EntityData::set_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); + + 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"); + + ClassDB::bind_method(D_METHOD("get_entity_controller"), &EntityData::get_entity_controller); + ClassDB::bind_method(D_METHOD("set_entity_controller", "value"), &EntityData::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_entity_name"), &EntityData::get_entity_name); ClassDB::bind_method(D_METHOD("set_entity_name", "value"), &EntityData::set_entity_name); @@ -953,8 +989,27 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_player_resource_type"), &EntityData::get_player_resource_type); ClassDB::bind_method(D_METHOD("set_player_resource_type", "value"), &EntityData::set_player_resource_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "player_resource_type", PROPERTY_HINT_ENUM, "None, Rage, Mana, Energy, Time Anomaly"), "set_player_resource_type", "get_player_resource_type"); + + // Loot DB + ClassDB::bind_method(D_METHOD("get_loot_db"), &EntityData::get_loot_db); + ClassDB::bind_method(D_METHOD("set_loot_db", "value"), &EntityData::set_loot_db); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "loot_db", PROPERTY_HINT_RESOURCE_TYPE, "LootDataBase"), "set_loot_db", "get_loot_db"); + ClassDB::bind_method(D_METHOD("generate_name"), &EntityData::generate_name); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, "name"), "_generate_name")); + + ADD_GROUP("Immunities", "immunity"); + ClassDB::bind_method(D_METHOD("get_immunity_flags"), &EntityData::get_immunity_flags); + ClassDB::bind_method(D_METHOD("set_immunity_flags", "value"), &EntityData::set_immunity_flags); + ADD_PROPERTY(PropertyInfo(Variant::INT, "immunity_flags", PROPERTY_HINT_FLAGS, EntityEnums::BINDING_STRING_ENTITY_IMMUNITY_FLAGS), "set_immunity_flags", "get_immunity_flags"); + + ADD_GROUP("Entity Flags", "entity_flags"); + ClassDB::bind_method(D_METHOD("get_entity_flags"), &EntityData::get_entity_flags); + ClassDB::bind_method(D_METHOD("set_entity_flags", "value"), &EntityData::set_entity_flags); + ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_flags", PROPERTY_HINT_FLAGS, EntityEnums::BINDING_STRING_ENTITY_FLAGS), "set_entity_flags", "get_entity_flags"); + //// Specs //// + ADD_GROUP("Specs", "specs"); ClassDB::bind_method(D_METHOD("get_num_specs"), &EntityData::get_num_specs); ClassDB::bind_method(D_METHOD("set_num_specs", "value"), &EntityData::set_num_specs); @@ -966,6 +1021,7 @@ void EntityData::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "specs", PROPERTY_HINT_NONE, "17/17:CharacterSpec", PROPERTY_USAGE_DEFAULT, "CharacterSpec"), "set_specs", "get_specs"); //// Spell //// + ADD_GROUP("Spells", "spells"); ClassDB::bind_method(D_METHOD("get_num_spells"), &EntityData::get_num_spells); ClassDB::bind_method(D_METHOD("set_num_spells", "value"), &EntityData::set_num_spells); @@ -977,6 +1033,7 @@ void EntityData::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "spells", PROPERTY_HINT_NONE, "17/17:Spell", PROPERTY_USAGE_DEFAULT, "Spell"), "set_spells", "get_spells"); //// AURAS //// + ADD_GROUP("Auras", "auras"); ClassDB::bind_method(D_METHOD("get_num_auras"), &EntityData::get_num_auras); ClassDB::bind_method(D_METHOD("set_num_auras", "value"), &EntityData::set_num_auras); @@ -988,6 +1045,7 @@ void EntityData::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "auras", PROPERTY_HINT_NONE, "17/17:Aura", PROPERTY_USAGE_DEFAULT, "Aura"), "set_auras", "get_auras"); //// AI ACTIONS //// + ADD_GROUP("Ai_actions", "ai_actions"); ClassDB::bind_method(D_METHOD("get_num_ai_actions"), &EntityData::get_num_ai_actions); ClassDB::bind_method(D_METHOD("set_num_ai_actions", "value"), &EntityData::set_num_ai_actions); @@ -997,23 +1055,24 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ai_actions"), &EntityData::get_ai_actions); ClassDB::bind_method(D_METHOD("set_ai_actions", "auras"), &EntityData::set_ai_actions); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "ai_actions", PROPERTY_HINT_NONE, "17/17:AIAction", PROPERTY_USAGE_DEFAULT, "AIAction"), "set_ai_actions", "get_ai_actions"); - - // Loot DB - ClassDB::bind_method(D_METHOD("get_loot_db"), &EntityData::get_loot_db); - ClassDB::bind_method(D_METHOD("set_loot_db", "value"), &EntityData::set_loot_db); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "loot_db", PROPERTY_HINT_RESOURCE_TYPE, "LootDataBase"), "set_loot_db", "get_loot_db"); - - ClassDB::bind_method(D_METHOD("generate_name"), &EntityData::generate_name); - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, "name"), "_generate_name")); } EntityData::EntityData() { _id = 0; _player_resource_type = 0; + + + _entity_type = EntityEnums::ENITIY_TYPE_NONE; + _immunity_flags = 0; + _entity_flags = 0; + _entity_controller = EntityEnums::ENITIY_CONTROLLER_NONE; + + _player_resource_type = 0; } EntityData::~EntityData() { _spells.clear(); _specs.clear(); _auras.clear(); + _ai_actions.clear(); } diff --git a/entities/data/entity_data.h b/entities/data/entity_data.h index e356eff..766522f 100644 --- a/entities/data/entity_data.h +++ b/entities/data/entity_data.h @@ -40,6 +40,18 @@ class EntityData : public Resource { public: int get_id(); void set_id(int value); + + EntityEnums::EntityType get_entity_type(); + void set_entity_type(EntityEnums::EntityType value); + + int get_immunity_flags(); + void set_immunity_flags(int value); + + int get_entity_flags(); + void set_entity_flags(int value); + + EntityEnums::EntityController get_entity_controller(); + void set_entity_controller(EntityEnums::EntityController value); String get_entity_name(); void set_entity_name(String value); @@ -207,6 +219,11 @@ protected: private: int _id; + + EntityEnums::EntityType _entity_type; + int _immunity_flags; + int _entity_flags; + EntityEnums::EntityController _entity_controller; String _entity_name; diff --git a/entities/entity.cpp b/entities/entity.cpp index 1bac869..00cf108 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -86,7 +86,6 @@ void Entity::sets_immunity_flags(int value) { _s_immunity_flags = value; } - int Entity::gets_entity_flags() { return _s_entity_flags; } @@ -191,20 +190,37 @@ Ref Entity::gets_entity_data() { void Entity::sets_entity_data(Ref value) { _s_entity_data = value; - if (value.is_valid()) { - value->setup_resources(this); - sinitialize_stats(); - sets_entity_data_id(value->get_id()); - } - - if (!Engine::get_singleton()->is_editor_hint()) - set_process(value.is_valid()); + setup(); emit_signal("sentity_data_changed", value); //SEND_RPC(rpc("setc_entity_data", value), setc_entity_data(value)); } +void Entity::setup() { + if (has_method("_setup")) { + call("_setup"); + } +} + +void Entity::_setup() { + if (_s_entity_data.is_valid()) { + _s_entity_data->setup_resources(this); + sinitialize_stats(); + sets_entity_data_id(_s_entity_data->get_id()); + + + 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()); + sets_player_name(_s_entity_data->get_entity_name()); + } + + if (!Engine::get_singleton()->is_editor_hint()) + set_process(_s_entity_data.is_valid()); +} + Entity::Entity() { _s_guid = 0; _c_guid = 0; @@ -2822,7 +2838,7 @@ void Entity::_bind_methods() { ADD_SIGNAL(MethodInfo("sdied", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); ADD_SIGNAL(MethodInfo("cdied", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); - + //SpellCastSignals ADD_SIGNAL(MethodInfo("scast_started", PropertyInfo(Variant::OBJECT, "spell_cast_info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); ADD_SIGNAL(MethodInfo("scast_failed", PropertyInfo(Variant::OBJECT, "spell_cast_info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -2849,6 +2865,13 @@ void Entity::_bind_methods() { ADD_SIGNAL(MethodInfo("caura_removed_expired", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); //ADD_SIGNAL(MethodInfo("caura_refreshed", PropertyInfo(Variant::OBJECT, "aura_data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"))); + //setup + BIND_VMETHOD(MethodInfo("_setup", PropertyInfo(Variant::OBJECT, "entity_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityData"))); + + ClassDB::bind_method(D_METHOD("setup"), &Entity::setup); + ClassDB::bind_method(D_METHOD("_setup"), &Entity::_setup); + + //binds ClassDB::bind_method(D_METHOD("sdie"), &Entity::sdie); ClassDB::bind_method(D_METHOD("cdie"), &Entity::cdie); diff --git a/entities/entity.h b/entities/entity.h index 47be123..6276bf0 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -147,7 +147,6 @@ public: int gets_immunity_flags(); void sets_immunity_flags(int value); - int gets_entity_flags(); void sets_entity_flags(int value); @@ -475,6 +474,9 @@ public: String random_name(); + void setup(); + void _setup(); + Entity(); ~Entity();