void Update() { #if SNS_DEV if (!SimpleSyncSettings.single.enabled) { return; } #endif if (simulationHasRun) { PostSimulate(); } DoubleTime.SnapUpdate(); NormTimeSinceFixed = (Time.time - Time.fixedTime) / Time.fixedDeltaTime; int cnt = onPreUpdates.Count; for (int i = 0; i < cnt; ++i) { onPreUpdates[i].OnPreUpdate(); } float t = (Time.time - lastSentTickTime) / (Time.fixedDeltaTime * sendEveryXTick); cnt = onInterpolates.Count; for (int i = 0; i < cnt; ++i) { onInterpolates[i].OnInterpolate(_prevFrameId, _currFrameId, t); } }
private void FixedUpdate() { #if SNS_DEV if (!SimpleSyncSettings.single.enabled) { return; } #endif /// Halt everything if networking isn't ready. bool readyToSend = NetMsgSends.ReadyToSend; if (!readyToSend) { DoubleTime.SnapFixed(); return; } if (simulationHasRun) { PostSimulate(); } DoubleTime.SnapFixed(); #if PUN_2_OR_NEWER /// Make sure we don't have any incoming messages. PUN checks this pre-Update but not so explicitly at the top of the fixed. /// We want to ensure that we are running our simulation with the most current network input/states so best to make sure we have all that is available. /// Make sure Photon isn't holding out on us just because a FixedUpdate didn't happen this Update() bool doDispatch = true; while (PhotonNetwork.IsMessageQueueRunning && doDispatch) { // DispatchIncomingCommands() returns true of it found any command to dispatch (event, result or state change) doDispatch = PhotonNetwork.NetworkingClient.LoadBalancingPeer.DispatchIncomingCommands(); } rtt = PhotonNetwork.GetPing() * .001f; #endif /// Moved to NetMasterLate //int cnt = onPreSimulates.Count; //for (int i = 0; i < cnt; ++i) // onPreSimulates[i].OnPreSimulate(_currFrameId, _currSubFrameId); simulationHasRun = true; }