using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CryptidLabs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TeleporterBeamQoL")] [assembly: AssemblyTitle("TeleporterBeamQoL")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TeleporterBeamQoL { [BepInPlugin("com.cryptidlabs.teleporterbeamqol", "Teleporter Beam QoL", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class BeamColorController : MonoBehaviour { public TeleporterInteraction Teleporter; private ParticleSystemRenderer beamRenderer; private bool activated; private bool completed; private float hue; private float displayedSpeed; public void MarkActivated() { activated = true; completed = false; if (pluginEnabled.Value) { ((Component)this).gameObject.SetActive(true); } } public void MarkCompleted() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) completed = true; if (pluginEnabled.Value && staticOnCompletion.Value) { ((Component)this).gameObject.SetActive(true); ApplyColor(GetStaticColor()); } } private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) beamRenderer = ((Component)this).GetComponentInChildren(true); displayedSpeed = Mathf.Max(0f, rgbSpeed.Value); ApplyColor(GetStaticColor()); } private void Update() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) if (!pluginEnabled.Value) { return; } if ((Object)(object)Teleporter != (Object)null && (Teleporter.isCharged || Teleporter.chargeFraction >= 0.999f)) { completed = true; } if (completed && staticOnCompletion.Value) { ((Component)this).gameObject.SetActive(true); ApplyColor(GetStaticColor()); return; } if (!rgbCycleEnabled.Value) { ApplyColor(GetStaticColor()); return; } if (rainbowOnActivation.Value && !activated) { ApplyColor(GetStaticColor()); return; } float num = Mathf.Max(0f, rgbSpeed.Value); if (slowDownWithCharge.Value && (Object)(object)Teleporter != (Object)null) { float num2 = Mathf.Clamp01(minSpeedMultiplier.Value); float num3 = 1f - (1f - num2) * Mathf.Clamp01(Teleporter.chargeFraction); num *= num3; } if (smoothSpeedChanges.Value) { displayedSpeed = Mathf.MoveTowards(displayedSpeed, num, Mathf.Max(0.001f, speedChangeRate.Value) * Time.deltaTime); } else { displayedSpeed = num; } hue = Mathf.Repeat(hue + displayedSpeed * Time.deltaTime, 1f); Color color = Color.HSVToRGB(hue, 1f, 1f); color.a = staticColor.Value.a; ApplyColor(ApplyBrightness(color)); } private void ApplyColor(Color color) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)beamRenderer == (Object)null) { beamRenderer = ((Component)this).GetComponentInChildren(true); } if (!((Object)(object)beamRenderer == (Object)null)) { Material material = ((Renderer)beamRenderer).material; if (!((Object)(object)material == (Object)null)) { material.SetColor("_TintColor", color); material.SetColor("_Color", color); } } } } [CompilerGenerated] private static class <>O { public static hook_Awake <0>__TeleporterInteraction_Awake; public static hook_OnInteractionBegin <1>__TeleporterInteraction_OnInteractionBegin; public static Action <2>__OnTeleporterCharged; } public const string PluginGuid = "com.cryptidlabs.teleporterbeamqol"; public const string PluginName = "Teleporter Beam QoL"; public const string PluginVersion = "1.0.1"; private const string OriginalTeleporterBeamGuid = "com.rob.TeleporterBeam"; private static ConfigEntry pluginEnabled; private static ConfigEntry rgbCycleEnabled; private static ConfigEntry rainbowOnActivation; private static ConfigEntry staticOnCompletion; private static ConfigEntry slowDownWithCharge; private static ConfigEntry smoothSpeedChanges; private static ConfigEntry rgbSpeed; private static ConfigEntry minSpeedMultiplier; private static ConfigEntry speedChangeRate; private static ConfigEntry beamBrightness; private static ConfigEntry staticColor; private static ConfigEntry staticColorHex; private static ConfigEntry legacyConfigMigrated; private void Awake() { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown pluginEnabled = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Enabled", true, "Master toggle for Teleporter Beam QoL behavior."); rgbCycleEnabled = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "RGB Cycle Enabled", true, "Cycle the teleporter beam through the full color spectrum."); rainbowOnActivation = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Rainbow On Activation", true, "Start the full-spectrum rainbow when the teleporter is activated instead of while it is idle."); staticOnCompletion = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Static On Completion", true, "Switch the beam back to Static Color after the teleporter finishes charging."); slowDownWithCharge = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Slow Down With Charge", true, "Reduce rainbow cycle speed as the teleporter charge timer fills."); smoothSpeedChanges = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Smooth Speed Changes", true, "Smooth RGB speed changes so charge-speed effects such as Focused Convergence do not make the beam lurch."); rgbSpeed = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "RGB Cycle Speed", 0.02f, "Full-spectrum hue cycles per second."); minSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Minimum Speed Multiplier", 0.15f, "Lowest speed multiplier at full charge when slowdown is enabled. Use 0 to 1."); speedChangeRate = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Speed Change Rate", 0.02f, "Maximum RGB speed adjustment per second when Smooth Speed Changes is enabled."); beamBrightness = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Beam Brightness", 0.45f, "Multiplies the beam color before the glow shader. Lower this if colors look white or overexposed."); staticColor = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Static Color", new Color(72f / 85f, 0.7058824f, 0.972549f, 1f), "Static beam color before activation, whenever RGB cycling is disabled, and after completion when Static On Completion is enabled."); staticColorHex = ((BaseUnityPlugin)this).Config.Bind("Teleporter Beam", "Static Color Hex", "#D8B4F8", "Optional hex override for Static Color. Use #RRGGBB or #RRGGBBAA. Leave blank to use the color picker value."); legacyConfigMigrated = ((BaseUnityPlugin)this).Config.Bind("Migration", "Legacy Config Migrated", false, "Internal flag used after importing settings from a previously patched TeleporterBeam config."); MigrateLegacyPatchedConfig(); object obj = <>O.<0>__TeleporterInteraction_Awake; if (obj == null) { hook_Awake val = TeleporterInteraction_Awake; <>O.<0>__TeleporterInteraction_Awake = val; obj = (object)val; } TeleporterInteraction.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__TeleporterInteraction_OnInteractionBegin; if (obj2 == null) { hook_OnInteractionBegin val2 = TeleporterInteraction_OnInteractionBegin; <>O.<1>__TeleporterInteraction_OnInteractionBegin = val2; obj2 = (object)val2; } TeleporterInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj2; TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterCharged; RegisterRiskOfOptions(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Teleporter Beam QoL loaded."); } private static void MigrateLegacyPatchedConfig() { //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (legacyConfigMigrated.Value) { return; } string path = Path.Combine(Paths.ConfigPath, "com.rob.TeleporterBeam.cfg"); if (!File.Exists(path)) { legacyConfigMigrated.Value = true; return; } Dictionary dictionary = ReadLegacyTeleporterBeamSection(path); if (TryGetBool(dictionary, "RGB Cycle Enabled", out var result)) { rgbCycleEnabled.Value = result; } if (TryGetFloat(dictionary, "RGB Cycle Speed", out var result2)) { rgbSpeed.Value = result2; } if (TryGetBool(dictionary, "Rainbow On Activation", out var result3)) { rainbowOnActivation.Value = result3; } if (TryGetBool(dictionary, "Slow Down With Charge", out var result4)) { slowDownWithCharge.Value = result4; } if (TryGetFloat(dictionary, "Minimum Speed Multiplier", out var result5)) { minSpeedMultiplier.Value = result5; } if (TryGetFloat(dictionary, "Beam Brightness", out var result6)) { beamBrightness.Value = result6; } if (dictionary.TryGetValue("Static Color Hex", out var value)) { staticColorHex.Value = value; } if (dictionary.TryGetValue("Static Color", out var value2) && TryParseHexColor(value2, out var color)) { staticColor.Value = color; } legacyConfigMigrated.Value = true; } private static Dictionary ReadLegacyTeleporterBeamSection(string path) { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); bool flag = false; string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text.StartsWith("#", StringComparison.Ordinal)) { continue; } if (text.StartsWith("[", StringComparison.Ordinal) && text.EndsWith("]", StringComparison.Ordinal)) { flag = string.Equals(text, "[Teleporter Beam]", StringComparison.OrdinalIgnoreCase); } else if (flag) { int num = text.IndexOf('='); if (num > 0) { dictionary[text.Substring(0, num).Trim()] = text.Substring(num + 1).Trim(); } } } return dictionary; } private static bool TryGetBool(Dictionary values, string key, out bool result) { result = false; if (values.TryGetValue(key, out var value)) { return bool.TryParse(value, out result); } return false; } private static bool TryGetFloat(Dictionary values, string key, out float result) { result = 0f; if (values.TryGetValue(key, out var value)) { return float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result); } return false; } private void OnDestroy() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__TeleporterInteraction_Awake; if (obj == null) { hook_Awake val = TeleporterInteraction_Awake; <>O.<0>__TeleporterInteraction_Awake = val; obj = (object)val; } TeleporterInteraction.Awake -= (hook_Awake)obj; object obj2 = <>O.<1>__TeleporterInteraction_OnInteractionBegin; if (obj2 == null) { hook_OnInteractionBegin val2 = TeleporterInteraction_OnInteractionBegin; <>O.<1>__TeleporterInteraction_OnInteractionBegin = val2; obj2 = (object)val2; } TeleporterInteraction.OnInteractionBegin -= (hook_OnInteractionBegin)obj2; TeleporterInteraction.onTeleporterChargedGlobal -= OnTeleporterCharged; } private static void TeleporterInteraction_Awake(orig_Awake orig, TeleporterInteraction self) { orig.Invoke(self); TryAttachController(self); } private static void TeleporterInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator) { orig.Invoke(self, activator); BeamColorController beamColorController = TryAttachController(self); if ((Object)(object)beamColorController != (Object)null) { beamColorController.MarkActivated(); } } private static void OnTeleporterCharged(TeleporterInteraction teleporter) { BeamColorController beamColorController = TryAttachController(teleporter); if ((Object)(object)beamColorController != (Object)null) { beamColorController.MarkCompleted(); } } private static BeamColorController TryAttachController(TeleporterInteraction teleporter) { if ((Object)(object)teleporter == (Object)null) { return null; } ModelLocator component = ((Component)teleporter).GetComponent(); Transform val = (((Object)(object)component != (Object)null) ? component.modelTransform : null); Transform val2 = (((Object)(object)val != (Object)null) ? val.Find("TeleporterBeam") : null); if ((Object)(object)val2 == (Object)null) { return null; } BeamColorController beamColorController = ((Component)val2).GetComponent(); if ((Object)(object)beamColorController == (Object)null) { beamColorController = ((Component)val2).gameObject.AddComponent(); } beamColorController.Teleporter = teleporter; return beamColorController; } private static Color GetStaticColor() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Color color; Color color2 = ((!TryParseHexColor(staticColorHex.Value, out color)) ? staticColor.Value : color); return ApplyBrightness(color2); } private static Color ApplyBrightness(Color color) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, beamBrightness.Value); return new Color(color.r * num, color.g * num, color.b * num, color.a); } private static bool TryParseHexColor(string value, out Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) color = default(Color); if (string.IsNullOrWhiteSpace(value)) { return false; } string text = value.Trim(); if (!text.StartsWith("#", StringComparison.Ordinal)) { text = "#" + text; } return ColorUtility.TryParseHtmlString(text, ref color); } private static void RegisterRiskOfOptions() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { ModSettingsManager.SetModDescription("Adds RGB cycling, static color controls, brightness, charge slowdown, and static-on-completion behavior for ParticleSystem's TeleporterBeam.", "com.cryptidlabs.teleporterbeamqol", "Teleporter Beam QoL"); Sprite val = LoadSprite(Path.Combine(GetPluginDirectory(), "icon.png"), "TeleporterBeamQoLIcon"); if ((Object)(object)val != (Object)null) { ModSettingsManager.SetModIcon(val, "com.cryptidlabs.teleporterbeamqol", "Teleporter Beam QoL"); } AddRiskOfOptionsOption((BaseOption)new CheckBoxOption(pluginEnabled)); AddRiskOfOptionsOption((BaseOption)new CheckBoxOption(rgbCycleEnabled)); AddRiskOfOptionsOption((BaseOption)new CheckBoxOption(rainbowOnActivation)); AddRiskOfOptionsOption((BaseOption)new CheckBoxOption(staticOnCompletion)); AddRiskOfOptionsOption((BaseOption)new CheckBoxOption(slowDownWithCharge)); AddRiskOfOptionsOption((BaseOption)new CheckBoxOption(smoothSpeedChanges)); AddRiskOfOptionsOption((BaseOption)new StepSliderOption(rgbSpeed)); AddRiskOfOptionsOption((BaseOption)new StepSliderOption(minSpeedMultiplier)); AddRiskOfOptionsOption((BaseOption)new StepSliderOption(speedChangeRate)); AddRiskOfOptionsOption((BaseOption)new StepSliderOption(beamBrightness)); AddRiskOfOptionsOption((BaseOption)new ColorOption(staticColor)); AddRiskOfOptionsOption((BaseOption)new StringInputFieldOption(staticColorHex)); } } private static void AddRiskOfOptionsOption(BaseOption option) { ModSettingsManager.AddOption(option, "com.cryptidlabs.teleporterbeamqol", "Teleporter Beam QoL"); } private static Sprite LoadSprite(string path, string spriteName) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(path)) { return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { return null; } ((Object)val).name = spriteName; ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width); } private static string GetPluginDirectory() { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Paths.PluginPath; } } }