Implemented EntityResources.

This commit is contained in:
Relintai 2020-03-11 16:08:07 +01:00
parent 3686150a44
commit 4dce51d019
10 changed files with 372 additions and 57 deletions

View File

@ -814,7 +814,20 @@ void Aura::son_character_level_up(Ref<AuraData> data, int value) {
if (has_method("_son_character_level_up"))
call("_son_character_level_up", data, value);
}
void Aura::son_entity_resource_added(Ref<AuraData> data, Ref<EntityResource> 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<AuraData> data, Ref<EntityResource> 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<AuraData> data, Ref<SpellCastInfo> info) {
if (has_method("_con_cast_failed"))
call("_con_cast_failed", data, info);
@ -945,6 +958,21 @@ void Aura::con_character_level_up(Ref<AuraData> data, int value) {
call("_con_character_level_up", data, value);
}
void Aura::con_entity_resource_added(Ref<AuraData> data, Ref<EntityResource> 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<AuraData> data, Ref<EntityResource> 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<AuraData> data, ItemEnums::EquipSlots equip_slot, Ref<ItemInstance> 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")));

View File

@ -302,6 +302,9 @@ public:
void son_class_level_up(Ref<AuraData> data, int value);
void son_character_level_up(Ref<AuraData> data, int value);
void son_entity_resource_added(Ref<AuraData> data, Ref<EntityResource> resource);
void son_entity_resource_removed(Ref<AuraData> data, Ref<EntityResource> resource);
//Clientside Event Handlers
void con_cast_failed(Ref<AuraData> data, Ref<SpellCastInfo> info);
void con_cast_started(Ref<AuraData> data, Ref<SpellCastInfo> info);
@ -332,6 +335,9 @@ public:
void con_class_level_up(Ref<AuraData> data, int value);
void con_character_level_up(Ref<AuraData> data, int value);
void con_entity_resource_added(Ref<AuraData> data, Ref<EntityResource> resource);
void con_entity_resource_removed(Ref<AuraData> data, Ref<EntityResource> resource);
//Equipment
bool should_deny_equip(Ref<AuraData> data, ItemEnums::EquipSlots equip_slot, Ref<ItemInstance> item);

View File

@ -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<EntityResource> resource) {
if (has_method("_son_entity_resource_added"))
call("_son_entity_resource_added", resource);
}
void EntityClassData::son_entity_resource_removed(Ref<EntityResource> resource) {
if (has_method("_son_entity_resource_removed"))
call("_son_entity_resource_removed", resource);
}
//Clientside Event Handlers
void EntityClassData::con_cast_failed(Ref<SpellCastInfo> 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<EntityResource> resource) {
if (has_method("_con_entity_resource_added"))
call("_con_entity_resource_added", resource);
}
void EntityClassData::con_entity_resource_removed(Ref<EntityResource> 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")));

View File

@ -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<EntityResource> resource);
void son_entity_resource_removed(Ref<EntityResource> resource);
//Clientside Event Handlers
void con_cast_failed(Ref<SpellCastInfo> info);
void con_cast_started(Ref<SpellCastInfo> 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<EntityResource> resource);
void con_entity_resource_removed(Ref<EntityResource> resource);
//Equipment
bool should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_slot, Ref<ItemInstance> item);

View File

@ -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<EntityResource> 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<EntityResource> 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<SpellCastInfo> 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<EntityResource> 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<EntityResource> 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<ItemInstance> 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")));

View File

@ -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<EntityResource> resource);
void son_entity_resource_removed(Ref<EntityResource> resource);
//Clientside Event Handlers
void con_cast_failed(Ref<SpellCastInfo> info);
void con_cast_started(Ref<SpellCastInfo> 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<EntityResource> resource);
void con_entity_resource_removed(Ref<EntityResource> resource);
//Equipment
bool should_deny_equip(Entity *entity, ItemEnums::EquipSlots equip_slot, Ref<ItemInstance> item);

View File

