public T ParseJSON <T>(JObject eventNode, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod) where T : ChromaJSONBeatmapObject
        {
            IEnumerator <KeyValuePair <string, JToken> > nodeEnum = eventNode.GetEnumerator();

            while (nodeEnum.MoveNext())
            {
                string key   = nodeEnum.Current.Key;
                JToken value = nodeEnum.Current.Value;

                switch (key)
                {
                case "_time":
                    time = GetRealTimeFromBPMTime(value.Value <float>(), ref beatsPerMinute, ref shuffle, ref shufflePeriod);
                    break;

                case "_type":
                    type = (BeatmapEventType)value.Value <int>();
                    break;

                default:
                    ParseNode(key, value.Value <JObject>());
                    break;
                }
            }

            return(this as T);
        }
 // Laser rotation
 private static void Prefix(BeatmapEventData beatmapEventData, BeatmapEventType ____eventL, BeatmapEventType ____eventR)
 {
     if (beatmapEventData.type == ____eventL || beatmapEventData.type == ____eventR)
     {
         LastLightPairRotationEventEffectData = beatmapEventData;
     }
 }
Esempio n. 3
0
 public static void SetLightingColors(this BeatmapEventType lse, Color?color0, Color?color1, Color?color0Boost = null, Color?color1Boost = null)
 {
     foreach (LSEColorManager l in LSEColorManager.GetLSEColorManager(lse))
     {
         l.SetLightingColors(color0, color1, color0Boost, color1Boost);
     }
 }
Esempio n. 4
0
 public static void SetActiveColors(this BeatmapEventType lse)
 {
     foreach (LSEColorManager l in LSEColorManager.GetLSEColorManager(lse))
     {
         l.SetActiveColors();
     }
 }
Esempio n. 5
0
        internal static IEnumerator Routine(LightSwitchEventEffect lse, BeatmapEventType type, Color colour, float delay)
        {
            BloomPrePassLight[] lights = lse.GetField <BloomPrePassLight[]>("_lights");
            Dictionary <int, List <BloomPrePassLight> > lightWavesByPosition = new Dictionary <int, List <BloomPrePassLight> >();

            for (int i = 0; i < lights.Length; i++)
            {
                List <BloomPrePassLight> wave;
                if (!lightWavesByPosition.TryGetValue(Mathf.FloorToInt(lights[i].transform.position.z), out wave))
                {
                    wave = new List <BloomPrePassLight>();
                    lightWavesByPosition.Add(Mathf.FloorToInt(lights[i].transform.position.z), wave);
                }
                wave.Add(lights[i]);
            }

            ChromaLogger.Log("Found " + lightWavesByPosition.Count + " waves!");

            List <List <BloomPrePassLight> > lightWaves = new List <List <BloomPrePassLight> >();

            foreach (KeyValuePair <int, List <BloomPrePassLight> > kv in lightWavesByPosition)
            {
                lightWaves.Add(kv.Value);
            }

            for (int i = 0; i < lightWaves.Count; i++)
            {
                for (int j = 0; j < lightWaves[i].Count; j++)
                {
                    lightWaves[i][j].color = colour;
                }
                yield return(new WaitForSeconds(delay));
            }
        }
