public void CreateTrackRings(GameObject go)
        {
            rotationSpawners       = new List <TrackLaneRingsRotationEffectSpawner>();
            stepSpawners           = new List <TrackLaneRingsPositionStepEffectSpawner>();
            trackLaneRingsManagers = new List <TrackLaneRingsManager>();
            trackRingsDescriptors  = new List <TrackRings>();

            TrackRings[] ringsDescriptors = go.GetComponentsInChildren <TrackRings>();
            foreach (TrackRings trackRingDesc in ringsDescriptors)
            {
                trackRingsDescriptors.Add(trackRingDesc);

                TrackLaneRingsManager ringsManager =
                    trackRingDesc.gameObject.AddComponent <TrackLaneRingsManager>();
                trackLaneRingsManagers.Add(ringsManager);
                PlatformManager.SpawnedComponents.Add(ringsManager);
                TrackLaneRing ring = trackRingDesc.trackLaneRingPrefab.AddComponent <TrackLaneRing>();
                PlatformManager.SpawnedComponents.Add(ring);

                ReflectionUtil.SetPrivateField(ringsManager, "_trackLaneRingPrefab", ring);
                ReflectionUtil.SetPrivateField(ringsManager, "_ringCount", trackRingDesc.ringCount);
                ReflectionUtil.SetPrivateField(ringsManager, "_ringPositionStep", trackRingDesc.ringPositionStep);
                if (trackRingDesc.useRotationEffect)
                {
                    TrackLaneRingsRotationEffect rotationEffect =
                        trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffect>();
                    PlatformManager.SpawnedComponents.Add(rotationEffect);

                    ReflectionUtil.SetPrivateField(rotationEffect, "_trackLaneRingsManager", ringsManager);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationAngle", trackRingDesc.startupRotationAngle);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationStep", trackRingDesc.startupRotationStep);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationPropagationSpeed", (int)Math.Round(trackRingDesc.startupRotationPropagationSpeed));
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationFlexySpeed", trackRingDesc.startupRotationFlexySpeed);

                    TrackLaneRingsRotationEffectSpawner rotationEffectSpawner =
                        trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffectSpawner>();
                    rotationSpawners.Add(rotationEffectSpawner);
                    PlatformManager.SpawnedComponents.Add(rotationEffectSpawner);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapObjectCallbackController", Plugin.bocc);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.rotationSongEventType);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationStep", trackRingDesc.rotationStep);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationPropagationSpeed", (int)Math.Round(trackRingDesc.rotationPropagationSpeed));
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationFlexySpeed", trackRingDesc.rotationFlexySpeed);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_trackLaneRingsRotationEffect", rotationEffect);
                }
                if (trackRingDesc.useStepEffect)
                {
                    TrackLaneRingsPositionStepEffectSpawner stepEffectSpawner =
                        trackRingDesc.gameObject.AddComponent <TrackLaneRingsPositionStepEffectSpawner>();
                    stepSpawners.Add(stepEffectSpawner);
                    PlatformManager.SpawnedComponents.Add(stepEffectSpawner);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapObjectCallbackController", Plugin.bocc);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_trackLaneRingsManager", ringsManager);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.stepSongEventType);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_minPositionStep", trackRingDesc.minPositionStep);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_maxPositionStep", trackRingDesc.maxPositionStep);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_moveSpeed", trackRingDesc.moveSpeed);
                }
            }
        }
示例#2
0
        internal static void PostfillComponentsData(Transform root, Transform original, List <IComponentData> componentDatas)
        {
            SkipAwake = false;

            TrackLaneRingsManager trackLaneRingsManager = root.GetComponent <TrackLaneRingsManager>();

            if (trackLaneRingsManager != null)
            {
                TrackLaneRingsManager originalManager = original.GetComponent <TrackLaneRingsManager>();
                foreach (TrackLaneRingsManagerComponentData componentData in componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == originalManager))
                {
                    componentData.NewTrackLaneRingsManager = trackLaneRingsManager;
                }
            }

            TrackLaneRingsRotationEffect rotationEffect = root.GetComponent <TrackLaneRingsRotationEffect>();

            if (rotationEffect != null)
            {
                UnityEngine.Object.Destroy(rotationEffect);
            }

            foreach (Transform transform in root)
            {
                int index = transform.GetSiblingIndex();
                PostfillComponentsData(transform, original.GetChild(index), componentDatas);
            }
        }
