Add NetworkReplicationNode::SetObject to customize object replication settings at runtime

This commit is contained in:
Wojtek Figat
2024-09-29 22:08:31 +02:00
parent 5f19538455
commit 5f7075d2f7
2 changed files with 18 additions and 0 deletions

View File

@@ -74,6 +74,17 @@ bool NetworkReplicationNode::GetObject(ScriptingObject* obj, NetworkReplicationH
return false; return false;
} }
bool NetworkReplicationNode::SetObject(const NetworkReplicationHierarchyObject& value)
{
const int32 index = Objects.Find(value.Object);
if (index != -1)
{
Objects[index] = value;
return true;
}
return false;
}
bool NetworkReplicationNode::DirtyObject(ScriptingObject* obj) bool NetworkReplicationNode::DirtyObject(ScriptingObject* obj)
{ {
const int32 index = Objects.Find(obj); const int32 index = Objects.Find(obj);

View File

@@ -208,6 +208,13 @@ API_CLASS(Abstract, Namespace = "FlaxEngine.Networking") class FLAXENGINE_API Ne
/// <returns>True on successful retrieval, otherwise false.</returns> /// <returns>True on successful retrieval, otherwise false.</returns>
API_FUNCTION() virtual bool GetObject(ScriptingObject* obj, NetworkReplicationHierarchyObject& result); API_FUNCTION() virtual bool GetObject(ScriptingObject* obj, NetworkReplicationHierarchyObject& result);
/// <summary>
/// Sets object properties in the hierarchy. Can be used to modify replication settings at runtime.
/// </summary>
/// <param name="value">The object data to update.</param>
/// <returns>True on successful update, otherwise false (eg, if specific object has not been added to this node).</returns>
API_FUNCTION() virtual bool SetObject(const NetworkReplicationHierarchyObject& value);
/// <summary> /// <summary>
/// Force replicates the object during the next update. Resets any internal tracking state to force the synchronization. /// Force replicates the object during the next update. Resets any internal tracking state to force the synchronization.
/// </summary> /// </summary>