예제 #1
0
        private void HandleObstacleDidStartMovementEvent(BeatmapObjectSpawnController obstacleSpawnController, ObstacleController obstacleController)
        {
            try {
                StretchableObstacle stretchableObstacle    = ReflectionUtil.GetField <StretchableObstacle>(obstacleController, "_stretchableObstacle");
                StretchableCube     stretchableCoreOutside = ReflectionUtil.GetField <StretchableCube>(stretchableObstacle, "_stretchableCoreOutside");
                StretchableCube     stretchableCoreInside  = ReflectionUtil.GetField <StretchableCube>(stretchableObstacle, "_stretchableCoreInside");
                bool didRecolour = VFX.VFXRainbowBarriers.IsRainbowWalls();

                ChromaHandleBarrierSpawnedEvent?.Invoke(ref stretchableObstacle, ref stretchableCoreOutside, ref stretchableCoreInside, ref obstacleSpawnController, ref obstacleController, ref didRecolour);

                if (!didRecolour)
                {
                    RecolourWall(stretchableCoreInside, obstacleController.obstacleData.time);
                    RecolourWall(stretchableCoreOutside, obstacleController.obstacleData.time);
                }
            } catch (Exception e) {
                ChromaLogger.Log(e);
            }
        }
예제 #2
0
 private static void SetupCombinedTechnicolourPalette()
 {
     if (_technicolourColdPalette == null || _technicolourWarmPalette == null)
     {
         return;
     }
     Color[] newCombined = new Color[_technicolourColdPalette.Length + _technicolourWarmPalette.Length];
     for (int i = 0; i < _technicolourColdPalette.Length; i++)
     {
         newCombined[i] = _technicolourColdPalette[i];
     }
     for (int i = 0; i < _technicolourWarmPalette.Length; i++)
     {
         newCombined[_technicolourColdPalette.Length + i] = _technicolourWarmPalette[i];
     }
     System.Random shuffleRandom = new System.Random();
     _technicolourCombinedPalette = newCombined.OrderBy(x => shuffleRandom.Next()).ToArray();
     ChromaLogger.Log("Combined TC Palette formed : " + _technicolourCombinedPalette.Length);
 }
예제 #3
0
        internal static ChromaBehaviour CreateNewInstance()
        {
            IsLoadingSong = true;
            ChromaLogger.Log("ChromaBehaviour attempting creation.", ChromaLogger.Level.DEBUG);
            ClearInstance();

            if (SceneUtils.IsTargetGameScene(SceneManager.GetActiveScene().buildIndex))
            {
                GameObject      instanceObject = new GameObject("ChromaBehaviour");
                ChromaBehaviour behaviour      = instanceObject.AddComponent <ChromaBehaviour>();
                _instance = behaviour;
                ChromaLogger.Log("ChromaBehaviour instantiated.", ChromaLogger.Level.DEBUG);
                return(behaviour);
            }
            else
            {
                ChromaLogger.Log("Invalid scene index.");
                return(null);
            }
        }
예제 #4
0
        public void OnUpdate()
        {
            if (doRefreshLights && SceneManager.GetActiveScene() != null && SceneManager.GetActiveScene().name == "MenuCore")
            {
                ColourManager.RefreshLights();
                doRefreshLights = false;
            }

            if (Input.GetKeyDown(KeyCode.Backslash))
            {
                ChromaConfig.LoadSettings(ChromaConfig.LoadSettingsType.MANUAL);
            }

            if (Input.GetKeyDown(KeyCode.Period) && ChromaConfig.DebugMode)
            {
                if (Input.GetKey(KeyCode.Alpha1))
                {
                    ColourManager.RecolourNeonSign(ColourManager.SignA, ColourManager.SignB);
                }
                else if (Input.GetKey(KeyCode.Alpha2))
                {
                    ColourManager.RefreshLights();
                }
                else if (Input.GetKey(KeyCode.Alpha3))
                {
                    ChromaTesting.Test();
                }
                else
                {
                    ChromaLogger.Log(" [[ Debug Info ]]");

                    if (ChromaConfig.TechnicolourEnabled)
                    {
                        ChromaLogger.Log("TechnicolourStyles (Lights | Walls | Notes | Sabers) : " + ChromaConfig.TechnicolourLightsStyle + " | " + ChromaConfig.TechnicolourWallsStyle + " | " + ChromaConfig.TechnicolourBlocksStyle + " | " + ChromaConfig.TechnicolourSabersStyle);
                        ChromaLogger.Log("Technicolour (Lights | Walls | Notes | Sabers) : " + ColourManager.TechnicolourLights + " | " + ColourManager.TechnicolourBarriers + " | " + ColourManager.TechnicolourBlocks + " | " + ColourManager.TechnicolourSabers);
                    }

                    DebugButtonPressedEvent?.Invoke();
                }
            }
        }
