From ddee5f605018c77e92378b525bd23ba32fb1263a Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sat, 9 Jul 2022 20:45:30 +0200 Subject: Add peer visibility to MultiplayerSynchronizer. MultiplayerSynchronizers can now be configured to limit their visibility to a subset of the connected peers, if the synchronized node was spawned by a MultiplayerSpawner (either automatically or via custom spawn) the given node will also be despawned remotely. The replication system doesn't have the logic to handle subspawn directly, but it is possible to handle them appropriately by manually updating the visibility of the parent before changing the one of the nested spawns via the "update_visibility" function. The visibility of each MultiplayerSynchronizer can be controlled by adding or remove filters via "[add|remove]_visibility_filter(callable)". To further optimize the network code, visibility filters can be configured to be automatically updated during idle or physics frame, or set to always require manual update (via the "update_visibility" function). --- core/multiplayer/multiplayer_api.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/multiplayer/multiplayer_api.h') diff --git a/core/multiplayer/multiplayer_api.h b/core/multiplayer/multiplayer_api.h index cc7743ccf8..35452acb1f 100644 --- a/core/multiplayer/multiplayer_api.h +++ b/core/multiplayer/multiplayer_api.h @@ -77,7 +77,8 @@ public: virtual void process_confirm_path(int p_from, const uint8_t *p_packet, int p_packet_len) {} // Returns true if all peers have cached path. - virtual bool send_object_cache(Object *p_obj, NodePath p_path, int p_target, int &p_id) { return false; } + virtual bool send_object_cache(Object *p_obj, int p_target, int &r_id) { return false; } + virtual int make_object_cache(Object *p_obj) { return false; } virtual Object *get_cached_object(int p_from, uint32_t p_cache_id) { return nullptr; } virtual bool is_cache_confirmed(NodePath p_path, int p_peer) { return false; } @@ -160,7 +161,8 @@ public: Error replication_start(Object *p_object, Variant p_config); Error replication_stop(Object *p_object, Variant p_config); // Cache API - bool send_object_cache(Object *p_obj, NodePath p_path, int p_target, int &p_id); + bool send_object_cache(Object *p_obj, int p_target, int &r_id); + int make_object_cache(Object *p_obj); Object *get_cached_object(int p_from, uint32_t p_cache_id); bool is_cache_confirmed(NodePath p_path, int p_peer); -- cgit v1.2.3