Example #1
0
        /// <summary>
        ///DV 帧更新
        ///是在lockstep创建的时候传这个方法给他
        /// </summary>
        void OnStepUpdate(List <InputDataBase> allInputData)
        {
            // 添加当前时间
            time += lockedTimeStep;

            if (ReplayRecord.replayMode != ReplayMode.LOAD_REPLAY)
            {
                // 非录像模式, 检测GameObject CheckGameObjectsSafeMap();
                CheckGameObjectsSafeMap();
            }

            TrueSyncInput.SetAllInputs(null);

            // 遍历generalBehaviours普通行为列表,调行为的OnPreSyncedUpdate()。还会调协程更新instance.scheduler.UpdateAllCoroutines();
            for (int index = 0, length = generalBehaviours.Count; index < length; index++)
            {
                TrueSyncManagedBehaviour bh = generalBehaviours[index];

                if (bh != null && !bh.disabled)
                {
                    bh.OnPreSyncedUpdate();
                    instance.scheduler.UpdateAllCoroutines();
                }
            }

            // 遍历allInputData,和对应玩家的行为列表behaviorsByPlayer。 调行为的OnPreSyncedUpdate()。还会调协程更新instance.scheduler.UpdateAllCoroutines();
            for (int index = 0, length = allInputData.Count; index < length; index++)
            {
                InputDataBase playerInputData = allInputData[index];

                if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
                {
                    List <TrueSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                    for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                    {
                        TrueSyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                        if (bh != null && !bh.disabled)
                        {
                            bh.OnPreSyncedUpdate();
                            instance.scheduler.UpdateAllCoroutines();
                        }
                    }
                }
            }

            TrueSyncInput.SetAllInputs(allInputData);

            TrueSyncInput.CurrentSimulationData = null;
            // 遍历generalBehaviours普通行为列表,调行为的OnSyncedUpdate()。还会调协程更新instance.scheduler.UpdateAllCoroutines();
            for (int index = 0, length = generalBehaviours.Count; index < length; index++)
            {
                TrueSyncManagedBehaviour bh = generalBehaviours[index];

                if (bh != null && !bh.disabled)
                {
                    bh.OnSyncedUpdate();
                    instance.scheduler.UpdateAllCoroutines();
                }
            }

            // 遍历allInputData,和对应玩家的行为列表behaviorsByPlayer。 调行为的OnSyncedUpdate()。还会调协程更新instance.scheduler.UpdateAllCoroutines();
            for (int index = 0, length = allInputData.Count; index < length; index++)
            {
                InputDataBase playerInputData = allInputData[index];

                if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
                {
                    TrueSyncInput.CurrentSimulationData = (InputData)playerInputData;

                    List <TrueSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                    for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                    {
                        TrueSyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                        if (bh != null && !bh.disabled)
                        {
                            bh.OnSyncedUpdate();
                            instance.scheduler.UpdateAllCoroutines();
                        }
                    }
                }

                TrueSyncInput.CurrentSimulationData = null;
            }

            // 检测占存行为列表CheckQueuedBehaviours()。给他们分配拥有者和调同步开始方法
            CheckQueuedBehaviours();
        }
