summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-07-14 20:37:26 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-07-14 20:50:55 +0200
commitb6dc799e6412854d5a35f907a740ee155ef1bdc2 (patch)
treef887ae6064a6c81cc3073bc9c2500b161ac8753a
parent0f7625ab46a64b3f5da2b09969ebabf38df9a6e9 (diff)
downloadredot-engine-b6dc799e6412854d5a35f907a740ee155ef1bdc2.tar.gz
[MP] Use get/set indexed in MultiplayerSynchronizer
Allows synchronizing (sub-)resource properties, transform components, etc. by using subnames. As an example, `.:transform.x` will only synchronize the `x` component of the root transform instead of the whole transform. This can also be used to synchronize a resource own properties, as long as they are synchronizable (i.e. the property itself is not an Object, RID, or Callable).
-rw-r--r--modules/multiplayer/multiplayer_synchronizer.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/multiplayer/multiplayer_synchronizer.cpp b/modules/multiplayer/multiplayer_synchronizer.cpp
index e5207fdae2..9c2d281f72 100644
--- a/modules/multiplayer/multiplayer_synchronizer.cpp
+++ b/modules/multiplayer/multiplayer_synchronizer.cpp
@@ -157,7 +157,7 @@ Error MultiplayerSynchronizer::get_state(const List<NodePath> &p_properties, Obj
bool valid = false;
const Object *obj = _get_prop_target(p_obj, prop);
ERR_FAIL_COND_V(!obj, FAILED);
- r_variant.write[i] = obj->get(prop.get_concatenated_subnames(), &valid);
+ r_variant.write[i] = obj->get_indexed(prop.get_subnames(), &valid);
r_variant_ptrs.write[i] = &r_variant[i];
ERR_FAIL_COND_V_MSG(!valid, ERR_INVALID_DATA, vformat("Property '%s' not found.", prop));
i++;
@@ -171,7 +171,7 @@ Error MultiplayerSynchronizer::set_state(const List<NodePath> &p_properties, Obj
for (const NodePath &prop : p_properties) {
Object *obj = _get_prop_target(p_obj, prop);
ERR_FAIL_COND_V(!obj, FAILED);
- obj->set(prop.get_concatenated_subnames(), p_state[i]);
+ obj->set_indexed(prop.get_subnames(), p_state[i]);
i += 1;
}
return OK;