diff --git a/data/auras/aura.cpp b/data/auras/aura.cpp index 1fb275c..f9c6dd3 100644 --- a/data/auras/aura.cpp +++ b/data/auras/aura.cpp @@ -814,7 +814,20 @@ void Aura::son_character_level_up(Ref data, int value) { if (has_method("_son_character_level_up")) call("_son_character_level_up", data, value); } +void Aura::son_entity_resource_added(Ref data, Ref resource) { + ERR_FAIL_COND(!data.is_valid()); + ERR_FAIL_COND(!resource.is_valid()); + if (has_method("_son_entity_resource_added")) + call("_son_entity_resource_added", data, resource); +} +void Aura::son_entity_resource_removed(Ref data, Ref resource) { + ERR_FAIL_COND(!data.is_valid()); + ERR_FAIL_COND(!resource.is_valid()); + + if (has_method("_son_entity_resource_removed")) + call("_son_entity_resource_removed", data, resource); +} void Aura::con_cast_failed(Ref data, Ref info) { if (has_method("_con_cast_failed")) call("_con_cast_failed", data, info); @@ -945,6 +958,21 @@ void Aura::con_character_level_up(Ref data, int value) { call("_con_character_level_up", data, value); } +void Aura::con_entity_resource_added(Ref data, Ref resource) { + ERR_FAIL_COND(!data.is_valid()); + ERR_FAIL_COND(!resource.is_valid()); + + if (has_method("_con_entity_resource_added")) + call("_con_entity_resource_added", data, resource); +} +void Aura::con_entity_resource_removed(Ref data, Ref resource) { + ERR_FAIL_COND(!data.is_valid()); + ERR_FAIL_COND(!resource.is_valid()); + + if (has_method("_con_entity_resource_removed")) + call("_con_entity_resource_removed", data, resource); +} + //Equipment bool Aura::should_deny_equip(Ref data, ItemEnums::EquipSlots equip_slot, Ref item) { @@ -1397,6 +1425,9 @@ void Aura::_bind_methods() { ClassDB::bind_method(D_METHOD("son_class_level_up", "data", "value"), &Aura::son_class_level_up); ClassDB::bind_method(D_METHOD("son_character_level_up", "data", "value"), &Aura::son_character_level_up); + ClassDB::bind_method(D_METHOD("son_entity_resource_added", "data", "value"), &Aura::son_entity_resource_added); + ClassDB::bind_method(D_METHOD("son_entity_resource_removed", "data", "value"), &Aura::son_entity_resource_removed); + BIND_VMETHOD(MethodInfo("_son_before_cast", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_son_before_cast_target", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_son_cast_started", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -1441,6 +1472,9 @@ void Aura::_bind_methods() { BIND_VMETHOD(MethodInfo("_son_class_level_up", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); BIND_VMETHOD(MethodInfo("_son_character_level_up", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_son_entity_resource_added", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_son_entity_resource_removed", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); + //Clientside Event Handlers ClassDB::bind_method(D_METHOD("con_cast_failed", "data", "info"), &Aura::con_cast_failed); ClassDB::bind_method(D_METHOD("con_cast_started", "data", "info"), &Aura::con_cast_started); @@ -1471,6 +1505,9 @@ void Aura::_bind_methods() { ClassDB::bind_method(D_METHOD("con_class_level_up", "data", "value"), &Aura::con_class_level_up); ClassDB::bind_method(D_METHOD("con_character_level_up", "data", "value"), &Aura::con_character_level_up); + ClassDB::bind_method(D_METHOD("con_entity_resource_added", "data", "value"), &Aura::con_entity_resource_added); + ClassDB::bind_method(D_METHOD("con_entity_resource_removed", "data", "value"), &Aura::con_entity_resource_removed); + BIND_VMETHOD(MethodInfo("_con_cast_failed", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_started", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_state_changed", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -1500,6 +1537,9 @@ void Aura::_bind_methods() { BIND_VMETHOD(MethodInfo("_con_class_level_up", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); BIND_VMETHOD(MethodInfo("_con_character_level_up", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_con_entity_resource_added", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_con_entity_resource_removed", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "value"))); + //Equipment BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "ret"), "_should_deny_equip", PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "AuraData"), PropertyInfo(Variant::INT, "equip_slot"), PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"))); diff --git a/data/auras/aura.h b/data/auras/aura.h index c609e5c..38de8c3 100644 --- a/data/auras/aura.h +++ b/data/auras/aura.h @@ -302,6 +302,9 @@ public: void son_class_level_up(Ref data, int value); void son_character_level_up(Ref data, int value); + void son_entity_resource_added(Ref data, Ref resource); + void son_entity_resource_removed(Ref data, Ref resource); + //Clientside Event Handlers void con_cast_failed(Ref data, Ref info); void con_cast_started(Ref data, Ref info); @@ -332,6 +335,9 @@ public: void con_class_level_up(Ref data, int value); void con_character_level_up(Ref data, int value); + void con_entity_resource_added(Ref data, Ref resource); + void con_entity_resource_removed(Ref data, Ref resource); + //Equipment bool should_deny_equip(Ref data, ItemEnums::EquipSlots equip_slot, Ref item); diff --git a/entities/data/entity_class_data.cpp b/entities/data/entity_class_data.cpp index fb2ac95..7baab02 100644 --- a/entities/data/entity_class_data.cpp +++ b/entities/data/entity_class_data.cpp @@ -381,8 +381,7 @@ void EntityClassData::setup_resources(Entity *entity) { if (_inherits.is_valid()) _inherits->setup_resources(entity); - if (has_method("_setup_resources")) - call("_setup_resources", entity); + call("_setup_resources", entity); } void EntityClassData::_setup_resources(Node *entity) { @@ -660,6 +659,16 @@ void EntityClassData::son_character_level_up_bind(Node *entity, int value) { son_character_level_up(e, value); } +void EntityClassData::son_entity_resource_added(Ref resource) { + if (has_method("_son_entity_resource_added")) + call("_son_entity_resource_added", resource); +} + +void EntityClassData::son_entity_resource_removed(Ref resource) { + if (has_method("_son_entity_resource_removed")) + call("_son_entity_resource_removed", resource); +} + //Clientside Event Handlers void EntityClassData::con_cast_failed(Ref info) { ERR_FAIL_COND(!info.is_valid()); @@ -852,7 +861,15 @@ void EntityClassData::con_character_level_up_bind(Node *entity, int value) { con_character_level_up(e, value); } -//Equipment +void EntityClassData::con_entity_resource_added(Ref resource) { + if (has_method("_con_entity_resource_added")) + call("_con_entity_resource_added", resource); +} + +void EntityClassData::con_entity_resource_removed(Ref resource) { + if (has_method("_con_entity_resource_removed")) + call("_con_entity_resource_removed", resource); +} //Equipment @@ -986,6 +1003,9 @@ void EntityClassData::_bind_methods() { ClassDB::bind_method(D_METHOD("son_class_level_up", "entity", "value"), &EntityClassData::son_class_level_up_bind); ClassDB::bind_method(D_METHOD("son_character_level_up", "entity", "value"), &EntityClassData::son_character_level_up_bind); + ClassDB::bind_method(D_METHOD("son_entity_resource_added", "resource"), &EntityClassData::son_entity_resource_added); + ClassDB::bind_method(D_METHOD("son_entity_resource_removed", "resource"), &EntityClassData::son_entity_resource_removed); + BIND_VMETHOD(MethodInfo("_son_before_cast", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_son_before_cast_target", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_son_cast_started", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -1025,6 +1045,12 @@ void EntityClassData::_bind_methods() { BIND_VMETHOD(MethodInfo("_son_class_level_up", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "value"))); BIND_VMETHOD(MethodInfo("_son_character_level_up", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_son_entity_resource_added", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + BIND_VMETHOD(MethodInfo("_son_entity_resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + + BIND_VMETHOD(MethodInfo("_con_entity_resource_added", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + BIND_VMETHOD(MethodInfo("_con_entity_resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + BIND_VMETHOD(MethodInfo("_setup_resources", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); //Clientside Event Handlers @@ -1052,6 +1078,9 @@ void EntityClassData::_bind_methods() { ClassDB::bind_method(D_METHOD("con_class_level_up", "entity", "value"), &EntityClassData::con_class_level_up_bind); ClassDB::bind_method(D_METHOD("con_character_level_up", "entity", "value"), &EntityClassData::con_character_level_up_bind); + ClassDB::bind_method(D_METHOD("con_entity_resource_added", "resource"), &EntityClassData::con_entity_resource_added); + ClassDB::bind_method(D_METHOD("con_entity_resource_removed", "resource"), &EntityClassData::con_entity_resource_removed); + BIND_VMETHOD(MethodInfo("_con_cast_failed", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_started", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_state_changed", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); diff --git a/entities/data/entity_class_data.h b/entities/data/entity_class_data.h index 46fc466..be6b959 100644 --- a/entities/data/entity_class_data.h +++ b/entities/data/entity_class_data.h @@ -195,6 +195,9 @@ public: void son_character_level_up(Entity *entity, int value); void son_character_level_up_bind(Node *entity, int value); + void son_entity_resource_added(Ref resource); + void son_entity_resource_removed(Ref resource); + //Clientside Event Handlers void con_cast_failed(Ref info); void con_cast_started(Ref info); @@ -231,6 +234,9 @@ public: void con_character_level_up(Entity *entity, int value); void con_character_level_up_bind(Node *entity, int value); + void con_entity_resource_added(Ref resource); + void con_entity_resource_removed(Ref resource); + //Equipment bool should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_slot, Ref item); diff --git a/entities/data/entity_data.cpp b/entities/data/entity_data.cpp index b70aaa6..ff183fc 100644 --- a/entities/data/entity_data.cpp +++ b/entities/data/entity_data.cpp @@ -637,6 +637,24 @@ void EntityData::son_character_level_up_bind(Node *entity, int value) { son_character_level_up(e, value); } +void EntityData::son_entity_resource_added(Ref resource) { + if (_entity_class_data.is_valid()) + _entity_class_data->son_entity_resource_added(resource); + + if (has_method("_son_entity_resource_added")) + call("_son_entity_resource_added", resource); +} + + +void EntityData::son_entity_resource_removed(Ref resource) { + if (_entity_class_data.is_valid()) { + _entity_class_data->son_entity_resource_removed(resource); + } + + if (has_method("_son_entity_resource_removed")) + call("_son_entity_resource_removed", resource); +} + //Clientside Event Handlers void EntityData::con_cast_failed(Ref info) { ERR_FAIL_COND(!info.is_valid()); @@ -895,6 +913,26 @@ void EntityData::con_character_level_up_bind(Node *entity, int value) { con_character_level_up(e, value); } +void EntityData::con_entity_resource_added(Ref resource) { + if (_entity_class_data.is_valid()) { + _entity_class_data->con_entity_resource_added(resource); + } + + if (has_method("_con_entity_resource_added")) + call("_con_entity_resource_added", resource); +} + + +void EntityData::con_entity_resource_removed(Ref resource) { + if (_entity_class_data.is_valid()) { + _entity_class_data->con_entity_resource_removed(resource); + } + + if (has_method("_con_entity_resource_removed")) + call("_con_entity_resource_removed", resource); +} + + //Equipment bool EntityData::should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_slot, Ref item) { @@ -1062,6 +1100,9 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("son_class_level_up", "entity", "value"), &EntityData::son_class_level_up_bind); ClassDB::bind_method(D_METHOD("son_character_level_up", "entity", "value"), &EntityData::son_character_level_up_bind); + ClassDB::bind_method(D_METHOD("son_entity_resource_added", "resource"), &EntityData::son_entity_resource_added); + ClassDB::bind_method(D_METHOD("son_entity_resource_removed", "resource"), &EntityData::son_entity_resource_removed); + BIND_VMETHOD(MethodInfo("_son_before_cast", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_son_before_cast_target", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_son_cast_started", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -1106,6 +1147,9 @@ void EntityData::_bind_methods() { BIND_VMETHOD(MethodInfo("_son_class_level_up", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "value"))); BIND_VMETHOD(MethodInfo("_son_character_level_up", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_son_entity_resource_added", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + BIND_VMETHOD(MethodInfo("_son_entity_resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + BIND_VMETHOD(MethodInfo("_setup_resources", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); //Clientside Event Handlers @@ -1133,6 +1177,9 @@ void EntityData::_bind_methods() { ClassDB::bind_method(D_METHOD("con_class_level_up", "entity", "value"), &EntityData::con_class_level_up_bind); ClassDB::bind_method(D_METHOD("con_character_level_up", "entity", "value"), &EntityData::con_character_level_up_bind); + ClassDB::bind_method(D_METHOD("con_entity_resource_added", "resource"), &EntityData::con_entity_resource_added); + ClassDB::bind_method(D_METHOD("con_entity_resource_removed", "resource"), &EntityData::con_entity_resource_removed); + BIND_VMETHOD(MethodInfo("_con_cast_failed", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_started", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); BIND_VMETHOD(MethodInfo("_con_cast_state_changed", PropertyInfo(Variant::OBJECT, "info", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); @@ -1157,6 +1204,9 @@ void EntityData::_bind_methods() { BIND_VMETHOD(MethodInfo("_con_class_level_up", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "value"))); BIND_VMETHOD(MethodInfo("_con_character_level_up", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "value"))); + BIND_VMETHOD(MethodInfo("_con_entity_resource_added", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + BIND_VMETHOD(MethodInfo("_con_entity_resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource"))); + //Equipment BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "ret"), "_should_deny_equip", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::INT, "equip_slot"), PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"))); diff --git a/entities/data/entity_data.h b/entities/data/entity_data.h index ef1e92f..ec7646d 100644 --- a/entities/data/entity_data.h +++ b/entities/data/entity_data.h @@ -190,6 +190,9 @@ public: void son_character_level_up(Entity *entity, int value); void son_character_level_up_bind(Node *entity, int value); + void son_entity_resource_added(Ref resource); + void son_entity_resource_removed(Ref resource); + //Clientside Event Handlers void con_cast_failed(Ref info); void con_cast_started(Ref info); @@ -226,6 +229,9 @@ public: void con_character_level_up(Entity *entity, int value); void con_character_level_up_bind(Node *entity, int value); + void con_entity_resource_added(Ref resource); + void con_entity_resource_removed(Ref resource); + //Equipment bool should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_slot, Ref item); diff --git a/entities/entity.cpp b/entities/entity.cpp index 4e092ea..21a3c1a 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -36,6 +36,8 @@ SOFTWARE. #include "./data/talent_row_data.h" #include "./skills/entity_skill.h" +#include "core/script_language.h" + NodePath Entity::get_body_path() { return _body_path; } @@ -466,8 +468,14 @@ void Entity::_setup(Ref info) { ERR_CONTINUE(!res.is_valid()); res->resolve_references(); + } - //SEND + for (int i = 0; i < _c_resources.size(); ++i) { + Ref res = _c_resources.get(i); + + ERR_CONTINUE(!res.is_valid()); + + res->resolve_references(); } if (gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY) { @@ -556,6 +564,14 @@ void Entity::_setup(Ref info) { res->resolve_references(); } + for (int i = 0; i < _c_resources.size(); ++i) { + Ref res = _c_resources.get(i); + + ERR_CONTINUE(!res.is_valid()); + + res->resolve_references(); + } + sets_ai(_s_entity_data->get_ai_instance()); if (!Engine::get_singleton()->is_editor_hint()) @@ -891,7 +907,11 @@ Dictionary Entity::_to_dict() { Dictionary rd; for (int i = 0; i < _s_resources.size(); ++i) { - rd[i] = _s_resources.get(i)->to_dict(); + Ref r = _s_resources.get(i); + + ERR_CONTINUE(!r.is_valid()); + + rd[String::num(i)] = r->to_dict(); } dict["resources"] = rd; @@ -1068,12 +1088,21 @@ void Entity::_from_dict(const Dictionary &dict) { Dictionary rd = dict.get("resources", Dictionary()); for (int i = 0; i < rd.size(); ++i) { - Ref r; - r.instance(); + Dictionary ird = rd.get(String::num(i), Dictionary()); - r->from_dict(rd.get(String::num(i), Dictionary())); + int data_id = ird.get("data_id", 0); - adds_resource(r); + Ref resd = EntityDataManager::get_instance()->get_entity_resource(data_id); + + ERR_CONTINUE(!resd.is_valid()); + + Ref res = resd->get_entity_resource_instance(); + + ERR_CONTINUE(!res.is_valid()); + + res->from_dict(ird); + + adds_resource(res); } //// GCD //// @@ -1924,6 +1953,8 @@ void Entity::adds_resource(Ref resource) { resource->ons_added(this); + son_entity_resource_added(resource); + VRPCOBJP(addc_resource_rpc, _s_resources.size() - 1, JSON::print(resource->to_dict()), addc_resource, _s_resources.size() - 1, resource); } int Entity::gets_resource_count() { @@ -1932,8 +1963,11 @@ int Entity::gets_resource_count() { void Entity::removes_resource(int index) { ERR_FAIL_INDEX(index, _s_resources.size()); + Ref res = _s_resources.get(index); _s_resources.remove(index); + son_entity_resource_removed(res); + VRPC(removec_resource, index); } void Entity::clears_resource() { @@ -1943,10 +1977,48 @@ void Entity::clears_resource() { } void Entity::addc_resource_rpc(int index, String data) { - Ref res; - res.instance(); - res->from_dict(data_as_dict(data)); + //Ref res; + + Dictionary dict = data_as_dict(data); + /* + String clsname = dict.get("id", "EntityResource"); + + res = Ref(Object::cast_to(ClassDB::instance(clsname))); + + ERR_FAIL_COND(!res.is_valid()); + //res.instance(); + + String script_path = dict.get("script", ""); + + Ref