Пример #1
0
        internal static void RegisterLoopSystems()
        {
            var rootPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();

            for (int i = 0; i < rootPlayerLoop.subSystemList.Length; i++)
            {
                ref var currentSystem = ref rootPlayerLoop.subSystemList[i];

                if (currentSystem.type == typeof(Initialization))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkInitialization.CreateLoopSystem(), null, LoopSystemPosition.After);
                }
                else if (currentSystem.type == typeof(EarlyUpdate))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkEarlyUpdate.CreateLoopSystem(), typeof(EarlyUpdate.ScriptRunDelayedStartupFrame), LoopSystemPosition.Before);
                }
                else if (currentSystem.type == typeof(FixedUpdate))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkFixedUpdate.CreateLoopSystem(), typeof(FixedUpdate.ScriptRunBehaviourFixedUpdate), LoopSystemPosition.Before);
                }
                else if (currentSystem.type == typeof(PreUpdate))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkPreUpdate.CreateLoopSystem(), typeof(PreUpdate.PhysicsUpdate), LoopSystemPosition.Before);
                }
                else if (currentSystem.type == typeof(Update))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkUpdate.CreateLoopSystem(), typeof(Update.ScriptRunBehaviourUpdate), LoopSystemPosition.Before);
                }
                else if (currentSystem.type == typeof(PreLateUpdate))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkPreLateUpdate.CreateLoopSystem(), typeof(PreLateUpdate.ScriptRunBehaviourLateUpdate), LoopSystemPosition.Before);
                }
                else if (currentSystem.type == typeof(PostLateUpdate))
                {
                    TryAddLoopSystem(ref currentSystem, NetworkPostLateUpdate.CreateLoopSystem(), typeof(PostLateUpdate.PlayerSendFrameComplete), LoopSystemPosition.After);
                }
            }
Пример #2
0
        private static void Initialize()
        {
            var customPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();

            for (int i = 0; i < customPlayerLoop.subSystemList.Length; i++)
            {
                var playerLoopSystem = customPlayerLoop.subSystemList[i];

                if (playerLoopSystem.type == typeof(Initialization))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        // insert at the bottom of `Initialization`
                        subsystems.Add(NetworkInitialization.CreateLoopSystem());
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }
                else if (playerLoopSystem.type == typeof(EarlyUpdate))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        int subsystemCount = subsystems.Count;
                        for (int k = 0; k < subsystemCount; k++)
                        {
                            if (subsystems[k].type == typeof(EarlyUpdate.ScriptRunDelayedStartupFrame))
                            {
                                // insert before `EarlyUpdate.ScriptRunDelayedStartupFrame`
                                subsystems.Insert(k, NetworkEarlyUpdate.CreateLoopSystem());
                                break;
                            }
                        }
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }
                else if (playerLoopSystem.type == typeof(FixedUpdate))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        int subsystemCount = subsystems.Count;
                        for (int k = 0; k < subsystemCount; k++)
                        {
                            if (subsystems[k].type == typeof(FixedUpdate.ScriptRunBehaviourFixedUpdate))
                            {
                                // insert before `FixedUpdate.ScriptRunBehaviourFixedUpdate`
                                subsystems.Insert(k, NetworkFixedUpdate.CreateLoopSystem());
                                break;
                            }
                        }
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }
                else if (playerLoopSystem.type == typeof(PreUpdate))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        int subsystemCount = subsystems.Count;
                        for (int k = 0; k < subsystemCount; k++)
                        {
                            if (subsystems[k].type == typeof(PreUpdate.PhysicsUpdate))
                            {
                                // insert before `PreUpdate.PhysicsUpdate`
                                subsystems.Insert(k, NetworkPreUpdate.CreateLoopSystem());
                                break;
                            }
                        }
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }
                else if (playerLoopSystem.type == typeof(Update))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        int subsystemCount = subsystems.Count;
                        for (int k = 0; k < subsystemCount; k++)
                        {
                            if (subsystems[k].type == typeof(Update.ScriptRunBehaviourUpdate))
                            {
                                // insert before `Update.ScriptRunBehaviourUpdate`
                                subsystems.Insert(k, NetworkUpdate.CreateLoopSystem());
                                break;
                            }
                        }
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }
                else if (playerLoopSystem.type == typeof(PreLateUpdate))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        int subsystemCount = subsystems.Count;
                        for (int k = 0; k < subsystemCount; k++)
                        {
                            if (subsystems[k].type == typeof(PreLateUpdate.ScriptRunBehaviourLateUpdate))
                            {
                                // insert before `PreLateUpdate.ScriptRunBehaviourLateUpdate`
                                subsystems.Insert(k, NetworkPreLateUpdate.CreateLoopSystem());
                                break;
                            }
                        }
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }
                else if (playerLoopSystem.type == typeof(PostLateUpdate))
                {
                    var subsystems = playerLoopSystem.subSystemList.ToList();
                    {
                        int subsystemCount = subsystems.Count;
                        for (int k = 0; k < subsystemCount; k++)
                        {
                            if (subsystems[k].type == typeof(PostLateUpdate.PlayerSendFrameComplete))
                            {
                                // insert after `PostLateUpdate.PlayerSendFrameComplete`
                                subsystems.Insert(k + 1, NetworkPostLateUpdate.CreateLoopSystem());
                                break;
                            }
                        }
                    }
                    playerLoopSystem.subSystemList = subsystems.ToArray();
                }

                customPlayerLoop.subSystemList[i] = playerLoopSystem;
            }

            PlayerLoop.SetPlayerLoop(customPlayerLoop);
        }