Esempio n. 6
0
        public T ParseJSON <T>(JSONNode eventNode, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod) where T : ChromaJSONBeatmapObject
        {
            JSONNode.Enumerator nodeEnum = eventNode.GetEnumerator();
            while (nodeEnum.MoveNext())
            {
                string   key  = nodeEnum.Current.Key;
                JSONNode node = nodeEnum.Current.Value;

                switch (key)
                {
                case "_time":
                    time = GetRealTimeFromBPMTime(node.AsFloat, ref beatsPerMinute, ref shuffle, ref shufflePeriod);
                    break;

                case "_type":
                    type = (BeatmapEventType)node.AsInt;
                    break;

                default:
                    ParseNode(key, node);
                    break;
                }
            }

            return(this as T);
        }
        private static bool Prefix(LightPairRotationEventEffect __instance, BeatmapEventType ____eventL, float startRotationOffset, float direction, object ____rotationDataL, object ____rotationDataR)
        {
            BeatmapEventData beatmapEventData = LightPairRotationEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LastLightPairRotationEventEffectData;

            bool isLeftEvent = beatmapEventData.type == ____eventL;

            if (_rotationDataType == null)
            {
                GetRotationData();
            }

            object rotationData = isLeftEvent ? ____rotationDataL : ____rotationDataR;

            ChromaLaserSpeedEventData chromaData = (ChromaLaserSpeedEventData)ChromaEventDatas[beatmapEventData];

            bool  lockPosition   = chromaData.LockPosition;
            float precisionSpeed = chromaData.PreciseSpeed;
            int?  dir            = chromaData.Direction;

            switch (dir)
            {
            case 0:
                direction = isLeftEvent ? -1 : 1;
                break;

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

            // Actual lasering
            Transform  transform          = (Transform)_rotationDataType.GetField("transform").GetValue(rotationData);
            Quaternion startRotation      = (Quaternion)_rotationDataType.GetField("startRotation").GetValue(rotationData);
            float      startRotationAngle = (float)_rotationDataType.GetField("startRotationAngle").GetValue(rotationData);
            Vector3    rotationVector     = __instance.GetField <Vector3, LightPairRotationEventEffect>("_rotationVector");

            if (beatmapEventData.value == 0)
            {
                _rotationDataType.GetField("enabled").SetValue(rotationData, false);
                if (!lockPosition)
                {
                    _rotationDataType.GetField("rotationAngle").SetValue(rotationData, startRotationAngle);
                    transform.localRotation = startRotation * Quaternion.Euler(rotationVector * startRotationAngle);
                }
            }
            else if (beatmapEventData.value > 0)
            {
                _rotationDataType.GetField("enabled").SetValue(rotationData, true);
                _rotationDataType.GetField("rotationSpeed").SetValue(rotationData, precisionSpeed * 20f * direction);
                if (!lockPosition)
                {
                    float rotationAngle = startRotationOffset + startRotationAngle;
                    _rotationDataType.GetField("rotationAngle").SetValue(rotationData, rotationAngle);
                    transform.localRotation = startRotation * Quaternion.Euler(rotationVector * rotationAngle);
                }
            }

            return(false);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
 private static void Prefix(BeatmapEventData beatmapEventData, BeatmapEventType ____colorEvent)
 {
     if (beatmapEventData.type == ____colorEvent)
     {
         // Some redundancy here but f**k it
         ____colorEvent.GetParticleColorizers().ForEach(n => n.PreviousValue = beatmapEventData.value);
     }
 }
Esempio n. 10
0
        // Laser rotation
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Prefix(BeatmapEventData beatmapEventData, BeatmapEventType ____eventL, BeatmapEventType ____eventR)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (beatmapEventData.type == ____eventL || beatmapEventData.type == ____eventR)
            {
                LastLightPairRotationEventEffectData = beatmapEventData;
            }
        }
Esempio n. 11
0
            internal static LSEColorManager CreateLSEColorManager(MonoBehaviour lse, BeatmapEventType type)
            {
                LSEColorManager lsecm;

                lsecm = new LSEColorManager(lse, type);
                _lseColorManagers.Add(lse, lsecm);
                return(lsecm);
            }
Esempio n. 12
0
        /*
         * LSE ColourSO holders
         */

        internal static void LSEStart(LightSwitchEventEffect lse, BeatmapEventType type)
        {
            LSEColourManager lsecm = LSEColourManager.GetOrCreateLSEColourManager(lse, type);

            if (type == BeatmapEventType.Event1)
            {
                ChromaTesting.lse = lse; ChromaTesting.type = type;
            }
        }
Esempio n. 13
0
 private void Update()
 {
     foreach (KeyValuePair <BeatmapEventType, ChromaGradientEvent> valuePair in new Dictionary <BeatmapEventType, ChromaGradientEvent>(Gradients))
     {
         Color            color     = valuePair.Value.Interpolate();
         BeatmapEventType eventType = valuePair.Key;
         eventType.ColorizeLight(true, color, color, color, color);
     }
 }
Esempio n. 14
0
 internal ChromaGradientEvent(Color initcolor, Color endcolor, float start, float duration, BeatmapEventType eventType, Functions easing = Functions.easeLinear)
 {
     _initcolor = initcolor;
     _endcolor  = endcolor;
     _start     = start;
     _duration  = 60f * duration / ChromaController.BeatmapObjectSpawnController !.currentBpm;
     _event     = eventType;
     _easing    = easing;
 }
Esempio n. 15
0
        private CustomBeatmapEventData NewCustomBeatmapEventData(float time, BeatmapEventType type, int value)
        {
            Type            t  = typeof(CustomBeatmapEventData);
            ConstructorInfo ci = t.GetConstructor(
                BindingFlags.Instance | BindingFlags.NonPublic,
                null, new[] { typeof(float), typeof(BeatmapEventType), typeof(int), typeof(float), typeof(Dictionary <string, object>) }, null);

            return((CustomBeatmapEventData)ci.Invoke(new object[] { time, type, value, (float)value, new Dictionary <string, object>() }));
        }
Esempio n. 16
0
 private void Initialize(LightSwitchEventEffect lse, BeatmapEventType type)
 {
     this.lse  = lse;
     this.type = type;
     InitializeSOs(lse, "_lightColor0", ref _lightColor0, ref _lightColor0_Original, ref m_lightColor0);
     InitializeSOs(lse, "_highlightColor0", ref _highlightColor0, ref _highlightColor0_Original, ref m_highlightColor0);
     InitializeSOs(lse, "_lightColor1", ref _lightColor1, ref _lightColor1_Original, ref m_lightColor1);
     InitializeSOs(lse, "_highlightColor1", ref _highlightColor1, ref _highlightColor1_Original, ref m_highlightColor1);
 }
Esempio n. 17
0
 private void Update()
 {
     foreach (KeyValuePair <BeatmapEventType, ChromaGradientEvent> valuePair in new Dictionary <BeatmapEventType, ChromaGradientEvent>(Gradients))
     {
         Color            color     = valuePair.Value.Interpolate();
         BeatmapEventType eventType = valuePair.Key;
         eventType.SetLightingColors(color, color, color, color);
         eventType.SetActiveColors();
     }
 }
Esempio n. 18
0
        private static List <ParticleColorizer> GetOrCreateColorizerList(BeatmapEventType eventType)
        {
            if (!Colorizers.TryGetValue(eventType, out List <ParticleColorizer> colorizers))
            {
                colorizers = new List <ParticleColorizer>();
                Colorizers.Add(eventType, colorizers);
            }

            return(colorizers);
        }
Esempio n. 19
0
        private void OnLightColorChanged(BeatmapEventType eventType, Color[] colors)
        {
            if (eventType == _eventType)
            {
                for (int i = 0; i < COLOR_FIELDS; i++)
                {
                    _simpleColorSOs[i].SetColor(colors[i]);
                }

                ParticleSystemEventEffect particleSystemEventEffect = _particleSystemEventEffect;
                Color color;
                Color afterHighlightColor;
                switch (PreviousValue)
                {
                case 0:
                    _particleColorAccessor(ref particleSystemEventEffect) = _offColorAccessor(ref particleSystemEventEffect);
                    particleSystemEventEffect.RefreshParticles();
                    break;

                case 1:
                case 5:
                    color = (PreviousValue == 1) ? _multipliedColorSOs[0] : _multipliedColorSOs[1];
                    _particleColorAccessor(ref particleSystemEventEffect) = color;
                    _offColorAccessor(ref particleSystemEventEffect)      = color.ColorWithAlpha(0);
                    particleSystemEventEffect.RefreshParticles();
                    break;

                case 2:
                case 6:
                    color = (PreviousValue == 2) ? _multipliedHighlightColorSOs[0] : _multipliedHighlightColorSOs[1];
                    _highlightColorAccessor(ref particleSystemEventEffect) = color;
                    _offColorAccessor(ref particleSystemEventEffect)       = color.ColorWithAlpha(0);
                    afterHighlightColor = (PreviousValue == 2) ? _multipliedColorSOs[0] : _multipliedColorSOs[1];
                    _afterHighlightColorAccessor(ref particleSystemEventEffect) = afterHighlightColor;

                    _particleColorAccessor(ref particleSystemEventEffect) = Color.Lerp(afterHighlightColor, color, _highlightValueAccessor(ref particleSystemEventEffect));
                    particleSystemEventEffect.RefreshParticles();
                    break;

                case 3:
                case 7:
                case -1:
                    color = (PreviousValue == 3) ? _multipliedHighlightColorSOs[0] : _multipliedHighlightColorSOs[1];
                    _highlightColorAccessor(ref particleSystemEventEffect) = color;
                    _offColorAccessor(ref particleSystemEventEffect)       = color.ColorWithAlpha(0);
                    _particleColorAccessor(ref particleSystemEventEffect)  = color;
                    afterHighlightColor = _offColorAccessor(ref particleSystemEventEffect);
                    _afterHighlightColorAccessor(ref particleSystemEventEffect) = afterHighlightColor;

                    _particleColorAccessor(ref particleSystemEventEffect) = Color.Lerp(afterHighlightColor, color, _highlightValueAccessor(ref particleSystemEventEffect));
                    particleSystemEventEffect.RefreshParticles();
                    break;
                }
            }
        }
Esempio n. 20
0
 public static LSEColourManager GetLSEColourManager(BeatmapEventType type)
 {
     for (int i = 0; i < LSEColourManagers.Count; i++)
     {
         if (LSEColourManagers[i].type == type)
         {
             return(LSEColourManagers[i]);
         }
     }
     return(null);
 }
Esempio n. 21
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;

                    Lights = lse.GetField <LightWithIdManager, LightSwitchEventEffect>("_lightManager").GetField <List <ILightWithId>[], LightWithIdManager>("_lights")[lse.lightsId];
                    IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >();
                    foreach (ILightWithId light in Lights)
                    {
                        if (light is MonoBehaviour monoBehaviour)
                        {
                            int z = Mathf.RoundToInt(monoBehaviour.transform.position.z);
                            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++;
                    }
                }
            }