예제 #5
0
        public static void RefreshLights()
        {
            try {
                ChromaLogger.Log("Refreshing Lights");

                Color ambientLight = ColourManager.LightAmbient;
                Color red          = ColourManager.LightAmbient;
                Color blue         = ColourManager.LightAmbient;
                Color redLight     = ColourManager.LightAmbient;
                Color blueLight    = ColourManager.LightAmbient;
                Color platform     = ColourManager.LightAmbient;
                Color signA        = ColourManager.LightAmbient;
                Color signB        = ColourManager.LightAmbient;
                Color laser        = ColourManager.LaserPointerColour;

                string ambientSound = null;

                RefreshLightsEvent?.Invoke(ref ambientLight, ref red, ref blue, ref redLight, ref blueLight, ref platform, ref signA, ref signB, ref laser, ref ambientSound);

                //ColourManager.RecolourAllLights(ColourManager.LightA, ColourManager.LightB);
                ResetAllLights();
                ColourManager.RecolourAmbientLights(ambientLight);
                if (!SceneUtils.IsTargetGameScene(SceneManager.GetActiveScene()))
                {
                    ColourManager.RecolourNeonSign(signA, signB);
                    ColourManager.RecolourMenuStuff(red, blue, redLight, blueLight, platform, laser);
                }

                if (ambientSound == null)
                {
                    AudioUtil.Instance.StopAmbianceSound();
                }
                else
                {
                    AudioUtil.Instance.StartAmbianceSound(ambientSound);
                }
            } catch (Exception e) {
                ChromaLogger.Log("Error refreshing lights!");
                ChromaLogger.Log(e, ChromaLogger.Level.WARNING);
            }
        }
예제 #6
0
        internal GameObjectInfo(GameObject gameObject)
        {
            List <string> nameList = new List <string>();

            Transform transform = gameObject.transform;

            while (true)
            {
                int index;
                if (transform.parent != null)
                {
                    index = transform.GetSiblingIndex();
                }
                else
                {
                    // Why doesnt GetSiblingIndex work on root objects?
                    GameObject[] rootGameObjects = transform.gameObject.scene.GetRootGameObjects();
                    index = Array.IndexOf(rootGameObjects, transform.gameObject);
                }

                nameList.Add($"[{index}]{transform.name}");

                if (transform.parent == null)
                {
                    break;
                }

                transform = transform.parent;
            }

            nameList.Add($"{gameObject.scene.name}");
            nameList.Reverse();

            FullID = string.Join(".", nameList);
            if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
            {
                ChromaLogger.Log(FullID);
            }

            GameObject = gameObject;
        }
예제 #7
0
        private void HandleObstacleDidStartMovementEvent(BeatmapObjectSpawnController obstacleSpawnController, ObstacleController obstacleController)
        {
            try {
                StretchableObstacle             stretchableObstacle = ReflectionUtil.GetField <StretchableObstacle>(obstacleController, "_stretchableObstacle");
                StretchableCube                 stretchableCore     = ReflectionUtil.GetField <StretchableCube>(stretchableObstacle, "_stretchableCore");
                ParametricBoxFrameController    frameController     = ReflectionUtil.GetField <ParametricBoxFrameController>(stretchableObstacle, "_obstacleFrame");
                ParametricBoxFakeGlowController fakeGlowController  = ReflectionUtil.GetField <ParametricBoxFakeGlowController>(stretchableObstacle, "_obstacleFakeGlow");
                float time  = obstacleController.obstacleData.time;
                Color color = ColourManager.GetBarrierColour(time);
                frameController.color    = color;
                fakeGlowController.color = color;
                bool didRecolour = VFX.VFXRainbowBarriers.IsRainbowWalls();

                ChromaHandleBarrierSpawnedEvent?.Invoke(ref stretchableObstacle, ref obstacleSpawnController, ref obstacleController, ref didRecolour);

                if (!didRecolour && color != ColourManager.DefaultBarrierColour && color != Color.clear)
                {
                    RecolourWall(stretchableCore, ColourManager.GetCorrectedBarrierColour(time));
                }
            } catch (Exception e) {
                ChromaLogger.Log(e);
            }
        }
