public void CreateEffects(GameObject go)
        {
            if (lightRotationEffects == null)
            {
                lightRotationEffects = new List <LightRotationEventEffect>();
            }
            if (effectDescriptors == null)
            {
                effectDescriptors = new List <RotationEventEffect>();
            }

            RotationEventEffect[] localDescriptors = go.GetComponentsInChildren <RotationEventEffect>(true);

            if (localDescriptors == null)
            {
                return;
            }

            foreach (RotationEventEffect effectDescriptor in effectDescriptors)
            {
                LightRotationEventEffect rotEvent = effectDescriptor.gameObject.AddComponent <LightRotationEventEffect>();

                ReflectionUtil.SetPrivateField(rotEvent, "_event", (BeatmapEventType)effectDescriptor.eventType);
                ReflectionUtil.SetPrivateField(rotEvent, "_rotationVector", effectDescriptor.rotationVector);
                ReflectionUtil.SetPrivateField(rotEvent, "_transform", rotEvent.transform);
                ReflectionUtil.SetPrivateField(rotEvent, "_startRotation", rotEvent.transform.rotation);
                lightRotationEffects.Add(rotEvent);
                effectDescriptors.Add(effectDescriptor);
            }
        }
예제 #2
0
 internal void CreateEffects(GameObject currentPlatform)
 {
     if (_beatmapObjectCallbackController != null)
     {
         foreach (PairRotationEventEffect descriptor in currentPlatform.GetComponentsInChildren <PairRotationEventEffect>(true))
         {
             LightPairRotationEventEffect rotEffect = descriptor.gameObject.AddComponent <LightPairRotationEventEffect>();
             rotEffect.SetField("_beatmapObjectCallbackController", _beatmapObjectCallbackController);
             rotEffect.SetField("_eventL", (BeatmapEventType)descriptor.eventL);
             rotEffect.SetField("_eventR", (BeatmapEventType)descriptor.eventR);
             rotEffect.SetField("_rotationVector", descriptor.rotationVector);
             rotEffect.SetField("_transformL", descriptor.tranformL);
             rotEffect.SetField("_transformR", descriptor.tranformR);
             rotEffect.SetField("_useZPositionForAngleOffset", descriptor.useZPositionForAngleOffset);
             rotEffect.SetField("_overrideRandomValues", descriptor.overrideRandomValues);
             rotEffect.SetField("_randomStartRotation", descriptor.randomStartRotation);
             rotEffect.SetField("_randomDirection", descriptor.randomDirection);
             PlatformManager.SpawnedComponents.Add(rotEffect);
         }
         foreach (var descriptor in currentPlatform.GetComponentsInChildren <RotationEventEffect>(true))
         {
             LightRotationEventEffect rotEffect = descriptor.gameObject.AddComponent <LightRotationEventEffect>();
             rotEffect.SetField("_beatmapObjectCallbackController", _beatmapObjectCallbackController);
             rotEffect.SetField("_event", (BeatmapEventType)descriptor.eventType);
             rotEffect.SetField("_rotationVector", descriptor.rotationVector);
             rotEffect.SetField("_transform", descriptor.transform);
         }
     }
 }