示例#3
0
        internal static void PrefillComponentsData(Transform root, List <IComponentData> componentDatas)
        {
            SkipAwake = true;

            TrackLaneRingsManager trackLaneRingsManager = root.GetComponent <TrackLaneRingsManager>();

            if (trackLaneRingsManager != null)
            {
                componentDatas.Add(new TrackLaneRingsManagerComponentData()
                {
                    OldTrackLaneRingsManager = trackLaneRingsManager,
                });
            }

            foreach (Transform transform in root)
            {
                PrefillComponentsData(transform, componentDatas);
            }
        }
        public static RingRotationEffectController Create(TrackLaneRingsRotationEffectSpawner baseEffect)
        {
            BeatmapEventType eventTypeForThisEffect = Helper.GetValue <BeatmapEventType>(baseEffect, "_beatmapEventType");
            RotationStepType stepType = Helper.GetValue <RotationStepType>(baseEffect, "_rotationStepType");
            float            stepMax  = Helper.GetValue <float>(baseEffect, "_rotationStep");
            float            rotation = Helper.GetValue <float>(baseEffect, "_rotation");
            int   propagationSpeed    = Helper.GetValue <int>(baseEffect, "_rotationPropagationSpeed");
            float flexySpeed          = Helper.GetValue <float>(baseEffect, "_rotationFlexySpeed");

            TrackLaneRingsRotationEffect rotationEffect = Helper.GetValue <TrackLaneRingsRotationEffect>(baseEffect, "_trackLaneRingsRotationEffect");

            TrackLaneRingsManager manager = Helper.GetValue <TrackLaneRingsManager>(rotationEffect, "_trackLaneRingsManager");

            float startupAngle            = Helper.GetValue <float>(rotationEffect, "_startupRotationAngle");
            float startupStep             = Helper.GetValue <float>(rotationEffect, "_startupRotationStep");
            int   startupPropagationSpeed = Helper.GetValue <int>(rotationEffect, "_startupRotationPropagationSpeed");
            float startupFlexySpeed       = Helper.GetValue <float>(rotationEffect, "_startupRotationFlexySpeed");

            RotationEffect startupRotationEffect = new RotationEffect
            {
                progress         = 0,
                angle            = startupAngle,
                step             = startupStep,
                propagationSpeed = startupPropagationSpeed,
                flexySpeed       = startupFlexySpeed
            };

            RingRotationEffectController controller = new GameObject("TwitchFXRingRotationController").AddComponent <RingRotationEffectController>();

            controller.eventTypeForThisEffect = eventTypeForThisEffect;
            controller.manager  = manager;
            controller.name     = baseEffect.name;
            controller.isBig    = baseEffect.name.Contains("Big");
            controller.stepType = stepType;
            controller.stepMax  = stepMax;
            controller.startupRotationEffect = startupRotationEffect;
            controller.rotation         = rotation;
            controller.propagationSpeed = propagationSpeed;
            controller.flexySpeed       = flexySpeed;

            return(controller);
        }
示例#5
0
 private static void Postfix(TrackLaneRingsManager __instance)
 {
     RingManagers.Add(__instance);
 }
 internal void SetNewRingManager(TrackLaneRingsManager trackLaneRingsManager)
 {
     _trackLaneRingsManager = trackLaneRingsManager;
 }