예제 #8
0
        internal static void Init(CustomBeatmapData customBeatmap)
        {
            dynamic       dynData       = customBeatmap.beatmapCustomData;
            List <object> objectsToKill = Trees.at(dynData, ENVIRONMENTREMOVAL);

            if (objectsToKill != null)
            {
                ChromaLogger.Log("Legacy Environment Removal Detected...", IPA.Logging.Logger.Level.Warning);
                ChromaLogger.Log("Please do not use Legacy Environment Removal for new maps as it is deprecated and its functionality in future versions of Chroma cannot be guaranteed", IPA.Logging.Logger.Level.Warning);

                IEnumerable <GameObject> gameObjects = Resources.FindObjectsOfTypeAll <GameObject>();
                foreach (string s in objectsToKill.Cast <string>())
                {
                    if (s == "TrackLaneRing" || s == "BigTrackLaneRing")
                    {
                        foreach (GameObject n in gameObjects.Where(obj => obj.name.Contains(s)))
                        {
                            if (s == "TrackLaneRing" && n.name.Contains("Big"))
                            {
                                continue;
                            }

                            n.SetActive(false);
                        }
                    }
                    else
                    {
                        foreach (GameObject n in gameObjects
                                 .Where(obj => obj.name.Contains(s) && (obj.scene.name?.Contains("Environment") ?? false) && (!obj.scene.name?.Contains("Menu") ?? false)))
                        {
                            n.SetActive(false);
                        }
                    }
                }
            }
        }
예제 #9
0
        private void Initialize()
        {
            try {
                try {
                    Directory.CreateDirectory(Environment.CurrentDirectory.Replace('\\', '/') + "/UserData/Chroma");
                } catch (Exception e) {
                    ChromaLogger.Log("Error " + e.Message + " while trying to create Chroma directory", ChromaLogger.Level.WARNING);
                }

                ChromaLogger.Init();

                ChromaLogger.Log("************************************", ChromaLogger.Level.INFO);
                ChromaLogger.Log("Initializing Chroma [" + ChromaPlugin.Version.ToString() + "]", ChromaLogger.Level.INFO);
                ChromaLogger.Log("************************************", ChromaLogger.Level.INFO);

                //Used for getting gamemode data mostly
                try {
                    ChromaLogger.Log("Initializing Coordinators");
                    BaseGameMode.InitializeCoordinators();
                } catch (Exception e) {
                    ChromaLogger.Log("Error initializing coordinators", ChromaLogger.Level.ERROR);
                    throw e;
                }

                ChromaLogger.Log("Registering scenechange events");
                SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
                SceneManager.sceneLoaded        += SceneManager_sceneLoaded;

                //Getting and starting all the extension plugins
                try {
                    ChromaLogger.Log("Checking for extensions.");
                    foreach (PluginLoader.PluginInfo pluginInfo in PluginManager.AllPlugins)
                    {
                        //We can't get IBeatSaberPlugin references

                        /*if (plugin is IChromaExtension chromaExtension) {
                         *  chromaExtension.ChromaApplicationStarted(this);
                         *  chromaExtensions.Add(chromaExtension);
                         * }*/
                    }
                } catch (Exception) {
                    ChromaLogger.Log("Error adding all Extension plugins!  Extension registration interrupted.", ChromaLogger.Level.ERROR);
                }

                //Harmony & extension Harmony patches
                ChromaLogger.Log("Patching with Harmony.");
                try {
                    coreHarmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
                    harmonyInstances.Add(coreHarmony);
                    foreach (IChromaExtension extension in chromaExtensions)
                    {
                        HarmonyInstance newPatch = extension.PatchHarmony();
                        if (newPatch != null)
                        {
                            harmonyInstances.Add(newPatch);
                        }
                    }
                } catch (Exception e) {
                    ChromaLogger.Log(e);
                    ChromaLogger.Log("This plugin requires Harmony.  Either you do not have it installed, or there was an error.", ChromaLogger.Level.ERROR);
                }

                ChromaLogger.Log("Creating AudioUtil");
                AudioUtil ab = AudioUtil.Instance;

                //Configuration Files
                try {
                    ChromaLogger.Log("Initializing Configuration");
                    ChromaConfig.Init();
                    ChromaConfig.LoadSettings(ChromaConfig.LoadSettingsType.INITIAL);
                } catch (Exception e) {
                    ChromaLogger.Log("Error loading Chroma configuration", ChromaLogger.Level.ERROR);
                    throw e;
                }

                ChromaLogger.Log("Refreshing Lights");
                ColourManager.RefreshLights();

                //Side panel
                try {
                    ChromaLogger.Log("Stealing Patch Notes Panel");
                    Greetings.RegisterChromaSideMenu();
                    SidePanelUtil.ReleaseInfoEnabledEvent += ReleaseInfoEnabled;
                } catch (Exception e) {
                    ChromaLogger.Log("Error handling UI side panel", ChromaLogger.Level.ERROR);
                    throw e;
                }
            } catch (Exception e) {
                ChromaLogger.Log("Failed to initialize ChromaPlugin!  Major error!", ChromaLogger.Level.ERROR);
                ChromaLogger.Log(e);
            }

            ChromaLogger.Log("Chroma finished initializing.  " + chromaExtensions.Count + " extensions found.", ChromaLogger.Level.INFO);

            try {
                SongCore.Collections.RegisterCapability("Chroma");
                SongCore.Collections.RegisterCapability("ChromaLite");
            } catch (Exception) {
                // This version of SongLoader doesn't support capabilities
            }
        }
