Skip to content

Commit b6dc799

Browse files
committed
[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).
1 parent 0f7625a commit b6dc799

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/multiplayer/multiplayer_synchronizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Error MultiplayerSynchronizer::get_state(const List<NodePath> &p_properties, Obj
157157
bool valid = false;
158158
const Object *obj = _get_prop_target(p_obj, prop);
159159
ERR_FAIL_COND_V(!obj, FAILED);
160-
r_variant.write[i] = obj->get(prop.get_concatenated_subnames(), &valid);
160+
r_variant.write[i] = obj->get_indexed(prop.get_subnames(), &valid);
161161
r_variant_ptrs.write[i] = &r_variant[i];
162162
ERR_FAIL_COND_V_MSG(!valid, ERR_INVALID_DATA, vformat("Property '%s' not found.", prop));
163163
i++;
@@ -171,7 +171,7 @@ Error MultiplayerSynchronizer::set_state(const List<NodePath> &p_properties, Obj
171171
for (const NodePath &prop : p_properties) {
172172
Object *obj = _get_prop_target(p_obj, prop);
173173
ERR_FAIL_COND_V(!obj, FAILED);
174-
obj->set(prop.get_concatenated_subnames(), p_state[i]);
174+
obj->set_indexed(prop.get_subnames(), p_state[i]);
175175
i += 1;
176176
}
177177
return OK;

0 commit comments

Comments
 (0)