示例#7
0
            private LSEColorManager(MonoBehaviour mono, BeatmapEventType type)
            {
                _lse  = mono;
                _type = type;
                InitializeSOs(mono, "_lightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mLightColor0);
                InitializeSOs(mono, "_highlightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mHighlightColor0);
                InitializeSOs(mono, "_lightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mLightColor1);
                InitializeSOs(mono, "_highlightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mHighlightColor1);

                if (mono is LightSwitchEventEffect lse)
                {
                    InitializeSOs(mono, "_lightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mLightColor0Boost);
                    InitializeSOs(mono, "_highlightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mHighlightColor0Boost);
                    InitializeSOs(mono, "_lightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mLightColor1Boost);
                    InitializeSOs(mono, "_highlightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mHighlightColor1Boost);
                    _supportBoostColor = true;

                    LightWithIdManager lightManager = lse.GetField <LightWithIdManager, LightSwitchEventEffect>("_lightManager");
                    Lights = lightManager.GetField <List <ILightWithId>[], LightWithIdManager>("_lights")[lse.lightsId].ToList();

                    IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >();
                    TrackLaneRingsManager[] managers = Object.FindObjectsOfType <TrackLaneRingsManager>();
                    foreach (ILightWithId light in Lights)
                    {
                        if (light is MonoBehaviour monoBehaviour)
                        {
                            int z = Mathf.RoundToInt(monoBehaviour.transform.position.z);

                            TrackLaneRing ring = monoBehaviour.GetComponentInParent <TrackLaneRing>();
                            if (ring != null)
                            {
                                TrackLaneRingsManager mngr = managers.FirstOrDefault(it => it.Rings.IndexOf(ring) >= 0);
                                if (mngr != null)
                                {
                                    z = 1000 + mngr.Rings.IndexOf(ring);
                                }
                            }

                            if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list))
                            {
                                list.Add(light);
                            }
                            else
                            {
                                list = new List <ILightWithId>()
                                {
                                    light
                                };
                                lightsPreGroup.Add(z, list);
                            }
                        }
                    }

                    LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][];
                    int i = 0;
                    foreach (List <ILightWithId> lightList in lightsPreGroup.Values)
                    {
                        if (lightList is null)
                        {
                            continue;
                        }

                        LightsPropagationGrouped[i] = lightList.ToArray();
                        i++;
                    }
                }
            }
示例#8
0
        /// <summary>
        /// Creates and stores references to multiple objects (of different types) per <see cref="TrackRings"/> on the <paramref name="gameObject"/>
        /// </summary>
        /// <param name="gameObject">What <see cref="GameObject"/> to create TrackRings for</param>
        internal void CreateTrackRings(GameObject gameObject)
        {
            rotationSpawners       = new List <TrackLaneRingsRotationEffectSpawner>();
            stepSpawners           = new List <TrackLaneRingsPositionStepEffectSpawner>();
            trackLaneRingsManagers = new List <TrackLaneRingsManager>();
            trackRingsDescriptors  = new List <TrackRings>();

            TrackRings[] ringsDescriptors = gameObject.GetComponentsInChildren <TrackRings>();
            foreach (TrackRings trackRingDesc in ringsDescriptors)
            {
                trackRingsDescriptors.Add(trackRingDesc);

                TrackLaneRingsManager ringsManager = trackRingDesc.gameObject.AddComponent <TrackLaneRingsManager>();
                trackLaneRingsManagers.Add(ringsManager);
                PlatformManager.SpawnedComponents.Add(ringsManager);

                TrackLaneRing ring = trackRingDesc.trackLaneRingPrefab.AddComponent <TrackLaneRing>();
                PlatformManager.SpawnedComponents.Add(ring);

                ringsManager.SetField("_trackLaneRingPrefab", ring);
                ringsManager.SetField("_ringCount", trackRingDesc.ringCount);
                ringsManager.SetField("_ringPositionStep", trackRingDesc.ringPositionStep);
                ringsManager.SetField("_spawnAsChildren", true);

                if (trackRingDesc.useRotationEffect)
                {
                    TrackLaneRingsRotationEffect rotationEffect = trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffect>();
                    PlatformManager.SpawnedComponents.Add(rotationEffect);
                    rotationEffect.SetField("_trackLaneRingsManager", ringsManager);
                    rotationEffect.SetField("_startupRotationAngle", trackRingDesc.startupRotationAngle);
                    rotationEffect.SetField("_startupRotationStep", trackRingDesc.startupRotationStep);
                    int   timePerRing   = trackRingDesc.startupRotationPropagationSpeed / trackRingDesc.ringCount;
                    float ringsPerFrame = Time.fixedDeltaTime / timePerRing;
                    rotationEffect.SetField("_startupRotationPropagationSpeed", Math.Max((int)ringsPerFrame, 1));
                    rotationEffect.SetField("_startupRotationFlexySpeed", trackRingDesc.startupRotationFlexySpeed);

                    TrackLaneRingsRotationEffectSpawner rotationEffectSpawner = trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffectSpawner>();
                    rotationSpawners.Add(rotationEffectSpawner);
                    PlatformManager.SpawnedComponents.Add(rotationEffectSpawner);
                    rotationEffectSpawner.SetField("_beatmapObjectCallbackController", _beatmapObjectCallbackController);

                    rotationEffectSpawner.SetField("_beatmapEventType", (BeatmapEventType)trackRingDesc.rotationSongEventType);
                    rotationEffectSpawner.SetField("_rotationStep", trackRingDesc.rotationStep);
                    int   timePerRing2   = trackRingDesc.rotationPropagationSpeed / trackRingDesc.ringCount;
                    float ringsPerFrame2 = Time.fixedDeltaTime / timePerRing2;
                    rotationEffectSpawner.SetField("_rotationPropagationSpeed", Math.Max((int)ringsPerFrame2, 1));
                    rotationEffectSpawner.SetField("_rotationFlexySpeed", trackRingDesc.rotationFlexySpeed);
                    rotationEffectSpawner.SetField("_trackLaneRingsRotationEffect", rotationEffect);
                }
                if (trackRingDesc.useStepEffect)
                {
                    TrackLaneRingsPositionStepEffectSpawner stepEffectSpawner = trackRingDesc.gameObject.AddComponent <TrackLaneRingsPositionStepEffectSpawner>();
                    stepSpawners.Add(stepEffectSpawner);
                    PlatformManager.SpawnedComponents.Add(stepEffectSpawner);
                    stepEffectSpawner.SetField("_beatmapObjectCallbackController", _beatmapObjectCallbackController);

                    stepEffectSpawner.SetField("_trackLaneRingsManager", ringsManager);
                    stepEffectSpawner.SetField("_beatmapEventType", (BeatmapEventType)trackRingDesc.stepSongEventType);
                    stepEffectSpawner.SetField("_minPositionStep", trackRingDesc.minPositionStep);
                    stepEffectSpawner.SetField("_maxPositionStep", trackRingDesc.maxPositionStep);
                    stepEffectSpawner.SetField("_moveSpeed", trackRingDesc.moveSpeed);
                }
            }
        }
示例#9
0
        internal LightColorizer(LightSwitchEventEffect lightSwitchEventEffect, BeatmapEventType beatmapEventType)
        {
            _lightSwitchEventEffect = lightSwitchEventEffect;
            _eventType = beatmapEventType;
            InitializeSO("_lightColor0", 0);
            InitializeSO("_highlightColor0", 0);
            InitializeSO("_lightColor1", 1);
            InitializeSO("_highlightColor1", 1);
            InitializeSO("_lightColor0Boost", 2);
            InitializeSO("_highlightColor0Boost", 2);
            InitializeSO("_lightColor1Boost", 3);
            InitializeSO("_highlightColor1Boost", 3);

            // AAAAAA PROPAGATION STUFFF
            LightWithIdManager lightManager = _lightManagerAccessor(ref lightSwitchEventEffect);

            Lights = _lightsAccessor(ref lightManager)[lightSwitchEventEffect.lightsId].ToList();

            IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >();

            TrackLaneRingsManager[] managers = UnityEngine.Object.FindObjectsOfType <TrackLaneRingsManager>();
            foreach (ILightWithId light in Lights)
            {
                if (light is MonoBehaviour monoBehaviour)
                {
                    int z = Mathf.RoundToInt(monoBehaviour.transform.position.z);

                    TrackLaneRing ring = monoBehaviour.GetComponentInParent <TrackLaneRing>();
                    if (ring != null)
                    {
                        TrackLaneRingsManager mngr = managers.FirstOrDefault(it => it.Rings.IndexOf(ring) >= 0);
                        if (mngr != null)
                        {
                            z = 1000 + mngr.Rings.IndexOf(ring);
                        }
                    }

                    if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list))
                    {
                        list.Add(light);
                    }
                    else
                    {
                        list = new List <ILightWithId>()
                        {
                            light
                        };
                        lightsPreGroup.Add(z, list);
                    }
                }
            }

            LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][];
            int i = 0;

            foreach (List <ILightWithId> lightList in lightsPreGroup.Values)
            {
                if (lightList is null)
                {
                    continue;
                }

                LightsPropagationGrouped[i] = lightList.ToArray();
                i++;
            }

            // ok we done
            Colorizers.Add(beatmapEventType, this);
        }
示例#10
0
        internal static void InitializeComponents(Transform root, Transform original, List <GameObjectInfo> gameObjectInfos, List <IComponentData> componentDatas, int?lightID)
        {
            void GetComponentAndOriginal <T>(Action <T, T> initializeDelegate)
            {
                T[] rootComponents     = root.GetComponents <T>();
                T[] originalComponents = original.GetComponents <T>();

                for (int i = 0; i < rootComponents.Length; i++)
                {
                    initializeDelegate(rootComponents[i], originalComponents[i]);

                    if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug)
                    {
                        Plugin.Logger.Log($"Initialized {typeof(T).Name}");
                    }
                }
            }

            GetComponentAndOriginal <LightWithIdMonoBehaviour>((rootComponent, originalComponent) =>
            {
                _lightWithIdMonoBehaviourManagerAccessor(ref rootComponent) = _lightWithIdMonoBehaviourManagerAccessor(ref originalComponent);
                LightColorizer.RegisterLight(rootComponent, lightID);
            });

            GetComponentAndOriginal <LightWithIds>((rootComponent, originalComponent) =>
            {
                _lightWithIdsManagerAccessor(ref rootComponent) = _lightWithIdsManagerAccessor(ref originalComponent);
                LightColorizer.RegisterLight(rootComponent, lightID);
            });

            GetComponentAndOriginal <TrackLaneRing>((rootComponent, originalComponent) =>
            {
                if (EnvironmentEnhancementManager.RingRotationOffsets.TryGetValue(originalComponent, out Quaternion offset))
                {
                    EnvironmentEnhancementManager.RingRotationOffsets.Add(rootComponent, offset);
                }

                _ringTransformAccessor(ref rootComponent)  = root;
                _positionOffsetAccessor(ref rootComponent) = _positionOffsetAccessor(ref originalComponent);
                _posZAccessor(ref rootComponent)           = _posZAccessor(ref originalComponent);

                TrackLaneRingsManager?managerToAdd = null;
                foreach (TrackLaneRingsManager manager in HarmonyPatches.TrackLaneRingsManagerAwake.RingManagers)
                {
                    TrackLaneRingsManagerComponentData componentData = componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == manager).FirstOrDefault();
                    if (componentData != null)
                    {
                        managerToAdd = componentData.NewTrackLaneRingsManager;
                    }
                    else
                    {
                        TrackLaneRingsManager managerRef = manager;
                        TrackLaneRing[] rings            = _ringsAccessor(ref managerRef);
                        if (rings.Contains(originalComponent))
                        {
                            managerToAdd = manager;
                        }
                    }

                    if (managerToAdd != null)
                    {
                        // ToList() to add and then back ToArray()
                        TrackLaneRing[] rings          = _ringsAccessor(ref managerToAdd);
                        List <TrackLaneRing> ringsList = rings?.ToList() ?? new List <TrackLaneRing>();
                        ringsList.Add(rootComponent);
                        _ringsAccessor(ref managerToAdd) = ringsList.ToArray();

                        break;
                    }
                }
            });

            GetComponentAndOriginal <TrackLaneRingsPositionStepEffectSpawner>((rootComponent, originalComponent) =>
            {
                foreach (TrackLaneRingsManager manager in HarmonyPatches.TrackLaneRingsManagerAwake.RingManagers)
                {
                    TrackLaneRingsManagerComponentData?componentData = componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == manager).FirstOrDefault();
                    if (componentData != null)
                    {
                        _stepSpawnerRingsManagerAccessor(ref rootComponent) = componentData.NewTrackLaneRingsManager !;

                        break;
                    }
                }
            });

            GetComponentAndOriginal <ChromaRingsRotationEffect>((rootComponent, originalComponent) =>
            {
                foreach (TrackLaneRingsManager manager in HarmonyPatches.TrackLaneRingsManagerAwake.RingManagers)
                {
                    TrackLaneRingsManagerComponentData?componentData = componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == manager).FirstOrDefault();
                    if (componentData != null)
                    {
                        rootComponent.SetNewRingManager(componentData.NewTrackLaneRingsManager !);

                        break;
                    }
                }
            });

            GetComponentAndOriginal <TrackLaneRingsRotationEffectSpawner>((rootComponent, originalComponent) =>
            {
                _rotationEffectSpawnerCallbackControllerAccessor(ref rootComponent) = _rotationEffectSpawnerCallbackControllerAccessor(ref originalComponent);
                _trackLaneRingsRotationEffectAccessor(ref rootComponent)            = rootComponent.GetComponent <ChromaRingsRotationEffect>();
            });

            GetComponentAndOriginal <Spectrogram>((rootComponent, originalComponent) => _spectrogramDataAccessor(ref rootComponent) = _spectrogramDataAccessor(ref originalComponent));

            GetComponentAndOriginal <LightRotationEventEffect>((rootComponent, originalComponent) => _lightCallbackControllerAccessor(ref rootComponent) = _lightCallbackControllerAccessor(ref originalComponent));

            GetComponentAndOriginal <LightPairRotationEventEffect>((rootComponent, originalComponent) =>
            {
                _lightPairCallbackControllerAccessor(ref rootComponent) = _lightPairCallbackControllerAccessor(ref originalComponent);

                Transform transformL = _transformLAccessor(ref originalComponent);
                Transform transformR = _transformRAccessor(ref originalComponent);

                _transformLAccessor(ref rootComponent) = root.GetChild(transformL.GetSiblingIndex());
                _transformRAccessor(ref rootComponent) = root.GetChild(transformR.GetSiblingIndex());

                // We have to enable the object to tell unity to run Start
                rootComponent.enabled = true;
            });

            GetComponentAndOriginal <ParticleSystemEventEffect>((rootComponent, originalComponent) =>
            {
                _particleCallbackControllerAccessor(ref rootComponent) = _particleCallbackControllerAccessor(ref originalComponent);
                _particleSystemAccessor(ref rootComponent)             = root.GetComponent <ParticleSystem>();

                rootComponent.enabled = true;
            });

            GetComponentAndOriginal <Mirror>((rootComponent, originalComponent) =>
            {
                _mirrorRendererAccessor(ref rootComponent) = UnityEngine.Object.Instantiate(_mirrorRendererAccessor(ref originalComponent));
                _mirrorMaterialAccessor(ref rootComponent) = UnityEngine.Object.Instantiate(_mirrorMaterialAccessor(ref originalComponent));
            });

            GameObjectInfo newGameObjectInfo = new GameObjectInfo(root.gameObject);

            gameObjectInfos.Add(newGameObjectInfo);

            foreach (Transform transform in root)
            {
                int index = transform.GetSiblingIndex();
                InitializeComponents(transform, original.GetChild(index), gameObjectInfos, componentDatas, lightID);
            }
        }