Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of WaterTweaker v1.3.0
WaterTweaker.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HG.Reflection; using Microsoft.CodeAnalysis; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("WaterTweaker")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WaterTweaker")] [assembly: AssemblyTitle("WaterTweaker")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 WaterTweaker { internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void LogDebug(object data) { _logSource.LogDebug(data); } internal static void LogError(object data) { _logSource.LogError(data); } internal static void LogFatal(object data) { _logSource.LogFatal(data); } internal static void LogInfo(object data) { _logSource.LogInfo(data); } internal static void LogMessage(object data) { _logSource.LogMessage(data); } internal static void LogWarning(object data) { _logSource.LogWarning(data); } } public static class RiskOfOptionsCompat { private static bool? _enabled; public static bool Enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); } return _enabled.Value; } } public static void AddOptionStepSlider(ConfigEntry<float> configEntry, float min, float max, float increment, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StepSliderOption(configEntry, new StepSliderConfig { min = min, max = max, increment = increment, name = name }), "Judgy.WaterTweaker", "WaterTweaker"); } public static void AddOptionCheckbox(ConfigEntry<bool> configEntry, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(configEntry, new CheckBoxConfig { name = name }), "Judgy.WaterTweaker", "WaterTweaker"); } public static void SetModDescription(string desc) { ModSettingsManager.SetModDescription(desc, "Judgy.WaterTweaker", "WaterTweaker"); } } [BepInPlugin("Judgy.WaterTweaker", "WaterTweaker", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class WaterTweakerPlugin : BaseUnityPlugin { public const string PluginGUID = "Judgy.WaterTweaker"; public const string PluginAuthor = "Judgy"; public const string PluginName = "WaterTweaker"; public const string PluginVersion = "1.3.0"; private const string MapWetlandName = "foggyswamp"; private bool tryApplyTweaks; private bool loopRunning; private int applyAttempts; public static ConfigEntry<float> ConfigWetlandWaterOpacity { get; set; } public static ConfigEntry<bool> ConfigWetlandWaterPP { get; set; } public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); ConfigWetlandWaterOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("WaterTweaker", "WetlandWaterOpacity", 1f, "Sets the Opacity of the water in Wetland Aspect (between 0.0 and 1.0)."); ConfigWetlandWaterOpacity.SettingChanged += OnWaterSettingsChanged; ConfigWetlandWaterPP = ((BaseUnityPlugin)this).Config.Bind<bool>("WaterTweaker", "WetlandPostProcessing", true, "Enables Post Processing effects when the camera goes underwater in Wetland Aspect."); ConfigWetlandWaterPP.SettingChanged += OnWaterSettingsChanged; if (RiskOfOptionsCompat.Enabled) { RiskOfOptionsCompat.AddOptionStepSlider(ConfigWetlandWaterOpacity, 0f, 1f, 0.1f, "Wetland Water Opacity"); RiskOfOptionsCompat.AddOptionCheckbox(ConfigWetlandWaterPP, "Wetland Post Processing"); RiskOfOptionsCompat.SetModDescription("Allows you to tweak the graphics settings of Wetland Aspect's water."); } SceneManager.activeSceneChanged += OnActiveSceneChanged; Log.LogInfo("Awake done."); } public void Update() { if (tryApplyTweaks && !loopRunning) { ((MonoBehaviour)this).StartCoroutine("ApplyTweaksCoroutine"); } } private IEnumerator ApplyTweaksCoroutine() { loopRunning = true; tryApplyTweaks = false; while (applyAttempts < 10 && !TryApplyTweaksWetland()) { applyAttempts++; yield return (object)new WaitForSeconds(0.5f); } applyAttempts = 0; loopRunning = false; } private bool TryApplyTweaksWetland() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) IEnumerable<GameObject> enumerable = Resources.FindObjectsOfTypeAll<GameObject>().Where(IsWaterPlaneObject); Log.LogInfo($"Trying to apply Wetland Water Tweaks to {enumerable.Count()} objects."); foreach (GameObject item in enumerable) { Transform val = item.transform.Find("PP"); if (!Object.op_Implicit((Object)(object)val)) { return false; } ((Component)val).gameObject.SetActive(ConfigWetlandWaterPP.Value); MeshRenderer component = item.GetComponent<MeshRenderer>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } Color color = ((Renderer)component).material.color; ((Renderer)component).material.color = new Color(color.r, color.g, color.b, Mathf.Clamp01(ConfigWetlandWaterOpacity.Value)); } return true; } private static bool IsWaterPlaneObject(GameObject go) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)go == (Object)null)) { _ = go.scene; Scene scene = go.scene; if (((Scene)(ref scene)).name != null && ((Object)go).name != null) { scene = go.scene; if (((Scene)(ref scene)).name.StartsWith("foggyswamp")) { return ((Object)go).name.StartsWith("water plane", StringComparison.OrdinalIgnoreCase); } return false; } } return false; } private void OnWaterSettingsChanged(object sender, EventArgs e) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name.StartsWith("foggyswamp")) { tryApplyTweaks = true; } } private void OnActiveSceneChanged(Scene oldScene, Scene newScene) { if (((Scene)(ref newScene)).name.StartsWith("foggyswamp")) { tryApplyTweaks = true; } } private void DEBUG_GoToWetlandMap() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) IEnumerable<SceneDef> source = ((IEnumerable<SceneDef>)(object)SceneCatalog.allSceneDefs).Where((SceneDef def) => def.cachedName == "foggyswamp"); if (source.Any()) { Run.instance.AdvanceStage(source.First()); } } } public static class WaterTweaker_Commands { [ConCommand(commandName = "watertweaker_opacity", helpText = "Set Opacity of the water in Wetland Aspect. Value must be between 0.0 and 1.0. args[0]=(float)value")] public static void CommandOpacity(ConCommandArgs args) { string text = ((ConCommandArgs)(ref args)).TryGetArgString(0); if (string.IsNullOrWhiteSpace(text)) { Debug.Log((object)("Current Water Opacity Value: `" + WaterTweakerPlugin.ConfigWetlandWaterOpacity.Value.ToString(CultureInfo.InvariantCulture) + "`.")); return; } text = text.Trim().Replace(',', '.'); if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { Debug.LogError((object)"Couldn't parse new value as float."); } else if (result >= 0f && result <= 1f) { WaterTweakerPlugin.ConfigWetlandWaterOpacity.Value = result; Debug.Log((object)("Water Opacity set to " + result.ToString(CultureInfo.InvariantCulture))); } else { Debug.LogError((object)"Opacity value out of bounds ! Must be between 0.0 and 1.0"); } } [ConCommand(commandName = "watertweaker_pp", helpText = "Enables Post processing effects when the camera is under water in Wetland Aspect. Value must be `true`, `false`, `0` or `1`. args[0]=(bool)value")] public static void CommandPP(ConCommandArgs args) { string text = ((ConCommandArgs)(ref args)).TryGetArgString(0); if (string.IsNullOrWhiteSpace(text)) { Debug.Log((object)$"Post processing effects enabled : `{WaterTweakerPlugin.ConfigWetlandWaterPP.Value}`."); return; } text = text.Trim().ToLower(); if (!TryParseBool(text, out var result)) { Debug.LogError((object)"Couldn't parse new value as bool. Value must be `true`, `false`, `0` or `1`"); return; } WaterTweakerPlugin.ConfigWetlandWaterPP.Value = result; Debug.Log((object)("Water Post Processing effects now " + (result ? "enabled." : "disabled."))); } private static bool TryParseBool(string input, out bool result) { if (bool.TryParse(input, out result)) { return true; } if (int.TryParse(input, out var result2)) { result = result2 > 0; return true; } return false; } } }