예제 #10
0
        internal static void Init(CustomBeatmapData customBeatmapData, float noteLinesDistance)
        {
            List <dynamic> environmentData = Trees.at(customBeatmapData.customData, ENVIRONMENT);

            GetAllGameObjects();
            if (environmentData != null)
            {
                RingRotationOffsets.Clear();
                ParametricBoxControllerParameters.TransformParameters.Clear();

                if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                {
                    ChromaLogger.Log($"=====================================");
                }

                foreach (dynamic gameObjectData in environmentData)
                {
                    string id = Trees.at(gameObjectData, ID);

                    string       lookupString = Trees.at(gameObjectData, LOOKUPMETHOD);
                    LookupMethod lookupMethod = (LookupMethod)Enum.Parse(typeof(LookupMethod), lookupString);

                    int?dupeAmount = (int?)Trees.at(gameObjectData, DUPLICATIONAMOUNT);

                    bool?active = (bool?)Trees.at(gameObjectData, ACTIVE);

                    Vector3?scale         = GetVectorData(gameObjectData, SCALE);
                    Vector3?position      = GetVectorData(gameObjectData, POSITION);
                    Vector3?rotation      = GetVectorData(gameObjectData, OBJECTROTATION);
                    Vector3?localPosition = GetVectorData(gameObjectData, LOCALPOSITION);
                    Vector3?localRotation = GetVectorData(gameObjectData, LOCALROTATION);

                    List <GameObjectInfo> foundObjects = LookupID(id, lookupMethod);
                    if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                    {
                        ChromaLogger.Log($"ID [\"{id}\"] using method [{lookupMethod:G}] found:");
                        foundObjects.ForEach(n => ChromaLogger.Log(n.FullID));
                    }

                    List <GameObjectInfo> gameObjectInfos;

                    if (dupeAmount.HasValue)
                    {
                        gameObjectInfos = new List <GameObjectInfo>();
                        foreach (GameObjectInfo gameObjectInfo in foundObjects)
                        {
                            if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                            {
                                ChromaLogger.Log($"Duplicating [{gameObjectInfo.FullID}]:");
                            }

                            GameObject gameObject = gameObjectInfo.GameObject;
                            Transform  parent     = gameObject.transform.parent;
                            Scene      scene      = gameObject.scene;

                            for (int i = 0; i < dupeAmount.Value; i++)
                            {
                                List <IComponentData> componentDatas = new List <IComponentData>();
                                ComponentInitializer.PrefillComponentsData(gameObject.transform, componentDatas);
                                GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject);
                                ComponentInitializer.PostfillComponentsData(newGameObject.transform, gameObject.transform, componentDatas);
                                SceneManager.MoveGameObjectToScene(newGameObject, scene);
                                newGameObject.transform.SetParent(parent, true);
                                ComponentInitializer.InitializeComponents(newGameObject.transform, gameObject.transform, _gameObjectInfos, componentDatas);
                                gameObjectInfos.AddRange(_gameObjectInfos.Where(n => n.GameObject == newGameObject));
                            }
                        }
                    }
                    else
                    {
                        gameObjectInfos = foundObjects;
                    }

                    foreach (GameObjectInfo gameObjectInfo in gameObjectInfos)
                    {
                        GameObject gameObject = gameObjectInfo.GameObject;

                        if (active.HasValue)
                        {
                            gameObjectInfo.GameObject.SetActive(active.Value);
                        }

                        Transform transform = gameObject.transform;

                        if (scale.HasValue)
                        {
                            transform.localScale = scale.Value;
                        }

                        if (position.HasValue)
                        {
                            transform.position = position.Value * noteLinesDistance;
                        }

                        if (rotation.HasValue)
                        {
                            transform.eulerAngles = rotation.Value;
                        }

                        if (localPosition.HasValue)
                        {
                            transform.localPosition = localPosition.Value * noteLinesDistance;
                        }

                        if (localRotation.HasValue)
                        {
                            transform.localEulerAngles = localRotation.Value;
                        }

                        // Handle TrackLaneRing
                        TrackLaneRing trackLaneRing = gameObject.GetComponent <TrackLaneRing>();
                        if (trackLaneRing != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                _positionOffsetAccessor(ref trackLaneRing) = transform.localPosition;
                                _posZAccessor(ref trackLaneRing) = 0;
                            }

                            if (rotation.HasValue || localRotation.HasValue)
                            {
                                RingRotationOffsets[trackLaneRing] = transform.localRotation;
                                _rotZAccessor(ref trackLaneRing) = 0;
                            }
                        }

                        // Handle ParametricBoxController
                        ParametricBoxController parametricBoxController = gameObject.GetComponent <ParametricBoxController>();
                        if (parametricBoxController != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                ParametricBoxControllerParameters.SetTransformPosition(parametricBoxController, transform.localPosition);
                            }

                            if (scale.HasValue)
                            {
                                ParametricBoxControllerParameters.SetTransformScale(parametricBoxController, transform.localScale);
                            }
                        }

                        if (NoodleExtensionsInstalled)
                        {
                            GameObjectTrackController.HandleTrackData(gameObject, gameObjectData, customBeatmapData, noteLinesDistance, trackLaneRing, parametricBoxController);
                        }
                    }

                    if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                    {
                        ChromaLogger.Log($"=====================================");
                    }
                }
            }

            LegacyEnvironmentRemoval.Init(customBeatmapData);
        }