예제 #3
0
        //Laser rotation
        static bool Prefix(LightRotationEventEffect __instance, ref BeatmapEventData beatmapEventData, ref BeatmapEventType ____event, ref Transform ____transform, ref Quaternion ____startRotation, ref Vector3 ____rotationVector, ref float ____rotationSpeed)
        {
            if (beatmapEventData.type == ____event)
            {
                if (!IsDefaults())
                {
                    if (beatmapEventData.value == 0)
                    {
                        __instance.enabled = false;
                        if (!ChromaEvent.disablePositionReset)
                        {
                            ____transform.localRotation = ____startRotation;
                        }
                    }
                    else if (beatmapEventData.value > 0)
                    {
                        if (!ChromaEvent.disablePositionReset)
                        {
                            ____transform.localRotation = ____startRotation;
                            ____transform.Rotate(____rotationVector, UnityEngine.Random.Range(0f, 180f), Space.Self);
                        }
                        __instance.enabled = true;
                        ____rotationSpeed  = (float)beatmapEventData.value * 20f * (GetRotationDirection());
                    }
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Creates all <see cref="LightRotationEventEffect"/>s for the <paramref name="currentPlatform"/><br/>
        /// (From <see cref="RotationEventEffect"/>s present on the <paramref name="currentPlatform"/>)
        /// </summary>
        /// <param name="currentPlatform">Current <see cref="CustomPlatform"/>s <see cref="GameObject"/></param>
        internal void CreateEffects(GameObject currentPlatform)
        {
            lightRotationEffects = new List <LightRotationEventEffect>();
            multiEffects         = new List <MultiRotationEventEffect.Actor>();

            RotationEventEffect[] effectDescriptors = currentPlatform.GetComponentsInChildren <RotationEventEffect>(true);

            foreach (RotationEventEffect effectDescriptor in effectDescriptors)
            {
                LightRotationEventEffect rotEvent = effectDescriptor.gameObject.AddComponent <LightRotationEventEffect>();
                PlatformManager.SpawnedComponents.Add(rotEvent);
                rotEvent.SetField("_event", (BeatmapEventType)effectDescriptor.eventType);
                rotEvent.SetField("_rotationVector", effectDescriptor.rotationVector);
                rotEvent.SetField("_transform", rotEvent.transform);
                rotEvent.SetField("_startRotation", rotEvent.transform.rotation);
                lightRotationEffects.Add(rotEvent);
            }
            MultiRotationEventEffect[] effectDescriptors2 = currentPlatform.GetComponentsInChildren <MultiRotationEventEffect>(true);
            foreach (MultiRotationEventEffect effectDescriptor in effectDescriptors2)
            {
                MultiRotationEventEffect.Actor rotEvent = effectDescriptor.Create();
                PlatformManager.SpawnedComponents.Add(rotEvent);
                multiEffects.Add(rotEvent);
            }
        }
예제 #5
0
        private static bool Prefix(
            BeatmapEventData beatmapEventData,
            LightRotationEventEffect __instance,
            BeatmapEventType ____event,
            Quaternion ____startRotation,
            ref float ____rotationSpeed,
            Vector3 ____rotationVector)
        {
            if (beatmapEventData.type == ____event)
            {
                ChromaEventData?chromaData = TryGetEventData(beatmapEventData);
                if (chromaData == null)
                {
                    return(true);
                }

                bool isLeftEvent = ____event == BeatmapEventType.Event12;

                bool  lockPosition   = chromaData.LockPosition;
                float precisionSpeed = chromaData.Speed.GetValueOrDefault(beatmapEventData.value);
                int?  dir            = chromaData.Direction;

                float direction = (Random.value > 0.5f) ? 1f : -1f;
                switch (dir)
                {
                case 0:
                    direction = isLeftEvent ? -1 : 1;
                    break;

                case 1:
                    direction = isLeftEvent ? 1 : -1;
                    break;
                }

                // Actual lasering
                if (beatmapEventData.value == 0)
                {
                    __instance.enabled = false;
                    if (!lockPosition)
                    {
                        __instance.transform.localRotation = ____startRotation;
                    }
                }
                else if (beatmapEventData.value > 0)
                {
                    __instance.enabled = true;
                    ____rotationSpeed  = precisionSpeed * 20f * direction;
                    if (!lockPosition)
                    {
                        __instance.transform.localRotation = ____startRotation;
                        __instance.transform.Rotate(____rotationVector, Random.Range(0f, 180f), Space.Self);
                    }
                }

                return(false);
            }

            return(true);
        }
        static bool Prefix(LightRotationEventEffect __instance)
        {
            ReflectionUtil.GetPrivateField <BeatmapObjectCallbackController>(__instance, "_beatmapObjectCallbackController").beatmapEventDidTriggerEvent += __instance.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger;
            ReflectionUtil.SetPrivateField(__instance, "_transform", __instance.transform);
            ReflectionUtil.SetPrivateField(__instance, "_startRotation", __instance.transform.localRotation); // This is the fix.
            __instance.enabled = false;

            return(false);
        }
예제 #7
0
        public static LightRotationEffectController Create(LightRotationEventEffect baseEffect)
        {
            BeatmapEventType eventTypeForThisEffect = Helper.GetValue <BeatmapEventType>(baseEffect, "_event");
            Transform        transform      = Helper.GetValue <Transform>(baseEffect, "_transform");
            Quaternion       startRotation  = Helper.GetValue <Quaternion>(baseEffect, "_startRotation");
            Vector3          rotationVector = Helper.GetValue <Vector3>(baseEffect, "_rotationVector");

            LightRotationEffectController controller = new GameObject("TwitchFXLightRotationEffectController").AddComponent <LightRotationEffectController>();

            controller.eventTypeForThisEffect = eventTypeForThisEffect;
            controller.transform      = transform;
            controller.startRotation  = startRotation;
            controller.rotationVector = rotationVector;

            return(controller);
        }
        protected override void Init()
        {
            if (rotationEffects.Length == 0 && pairRotationEffects.Length == 0)
            {
                return;
            }

            bocc.beatmapEventDidTriggerEvent += OnBeatmapEvent;

            rotationEffectControllers     = new LightRotationEffectController[rotationEffects.Length];
            pairRotationEffectControllers = new LightPairRotationEffectController[pairRotationEffects.Length];

            for (int i = 0; i < rotationEffects.Length; i++)
            {
                LightRotationEventEffect rotationEffect = rotationEffects[i];

                onPipedBeatmapEvent += rotationEffect.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger;
                bocc.beatmapEventDidTriggerEvent -= rotationEffect.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger;

                LightRotationEffectController rotationEffectController = LightRotationEffectController.Create(rotationEffect);
                CustomBeatmapEventManager.onCustomBeatmapEvent += rotationEffectController.OnEvent;

                rotationEffectControllers[i] = rotationEffectController;
            }

            for (int i = 0; i < pairRotationEffects.Length; i++)
            {
                LightPairRotationEventEffect pairRotationEffect = pairRotationEffects[i];

                onPipedBeatmapEvent += pairRotationEffect.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger;
                bocc.beatmapEventDidTriggerEvent -= pairRotationEffect.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger;

                LightPairRotationEffectController pairRotationEffectController = LightPairRotationEffectController.Create(pairRotationEffect);
                CustomBeatmapEventManager.onCustomBeatmapEvent += pairRotationEffectController.OnEvent;

                pairRotationEffectControllers[i] = pairRotationEffectController;
            }
        }
        public void CreateEffects(GameObject go)
        {
            if (lightRotationEffects == null)
            {
                lightRotationEffects = new List <LightRotationEventEffect>();
            }
            if (effectDescriptors == null)
            {
                effectDescriptors = new List <RotationEventEffect>();
            }

            RotationEventEffect[] localDescriptors = go.GetComponentsInChildren <RotationEventEffect>(true);

            if (localDescriptors == null)
            {
                return;
            }

            // Get the BeatmapObjectCallbackController floating in the level.
            BeatmapObjectCallbackController beatmapObjectCallbackController = ((BeatmapObjectCallbackController[])GameObject.FindObjectsOfType(typeof(BeatmapObjectCallbackController)))[0];

            foreach (RotationEventEffect effectDescriptor in localDescriptors)
            {
                LightRotationEventEffect rotEvent = effectDescriptor.gameObject.AddComponent <LightRotationEventEffect>();
                PlatformManager.SpawnedComponents.Add(rotEvent);

                // Convert the effect descriptor into the behaviour from the base game.
                ReflectionUtil.SetPrivateField(rotEvent, "_event", (BeatmapEventType)effectDescriptor.eventType);
                ReflectionUtil.SetPrivateField(rotEvent, "_rotationVector", effectDescriptor.rotationVector);
                ReflectionUtil.SetPrivateField(rotEvent, "_beatmapObjectCallbackController", beatmapObjectCallbackController);
                ReflectionUtil.SetPrivateField(rotEvent, "_transform", rotEvent.transform);
                ReflectionUtil.SetPrivateField(rotEvent, "_startRotation", rotEvent.transform.localRotation);
                lightRotationEffects.Add(rotEvent);
                effectDescriptors.Add(effectDescriptor);
            }
        }
예제 #10
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static bool Prefix(
            BeatmapEventData beatmapEventData,
            LightRotationEventEffect __instance,
            BeatmapEventType ____event,
            Quaternion ____startRotation,
            ref float ____rotationSpeed,
            Vector3 ____rotationVector)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (beatmapEventData.type == ____event)
            {
                if (beatmapEventData is CustomBeatmapEventData customData)
                {
                    bool isLeftEvent = ____event == BeatmapEventType.Event12;

                    dynamic dynData = customData.customData;

                    bool lockPosition = ((bool?)Trees.at(dynData, LOCKPOSITION)).GetValueOrDefault(false);

                    float precisionSpeed = ((float?)Trees.at(dynData, PRECISESPEED)).GetValueOrDefault(beatmapEventData.value);

                    int?dir = (int?)Trees.at(dynData, DIRECTION);
                    dir = dir.GetValueOrDefault(-1);

                    float direction = (Random.value > 0.5f) ? 1f : -1f;
                    switch (dir)
                    {
                    case 0:
                        direction = isLeftEvent ? -1 : 1;
                        break;

                    case 1:
                        direction = isLeftEvent ? 1 : -1;
                        break;
                    }

                    // Actual lasering
                    if (beatmapEventData.value == 0)
                    {
                        __instance.enabled = false;
                        if (!lockPosition)
                        {
                            __instance.transform.localRotation = ____startRotation;
                        }
                    }
                    else if (beatmapEventData.value > 0)
                    {
                        __instance.enabled = true;
                        ____rotationSpeed  = precisionSpeed * 20f * direction;
                        if (!lockPosition)
                        {
                            __instance.transform.localRotation = ____startRotation;
                            __instance.transform.Rotate(____rotationVector, Random.Range(0f, 180f), Space.Self);
                        }
                    }

                    return(false);
                }
            }

            return(true);
        }