public static void ParseJSONNoteData(JObject mainNode, ref List <ChromaJSONEventData> dataList, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod) { foreach (JObject node in mainNode.Children <JObject>()) { try { switch (node["_cType"].Value <string>()) { case "mayhem": dataList.Add(new MayhemEvent().ParseJSON <MayhemEvent>(node, ref beatsPerMinute, ref shuffle, ref shufflePeriod)); break; default: ChromaLogger.Log("Invalid _chromaEvent type " + node["_cType"].Value <string>(), ChromaLogger.Level.WARNING); break; } } catch (Exception e) { ChromaLogger.Log(e); } } /*if (chromaEvent != null) { * BeatmapEventData baseData = chromaEvent.CreateBaseGameBeatmapEvent(); * LinkEvents(baseData, chromaEvent); * dataList.Add(baseData); * ChromaLogger.Log("Added event " + baseData.ToString()); * }*/ }
public static bool SimpleEventActivate(TrackLaneRingsRotationEffectSpawner tre, ref BeatmapEventData beatmapEventData, ref BeatmapEventType eventType) { if (!ChromaConfig.LegacyLighting) { return(false); } int id = beatmapEventData.value; switch (id) { case CHROMA_EVENT_RING_ROTATE_RESET: float ringPropWas = ChromaRingPropagationEvent.ringPropagationMult; float ringSpeedWas = ChromaRingSpeedEvent.ringSpeedMult; float ringStepWas = ChromaRingStepEvent.ringStepMult; ChromaRingPropagationEvent.ringPropagationMult = 116f; ChromaRingSpeedEvent.ringSpeedMult = 116f; ChromaRingStepEvent.ringStepMult = 0; tre.InvokeMethod("HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger", new BeatmapEventData(beatmapEventData.time, BeatmapEventType.Event8, CHROMA_EVENT_RING_ROTATE_RIGHT)); ChromaRingPropagationEvent.ringPropagationMult = ringPropWas; ChromaRingSpeedEvent.ringSpeedMult = ringSpeedWas; ChromaRingStepEvent.ringStepMult = ringStepWas; ChromaLogger.Log("Ring reset called"); return(true); } return(false); }
private static void Prefix(IDifficultyBeatmap difficultyBeatmap, ref OverrideEnvironmentSettings overrideEnvironmentSettings) { if (difficultyBeatmap.beatmapData is CustomBeatmapData customBeatmapData) { IEnumerable <string> requirements = ((List <object>)Trees.at(customBeatmapData.beatmapCustomData, "_requirements"))?.Cast <string>(); IEnumerable <string> suggestions = ((List <object>)Trees.at(customBeatmapData.beatmapCustomData, "_suggestions"))?.Cast <string>(); bool chromaRequirement = (requirements?.Contains(Chroma.Plugin.REQUIREMENTNAME) ?? false) || (suggestions?.Contains(Chroma.Plugin.REQUIREMENTNAME) ?? false); // please let me remove this shit bool legacyOverride = difficultyBeatmap.beatmapData.beatmapEventsData.Any(n => n.value >= LegacyLightHelper.RGB_INT_OFFSET); if (legacyOverride) { ChromaLogger.Log("Legacy Chroma Detected...", IPA.Logging.Logger.Level.Warning); ChromaLogger.Log("Please do not use Legacy Chroma for new maps as it is deprecated and its functionality in future versions of Chroma cannot be guaranteed", IPA.Logging.Logger.Level.Warning); } ChromaController.ToggleChromaPatches((chromaRequirement || legacyOverride) && ChromaConfig.Instance.CustomColorEventsEnabled); ChromaController.DoColorizerSabers = chromaRequirement && ChromaConfig.Instance.CustomColorEventsEnabled; if (chromaRequirement && ChromaConfig.Instance.EnvironmentEnhancementsEnabled && Trees.at(customBeatmapData.beatmapCustomData, "_environmentRemoval") != null) { overrideEnvironmentSettings = null; } } }
public static LSEColourManager GetOrCreateLSEColourManager(LightSwitchEventEffect lse, BeatmapEventType type) { LSEColourManager lsecm; try { lsecm = GetLSEColourManager(type); } catch (Exception e) { ChromaLogger.Log(e); return(null); } try { if (lsecm != null) { lsecm.Initialize(lse, type); return(lsecm); } else { lsecm = new LSEColourManager(lse, type); lsecm.Initialize(lse, type); LSEColourManagers.Add(lsecm); return(lsecm); } } catch (Exception e) { ChromaLogger.Log(e); return(lsecm); } }
private static IEnumerator GetOnlineVersionRoutine(string url, Action <bool, string, string> action) { ChromaLogger.Log("Obtaining latest version information..."); using (UnityWebRequest www = UnityWebRequest.Get(url)) { yield return(www.SendWebRequest()); if (www.isHttpError || www.isNetworkError) { action?.Invoke(false, null, "Failed to download version info"); } else { ChromaLogger.Log("Obtained latest version info!"); JSONNode node = JSON.Parse(www.downloadHandler.text); foreach (JSONNode child in node.Children) { try { if (child["approval"]["status"] != "approved") { continue; } string version = child["version"].Value; upToDate = isLatestVersion(version); webVersion = version; action?.Invoke(upToDate, webVersion, null); break; } catch { action?.Invoke(false, null, "Failed to download version info"); } } } } ChromaLogger.Log("Finished hunting for version"); }
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)); } }
internal static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> instructionList = instructions.ToList(); bool foundStLoc = false; for (int i = 0; i < instructionList.Count; i++) { if (!foundStLoc && instructionList[i].opcode == OpCodes.Stloc_0) { foundStLoc = true; instructionList[i].opcode = OpCodes.Ldarg_1; CodeInstruction[] codeInstructions = new CodeInstruction[] { new CodeInstruction(OpCodes.Call, _getPrecisionStep), new CodeInstruction(OpCodes.Stloc_0), }; instructionList.InsertRange(i + 1, codeInstructions); } } if (!foundStLoc) { ChromaLogger.Log("Failed to find stloc.0!", IPA.Logging.Logger.Level.Error); } return(instructionList.AsEnumerable()); }
private static void AcquiredOnlineVersionInfo(bool upToDate, string webVersion, string errorMessage) { string replace; if (errorMessage != null) { replace = "<color=red>" + errorMessage + "</color>"; } else { if (upToDate) { replace = "<color=green>You have the most recent version!</color>"; } else { replace = "<color=red>Chroma is outdated!</color>"; } if (webVersion != null) { replace = replace + Environment.NewLine + "Latest public release: " + webVersion; } } SidePanelUtil.RegisterTextPanel("chroma", ResourceTextFiles.chromaNotes .Replace("%VER%", (upToDate ? "<color=green>" : "<color=red>") + ChromaPlugin.Instance.plugin.Version + "</color>") .Replace("%USERNAME%", ChromaConfig.Username) .Replace("%ONLINE_VER%", replace) ); SidePanelUtil.Update(); ChromaLogger.Log("Updated panel with version info"); }
public void Register() { if (HasData) { chromaBeatmaps.Add(beatmap, this); ChromaLogger.Log("Registered JSONBeatmap for " + beatmap.ToString()); } }
public static void LoadSettingsModel() { mainSettingsModel = UnityEngine.Resources.FindObjectsOfTypeAll <MainSettingsModel>().FirstOrDefault(); if (mainSettingsModel) { ChromaLogger.Log("Found settings model", ChromaLogger.Level.DEBUG); oldHaptics = mainSettingsModel.controllersRumbleEnabled; } }
public static bool IsTargetGameScene(Scene scene) { if (ChromaConfig.DebugMode) { ChromaLogger.Log("Checking scene: " + scene.name + " : " + scene.buildIndex); ChromaLogger.Log("gameplayMode string : |" + BaseGameMode.CurrentGameplayModeString + "|"); ChromaLogger.Log("Base Game Mode : |" + BaseGameMode.CurrentBaseGameMode + "|"); } return(IsTargetGameScene(scene.buildIndex)); }
public static float GetNoteScale(NoteData note) { try { float s = ChromaNoteScaleEvent.GetScale(note.time); HandleNoteScalingEvent?.Invoke(ref note, ref s); return(s); } catch (Exception e) { ChromaLogger.Log(e); return(1); } }
public override bool Activate(ref LightSwitchEventEffect light, ref BeatmapEventData data, ref BeatmapEventType eventType) { GameEnergyCounter counter = GameObject.FindObjectOfType <GameEnergyCounter>(); if (counter != null) { ChromaLogger.Log("Changing health by " + HealthChangeAmount); counter.AddEnergy(HealthChangeAmount); return(true); } return(false); }
static void Prefix(ref NoteController noteController) { if (ColourManager.TechnicolourBlocks) { try { //ColourManager.SetNoteTypeColourOverride(noteController.noteData.noteType, Color.green); ColourManager.SetNoteTypeColourOverride(noteController.noteData.noteType, ColourManager.GetTechnicolour(noteController.noteData, ChromaConfig.TechnicolourBlocksStyle)); } catch (Exception e) { ChromaLogger.Log(e); } } }
public static Texture2D Base64ToTexture2D(string encodedData) { byte[] imageData = Convert.FromBase64String(encodedData); Texture2D texture = new Texture2D(0, 0, TextureFormat.ARGB32, false, true); texture.hideFlags = HideFlags.HideAndDontSave; texture.filterMode = FilterMode.Trilinear; if (!ImageConversion.LoadImage(texture, imageData)) { ChromaLogger.Log(new Exception("Failed to load image from Base64String [" + encodedData + "]")); } return(texture); }
internal static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> instructionList = instructions.ToList(); bool foundScale = false; bool foundPosition = false; for (int i = 0; i < instructionList.Count; i++) { if (!foundScale && instructionList[i].opcode == OpCodes.Callvirt && ((MethodInfo)instructionList[i].operand).Name == "set_localScale") { foundScale = true; CodeInstruction[] codeInstructions = new CodeInstruction[] { new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Call, _getTransformScale), }; instructionList.InsertRange(i, codeInstructions); } if (!foundPosition && instructionList[i].opcode == OpCodes.Callvirt && ((MethodInfo)instructionList[i].operand).Name == "set_localPosition") { foundPosition = true; CodeInstruction[] codeInstructions = new CodeInstruction[] { new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Call, _getTransformPosition), }; instructionList.InsertRange(i, codeInstructions); } } if (!foundScale) { ChromaLogger.Log("Failed to find callvirt to set_localScale!", IPA.Logging.Logger.Level.Error); } if (!foundPosition) { ChromaLogger.Log("Failed to find callvirt to set_localPosition!", IPA.Logging.Logger.Level.Error); } return(instructionList.AsEnumerable()); }
public static bool FillColourEvent(BeatmapEventData bev, ref ChromaColourEvent unfilledColourEvent, params Color[] colors) { if (unfilledColourEvent != null) { unfilledColourEvent.Colors = colors; if (ChromaConfig.LegacyLighting) { ChromaEvent.SetChromaEvent(bev, unfilledColourEvent); } ChromaLogger.Log("Filled " + unfilledColourEvent.GetType().ToString() + " event."); unfilledColourEvent = null; return(true); } return(false); }
public static void Postfix(ref BeatmapData __result, ref string json, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod) { try { //TODO unbreak this /*JObject node = JObject.Parse(json); * JObject eventsNode = node["_chromaEvents"].Value<JObject>(); * ChromaJSONBeatmap chromaMap = new ChromaJSONBeatmap(__result); * if (eventsNode != null) { * ChromaJSONEventData.ParseJSONNoteData(eventsNode, ref chromaMap.chromaEvents, ref beatsPerMinute, ref shuffle, ref shufflePeriod); * } * chromaMap.Register();*/ } catch (Exception e) { ChromaLogger.Log(e); } }
private IEnumerator SmoothRainbowSaber(Action action) { secondsPerBeat = (60f / bpm); while (true) { yield return(new WaitForSeconds(RainbowSaberUpdateRate)); try { action(); saberColourizer.Colourize(controller.GetColor((Time.time + matchOffset) / secondsPerBeat)); } catch (Exception e) { ChromaLogger.Log(e); this.StopAllCoroutines(); } } }
public static void InitializeCoordinators() { if (_characteristicViewController == null) { _characteristicViewController = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSelectionViewController>().FirstOrDefault(); if (_characteristicViewController == null) { return; } _characteristicViewController.didSelectBeatmapCharacteristicEvent += _characteristicViewController_didSelectBeatmapCharacteristicEvent; } if (_soloFlowCoordinator == null) { _soloFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().FirstOrDefault(); if (_soloFlowCoordinator == null) { return; } _soloDetailView = _soloFlowCoordinator.GetField <StandardLevelDetailViewController>("_levelDetailViewController"); _practiceViewController = _soloFlowCoordinator.GetField <PracticeViewController>("_practiceViewController"); if (_soloDetailView != null) { _soloDetailView.didPressPlayButtonEvent += _soloDetailView_didPressPlayButtonEvent; } else { ChromaLogger.Log("Detail View Null", ChromaLogger.Level.WARNING); } if (_practiceViewController != null) { _practiceViewController.didPressPlayButtonEvent += _practiceViewController_didPressPlayButtonEvent; } else { ChromaLogger.Log("Practice View Null", ChromaLogger.Level.WARNING); } } if (_partyFlowCoordinator == null) { _partyFlowCoordinator = Resources.FindObjectsOfTypeAll <PartyFreePlayFlowCoordinator>().FirstOrDefault(); } }
void Init() { try { Directory.CreateDirectory(Environment.CurrentDirectory.Replace('\\', '/') + "/UserData/Chroma/Audio"); } catch (Exception e) { ChromaLogger.Log("Error " + e.Message + " while trying to create Audio directory", ChromaLogger.Level.WARNING); } ambianceSource = gameObject.AddComponent <AudioSource>(); MakeSourceNonDimensional(ambianceSource, true); AudioSource mainOneShot = AvailableOneShot; StartCoroutine(GenerateAudioClip(mainOneShot, "ConfigReload.wav")); StartCoroutine(GenerateAudioClip(ambianceSource, "RainLoop.wav")); //foreach (AudioSource a in GetComponents<AudioSource>()) MakeSourceNonDimensional(a); }
public void Inject(BeatmapData beatmap) { List <BeatmapEventData> eventData = beatmap.beatmapEventData.ToList(); foreach (ChromaJSONEventData cev in chromaEvents) { BeatmapEventData baseData = cev.RegisterLink(); eventData.Add(baseData); } eventData = eventData.OrderBy(x => x.time).ToList(); beatmap.SetProperty("beatmapEventData", eventData.ToArray()); ChromaLogger.Log("***"); ChromaLogger.Log("***"); ChromaLogger.Log("Injected ChromaJSONBeatmap"); ChromaLogger.Log("***"); ChromaLogger.Log("***"); }
private void Init() { try { if (lightningLights == null || lightningLights.Length < 1 || lightningLights[0] == null) { LightSwitchEventEffect[] origLights = ColourManager.GetAllLightSwitches(); if (lightningLights != null) { for (int j = 0; j < lightningLights.Length; j++) { Destroy(lightningLights[j].gameObject); } } List <BSLight> ll = new List <BSLight>(); for (int j = 0; j < origLights.Length; j++) { BSLight[] origLl = origLights[j].GetField <BSLight[]>("_lights"); for (int k = 0; k < origLl.Length; k++) { GameObject g = GameObject.Instantiate(origLl[k].gameObject); BSLight nl = g.GetComponent <BSLight>(); nl.color = Color.clear; nl.name = "CT_LightningLight_" + k; foreach (Renderer r in nl.GetComponentsInChildren <Renderer>()) { r.enabled = false; } ll.Add(nl); } } lightningLights = ll.ToArray(); for (int i = 0; i < lightningLights.Length; i++) { lightningLights[i].transform.SetParent(transform, true); } ChromaLogger.Log("VFXLightning set up with " + lightningLights.Length + " lights cloned."); } } catch (Exception e) { ChromaLogger.Log("Error initializing VFXLightning"); ChromaLogger.Log(e); } }
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 IEnumerator RainbowWalls() { float secondsPerBeat = (60f / bpm); while (true) { yield return(new WaitForSeconds(rainbowWallUpdateRate)); try { //color = ColourManager.GetTechnicolour(Time.time * RainbowWallCycleSpeed, ColourManager._technicolourWalls, ColourManager.TechnicolourTransition.SMOOTH); color = ColourManager.GetLerpedFromArray(ColourManager.TechnicolourCombinedPalette, Time.time / secondsPerBeat); //ChromaLogger.Log("Rainbow Walls " + color); ApplyGlobalWallColours(color); } catch (Exception e) { ChromaLogger.Log(e); this.StopAllCoroutines(); } } }
/* * RAINBOW */ void Init() { GetWallColours(); if (IsRainbowWalls()) { StartCoroutine(RainbowWalls()); ChromaLogger.Log("Rainbow Walls!", ChromaLogger.Level.DEBUG); } else if (ColourManager.BarrierColour == ColourManager.DefaultBarrierColour || ColourManager.BarrierColour == Color.clear) { ResetGlobalWallColours(); //We have default colours, boys! ChromaLogger.Log("Default Walls", ChromaLogger.Level.DEBUG); } else { ApplyGlobalWallColours(ColourManager.BarrierColour); ChromaLogger.Log(ColourManager.BarrierColour.ToString() + " Walls", ChromaLogger.Level.DEBUG); } }
private IEnumerator SmoothRainbowSabers(Action action) { secondsPerBeat = (60f / bpm); while (true) { yield return(new WaitForSeconds(rainbowSabersUpdate)); try { action(); foreach (SaberColourizer saber in saberColourizers) { saber.Colourize(saber.warm ? rainbowSaberColours[0] : rainbowSaberColours[1]); } } catch (Exception e) { ChromaLogger.Log(e); this.StopAllCoroutines(); } } }
public static void Postfix(ref BeatmapData __result, ref string json, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod) { try { JSONNode node = JSONNode.Parse(json); JSONNode eventsNode = node["_chromaEvents"]; ChromaJSONBeatmap chromaMap = new ChromaJSONBeatmap(__result); if (eventsNode != null) { ChromaJSONEventData.ParseJSONNoteData(eventsNode, ref chromaMap.chromaEvents, ref beatsPerMinute, ref shuffle, ref shufflePeriod); } /*JSONNode notesNode = node["_chromaEvents"]; * if (notesNode != null) { * BeatmapLineData[] linesData = ChromaJSONNoteData.ParseJSONNoteData(notesNode, __result.beatmapLinesData); * __result.SetProperty("beatmapLinesData", linesData); * }*/ chromaMap.Register(); } catch (Exception e) { ChromaLogger.Log(e); } }
IEnumerator GenerateAudioClip(AudioSource audioSource, string filenameWithExtension, bool play = false) { if (memorizedClips.ContainsKey(filenameWithExtension)) { audioSource.clip = memorizedClips[filenameWithExtension]; } else { string filePath = Environment.CurrentDirectory.Replace('\\', '/') + "/UserData/Chroma/Audio/" + filenameWithExtension; ChromaLogger.Log("Searching for audio file " + filePath, ChromaLogger.Level.DEBUG, false); using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(filePath, AudioType.WAV)) { yield return(www.SendWebRequest()); if (www.isHttpError || www.isNetworkError) { ChromaLogger.Log(www.error, ChromaLogger.Level.ERROR, false); yield break; } else { ChromaLogger.Log("Found sound " + filenameWithExtension, ChromaLogger.Level.ERROR, false); AudioClip downloadedClip = DownloadHandlerAudioClip.GetContent(www); if (downloadedClip == null) { ChromaLogger.Log("Failed to find sound " + filePath, ChromaLogger.Level.WARNING, false); yield break; } audioSource.clip = downloadedClip; memorizedClips[filenameWithExtension] = downloadedClip; } } } if (play) { audioSource.Play(); } yield break; }
internal static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> instructionList = instructions.ToList(); bool foundReturn = false; for (int i = 0; i < instructionList.Count; i++) { if (!foundReturn && instructionList[i].opcode == OpCodes.Ret) { foundReturn = true; instructionList.Insert(i, new CodeInstruction(OpCodes.Ldloc_0)); instructionList.Insert(i + 1, new CodeInstruction(OpCodes.Call, _setEnvironmentTable)); } } if (!foundReturn) { ChromaLogger.Log("Failed to find ret!", IPA.Logging.Logger.Level.Error); } return(instructionList.AsEnumerable()); }