mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-10 21:09:38 +01:00
Moved visibility rpcs (vrpc) from Entity to Node. Also added an unreliable variant.
This commit is contained in:
parent
44948a6f7a
commit
1dc5d84196
@ -961,8 +961,8 @@ void Entity::pet_adds(Entity *entity) {
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(entity));
|
||||
|
||||
//the owner always want to see his pet, and you pet will always want to see the owner
|
||||
sees_adds(entity);
|
||||
entity->sees_adds(this);
|
||||
sees_add(entity);
|
||||
entity->sees_add(this);
|
||||
|
||||
entity->pet_sets_owner(this);
|
||||
|
||||
@ -995,7 +995,7 @@ void Entity::pet_removes_index(int index) {
|
||||
|
||||
_s_pets.remove(index);
|
||||
|
||||
sees_removes(entity);
|
||||
sees_remove(entity);
|
||||
|
||||
for (int i = 0; i < _s_pets.size(); ++i) {
|
||||
Entity *pet = _s_pets.get(index);
|
||||
@ -3316,7 +3316,7 @@ void Entity::aura_removes(Ref<AuraData> aura) {
|
||||
|
||||
if (removed) {
|
||||
notification_saura(SpellEnums::NOTIFICATION_AURA_REMOVED, a);
|
||||
|
||||
|
||||
ERR_FAIL_COND(!aura->get_aura().is_valid());
|
||||
if (!aura->get_aura()->aura_get_hide()) {
|
||||
VRPCOBJ(aura_removec_rpc, JSON::print(aura->to_dict()), aura_removec, aura);
|
||||
@ -5702,176 +5702,6 @@ String Entity::random_name() {
|
||||
|
||||
//Networking
|
||||
|
||||
Entity *Entity::sees_gets(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _s_sees.size(), NULL);
|
||||
|
||||
return _s_sees.get(index);
|
||||
}
|
||||
void Entity::sees_removes_index(int index) {
|
||||
ERR_FAIL_INDEX(index, _s_sees.size());
|
||||
|
||||
Entity *e = _s_sees.get(index);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
_s_sees.remove(index);
|
||||
return;
|
||||
}
|
||||
|
||||
e->seen_by_removes(this);
|
||||
|
||||
_s_sees.remove(index);
|
||||
}
|
||||
void Entity::sees_removes(Entity *entity) {
|
||||
if (unlikely(!ObjectDB::instance_validate(entity))) {
|
||||
_s_sees.erase(entity);
|
||||
return;
|
||||
}
|
||||
|
||||
entity->seen_by_removes(this);
|
||||
|
||||
_s_sees.erase(entity);
|
||||
}
|
||||
void Entity::sees_removes_bind(Node *entity) {
|
||||
Entity *e = Object::cast_to<Entity>(entity);
|
||||
|
||||
ERR_FAIL_COND(!e);
|
||||
|
||||
sees_removes(e);
|
||||
}
|
||||
void Entity::sees_adds(Entity *entity) {
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(entity));
|
||||
|
||||
entity->seen_by_adds(this);
|
||||
|
||||
for (int i = 0; i < _s_sees.size(); ++i) {
|
||||
if (_s_sees.get(i) == entity)
|
||||
return;
|
||||
}
|
||||
|
||||
_s_sees.push_back(entity);
|
||||
}
|
||||
void Entity::sees_adds_bind(Node *entity) {
|
||||
Entity *e = Object::cast_to<Entity>(entity);
|
||||
|
||||
ERR_FAIL_COND(!e);
|
||||
|
||||
sees_adds(e);
|
||||
}
|
||||
int Entity::sees_gets_count() {
|
||||
return _s_sees.size();
|
||||
}
|
||||
|
||||
Entity *Entity::seen_by_gets(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _s_seen_by.size(), NULL);
|
||||
|
||||
return _s_seen_by.get(index);
|
||||
}
|
||||
void Entity::seen_by_removes_index(int index) {
|
||||
ERR_FAIL_INDEX(index, _s_sees.size());
|
||||
|
||||
_s_seen_by.remove(index);
|
||||
}
|
||||
void Entity::seen_by_removes(Entity *entity) {
|
||||
_s_seen_by.erase(entity);
|
||||
}
|
||||
void Entity::seen_by_removes_bind(Node *entity) {
|
||||
Entity *e = Object::cast_to<Entity>(entity);
|
||||
|
||||
ERR_FAIL_COND(!e);
|
||||
|
||||
seen_by_removes(e);
|
||||
}
|
||||
void Entity::seen_by_adds(Entity *entity) {
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(entity));
|
||||
|
||||
for (int i = 0; i < _s_seen_by.size(); ++i) {
|
||||
if (_s_seen_by.get(i) == entity)
|
||||
return;
|
||||
}
|
||||
|
||||
_s_seen_by.push_back(entity);
|
||||
}
|
||||
void Entity::seen_by_adds_bind(Node *entity) {
|
||||
Entity *e = Object::cast_to<Entity>(entity);
|
||||
|
||||
ERR_FAIL_COND(!e);
|
||||
|
||||
seen_by_adds(e);
|
||||
}
|
||||
|
||||
int Entity::seen_by_gets_count() {
|
||||
return _s_seen_by.size();
|
||||
}
|
||||
|
||||
void Entity::vrpc(const StringName &p_method, VARIANT_ARG_DECLARE) {
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
break;
|
||||
argc++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _s_seen_by.size(); ++i) {
|
||||
Entity *e = _s_seen_by.get(i);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
_s_seen_by.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
int netm = e->get_network_master();
|
||||
|
||||
if (netm != 1)
|
||||
rpcp(netm, false, p_method, argptr, argc);
|
||||
}
|
||||
|
||||
if (get_network_master() != 1)
|
||||
rpcp(get_network_master(), false, p_method, argptr, argc);
|
||||
}
|
||||
|
||||
Variant Entity::_vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
|
||||
r_error.argument = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
if (p_args[0]->get_type() != Variant::STRING) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
r_error.argument = 0;
|
||||
r_error.expected = Variant::STRING;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
StringName method = *p_args[0];
|
||||
|
||||
for (int i = 0; i < _s_seen_by.size(); ++i) {
|
||||
Entity *e = _s_seen_by.get(i);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
_s_seen_by.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
int netm = e->get_network_master();
|
||||
|
||||
if (netm != 1)
|
||||
rpcp(netm, false, method, &p_args[1], p_argcount - 1);
|
||||
}
|
||||
|
||||
//call(method, &p_args[1], p_argcount - 1);
|
||||
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
||||
Dictionary Entity::data_as_dict(String &data) {
|
||||
Error err;
|
||||
String err_txt;
|
||||
@ -6230,9 +6060,6 @@ Entity::~Entity() {
|
||||
|
||||
_action_bar_profile.unref();
|
||||
|
||||
_s_sees.clear();
|
||||
_s_seen_by.clear();
|
||||
|
||||
_s_ai.unref();
|
||||
|
||||
_s_pets.clear();
|
||||
@ -6623,14 +6450,6 @@ void Entity::_notification(int p_what) {
|
||||
case NOTIFICATION_PHYSICS_PROCESS: {
|
||||
son_physics_process(get_physics_process_delta_time());
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
for (int i = 0; i < _s_seen_by.size(); ++i) {
|
||||
Entity *e = _s_seen_by.get(i);
|
||||
|
||||
if (ObjectDB::instance_validate(e))
|
||||
e->sees_removes(this);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7839,26 +7658,6 @@ void Entity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_from_dict", "dict"), &Entity::_from_dict);
|
||||
ClassDB::bind_method(D_METHOD("_to_dict"), &Entity::_to_dict);
|
||||
|
||||
//Networking
|
||||
ClassDB::bind_method(D_METHOD("sees_gets", "index"), &Entity::sees_gets);
|
||||
ClassDB::bind_method(D_METHOD("sees_removes_index", "index"), &Entity::sees_removes_index);
|
||||
ClassDB::bind_method(D_METHOD("sees_removes", "entity"), &Entity::sees_removes_bind);
|
||||
ClassDB::bind_method(D_METHOD("sees_adds", "entity"), &Entity::sees_adds_bind);
|
||||
ClassDB::bind_method(D_METHOD("sees_gets_count"), &Entity::sees_gets_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("seen_by_gets", "index"), &Entity::seen_by_gets);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_removes_index", "index"), &Entity::seen_by_removes_index);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_removes", "entity"), &Entity::seen_by_removes_bind);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_adds", "entity"), &Entity::seen_by_adds_bind);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_gets_count"), &Entity::seen_by_gets_count);
|
||||
|
||||
MethodInfo mi;
|
||||
|
||||
mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
|
||||
|
||||
mi.name = "vrpc";
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "vrpc", &Entity::_vrpc_bind, mi);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("register_for_physics_process", "info"), &Entity::register_for_physics_process);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_maunal_process"), &Entity::get_maunal_process);
|
||||
|
@ -1060,25 +1060,6 @@ public:
|
||||
virtual void _from_dict(const Dictionary &dict);
|
||||
|
||||
// Networking
|
||||
Entity *sees_gets(int index);
|
||||
void sees_removes_index(int index);
|
||||
void sees_removes(Entity *entity);
|
||||
void sees_removes_bind(Node *entity);
|
||||
void sees_adds(Entity *entity);
|
||||
void sees_adds_bind(Node *entity);
|
||||
int sees_gets_count();
|
||||
|
||||
Entity *seen_by_gets(int index);
|
||||
void seen_by_removes_index(int index);
|
||||
void seen_by_removes(Entity *entity);
|
||||
void seen_by_removes_bind(Node *entity);
|
||||
void seen_by_adds(Entity *entity);
|
||||
void seen_by_adds_bind(Node *entity);
|
||||
int seen_by_gets_count();
|
||||
|
||||
void vrpc(const StringName &p_method, VARIANT_ARG_LIST);
|
||||
Variant _vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
|
||||
Dictionary data_as_dict(String &data);
|
||||
|
||||
void register_for_physics_process(Ref<SpellCastInfo> info);
|
||||
@ -1326,11 +1307,6 @@ private:
|
||||
Vector<Entity *> _s_pets;
|
||||
Vector<Entity *> _c_pets;
|
||||
|
||||
// Networking
|
||||
|
||||
Vector<Entity *> _s_sees;
|
||||
Vector<Entity *> _s_seen_by;
|
||||
|
||||
// Callbacks
|
||||
|
||||
Vector<Ref<SpellCastInfo>> _physics_process_scis;
|
||||
|
@ -113,6 +113,17 @@ void Node::_notification(int p_notification) {
|
||||
get_tree()->node_count--;
|
||||
orphan_node_count++;
|
||||
|
||||
for (int i = 0; i < data._seen_by.size(); ++i) {
|
||||
Node *n = data._seen_by.get(i);
|
||||
|
||||
if (ObjectDB::instance_validate(n)) {
|
||||
n->sees_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
data._seen_by.clear();
|
||||
data._sees.clear();
|
||||
|
||||
if (data.input) {
|
||||
remove_from_group("_vp_input" + itos(get_viewport()->get_instance_id()));
|
||||
}
|
||||
@ -557,6 +568,78 @@ void Node::_propagate_groups_dirty() {
|
||||
}
|
||||
}
|
||||
|
||||
Node *Node::sees_get(int p_index) {
|
||||
ERR_FAIL_INDEX_V(p_index, data._sees.size(), NULL);
|
||||
|
||||
return data._sees.get(p_index);
|
||||
}
|
||||
void Node::sees_remove_index(int p_index) {
|
||||
ERR_FAIL_INDEX(p_index, data._sees.size());
|
||||
|
||||
Node *e = data._sees.get(p_index);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
data._sees.remove(p_index);
|
||||
return;
|
||||
}
|
||||
|
||||
e->seen_by_remove(this);
|
||||
|
||||
data._sees.remove(p_index);
|
||||
}
|
||||
void Node::sees_remove(Node *p_node) {
|
||||
if (unlikely(!ObjectDB::instance_validate(p_node))) {
|
||||
data._sees.erase(p_node);
|
||||
return;
|
||||
}
|
||||
|
||||
p_node->seen_by_remove(this);
|
||||
|
||||
data._sees.erase(p_node);
|
||||
}
|
||||
void Node::sees_add(Node *p_node) {
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(p_node));
|
||||
|
||||
p_node->seen_by_add(this);
|
||||
|
||||
for (int i = 0; i < data._sees.size(); ++i) {
|
||||
if (data._sees.get(i) == p_node)
|
||||
return;
|
||||
}
|
||||
|
||||
data._sees.push_back(p_node);
|
||||
}
|
||||
int Node::sees_get_count() {
|
||||
return data._sees.size();
|
||||
}
|
||||
|
||||
Node *Node::seen_by_get(int p_index) {
|
||||
ERR_FAIL_INDEX_V(p_index, data._seen_by.size(), NULL);
|
||||
|
||||
return data._seen_by.get(p_index);
|
||||
}
|
||||
void Node::seen_by_remove_index(int p_index) {
|
||||
ERR_FAIL_INDEX(p_index, data._sees.size());
|
||||
|
||||
data._seen_by.remove(p_index);
|
||||
}
|
||||
void Node::seen_by_remove(Node *p_node) {
|
||||
data._seen_by.erase(p_node);
|
||||
}
|
||||
void Node::seen_by_add(Node *p_node) {
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(p_node));
|
||||
|
||||
for (int i = 0; i < data._seen_by.size(); ++i) {
|
||||
if (data._seen_by.get(i) == p_node)
|
||||
return;
|
||||
}
|
||||
|
||||
data._seen_by.push_back(p_node);
|
||||
}
|
||||
int Node::seen_by_get_count() {
|
||||
return data._seen_by.size();
|
||||
}
|
||||
|
||||
void Node::set_network_master(int p_peer_id, bool p_recursive) {
|
||||
data.network_master = p_peer_id;
|
||||
|
||||
@ -645,6 +728,68 @@ void Node::rpc_unreliable_id(int p_peer_id, const StringName &p_method, VARIANT_
|
||||
rpcp(p_peer_id, true, p_method, argptr, argc);
|
||||
}
|
||||
|
||||
void Node::vrpc(const StringName &p_method, VARIANT_ARG_DECLARE) {
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
break;
|
||||
argc++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < data._seen_by.size(); ++i) {
|
||||
Node *e = data._seen_by.get(i);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
data._seen_by.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
int netm = e->get_network_master();
|
||||
|
||||
if (netm != 1) {
|
||||
rpcp(netm, false, p_method, argptr, argc);
|
||||
}
|
||||
}
|
||||
|
||||
if (get_network_master() != 1) {
|
||||
rpcp(get_network_master(), false, p_method, argptr, argc);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::vrpc_unreliable(const StringName &p_method, VARIANT_ARG_DECLARE) {
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
break;
|
||||
argc++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < data._seen_by.size(); ++i) {
|
||||
Node *e = data._seen_by.get(i);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
data._seen_by.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
int netm = e->get_network_master();
|
||||
|
||||
if (netm != 1) {
|
||||
rpcp(netm, true, p_method, argptr, argc);
|
||||
}
|
||||
}
|
||||
|
||||
if (get_network_master() != 1) {
|
||||
rpcp(get_network_master(), true, p_method, argptr, argc);
|
||||
}
|
||||
}
|
||||
|
||||
Variant Node::_rpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
@ -749,6 +894,88 @@ Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Va
|
||||
return Variant();
|
||||
}
|
||||
|
||||
Variant Node::_vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
|
||||
r_error.argument = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
if (p_args[0]->get_type() != Variant::STRING) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
r_error.argument = 0;
|
||||
r_error.expected = Variant::STRING;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
StringName method = *p_args[0];
|
||||
|
||||
for (int i = 0; i < data._seen_by.size(); ++i) {
|
||||
Node *e = data._seen_by.get(i);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
data._seen_by.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
int netm = e->get_network_master();
|
||||
|
||||
if (netm != 1) {
|
||||
rpcp(netm, false, method, &p_args[1], p_argcount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
//call(method, &p_args[1], p_argcount - 1);
|
||||
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
||||
Variant Node::_vrpc_unreliable_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
|
||||
r_error.argument = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
if (p_args[0]->get_type() != Variant::STRING) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
r_error.argument = 0;
|
||||
r_error.expected = Variant::STRING;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
StringName method = *p_args[0];
|
||||
|
||||
for (int i = 0; i < data._seen_by.size(); ++i) {
|
||||
Node *e = data._seen_by.get(i);
|
||||
|
||||
if (unlikely(!ObjectDB::instance_validate(e))) {
|
||||
data._seen_by.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
int netm = e->get_network_master();
|
||||
|
||||
if (netm != 1) {
|
||||
rpcp(netm, true, method, &p_args[1], p_argcount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
//call(method, &p_args[1], p_argcount - 1);
|
||||
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
||||
void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
|
||||
ERR_FAIL_COND(!is_inside_tree());
|
||||
get_multiplayer()->rpcp(this, p_peer_id, p_unreliable, p_method, p_arg, p_argcount);
|
||||
@ -3062,6 +3289,18 @@ void Node::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_set_property_pinned", "property", "pinned"), &Node::set_property_pinned);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("sees_get", "index"), &Node::sees_get);
|
||||
ClassDB::bind_method(D_METHOD("sees_remove_index", "index"), &Node::sees_remove_index);
|
||||
ClassDB::bind_method(D_METHOD("sees_remove", "entity"), &Node::sees_remove);
|
||||
ClassDB::bind_method(D_METHOD("sees_add", "entity"), &Node::sees_add);
|
||||
ClassDB::bind_method(D_METHOD("sees_get_count"), &Node::sees_get_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("seen_by_get", "index"), &Node::seen_by_get);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_remove_index", "index"), &Node::seen_by_remove_index);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_remove", "entity"), &Node::seen_by_remove);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_add", "entity"), &Node::seen_by_add);
|
||||
ClassDB::bind_method(D_METHOD("seen_by_get_count"), &Node::seen_by_get_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_unique_name_in_owner", "enable"), &Node::set_unique_name_in_owner);
|
||||
ClassDB::bind_method(D_METHOD("is_unique_name_in_owner"), &Node::is_unique_name_in_owner);
|
||||
|
||||
@ -3074,6 +3313,10 @@ void Node::_bind_methods() {
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "rpc", &Node::_rpc_bind, mi);
|
||||
mi.name = "rpc_unreliable";
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "rpc_unreliable", &Node::_rpc_unreliable_bind, mi);
|
||||
mi.name = "vrpc";
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "vrpc", &Node::_vrpc_bind, mi);
|
||||
mi.name = "vrpc_unreliable";
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "vrpc_unreliable", &Node::_vrpc_bind, mi);
|
||||
|
||||
mi.arguments.push_front(PropertyInfo(Variant::INT, "peer_id"));
|
||||
|
||||
@ -3229,6 +3472,9 @@ Node::~Node() {
|
||||
data.owned.clear();
|
||||
data.children.clear();
|
||||
|
||||
data._sees.clear();
|
||||
data._seen_by.clear();
|
||||
|
||||
ERR_FAIL_COND(data.parent);
|
||||
ERR_FAIL_COND(data.children.size());
|
||||
|
||||
|
@ -118,8 +118,12 @@ private:
|
||||
|
||||
Node *pause_owner;
|
||||
|
||||
// Networking
|
||||
int network_master;
|
||||
Map<StringName, MultiplayerAPI::RPCMode> rpc_methods;
|
||||
//Used by vrpc
|
||||
Vector<Node *> _sees;
|
||||
Vector<Node *> _seen_by;
|
||||
|
||||
int process_priority;
|
||||
|
||||
@ -210,6 +214,8 @@ private:
|
||||
Variant _rpc_unreliable_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
Variant _rpc_id_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
Variant _rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
Variant _vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
Variant _vrpc_unreliable_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
|
||||
friend class SceneTree;
|
||||
|
||||
@ -504,8 +510,21 @@ public:
|
||||
|
||||
void set_display_folded(bool p_folded);
|
||||
bool is_displayed_folded() const;
|
||||
|
||||
/* NETWORK */
|
||||
|
||||
Node *sees_get(int p_index);
|
||||
void sees_remove_index(int p_index);
|
||||
void sees_remove(Node *p_node);
|
||||
void sees_add(Node *p_node);
|
||||
int sees_get_count();
|
||||
|
||||
Node *seen_by_get(int p_index);
|
||||
void seen_by_remove_index(int p_index);
|
||||
void seen_by_remove(Node *p_node);
|
||||
void seen_by_add(Node *p_node);
|
||||
int seen_by_get_count();
|
||||
|
||||
void set_network_master(int p_peer_id, bool p_recursive = true);
|
||||
int get_network_master() const;
|
||||
bool is_network_master() const;
|
||||
@ -516,6 +535,8 @@ public:
|
||||
void rpc_unreliable(const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
||||
void rpc_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
||||
void rpc_unreliable_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
||||
void vrpc(const StringName &p_method, VARIANT_ARG_LIST); //visibility rpc. Useful for implementing fog of war
|
||||
void vrpc_unreliable(const StringName &p_method, VARIANT_ARG_LIST);
|
||||
|
||||
void rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user