@ -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<EntityCreateInfo> info) {
ERR_CONTINUE(!res.is_valid());
res->resolve_references();
}
//SEND
for (int i = 0; i < _c_resources.size(); ++i) {
Ref<EntityResource> 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<EntityCreateInfo> info) {
res->resolve_references();
}
for (int i = 0; i < _c_resources.size(); ++i) {
Ref<EntityResource> 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<EntityResource> 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<EntityResource> 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<EntityResourceData> resd = EntityDataManager::get_instance()->get_entity_resource(data_id);
ERR_CONTINUE(!resd.is_valid());
Ref<EntityResource> 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<EntityResource> 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<EntityResource> 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<EntityResource> res;
res.instance();
res->from_dict(data_as_dict(data));
//Ref<EntityResource> res;
Dictionary dict = data_as_dict(data);
/*
String clsname = dict.get("id", "EntityResource");
res = Ref<EntityResource>(Object::cast_to<EntityResource>(ClassDB::instance(clsname)));
ERR_FAIL_COND(!res.is_valid());
//res.instance();
String script_path = dict.get("script", "");
Ref<Script> s;
if (script_path != "") {
if (ResourceLoader::exists(script_path)) {
s = ResourceLoader::load(script_path);
if (s.is_valid()) {
res->set_script(s.get_ref_ptr());
} else {
ERR_PRINT("Error, script is not valid! " + script_path);
}
}
}
Dictionary d = dict.get("data", Dictionary());
res->from_dict(d);
res->resolve_references();
*/
int data_id = dict.get("data_id", 0);
Ref<EntityResourceData> resd = EntityDataManager::get_instance()->get_entity_resource(data_id);
ERR_FAIL_COND(!resd.is_valid());
Ref<EntityResource> res = resd->get_entity_resource_instance();
ERR_FAIL_COND(!res.is_valid());
res->from_dict(dict);
addc_resource(index, res);
}
@ -1977,6 +2049,8 @@ void Entity::addc_resource(int index, Ref<EntityResource> resource) {
_c_resources.set(index, resource);
resource->onc_added(this);
con_entity_resource_added(resource);
}
int Entity::getc_resource_count() {
return _c_resources.size();
@ -1984,7 +2058,10 @@ int Entity::getc_resource_count() {
void Entity::removec_resource(int index) {
ERR_FAIL_INDEX(index, _c_resources.size());
Ref<EntityResource> res = _c_resources.get(index);
_c_resources.remove(index);
con_entity_resource_removed(res);
}
void Entity::clearc_resource() {
_s_resources.clear();
@ -2994,6 +3071,40 @@ void Entity::son_character_level_up(int value) {
emit_signal("son_character_level_up", this, value);
}
void Entity::son_entity_resource_added(Ref<EntityResource> resource) {
if (_s_entity_data.is_valid()) {
_s_entity_data->son_entity_resource_added(resource);
}
if (has_method("_son_entity_resource_added"))
call("_son_entity_resource_added", resource);
for (int i = 0; i < _s_auras.size(); ++i) {
Ref<AuraData> ad = _s_auras.get(i);
ad->get_aura()->son_entity_resource_added(ad, resource);
}
emit_signal("sentity_resource_added", resource);
}
void Entity::son_entity_resource_removed(Ref<EntityResource> resource) {
if (_s_entity_data.is_valid()) {
_s_entity_data->son_entity_resource_removed(resource);
}
if (has_method("_son_entity_resource_removed"))
call("_son_entity_resource_removed", resource);
for (int i = 0; i < _s_auras.size(); ++i) {
Ref<AuraData> ad = _s_auras.get(i);
ad->get_aura()->son_entity_resource_removed(ad, resource);
}
emit_signal("sentity_resource_removed", resource);
}
void Entity::adds_aura(Ref<AuraData> aura) {
ERR_FAIL_COND(!aura.is_valid());
@ -3721,6 +3832,40 @@ void Entity::con_character_level_up(int value) {
emit_signal("con_character_level_up", this, value);
}
void Entity::con_entity_resource_added(Ref<EntityResource> resource) {
if (_c_entity_data.is_valid()) {
_c_entity_data->con_entity_resource_added(resource);
}
if (has_method("_con_entity_resource_added"))
call("_con_entity_resource_added", resource);
for (int i = 0; i < _c_auras.size(); ++i) {
Ref<AuraData> ad = _c_auras.get(i);
ad->get_aura()->con_entity_resource_added(ad, resource);
}
emit_signal("centity_resource_added", resource);
}
void Entity::con_entity_resource_removed(Ref<EntityResource> resource) {
if (_c_entity_data.is_valid()) {
_c_entity_data->con_entity_resource_removed(resource);
}
if (has_method("_con_entity_resource_removed"))
call("_con_entity_resource_removed", resource);
for (int i = 0; i < _c_auras.size(); ++i) {
Ref<AuraData> ad = _c_auras.get(i);
ad->get_aura()->con_entity_resource_removed(ad, resource);
}
emit_signal("centity_resource_removed", resource);
}
//// Casting System ////
void Entity::sstart_casting(Ref<SpellCastInfo> info) {
@ -5293,6 +5438,11 @@ void Entity::update(float delta) {
if (res->get_should_process())
res->process_server(delta);
if (res->get_dirty()) {
sends_resource_curr_max(i, res->get_current_value(), res->get_max_value());
res->set_dirty(false);
}
}
}
@ -6129,6 +6279,11 @@ 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")));
ADD_SIGNAL(MethodInfo("sentity_resource_added", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource")));
ADD_SIGNAL(MethodInfo("sentity_resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource")));
ADD_SIGNAL(MethodInfo("centity_resource_added", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource")));
ADD_SIGNAL(MethodInfo("centity_resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "EntityResource")));
//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")));
@ -6223,6 +6378,9 @@ void Entity::_bind_methods() {
BIND_VMETHOD(MethodInfo("_son_class_level_up", PropertyInfo(Variant::INT, "value")));
BIND_VMETHOD(MethodInfo("_son_character_level_up", 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("_son_target_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "old_target", PROPERTY_HINT_RESOURCE_TYPE, "Entity")));
BIND_VMETHOD(MethodInfo("_con_target_changed", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), PropertyInfo(Variant::OBJECT, "old_target", PROPERTY_HINT_RESOURCE_TYPE, "Entity")));
@ -6255,6 +6413,9 @@ void Entity::_bind_methods() {
ClassDB::bind_method(D_METHOD("son_gcd_started"), &Entity::son_gcd_started);
ClassDB::bind_method(D_METHOD("son_gcd_finished"), &Entity::son_gcd_finished);
ClassDB::bind_method(D_METHOD("son_entity_resource_added", "resource"), &Entity::son_entity_resource_added);
ClassDB::bind_method(D_METHOD("son_entity_resource_removed", "resource"), &Entity::son_entity_resource_removed);
//Talents
ClassDB::bind_method(D_METHOD("gets_free_talent_points"), &Entity::gets_free_talent_points);
@ -6335,6 +6496,9 @@ void Entity::_bind_methods() {
BIND_VMETHOD(MethodInfo("_con_class_level_up", PropertyInfo(Variant::INT, "value")));
BIND_VMETHOD(MethodInfo("_con_character_level_up", 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")));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "value"), "_canc_interact"));
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "value"), "_cans_interact"));
BIND_VMETHOD(MethodInfo("_sinteract"));
@ -6371,6 +6535,9 @@ void Entity::_bind_methods() {
ClassDB::bind_method(D_METHOD("con_class_level_up", "value"), &Entity::con_class_level_up);
ClassDB::bind_method(D_METHOD("con_character_level_up", "value"), &Entity::con_character_level_up);
ClassDB::bind_method(D_METHOD("con_entity_resource_added", "resource"), &Entity::con_entity_resource_added);
ClassDB::bind_method(D_METHOD("con_entity_resource_removed", "resource"), &Entity::con_entity_resource_removed);
//Modifiers/Requesters
ClassDB::bind_method(D_METHOD("sapply_passives_damage_receive", "data"), &Entity::sapply_passives_damage_receive);
ClassDB::bind_method(D_METHOD("sapply_passives_damage_deal", "data"), &Entity::sapply_passives_damage_deal);

View File

@ -499,6 +499,9 @@ public:
void son_class_level_up(int value);
void son_character_level_up(int value);
void son_entity_resource_added(Ref<EntityResource> resource);
void son_entity_resource_removed(Ref<EntityResource> resource);
//Clientside EventHandlers
void con_cast_failed(Ref<SpellCastInfo> info);
void con_cast_started(Ref<SpellCastInfo> info);
@ -526,6 +529,9 @@ public:
void con_class_level_up(int value);
void con_character_level_up(int value);
void con_entity_resource_added(Ref<EntityResource> resource);
void con_entity_resource_removed(Ref<EntityResource> resource);
//Modifiers/Requesters
void sapply_passives_damage_receive(Ref<SpellDamageInfo> info);
void sapply_passives_damage_deal(Ref<SpellDamageInfo> info);

View File

@ -27,56 +27,61 @@ SOFTWARE.
#include "../stats/stat.h"
#include "entity_resource_data.h"
bool EntityResource::get_dirty() {
bool EntityResource::get_dirty() const {
return _dirty;
}
void EntityResource::set_dirty(bool value) {
void EntityResource::set_dirty(const bool value) {
_dirty = value;
}
bool EntityResource::get_should_process() {
bool EntityResource::get_should_process() const {
return _should_process;
}
void EntityResource::set_should_process(bool value) {
void EntityResource::set_should_process(const bool value) {
_should_process = value;
}
Ref<EntityResourceData> EntityResource::get_resource_data() {
return _data;
}
void EntityResource::set_resource_data(Ref<EntityResourceData> value) {
void EntityResource::set_resource_data(const Ref<EntityResourceData> &value) {
_data = value;
if (_data.is_valid())
_data_id = _data->get_id();
else
_data_id = 0;
_dirty = true;
emit_signal("changed", Ref<EntityResource>(this));
}
int EntityResource::get_data_id() {
int EntityResource::get_data_id() const {
return _data_id;
}
void EntityResource::set_data_id(int value) {
void EntityResource::set_data_id(const int value) {
_data_id = value;
}
int EntityResource::get_current_value() {
return _current;
}
void EntityResource::set_current_value(int value) {
_current = value;
_dirty = true;
emit_signal("changed", Ref<EntityResource>(this));
}
int EntityResource::get_max_value() {
int EntityResource::get_current_value() const {
return _current;
}
void EntityResource::set_current_value(const int value) {
_current = value;
_dirty = true;
emit_signal("changed", Ref<EntityResource>(this));
}
int EntityResource::get_max_value() const {
return _max;
}
void EntityResource::set_max_value(int value) {
void EntityResource::set_max_value(const int value) {
_max = value;
_dirty = true;
emit_signal("changed", Ref<EntityResource>(this));
}
@ -131,32 +136,32 @@ void EntityResource::onc_target_changed(Entity *entity, Entity *old_target) {
call("_ons_target_changed", entity, old_target);
}
void EntityResource::process_server(float delta) {
void EntityResource::process_server(const float delta) {
call("_process_server", delta);
}
void EntityResource::_process_server(float delta) {
void EntityResource::_process_server(const float delta) {
}
void EntityResource::process_client(float delta) {
void EntityResource::process_client(const float delta) {
call("_process_client", delta);
}
void EntityResource::_process_client(float delta) {
void EntityResource::_process_client(const float delta) {
}
void EntityResource::receivec_update(int current) {
void EntityResource::receivec_update(const int current) {
_current = current;
}
void EntityResource::receivec_update_full(int current, int max) {
void EntityResource::receivec_update_full(const int current, const int max) {
_current = current;
_max = max;
}
void EntityResource::receivec_update_string(String str) {
void EntityResource::receivec_update_string(const String str) {
if (has_method("_receivec_update_string"))
call("_receivec_update_string", str);
}
void EntityResource::resolve_references() {
_data = EntityDataManager::get_instance()->get_entity_resource(_data_id);
set_resource_data(EntityDataManager::get_instance()->get_entity_resource(_data_id));
}
Dictionary EntityResource::to_dict() {

View File

@ -33,23 +33,23 @@ class EntityResource : public Reference {
GDCLASS(EntityResource, Reference);
public:
bool get_dirty();
void set_dirty(bool value);
bool get_dirty() const;
void set_dirty(const bool value);
bool get_should_process();
void set_should_process(bool value);
bool get_should_process() const;
void set_should_process(const bool value);
Ref<EntityResourceData> get_resource_data();
void set_resource_data(Ref<EntityResourceData> value);
void set_resource_data(const Ref<EntityResourceData> &value);
int get_data_id();
void set_data_id(int value);
int get_data_id() const;
void set_data_id(const int value);
int get_current_value();
void set_current_value(int value);
int get_current_value() const;
void set_current_value(const int value);
int get_max_value();
void set_max_value(int value);
int get_max_value() const;
void set_max_value(const int value);
Entity *get_owner();
void set_owner(Entity *entity);
@ -64,15 +64,15 @@ public:
void ons_target_changed(Entity *entity, Entity *old_target);
void onc_target_changed(Entity *entity, Entity *old_target);
void process_server(float delta);
void _process_server(float delta);
void process_server(const float delta);
void _process_server(const float delta);
void process_client(float delta);
void _process_client(float delta);
void process_client(const float delta);
void _process_client(const float delta);
void receivec_update(int current);
void receivec_update_full(int current, int max);
void receivec_update_string(String str);
void receivec_update(const int current);
void receivec_update_full(const int current, const int max);
void receivec_update_string(const String str);
void resolve_references();