public static void ProcessInboundStream(ulong _uiLatency, CNetworkStream _cStream) { List<INetworkVar> cSyncedNetworkVars = new List<INetworkVar>(); float fSyncedTick = 0.0f; if (CNetwork.IsServer) { fSyncedTick = ((float)RakNet.RakNet.GetTimeMS()) / 1000.0f; fSyncedTick -= Mathf.Floor(fSyncedTick); fSyncedTick *= CNetworkServer.k_fSendRate; } else { fSyncedTick = CNetwork.Connection.Tick - ((float)_uiLatency / 1000.0f); if (fSyncedTick < 0.0f) { fSyncedTick = CNetworkServer.k_fSendRate - fSyncedTick; //Debug.Log(fSyncedTick); } } while (_cStream.HasUnreadData) { // Extract owner network view id CNetworkViewId cNetworkViewId = _cStream.ReadNetworkViewId(); // Extract procedure type EProdecure eProcedure = (EProdecure)_cStream.ReadByte(); // Retrieve network view instance CNetworkView cNetworkView = CNetworkView.FindUsingViewId(cNetworkViewId); // Process network var sync procedure if (eProcedure == EProdecure.SyncNetworkVar) { // Extract network var identifier byte bNetworkVarIdentifier = _cStream.ReadByte(); // Retrieve network var instance INetworkVar cNetworkVar = cNetworkView.m_mNetworkVars[bNetworkVarIdentifier]; // Retrieve network var type Type cVarType = cNetworkVar.GetValueType(); // Extract value serialized object cNewVarValue = _cStream.ReadType(cVarType); // Sync with new value cNetworkVar.SyncValue(cNewVarValue, fSyncedTick); // Add to callback list cSyncedNetworkVars.Add(cNetworkVar); } // Process network rpc procedure else if (eProcedure == EProdecure.InvokeNetworkRpc) { // Extract rpc method identifier byte bMethodIdentifier = _cStream.ReadByte(); // Retrieve method owner instance Component cParentComponent = cNetworkView.m_mNetworkRpcs[bMethodIdentifier].cUnityComponent; // Retrieve method info MethodInfo cMethodInfo = cNetworkView.m_mNetworkRpcs[bMethodIdentifier].cMethodInfo; // Extract method parameters object[] caParameterValues = _cStream.ReadMethodParameters(cMethodInfo); // Invoke the rpc method cMethodInfo.Invoke(cParentComponent, caParameterValues); } } // Invoke callbacks for synced network vars foreach (INetworkVar cSyncedNetworkVar in cSyncedNetworkVars) { cSyncedNetworkVar.InvokeSyncCallback(); } }