Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ internal void SyncVarUpdate()
FieldTypeHelper.WriteFieldType(writer, syncedVarFields[i].FieldInfo.GetValue(this), syncedVarFields[i].FieldValue);
syncedVarFields[i].FieldValue = FieldTypeHelper.GetReferenceArrayValue(syncedVarFields[i].FieldInfo.GetValue(this), syncedVarFields[i].FieldValue);
syncedVarFields[i].Dirty = false;
InvokeSyncvarMethodOnServer(syncedVarFields[i].HookMethod);
}
}
List<uint> stillDirtyIds = InternalMessageHandler.Send("MLAPI_SYNC_VAR_UPDATE", "MLAPI_INTERNAL", writer, networkId);
Expand Down Expand Up @@ -628,6 +629,7 @@ internal void SyncVarUpdate()
//Only targeted SyncedVars were changed. Thus we need to set them as non dirty here since it wont be done by the next loop.
syncedVarFields[i].FieldValue = FieldTypeHelper.GetReferenceArrayValue(syncedVarFields[i].FieldInfo.GetValue(this), syncedVarFields[i].FieldValue);
syncedVarFields[i].Dirty = false;
InvokeSyncvarMethodOnServer(syncedVarFields[i].HookMethod);
}
}
}
Expand Down Expand Up @@ -658,6 +660,7 @@ internal void SyncVarUpdate()
FieldTypeHelper.WriteFieldType(writer, syncedVarFields[i].FieldInfo.GetValue(this), syncedVarFields[i].FieldValue);
syncedVarFields[i].FieldValue = FieldTypeHelper.GetReferenceArrayValue(syncedVarFields[i].FieldInfo.GetValue(this), syncedVarFields[i].FieldValue);
syncedVarFields[i].Dirty = false;
InvokeSyncvarMethodOnServer(syncedVarFields[i].HookMethod);
}
}
List<uint> stillDirtyIds = InternalMessageHandler.Send("MLAPI_SYNC_VAR_UPDATE", "MLAPI_INTERNAL", writer, ownerClientId, networkId, null, null); // Send to everyone except target.
Expand All @@ -670,6 +673,12 @@ internal void SyncVarUpdate()
}
}

private void InvokeSyncvarMethodOnServer(MethodInfo hookMethod)
{
if (isServer && hookMethod != null)
hookMethod.Invoke(this, null);
}

private bool SetDirtyness()
{
if (!isServer)
Expand Down