Esempio n. 22
0
        private static void Postfix(ParticleSystemEventEffect __instance, BeatmapEventType ____colorEvent)
        {
            // If duplicated, clean up before duping
            ChromaParticleEventController oldController = __instance.GetComponent <ChromaParticleEventController>();

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

            __instance.StartCoroutine(WaitThenStart(__instance, ____colorEvent));
        }
Esempio n. 23
0
        internal ParticleColorizer(ParticleSystemEventEffect particleSystemEventEffect, BeatmapEventType beatmapEventType)
        {
            _particleSystemEventEffect = particleSystemEventEffect;
            _eventType = beatmapEventType;
            InitializeSO("_lightColor0", 0);
            InitializeSO("_highlightColor0", 0, true);
            InitializeSO("_lightColor1", 1);
            InitializeSO("_highlightColor1", 1, true);

            GetOrCreateColorizerList(beatmapEventType).Add(this);

            LightColorizer.LightColorChanged += OnLightColorChanged;
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        private static bool Prefix(LightSwitchEventEffect __instance, BeatmapEventType ____event, Color color)
        {
            if (LightColorManager.LightIDOverride != null)
            {
                List <ILightWithId> lights = __instance.GetLights();
                int type = (int)____event;
                IEnumerable <int> newIds = LightColorManager.LightIDOverride.Select(n => LightIDTableManager.GetActiveTableValue(type, n) ?? n);
                foreach (int id in newIds)
                {
                    ILightWithId lightWithId = lights.ElementAtOrDefault(id);
                    if (lightWithId != null)
                    {
                        if (lightWithId.isRegistered)
                        {
                            lightWithId.ColorWasSet(color);
                        }
                    }
                    else
                    {
                        ChromaLogger.Log($"Type [{type}] does not contain id [{id}].", IPA.Logging.Logger.Level.Warning);
                    }
                }

                LightColorManager.LightIDOverride = null;

                return(false);
            }

            // Legacy Prop Id stuff
            if (LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride != null)
            {
                ILightWithId[] lights = LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride;
                for (int i = 0; i < lights.Length; i++)
                {
                    lights[i].ColorWasSet(color);
                }

                LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride = null;

                return(false);
            }

            return(true);
        }
        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);
        }