예제 #11
0
        public static void RecolourNeonSign(Color colorA, Color colorB)
        {
            TubeBloomPrePassLight[] _prePassLights = UnityEngine.Object.FindObjectsOfType <TubeBloomPrePassLight>();

            foreach (var prePassLight in _prePassLights)
            {
                if (prePassLight != null)
                {
                    if (prePassLight.name.Contains("NeonLight (6)"))
                    {
                        if (colorA != Color.clear)
                        {
                            prePassLight.color = colorA;
                        }
                    }
                    if (prePassLight.name.Contains("NeonLight (8)"))
                    {
                        if (prePassLight.gameObject.transform.position.ToString() == "(0.0, 17.2, 24.8)")
                        {
                            if (colorA != Color.clear)
                            {
                                prePassLight.color = colorA;
                            }
                        }
                    }
                    if (prePassLight.name.Contains("BATNeon") || prePassLight.name.Contains("ENeon"))
                    {
                        if (colorB != Color.clear)
                        {
                            prePassLight.color = colorB;
                        }
                    }

                    //    Log($"PrepassLight: {prePassLight.name}");
                }
            }

            SpriteRenderer[] sprites = Resources.FindObjectsOfTypeAll <SpriteRenderer>();
            foreach (SpriteRenderer sprite in sprites)
            {
                if (sprite != null)
                {
                    if (sprite.name == "LogoSABER")
                    {
                        if (colorA != Color.clear)
                        {
                            sprite.color = colorA;
                        }
                    }
                    if (sprite.name == "LogoBAT" || sprite.name == "LogoE")
                    {
                        if (colorB != Color.clear)
                        {
                            sprite.color = colorB;
                        }
                    }
                }
            }

            TextMeshPro[] tmps = GameObject.FindObjectsOfType <TextMeshPro>();
            foreach (TextMeshPro tmp in tmps)
            {
                if (tmp.gameObject.name == "CustomMenuText")
                {
                    if (colorB != Color.clear)
                    {
                        tmp.color = colorB;
                    }
                }
                else if (tmp.gameObject.name == "CustomMenuText-Bot")
                {
                    if (colorA != Color.clear)
                    {
                        tmp.color = colorA;
                    }
                }
            }

            ChromaLogger.Log("Sign recoloured A:" + colorA.ToString() + " B:" + colorB.ToString());
        }
        internal static void Init(CustomBeatmapData customBeatmapData, float noteLinesDistance)
        {
            List <dynamic> environmentData = Trees.at(customBeatmapData.customData, "_environment");

            GetAllGameObjects();
            if (environmentData != null)
            {
                SkipRingUpdate = new Dictionary <TrackLaneRing, bool>();

                foreach (dynamic gameObjectData in environmentData)
                {
                    string id = Trees.at(gameObjectData, "_id");

                    string       lookupString = Trees.at(gameObjectData, "_lookupMethod");
                    LookupMethod lookupMethod = (LookupMethod)Enum.Parse(typeof(LookupMethod), lookupString);

                    bool hide = ((bool?)Trees.at(gameObjectData, "_hide")).GetValueOrDefault(false);

                    Vector3?scale         = GetVectorData(gameObjectData, "_scale");
                    Vector3?position      = GetVectorData(gameObjectData, "_position");
                    Vector3?rotation      = GetVectorData(gameObjectData, "_rotation");
                    Vector3?localPosition = GetVectorData(gameObjectData, "_localPosition");
                    Vector3?localRotation = GetVectorData(gameObjectData, "_localRotation");

                    List <GameObjectInfo> foundObjects = LookupID(id, lookupMethod);
                    foreach (GameObjectInfo gameObjectInfo in foundObjects)
                    {
                        GameObject gameObject = gameObjectInfo.GameObject;

                        if (hide)
                        {
                            gameObjectInfo.GameObject.SetActive(false);
                        }

                        Transform transform = gameObject.transform;

                        if (scale.HasValue)
                        {
                            transform.localScale = scale.Value;
                        }

                        if (position.HasValue)
                        {
                            transform.position = position.Value * noteLinesDistance;
                        }

                        if (rotation.HasValue)
                        {
                            transform.eulerAngles = rotation.Value;
                        }

                        if (localPosition.HasValue)
                        {
                            transform.localPosition = localPosition.Value * noteLinesDistance;
                        }

                        if (localRotation.HasValue)
                        {
                            transform.localEulerAngles = localRotation.Value;
                        }

                        // Handle TrackLaneRing
                        TrackLaneRing trackLaneRing = gameObject.GetComponent <TrackLaneRing>();
                        if (trackLaneRing != null)
                        {
                            if (position.HasValue || localPosition.HasValue)
                            {
                                _positionOffsetAccessor(ref trackLaneRing) = transform.position;
                                float zPosition = transform.position.z;
                                _prevPosZAccessor(ref trackLaneRing) = zPosition;
                                _posZAccessor(ref trackLaneRing)     = zPosition;
                            }

                            if (rotation.HasValue || localRotation.HasValue)
                            {
                                float zRotation = transform.rotation.z;
                                _prevRotZAccessor(ref trackLaneRing) = zRotation;
                                _rotZAccessor(ref trackLaneRing)     = zRotation;
                            }
                        }

                        if (Plugin.NoodleExtensionsInstalled && NoodleController.NoodleExtensionsActive)
                        {
                            GameObjectTrackController.HandleTrackData(gameObject, gameObjectData, customBeatmapData, noteLinesDistance, trackLaneRing);
                        }
                    }

                    if (Settings.ChromaConfig.Instance.PrintEnvironmentEnhancementDebug)
                    {
                        ChromaLogger.Log($"ID [\"{id}\"] using method [{lookupMethod.ToString("G")}] found:");
                        foundObjects.ForEach(n => ChromaLogger.Log(n.FullID));
                        ChromaLogger.Log($"=====================================");
                    }
                }
            }

            LegacyEnvironmentRemoval.Init(customBeatmapData);
        }