Example #2
0
        void OnStepUpdate(List <InputDataBase> allInputData)
        {
            time += lockedTimeStep;

            if (ReplayRecord.replayMode != ReplayMode.LOAD_REPLAY)
            {
                CheckGameObjectsSafeMap();
            }

            TrueSyncInput.SetAllInputs(null);

            for (int index = 0, length = generalBehaviours.Count; index < length; index++)
            {
                TrueSyncManagedBehaviour bh = generalBehaviours[index];

                if (bh != null && !bh.disabled)
                {
                    bh.OnPreSyncedUpdate();
                    instance.scheduler.UpdateAllCoroutines();
                }
            }

            for (int index = 0, length = allInputData.Count; index < length; index++)
            {
                InputDataBase playerInputData = allInputData[index];

                if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
                {
                    List <TrueSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                    for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                    {
                        TrueSyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                        if (bh != null && !bh.disabled)
                        {
                            bh.OnPreSyncedUpdate();
                            instance.scheduler.UpdateAllCoroutines();
                        }
                    }
                }
            }

            TrueSyncInput.SetAllInputs(allInputData);

            TrueSyncInput.CurrentSimulationData = null;
            for (int index = 0, length = generalBehaviours.Count; index < length; index++)
            {
                TrueSyncManagedBehaviour bh = generalBehaviours[index];

                if (bh != null && !bh.disabled)
                {
                    bh.OnSyncedUpdate();
                    instance.scheduler.UpdateAllCoroutines();
                }
            }

            for (int index = 0, length = allInputData.Count; index < length; index++)
            {
                InputDataBase playerInputData = allInputData[index];

                if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
                {
                    TrueSyncInput.CurrentSimulationData = (InputData)playerInputData;

                    List <TrueSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                    for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                    {
                        TrueSyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                        if (bh != null && !bh.disabled)
                        {
                            bh.OnSyncedUpdate();
                            instance.scheduler.UpdateAllCoroutines();
                        }
                    }
                }

                TrueSyncInput.CurrentSimulationData = null;
            }

            CheckQueuedBehaviours();
        }
        private void OnStepUpdate(List <InputData> i_AllInputData)
        {
            // Sync time.

            if (m_TimeScaler != null)
            {
                m_TimeScaler.Sync();
            }

            // PRE SYNC UPDATE

            // Clear input.

            TrueSyncInput.SetAllInputs(null);

            // Synced pre update on general behaviours.

            for (int index = 0; index < m_GeneralBehaviours.Count; ++index)
            {
                TrueSyncManagedBehaviour tsmb = m_GeneralBehaviours[index];

                if (tsmb == null || tsmb.disabled)
                {
                    continue;
                }

                tsmb.OnPreSyncedUpdate();
            }

            // Synced pre update on player behaviours.

            if (i_AllInputData != null)
            {
                for (int index = 0; index < i_AllInputData.Count; ++index)
                {
                    InputData inputData = i_AllInputData[index];

                    if (inputData == null)
                    {
                        continue;
                    }

                    List <TrueSyncManagedBehaviour> tsmbList = null;
                    if (m_BehavioursPerPlayer.TryGetValue(inputData.ownerID, out tsmbList))
                    {
                        for (int tsmbIndex = 0; tsmbIndex < tsmbList.Count; ++tsmbIndex)
                        {
                            TrueSyncManagedBehaviour tsmb = tsmbList[tsmbIndex];

                            if (tsmb == null || tsmb.disabled)
                            {
                                continue;
                            }

                            tsmb.OnPreSyncedUpdate();
                        }
                    }
                }
            }

            // UPDATE

            // Set input.

            TrueSyncInput.SetAllInputs(i_AllInputData);

            TrueSyncInput.CurrentSimulationData = null;

            // Synced update on general behaviours.

            for (int index = 0; index < m_GeneralBehaviours.Count; ++index)
            {
                TrueSyncManagedBehaviour tsmb = m_GeneralBehaviours[index];

                if (tsmb == null || tsmb.disabled)
                {
                    continue;
                }

                tsmb.OnSyncedUpdate();
            }

            // Synced update on player behaviours.

            if (i_AllInputData != null)
            {
                for (int index = 0; index < i_AllInputData.Count; ++index)
                {
                    InputData inputData = i_AllInputData[index];

                    if (inputData == null)
                    {
                        continue;
                    }

                    List <TrueSyncManagedBehaviour> tsmbList = null;
                    if (m_BehavioursPerPlayer.TryGetValue(inputData.ownerID, out tsmbList))
                    {
                        TrueSyncInput.CurrentSimulationData = inputData;

                        for (int tsmbIndex = 0; tsmbIndex < tsmbList.Count; ++tsmbIndex)
                        {
                            TrueSyncManagedBehaviour tsmb = tsmbList[tsmbIndex];

                            if (tsmb == null || tsmb.disabled)
                            {
                                continue;
                            }

                            tsmb.OnSyncedUpdate();
                        }
                    }
                }

                TrueSyncInput.CurrentSimulationData = null;
            }

            // LATE UPDATE

            // Clear input.

            TrueSyncInput.SetAllInputs(null);

            // Synced late update on general behaviours.

            for (int index = 0; index < m_GeneralBehaviours.Count; ++index)
            {
                TrueSyncManagedBehaviour tsmb = m_GeneralBehaviours[index];

                if (tsmb == null || tsmb.disabled)
                {
                    continue;
                }

                ITrueSyncBehaviour iTsb = tsmb.trueSyncBehavior;
                if (iTsb != null)
                {
                    if (iTsb is TrueSyncBehaviour)
                    {
                        TrueSyncBehaviour tsb = (TrueSyncBehaviour)iTsb;
                        tsb.OnLateSyncedUpdate();
                    }
                }
            }

            // Synced late update on player behaviours.

            if (i_AllInputData != null)
            {
                for (int index = 0; index < i_AllInputData.Count; ++index)
                {
                    InputData inputData = i_AllInputData[index];

                    if (inputData == null)
                    {
                        continue;
                    }

                    List <TrueSyncManagedBehaviour> tsmbList = null;
                    if (m_BehavioursPerPlayer.TryGetValue(inputData.ownerID, out tsmbList))
                    {
                        for (int tsmbIndex = 0; tsmbIndex < tsmbList.Count; ++tsmbIndex)
                        {
                            TrueSyncManagedBehaviour tsmb = tsmbList[tsmbIndex];

                            if (tsmb == null || tsmb.disabled)
                            {
                                continue;
                            }

                            ITrueSyncBehaviour iTsb = tsmb.trueSyncBehavior;
                            if (iTsb != null)
                            {
                                if (iTsb is TrueSyncBehaviour)
                                {
                                    TrueSyncBehaviour tsb = (TrueSyncBehaviour)iTsb;
                                    tsb.OnLateSyncedUpdate();
                                }
                            }
                        }
                    }
                }
            }

            // Process queued behaviours.

            ProcessQueuedBehaviours();
        }