Esempio n. 27
0
        internal static IEnumerator Routine(LightSwitchEventEffect lse, BeatmapEventType type, Color colourFrom, Color colourTo, float duration, float freq)
        {
            BloomPrePassLight[] lights = lse.GetField <BloomPrePassLight[]>("_lights");

            float time = 0;

            while (time < duration)
            {
                for (int i = 0; i < lights.Length; i++)
                {
                    lights[i].color = Color.Lerp(colourFrom, colourTo, time / duration);
                }
                yield return(new WaitForSeconds(freq));

                time += freq;
            }
            for (int i = 0; i < lights.Length; i++)
            {
                lights[i].color = colourTo;
            }
        }
Esempio n. 28
0
        public static LightPairRotationEffectController Create(LightPairRotationEventEffect baseEffect)
        {
            BeatmapEventType eventToggleRandomize = Helper.GetValue <BeatmapEventType>(baseEffect, "_switchOverrideRandomValuesEvent");
            BeatmapEventType eventL = Helper.GetValue <BeatmapEventType>(baseEffect, "_eventL");
            BeatmapEventType eventR = Helper.GetValue <BeatmapEventType>(baseEffect, "_eventR");

            bool  useZOffset   = Helper.GetValue <bool>(baseEffect, "_useZPositionForAngleOffset");
            float zOffsetScale = Helper.GetValue <float>(baseEffect, "_zPositionAngleOffsetScale");

            Vector3 rotationVector = Helper.GetValue <Vector3>(baseEffect, "_rotationVector");

            object baseRotationDataL = Helper.GetValue <object>(baseEffect, "_rotationDataL");
            object baseRotationDataR = Helper.GetValue <object>(baseEffect, "_rotationDataR");

            Transform  transformL          = Helper.GetValue <Transform>(baseRotationDataL, "transform");
            Quaternion startRotationL      = Helper.GetValue <Quaternion>(baseRotationDataL, "startRotation");
            float      startRotationAngleL = Helper.GetValue <float>(baseRotationDataL, "startRotationAngle");

            Transform  transformR          = Helper.GetValue <Transform>(baseRotationDataR, "transform");
            Quaternion startRotationR      = Helper.GetValue <Quaternion>(baseRotationDataR, "startRotation");
            float      startRotationAngleR = Helper.GetValue <float>(baseRotationDataR, "startRotationAngle");

            RotationData rotationDataL = new RotationData(transformL, startRotationL, startRotationAngleL);
            RotationData rotationDataR = new RotationData(transformR, startRotationR, startRotationAngleR);

            LightPairRotationEffectController controller = new GameObject("TwitchFXLightPairRotationEffectController").AddComponent <LightPairRotationEffectController>();

            controller.eventToggleRandomize = eventToggleRandomize;
            controller.eventL         = eventL;
            controller.eventR         = eventR;
            controller.transform      = baseEffect.transform;
            controller.useZOffset     = useZOffset;
            controller.zOffsetScale   = zOffsetScale;
            controller.rotationVector = rotationVector;
            controller.rotationL      = rotationDataL;
            controller.rotationR      = rotationDataR;

            return(controller);
        }