예제 #13
0
        private void GCSSFound(Scene scene, GameplayCoreSceneSetup gcss)
        {
            ChromaLogger.Log("Found GCSS!", ChromaLogger.Level.DEBUG);
            //Plugin.PlayReloadSound();

            _playerController = FindObjectOfType <PlayerController>();
            if (_playerController == null)
            {
                ChromaLogger.Log("Player Controller not found!", ChromaLogger.Level.WARNING);
            }

            /*if (!SceneUtils.IsTargetGameScene(scene.buildIndex)) {
             *  ChromaLogger.Log("Somehow we got to the point where we override a map, while not playing a map.  How did this happen?", ChromaLogger.Level.WARNING);
             *  return;
             * }*/

            if (gcss == null)
            {
                ChromaLogger.Log("Failed to obtain MainGameSceneSetup", ChromaLogger.Level.WARNING);
                return;
            }

            //GameplayCoreSetupData mgData = ReflectionUtil.GetPrivateField<MainGameSceneSetupData>(mgs, "_mainGameSceneSetupData");
            BS_Utils.Gameplay.LevelData levelData = BS_Utils.Plugin.LevelData;
            if (!levelData.IsSet)
            {
                ChromaLogger.Log("BS_Utils LevelData is not set", ChromaLogger.Level.WARNING);
                return;
            }
            PlayerSpecificSettings playerSettings = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.playerSpecificSettings;

            //Map

            BeatmapDataModel _beatmapDataModel = ReflectionUtil.GetField <BeatmapDataModel>(gcss, "_beatmapDataModel");

            if (_beatmapDataModel == null)
            {
                ChromaLogger.Log("{XXX} : NULL BEATMAP DATA MODEL", ChromaLogger.Level.ERROR);
            }
            if (_beatmapDataModel.beatmapData == null)
            {
                ChromaLogger.Log("{XXX} : NULL BEATMAP DATA MODEL BEATMAP DATA", ChromaLogger.Level.ERROR);
            }
            //BeatmapData beatmapData = CreateTransformedBeatmapData(mgData.difficultyLevel.beatmapData, mgData.gameplayOptions, mgData.gameplayMode);
            BeatmapData beatmapData = CreateTransformedBeatmapData(_beatmapDataModel.beatmapData, playerSettings, BaseGameMode.CurrentBaseGameMode);

            if (beatmapData != null)
            {
                _beatmapDataModel.beatmapData = beatmapData;
                ReflectionUtil.SetField(gcss, "_beatmapDataModel", _beatmapDataModel);
            }

            foreach (IChromaBehaviourExtension extension in extensions)
            {
                extension.PostInitialization(songBPM, beatmapData, playerSettings, scoreController);
            }

            //modes = GetModes(mgData.gameplayMode, chromaSong);

            if (ChromaConfig.DebugMode)
            {
                Console.WriteLine();
                Console.WriteLine();
                ChromaLogger.Log("Gamemode: " + BaseGameMode.CurrentBaseGameMode.ToString() + " -- Party: " + BaseGameMode.PartyMode, ChromaLogger.Level.DEBUG);
            }

            //ChromaLogger.Log("Modify Sabers was called", ChromaLogger.Level.DEBUG);

            ColourManager.RefreshLights();

            if (ChromaConfig.LightshowModifier)
            {
                foreach (Saber saber in GameObject.FindObjectsOfType <Saber>())
                {
                    saber.gameObject.SetActive(false);
                }
            }
        }
