internal override void PerformOp(OpContext context) { var colorManager = context.Manager.MassFirstOrDefaultAsset <ColorManager>(x => true, false)?.Object; if (colorManager == null) { Log.LogErr($"ChangeColorOp could not get the ColorManager class from assets!"); throw new Exception("Unable to find the color manager asset!"); } SimpleColorSO color = null; switch (_colorType) { case ColorType.LeftColor: color = colorManager.ColorA.Object; break; case ColorType.RightColor: color = colorManager.ColorB.Object; break; } if (color == null) { Log.LogErr($"Color type {_colorType} not found!"); throw new Exception($"Color type {_colorType} not found!"); } color.Color.A = (float)_color.A / (float)255; color.Color.R = (float)_color.R / (float)255; color.Color.G = (float)_color.G / (float)255; color.Color.B = (float)_color.B / (float)255; color.ObjectInfo.ParentFile.HasChanges = true; }
public static SimpleColorSO SetupNewLightColourSOs(MonoBehaviour light, String s, Color overrideMultiplierColour) { MultipliedColorSO mColorSO = light.GetField <MultipliedColorSO>(s); SimpleColorSO baseSO = mColorSO.GetField <SimpleColorSO>("_baseColor"); SimpleColorSO newBaseSO = ScriptableObject.CreateInstance <SimpleColorSO>();// new SimpleColorSO(); newBaseSO.SetColor(baseSO.color); MultipliedColorSO newMColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); if (overrideMultiplierColour == Color.clear) { newMColorSO.SetField("_multiplierColor", mColorSO.GetField <Color>("_multiplierColor")); } else { newMColorSO.SetField("_multiplierColor", overrideMultiplierColour); } newMColorSO.SetField("_baseColor", newBaseSO); light.SetField(s, newMColorSO); if (!light.name.Contains("chroma")) { light.name = light.name + "_chroma"; } return(newBaseSO); }
private void InitializeSO(string id, int index) { LightSwitchEventEffect lightSwitchEventEffect = _lightSwitchEventEffect; FieldAccessor <LightSwitchEventEffect, ColorSO> .Accessor colorSOAcessor = FieldAccessor <LightSwitchEventEffect, ColorSO> .GetAccessor(id); MultipliedColorSO lightMultSO = (MultipliedColorSO)colorSOAcessor(ref lightSwitchEventEffect); Color multiplierColor = _multiplierColorAccessor(ref lightMultSO); SimpleColorSO lightSO = _baseColorAccessor(ref lightMultSO); _originalColors[index] = lightSO.color; MultipliedColorSO mColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); _multiplierColorAccessor(ref mColorSO) = multiplierColor; SimpleColorSO sColorSO; if (_simpleColorSOs[index] == null) { sColorSO = ScriptableObject.CreateInstance <SimpleColorSO>(); sColorSO.SetColor(lightSO.color); _simpleColorSOs[index] = sColorSO; } else { sColorSO = _simpleColorSOs[index]; } _baseColorAccessor(ref mColorSO) = sColorSO; colorSOAcessor(ref lightSwitchEventEffect) = mColorSO; }
public static ColorSO GetCSO(Color color) { SimpleColorSO so = ScriptableObject.CreateInstance(typeof(SimpleColorSO)) as SimpleColorSO; so.SetColor(color); return(so); }
private static MultipliedColorSO CreateMultipliedColorSO(SimpleColorSO simpleColor, Color color) { MultipliedColorSO multipliedColor = ScriptableObject.CreateInstance <MultipliedColorSO>(); _baseColorAccessor(ref multipliedColor) = simpleColor; _multiplierColorAccessor(ref multipliedColor) = color; return(multipliedColor); }
private static MultipliedColorSO CreateMultipliedColorSO(SimpleColorSO simpleColor, Color color) { MultipliedColorSO multipliedColor = ScriptableObject.CreateInstance <MultipliedColorSO>(); multipliedColor.SetField("_baseColor", simpleColor); multipliedColor.SetField("_multiplierColor", color); return(multipliedColor); }
private OCColorManager(ObstacleController oc) { _oc = oc; _stretchableObstacle = _stretchableObstacleAccessor(ref _oc); _color_Original = oc.GetField <SimpleColorSO, ObstacleController>("_color").color; if (_color == null) { _color = ScriptableObject.CreateInstance <SimpleColorSO>(); _color.SetColor(_color_Original); } oc.SetField("_color", _color); }
public static void RecolourLight(ref MonoBehaviour obj, Color red, Color blue) { 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 void SetSongColors(Color colorLeft, Color colorRight, bool hasColors) { if (!hasColors) { return; } EnvironmentColorsSetter colorSetter = new GameObject("SongLoader Color Setter").AddComponent <EnvironmentColorsSetter>(); var scriptableColors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); SimpleColorSO[] A = new SimpleColorSO[2]; SimpleColorSO[] B = new SimpleColorSO[2]; foreach (var color in scriptableColors) { int i = 0; if (color.name == "Color0") { B[0] = color; i++; } else if (color.name == "BaseColor0") { A[0] = color; i++; } else if (color.name == "Color1") { A[1] = color; i++; } else if (color.name == "BaseColor1") { B[1] = color; i++; } } colorSetter.SetPrivateField("_colorsA", A); colorSetter.SetPrivateField("_colorsB", B); colorSetter.SetPrivateField("_colorManager", Resources.FindObjectsOfTypeAll <ColorManager>().First()); colorSetter.SetPrivateField("_overrideColorA", colorRight); colorSetter.SetPrivateField("_overrideColorB", colorLeft); colorSetter.Awake(); }
//We still need to do the first half of this even if the LSECM already exists as custom map colours exist and we need to be able to know the default colour private void InitializeSOs(LightSwitchEventEffect lse, string id, ref SimpleColorSO sColorSO, ref Color originalColour, ref MultipliedColorSO mColorSO) { MultipliedColorSO lightMultSO = lse.GetField <MultipliedColorSO>(id); Color multiplierColour = lightMultSO.GetField <Color>("_multiplierColor"); SimpleColorSO lightSO = lightMultSO.GetField <SimpleColorSO>("_baseColor"); originalColour = lightSO.color; if (mColorSO == null) { mColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); mColorSO.SetField("_multiplierColor", multiplierColour); sColorSO = ScriptableObject.CreateInstance <SimpleColorSO>(); sColorSO.SetColor(originalColour); mColorSO.SetField("_baseColor", sColorSO); } lse.SetField(id, mColorSO); }
private void InitializeSOs(MonoBehaviour lse, string id, ref SimpleColorSO sColorSO, ref Color originalColor, ref MultipliedColorSO mColorSO) { MultipliedColorSO lightMultSO = null; if (lse is LightSwitchEventEffect l1) { lightMultSO = (MultipliedColorSO)l1.GetField <ColorSO, LightSwitchEventEffect>(id); } else if (lse is ParticleSystemEventEffect p1) { lightMultSO = (MultipliedColorSO)p1.GetField <ColorSO, ParticleSystemEventEffect>(id); } Color multiplierColor = lightMultSO.GetField <Color, MultipliedColorSO>("_multiplierColor"); SimpleColorSO lightSO = lightMultSO.GetField <SimpleColorSO, MultipliedColorSO>("_baseColor"); originalColor = lightSO.color; if (mColorSO == null) { mColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); mColorSO.SetField("_multiplierColor", multiplierColor); if (sColorSO == null) { sColorSO = ScriptableObject.CreateInstance <SimpleColorSO>(); sColorSO.SetColor(originalColor); } mColorSO.SetField("_baseColor", sColorSO); } if (lse is LightSwitchEventEffect l2) { l2.SetField <LightSwitchEventEffect, ColorSO>(id, mColorSO); } else if (lse is ParticleSystemEventEffect p2) { p2.SetField <ParticleSystemEventEffect, ColorSO>(id, mColorSO); } }
private void InitializeSO(string id, int index, bool highlight = false) { ParticleSystemEventEffect particleSystemEventEffect = _particleSystemEventEffect; FieldAccessor <ParticleSystemEventEffect, ColorSO> .Accessor colorSOAcessor = FieldAccessor <ParticleSystemEventEffect, ColorSO> .GetAccessor(id); MultipliedColorSO lightMultSO = (MultipliedColorSO)colorSOAcessor(ref particleSystemEventEffect); Color multiplierColor = _multiplierColorAccessor(ref lightMultSO); SimpleColorSO lightSO = _baseColorAccessor(ref lightMultSO); MultipliedColorSO mColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); _multiplierColorAccessor(ref mColorSO) = multiplierColor; SimpleColorSO sColorSO; if (_simpleColorSOs[index] == null) { sColorSO = ScriptableObject.CreateInstance <SimpleColorSO>(); sColorSO.SetColor(lightSO.color); _simpleColorSOs[index] = sColorSO; } else { sColorSO = _simpleColorSOs[index]; } _baseColorAccessor(ref mColorSO) = sColorSO; if (highlight) { _multipliedHighlightColorSOs[index] = mColorSO; } else { _multipliedColorSOs[index] = mColorSO; } colorSOAcessor(ref particleSystemEventEffect) = mColorSO; }
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 void OpenCampaign(Campaign campaign) { try { unlockAllMissions = campaign.info.allUnlocked; if (campaign.background == null) { _backgroundImage.color = new Color(1, 1, 1, 0); } else { _backgroundImage.color = new Color(1, 1, 1, campaign.info.backgroundAlpha); _backgroundImage.sprite = campaign.background; } MenuLightsPresetSO customLights = Instantiate(baseDefaultLights); SimpleColorSO color = ScriptableObject.CreateInstance <SimpleColorSO>(); color.SetColor(new Color(campaign.info.lightColor.r, campaign.info.lightColor.g, campaign.info.lightColor.b)); foreach (LightIdColorPair pair in customLights.lightIdColorPairs) { pair.baseColor = color; } _campaignFlowCoordinator.SetPrivateField("_defaultLightsPreset", customLights); MissionNode[] missionNodes = new MissionNode[campaign.info.mapPositions.Count]; curCampaignNodes = missionNodes; MissionStage[] missionStages; if (campaign.info.unlockGate.Count == 0 || unlockAllMissions) { //campaigns require an unlock gate so I make a fake one above the visible map area missionStages = new MissionStage[1]; missionStages[0] = Instantiate(baseMissionStages[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionStages[0].SetPrivateField("_minimumMissionsToUnlock", 0); missionStages[0].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(0, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 + 1000, 0); } else { missionStages = new MissionStage[campaign.info.unlockGate.Count + 1]; for (int i = 0; i < missionStages.Length - 1; i++) { missionStages[i] = Instantiate(baseMissionStages[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionStages[i].SetPrivateField("_minimumMissionsToUnlock", campaign.info.unlockGate[i].clearsToPass); missionStages[i].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(campaign.info.unlockGate[i].x * EDITOR_TO_GAME_UNITS, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 - campaign.info.unlockGate[i].y * EDITOR_TO_GAME_UNITS, 0); } //ghost unlock gate required for some reason as last unlock gate never gets cleared missionStages[campaign.info.unlockGate.Count] = Instantiate(baseMissionStages[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionStages[campaign.info.unlockGate.Count].SetPrivateField("_minimumMissionsToUnlock", campaign.info.mapPositions.Count + 1); missionStages[campaign.info.unlockGate.Count].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(0, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 + 1000, 0); } curMissionStages = missionStages; _missionStagesManager.SetPrivateField("_missionStages", (from stage in missionStages orderby stage.minimumMissionsToUnlock select stage).ToArray()); for (int i = 0; i < missionNodes.Length; i++) { CampainMapPosition mapPosition = campaign.info.mapPositions[i]; missionNodes[i] = Instantiate(baseNodes[0], _missionNodesManager.GetPrivateField <GameObject>("_missionNodesParentObject").transform); missionNodes[i].gameObject.SetActive(true); missionNodes[i].SetPrivateField("_missionDataSO", campaign.challenges[i].GetMissionData(campaign)); missionNodes[i].GetPrivateField <RectTransform>("_rectTransform").localPosition = new Vector3(mapPosition.x * EDITOR_TO_GAME_UNITS, -baseMapHeight / 2 + campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET / 2 - mapPosition.y * EDITOR_TO_GAME_UNITS, 0); missionNodes[i].GetPrivateField <RectTransform>("_rectTransform").sizeDelta = new Vector2(12 * mapPosition.scale, 12 * mapPosition.scale); missionNodes[i].SetPrivateField("_letterPartName", mapPosition.letterPortion); missionNodes[i].SetPrivateField("_numberPartName", mapPosition.numberPortion); } for (int i = 0; i < missionNodes.Length; i++) { MissionNode[] children = new MissionNode[campaign.info.mapPositions[i].childNodes.Length]; for (int j = 0; j < children.Length; j++) { children[j] = missionNodes[campaign.info.mapPositions[i].childNodes[j]]; } missionNodes[i].SetPrivateField("_childNodes", children); } _missionNodesManager.SetPrivateField("_rootMissionNode", missionNodes[0]); _mapScrollView.GetPrivateField <RectTransform>("_contentRectTransform").SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, campaign.info.mapHeight * EDITOR_TO_GAME_UNITS + HEIGHT_OFFSET); CampaignInit(); PresentFlowCoordinator(_campaignFlowCoordinator, delegate() { _campaignFlowCoordinator.InvokePrivateMethod("SetTitle", new object[] { campaign.info.name, ViewController.AnimationType.In }); _missionNodeSelectionManager.didSelectMissionNodeEvent -= _missionSelectionMapViewController.HandleMissionNodeSelectionManagerDidSelectMissionNode; _missionLevelDetailViewController.didPressPlayButtonEvent -= _missionSelectionNavigationController.HandleMissionLevelDetailViewControllerDidPressPlayButton; _missionResultsViewController.retryButtonPressedEvent += HandleMissionResultsViewControllerRetryButtonPressed; _missionResultsViewController.retryButtonPressedEvent -= _campaignFlowCoordinator.HandleMissionResultsViewControllerRetryButtonPressed; _campaignFlowCoordinator.didFinishEvent -= BeatSaberUI.MainFlowCoordinator.HandleCampaignFlowCoordinatorDidFinish; _campaignFlowCoordinator.didFinishEvent += CloseCampaign; _missionSelectionMapViewController.didSelectMissionLevelEvent += HandleMissionSelectionMapViewControllerDidSelectMissionLevel; _missionResultsViewController.continueButtonPressedEvent += HandleMissionResultsViewControllerContinueButtonPressed; _missionMapAnimationController.ScrollToTopMostNotClearedMission(); _playButton.interactable = true; }); _missionNodeSelectionManager.didSelectMissionNodeEvent += HandleMissionNodeSelectionManagerDidSelectMissionNode; (_campaignChallengeLeaderbaordViewController.table.transform.GetChild(1).GetChild(0).transform as RectTransform).localScale = new Vector3(1, 0.9f, 1); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
public void SetSongColors(Color colorLeft, Color colorRight, bool hasColors) { if (!hasColors) { return; } Console.WriteLine("Colors: " + colorLeft.ToString() + " " + colorRight.ToString()); GameObject colorSetterObj = null; EnvironmentColorsSetter colorSetter; if (customSongInfo.environmentName.Contains("KDA")) { Console.WriteLine("KDA"); colorSetter = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault(); } else { colorSetterObj = new GameObject("SongLoader Color Setter"); colorSetterObj.SetActive(false); colorSetter = colorSetterObj.AddComponent <EnvironmentColorsSetter>(); } var scriptableColors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); SimpleColorSO[] A = new SimpleColorSO[2]; SimpleColorSO[] B = new SimpleColorSO[2]; foreach (var color in scriptableColors) { Console.WriteLine("Color: " + color.name); int i = 0; if (color.name == "BaseNoteColor1") { B[0] = color; i++; } else if (color.name == "BaseNoteColor0") { A[0] = color; i++; } else if (color.name == "BaseColor0") { A[1] = color; i++; } else if (color.name == "BaseColor1") { B[1] = color; i++; } } colorSetter.SetPrivateField("_colorsA", A); colorSetter.SetPrivateField("_colorsB", B); colorSetter.SetPrivateField("_colorManager", Resources.FindObjectsOfTypeAll <ColorManager>().First()); colorSetter.SetPrivateField("_overrideColorA", colorRight); colorSetter.SetPrivateField("_overrideColorB", colorLeft); Console.WriteLine("Turning on"); if (colorSetterObj != null) { colorSetterObj.SetActive(true); } colorSetter.Awake(); }
public void OnActiveSceneChanged(Scene arg0, Scene scene) { if (scene.name == "MenuViewControllers") { activateDuringIsolated = false; Log("Switched to Menu"); SharedCoroutineStarter.instance.StartCoroutine(GrabPP()); var controllers = Resources.FindObjectsOfTypeAll <VRController>(); if (controllers != null) { foreach (VRController controller in controllers) { if (controller != null) { if (controller.ToString() == "ControllerLeft (VRController)") { leftController = controller; } if (controller.ToString() == "ControllerRight (VRController)") { rightController = controller; } } // Log(controller.ToString()); } // Log("Left:" + leftController.ToString()); // Log("Right: " + rightController.ToString()); } } if (scene.name == "GameCore") { RemovePatches(); } if (_mainSettingsModel == null) { var menu = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault(); if (menu != null) { _mainSettingsModel = menu.GetField <MainSettingsModelSO>("_mainSettingsModel"); _mainSettingsModel.Load(true); Log("RUMBLE: " + _mainSettingsModel.controllersRumbleEnabled.ToString()); if (!setDefaultRumble) { defaultRumble = _mainSettingsModel.controllersRumbleEnabled; ModPrefs.SetInt("GameplayModifiersPlus", "GameRumbleSetting", _mainSettingsModel.controllersRumbleEnabled ? 1 : 0); setDefaultRumble = true; Log("Set Default Rumble Value"); } } } if (_mainSettingsModel != null) { defaultRumble = ModPrefs.GetInt("GameplayModifiersPlus", "GameRumbleSetting", -1, false) != 1 ? false : true; _mainSettingsModel.controllersRumbleEnabled.value = defaultRumble; _mainSettingsModel.Save(); } paused = false; if (!customColorsInstalled) { if (colorA != null) { colorA.SetColor(defColorA); } if (colorB != null) { colorB.SetColor(defColorB); } } // try // { if (scene.name == "EmptyTransition") { Log("Resetting Chat Powers Object"); if (chatPowers != null) { GameObject.Destroy(chatPowers); } } if (chatPowers == null) { Log("Null Creation of Chat Powers Object"); chatPowers = new GameObject("Chat Powers"); GameObject.DontDestroyOnLoad(chatPowers); twitchPowers = chatPowers.AddComponent <TwitchPowers>(); } // } // catch(Exception ex) // { // Log(ex.ToString()); // } GMPDisplay display = chatPowers.GetComponent <GMPDisplay>(); if (display != null) { display.Destroy(); GameObject.Destroy(display); } ReadPrefs(); if (GMPUI.chatIntegration && twitchPluginInstalled) { if (twitchPowers != null) { cooldowns.ResetCooldowns(); TwitchPowers.ResetPowers(false); twitchPowers.StopAllCoroutines(); } if (ChatConfig.resetChargesEachLevel) { charges = 0; } } // twitchCommands.StopAllCoroutines(); haveSongNJS = false; if (soundIsPlaying == true) { gnomeSound.Stop(); } soundIsPlaying = false; isValidScene = false; playerInfo = false; modifiersInit = false; if (arg0.name == "EmpyTransition" && chatPowers != null) { GameObject.Destroy(chatPowers); } if (scene.name == "GameCore") { Log("Isolated: " + BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); isValidScene = true; if (BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && !activateDuringIsolated) { Log("Isolated Level, not activating"); return; } // Log("Pre GrabGrab"); GameObject.Destroy(GameObject.Find("Color Setter")); soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault(); spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First(); energyPanel = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().First(); ColorManager = Resources.FindObjectsOfTypeAll <ColorManager>().First(); levelData = BS_Utils.Plugin.LevelData; // Log("Post GrabGrab"); if (spawnController != null) { spawnController.noteDidStartJumpEvent += SpawnController_ModifiedJump; spawnController.noteWasCutEvent += SpawnController_ScaleRemoveCut; spawnController.noteWasMissedEvent += SpawnController_ScaleRemoveMiss; } else { Log("Spawn Controller Null"); } // Log("Post GrabGrab 2"); currentSongSpeed = levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; BS_Utils.Plugin.LevelDidFinishEvent += LevelData_didFinishEvent; // Log("Post GrabGrab 3"); if (!Multiplayer.MultiMain.multiActive.Value) { if (GMPUI.chatIntegration && ChatConfig.maxCharges > 0 && twitchPluginInstalled) { chatPowers.AddComponent <GMPDisplay>(); } if (GMPUI.chatIntegration && ChatConfig.timeForCharges > 0 && twitchPluginInstalled) { twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime()); } } // Log("Post GrabGrab 4"); pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First(); var colors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); // Log("Pre Color"); foreach (SimpleColorSO color in colors) { // Log(color.name); if (color.name == "BaseNoteColor1") { colorA = color; } if (color.name == "BaseNoteColor0") { colorB = color; } } oldColorA.SetColor(colorA); oldColorB.SetColor(colorB); // Log("Pre ChatInt"); // Log(colorA.color.ToString()); if (GMPUI.chatIntegration && charges <= ChatConfig.maxCharges && twitchPluginInstalled) { charges += ChatConfig.chargesPerLevel; if (charges > ChatConfig.maxCharges) { charges = ChatConfig.maxCharges; } // TryAsyncMessage("Current Charges: " + charges); } // Log("Pre Audio/Player"); // ReflectionUtil.SetProperty(typeof(PracticePlugin.Plugin), "TimeScale", 1f); AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); if (AudioTimeSync != null) { songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource"); if (songAudio == null) { Log("Audio null"); } // Log("Object Found"); } //Get Sabers player = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault(); if (player != null) { playerInfo = true; } else { playerInfo = false; Log("Player is null"); } CheckGMPModifiers(); } }
public static bool Prefix(ObstacleController __instance, ObstacleData obstacleData, Vector3 startPos, Vector3 midPos, Vector3 endPos, float move1Duration, float move2Duration, float startTimeOffset, float singleLineWidth, float height, ref bool ____initialized, ref ObstacleData ____obstacleData, ref float ____obstacleDuration, ref Vector3 ____startPos, ref Vector3 ____midPos, ref Vector3 ____endPos, ref float ____move1Duration, ref float ____move2Duration, ref float ____startTimeOffset, ref StretchableObstacle ____stretchableObstacle, ref Bounds ____bounds, ref bool ____passedThreeQuartersOfMove2Reported, ref bool ____passedAvoidedMarkReported, ref float ____passedAvoidedMarkTime, ref float ____finishMovementTime, ref Action <ObstacleController> ___didInitEvent, ref SimpleColorSO ____color) { if (!Plugin.active) { return(true); } ____initialized = true; ____obstacleData = obstacleData; ____obstacleDuration = obstacleData.duration; float num = obstacleData.width * singleLineWidth; Vector3 vector = __instance.transform.rotation * new Vector3((num - singleLineWidth) * 0.5f, 0f, 0f); ____startPos = startPos + vector; ____midPos = midPos + vector; ____midPos.y = ____startPos.y; ____endPos = endPos + vector; ____endPos.y = ____startPos.y; ____move1Duration = move1Duration; ____move2Duration = move2Duration; ____startTimeOffset = startTimeOffset; float length = (____endPos - ____midPos).magnitude / move2Duration * obstacleData.duration; ____stretchableObstacle.SetSizeAndColor(num * 0.98f, height, length, ____color); ____bounds = ____stretchableObstacle.bounds; ____passedThreeQuartersOfMove2Reported = false; ____passedAvoidedMarkReported = false; ____passedAvoidedMarkTime = ____move1Duration + ____move2Duration * 0.5f + ____obstacleDuration + 0.15f; ____finishMovementTime = ____move1Duration + ____move2Duration + ____obstacleDuration; ___didInitEvent?.Invoke(__instance); return(false); }
private void SetSongColors(Data.ExtraSongData.MapColor left, Data.ExtraSongData.MapColor right) { Color colorLeft = new Color(left.r, left.g, left.b); Color colorRight = new Color(right.r, right.g, right.b); GameObject colorSetterObj = null; EnvironmentColorsSetter colorSetter; if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.environmentSceneInfo.sceneName.Contains("KDA")) { // Console.WriteLine("KDA"); colorSetter = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault(); } else { colorSetterObj = new GameObject("SongCore Color Setter"); colorSetterObj.SetActive(false); colorSetter = colorSetterObj.AddComponent <EnvironmentColorsSetter>(); } var scriptableColors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); SimpleColorSO[] A = new SimpleColorSO[2]; SimpleColorSO[] B = new SimpleColorSO[2]; foreach (var color in scriptableColors) { // Console.WriteLine("Color: " + color.name); int i = 0; if (color.name == "BaseNoteColor1") { B[0] = color; i++; } else if (color.name == "BaseNoteColor0") { A[0] = color; i++; } else if (color.name == "BaseColor0") { A[1] = color; i++; } else if (color.name == "BaseColor1") { B[1] = color; i++; } } colorSetter.SetPrivateField("_colorsA", A); colorSetter.SetPrivateField("_colorsB", B); colorSetter.SetPrivateField("_colorManager", Resources.FindObjectsOfTypeAll <ColorManager>().First()); colorSetter.SetPrivateField("_overrideColorA", colorRight); colorSetter.SetPrivateField("_overrideColorB", colorLeft); // Console.WriteLine("Turning on"); if (colorSetterObj != null) { colorSetterObj.SetActive(true); } colorSetter.Awake(); }
private static void Postfix(ref ObstacleController __instance, StretchableObstacle ____stretchableObstacle, ref SimpleColorSO ____color) { try { CustomMaterial customMaterial = MaterialAssetLoader.CustomMaterialObjects[MaterialAssetLoader.SelectedMaterial]; if (customMaterial.FileName != "DefaultMaterials") { Renderer mesh = __instance.gameObject.GetComponentInChildren <Renderer>(); Color color = ____color.color; if (customMaterial.Descriptor.Overlay) { GameObject overlay = MeshUtils.CreateOverlay(mesh, customMaterial.MaterialRenderer, customMaterial.Descriptor.OverlayOffset); MaterialUtils.SetMaterialsColor(overlay?.GetComponent <Renderer>().materials, color); if (customMaterial.Descriptor.ReplaceMesh) { MeshUtils.ReplaceMesh(overlay.GetComponent <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier); if (!customMaterial.Descriptor.ReplaceOnlyOverlayMesh) { MeshUtils.ReplaceMesh(__instance.gameObject.GetComponentInChildren <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier); } } } else { MaterialUtils.ReplaceRenderer(mesh, customMaterial.MaterialRenderer); MaterialUtils.SetMaterialsColor(mesh?.materials, color); if (customMaterial.Descriptor.ReplaceMesh) { MeshUtils.ReplaceMesh(__instance.gameObject.GetComponentInChildren <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier); } } } if (!Configuration.EnableObstacleFrame) { ParametricBoxFrameController frame = ____stretchableObstacle.GetPrivateField <ParametricBoxFrameController>("_obstacleFrame"); frame.enabled = false; } } catch (Exception ex) { Logger.log.Error(ex); } }
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene) { paused = false; if (!customColorsInstalled) { if (colorA != null) { colorA.SetColor(defColorA); } if (colorB != null) { colorB.SetColor(defColorB); } } // try // { if (scene.name == "EmptyTransition") { Log("Resetting Chat Powers Object"); if (chatPowers != null) { GameObject.Destroy(chatPowers); } } if (chatPowers == null) { Log("Null Creation of Chat Powers Object"); chatPowers = new GameObject("Chat Powers"); twitchPowers = chatPowers.AddComponent <TwitchPowers>(); GameObject.DontDestroyOnLoad(chatPowers); } // } // catch(Exception ex) // { // Log(ex.ToString()); // } GMPDisplay display = chatPowers.GetComponent <GMPDisplay>(); if (display != null) { display.Destroy(); GameObject.Destroy(display); } ReadPrefs(); if (GMPUI.chatIntegration) { if (twitchPowers != null) { cooldowns.ResetCooldowns(); TwitchPowers.ResetPowers(false); twitchPowers.StopAllCoroutines(); } if (Config.resetChargesperLevel) { charges = 0; } } // twitchCommands.StopAllCoroutines(); haveSongNJS = false; invalidForScoring = false; if (soundIsPlaying == true) { gnomeSound.Stop(); } soundIsPlaying = false; isValidScene = false; playerInfo = false; if (arg0.name == "EmpyTransition" && chatPowers != null) { GameObject.Destroy(chatPowers); } if (scene.name == ("Menu")) { Log("Switched to Menu"); SharedCoroutineStarter.instance.StartCoroutine(GrabPP()); if (_hasRegistered == false) { TwitchConnection.Instance.StartConnection(); TwitchConnection.Instance.RegisterOnMessageReceived(TwitchConnection_OnMessageReceived); _hasRegistered = true; } var controllers = Resources.FindObjectsOfTypeAll <VRController>(); if (controllers != null) { foreach (VRController controller in controllers) { if (controller != null) { if (controller.ToString() == "ControllerLeft (VRController)") { leftController = controller; } if (controller.ToString() == "ControllerRight (VRController)") { rightController = controller; } } // Log(controller.ToString()); } Log("Left:" + leftController.ToString()); Log("Right: " + rightController.ToString()); } } if (scene.name == "GameCore") { environmentColorsSetter = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault(); soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().First(); levelData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().First(); spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().First(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First(); energyPanel = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().First(); spawnController.noteDidStartJumpEvent += SpawnController_ModifiedJump; spawnController.noteWasCutEvent += SpawnController_ScaleRemoveCut; spawnController.noteWasMissedEvent += SpawnController_ScaleRemoveMiss; currentSongSpeed = levelData.gameplayCoreSetupData.gameplayModifiers.songSpeedMul; levelData.didFinishEvent += LevelData_didFinishEvent; if (GMPUI.njsRandom) { twitchPowers.StartCoroutine(TwitchPowers.RandomNJS()); } Log(GMPUI.swapSabers.ToString()); if (GMPUI.noArrows) { twitchPowers.StartCoroutine(TwitchPowers.NoArrows()); } if (GMPUI.chatIntegration && Config.maxCharges > 0) { chatPowers.AddComponent <GMPDisplay>(); } if (Config.timeForCharges > 0) { twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime()); } pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First(); var colors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); foreach (SimpleColorSO color in colors) { Log(color.name); if (color.name == "Color0") { colorA = color; } if (color.name == "Color1") { colorB = color; } } oldColorA.SetColor(colorA); oldColorB.SetColor(colorB); Log(colorA.color.ToString()); if (GMPUI.chatIntegration && charges <= Config.maxCharges) { charges += Config.chargesPerLevel; if (charges > Config.maxCharges) { charges = Config.maxCharges; } // TwitchConnection.Instance.SendChatMessage("Current Charges: " + charges); } // ReflectionUtil.SetProperty(typeof(PracticePlugin.Plugin), "TimeScale", 1f); isValidScene = true; AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); if (AudioTimeSync != null) { songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource"); if (songAudio != null) { Log("Audio not null"); } Log("Object Found"); } //Get Sabers player = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault(); if (player != null) { leftSaber = player.leftSaber; rightSaber = player.rightSaber; playerInfo = true; } else { playerInfo = false; Log("Player is null"); } Log(leftSaber.handlePos.ToString()); Log(leftSaber.saberBladeTopPos.ToString()); if (GMPUI.swapSabers) { Log("Testing Ground Active"); try { SharedCoroutineStarter.instance.StartCoroutine(TwitchPowers.TestingGround(5f)); } catch (Exception ex) { Log(ex.ToString()); } } // SharedCoroutineStarter.instance.StartCoroutine(SwapSabers(leftSaber, rightSaber)); if (GMPUI.gnomeOnMiss == true) { invalidForScoring = true; if (spawnController != null) { spawnController.noteWasMissedEvent += delegate(BeatmapObjectSpawnController beatmapObjectSpawnController2, NoteController noteController) { if (noteController.noteData.noteType != NoteType.Bomb) { try { twitchPowers.StartCoroutine(TwitchPowers.SpecialEvent()); Log("Gnoming"); } catch (Exception ex) { Log(ex.ToString()); } } }; spawnController.noteWasCutEvent += delegate(BeatmapObjectSpawnController beatmapObjectSpawnController2, NoteController noteController, NoteCutInfo noteCutInfo) { if (!noteCutInfo.allIsOK) { twitchPowers.StartCoroutine(TwitchPowers.SpecialEvent()); Log("Gnoming"); } }; } } if (GMPUI.bulletTime || GMPUI.chatIntegration || GMPUI.fixedNoteScale != 1f) { invalidForScoring = true; } /* * if(GMPUI.superHot == true) * { * startGMPUI.superHot = false; * SharedCoroutineStarter.instance.StartCoroutine(Wait(1f)); * * } * */ } }