Esempio n. 29
0
        public CustomBeatmapEventData(
            float time,
            BeatmapEventType type,
            int value,
            Color?color,
            ColorGradient?colorGradient,
            float?direction,
            float?rotationSpeed,
            bool?rotationLockPosition,
            float?rotationStartPosition,
            string ringsNameFilter,

            bool?ringsCounterSpin,
            bool?ringsReset,
            float?ringsStep,
            float?ringsPropagationSpeed,
            float?ringsFlexySpeed,
            float?ringsStepMultiplier,
            float?ringsPropagationSpeedMultiplier,
            float?ringsFlexySpeedMultiplier
            ) : base(time, type, value)
        {
            this.color                           = color;
            this.colorGradient                   = colorGradient;
            this.direction                       = direction;
            this.rotationSpeed                   = rotationSpeed;
            this.rotationLockPosition            = rotationLockPosition;
            this.rotationStartPosition           = rotationStartPosition;
            this.ringsNameFilter                 = ringsNameFilter;
            this.ringsCounterSpin                = ringsCounterSpin;
            this.ringsReset                      = ringsReset;
            this.ringsStep                       = ringsStep;
            this.ringsPropagationSpeed           = ringsPropagationSpeed;
            this.ringsFlexySpeed                 = ringsFlexySpeed;
            this.ringsStepMultiplier             = ringsStepMultiplier;
            this.ringsPropagationSpeedMultiplier = ringsPropagationSpeedMultiplier;
            this.ringsFlexySpeedMultiplier       = ringsFlexySpeedMultiplier;
        }
Esempio n. 30
0
        private static bool Prefix(LightSwitchEventEffect __instance, BeatmapEventType ____event, Color color)
        {
            if (LightColorManager.LightIDOverride != null)
            {
                List <ILightWithId> lights = __instance.GetLights();
                int type = (int)____event;
                IEnumerable <int> newIds = LightColorManager.LightIDOverride.Select(n => LightIDTableManager.GetActiveTableValue(type, n) ?? n);
                foreach (int id in newIds)
                {
                    if (lights[id].isRegistered)
                    {
                        lights[id].ColorWasSet(color);
                    }
                }

                LightColorManager.LightIDOverride = null;

                return(false);
            }

            // Legacy Prop Id stuff
            if (LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride != null)
            {
                ILightWithId[] lights = LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride;
                for (int i = 0; i < lights.Length; i++)
                {
                    lights[i].ColorWasSet(color);
                }

                LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride = null;

                return(false);
            }

            return(true);
        }