예제 #14
0
        /*public static void RecolourLight(ref LightSwitchEventEffect obj, Color red, Color blue) {
         *  if (obj.name.Contains("nightmare")) return;
         *  string[] sa = new string[] { "_lightColor0", "_highlightColor0", "_lightColor1", "_highlightColor1" };
         *
         *  for (int i = 0; i < sa.Length; i++) {
         *      string s = sa[i];
         *
         *      SimpleColorSO baseSO = SetupNewLightColourSOs(obj, s);
         *
         *      Color newColour = i < sa.Length / 2 ? blue : red;
         *      if (newColour == Color.clear) continue;
         *
         *      baseSO.SetColor(newColour);
         *  }
         * }*/

        public static void RecolourMenuStuff(Color red, Color blue, Color redLight, Color blueLight, Color platformLight, Color laser)
        {
            Renderer[] rends2 = GameObject.FindObjectsOfType <Renderer>();

            foreach (Renderer rend in rends2)
            {
                if (rend.name.Contains("Laser") && laser != Color.clear)
                {
                    rend.material.color = laser;
                    if (rend.material.HasProperty("_color"))
                    {
                        rend.material.SetColor("_color", laser);
                    }
                    if (rend.material.HasProperty("_Color"))
                    {
                        rend.material.SetColor("_Color", laser);
                    }
                }
                if (rend.name.Contains("Glow") && platformLight != Color.clear)
                {
                    rend.material.color = platformLight;
                    if (rend.material.HasProperty("_color"))
                    {
                        rend.material.SetColor("_color", platformLight);
                    }
                    if (rend.material.HasProperty("_Color"))
                    {
                        rend.material.SetColor("_Color", platformLight);
                    }
                }
                if (rend.name.Contains("Feet") && platformLight != Color.clear)
                {
                    rend.material.color = platformLight;
                    if (rend.material.HasProperty("_color"))
                    {
                        rend.material.SetColor("_color", platformLight);
                    }
                    if (rend.material.HasProperty("_Color"))
                    {
                        rend.material.SetColor("_Color", platformLight);
                    }
                }

                /*if (rend.name.Contains("Neon")) {
                 *  rend.material.color = blue;
                 *  if (rend.material.HasProperty("_color")) rend.material.SetColor("_color", blue);
                 *  if (rend.material.HasProperty("_Color")) rend.material.SetColor("_Color", blue);
                 * }
                 * if (rend.name.Contains("Border")) {
                 *  rend.material.color = blue;
                 *  if (rend.material.HasProperty("_color")) rend.material.SetColor("_color", blueLight);
                 *  if (rend.material.HasProperty("_Color")) rend.material.SetColor("_Color", blueLight);
                 * }*/
                /*if (rend.name.Contains("Light")) {
                 *  rend.material.color = blue;
                 *  if (rend.material.HasProperty("_color")) rend.material.SetColor("_color", blue);
                 *  if (rend.material.HasProperty("_Color")) rend.material.SetColor("_Color", blue);
                 * }*/
                if (rend.name.Contains("VRCursor") && ColourManager.LaserPointerColour != Color.clear)
                {
                    rend.material.color = ColourManager.LaserPointerColour;
                    if (rend.material.HasProperty("_color"))
                    {
                        rend.material.SetColor("_color", ColourManager.LaserPointerColour);
                    }
                    if (rend.material.HasProperty("_Color"))
                    {
                        rend.material.SetColor("_Color", ColourManager.LaserPointerColour);
                    }
                }
                if (rend.name.Contains("Frame") && platformLight != Color.clear)
                {
                    rend.material.color = platformLight;
                    if (rend.material.HasProperty("_color"))
                    {
                        rend.material.SetColor("_color", platformLight);
                    }
                    if (rend.material.HasProperty("_Color"))
                    {
                        rend.material.SetColor("_Color", platformLight);
                    }
                }

                /*ChromaLogger.Log(rend.gameObject.name + " ::: " + rend.name.ToString());
                 * if (rend.materials.Length > 0) {
                 *  if (Vector3.Distance(rend.transform.position, Vector3.zero) < 4f) {
                 *      foreach (Material m in rend.materials) {
                 *          ChromaLogger.Log("___" + m.name);
                 *      }
                 *  }
                 * }*/
            }

            ChromaLogger.Log("Colourizing menustuff");
        }
예제 #15
0
        internal static void InitializeComponents(Transform root, Transform original, List <GameObjectInfo> gameObjectInfos, List <IComponentData> componentDatas)
        {
            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)
                    {
                        ChromaLogger.Log($"Initialized {typeof(T).Name}");
                    }
                }
            }

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

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

            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);
            }
        }