Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BrighterWisplight v1.2.1
plugins/BrighterWisplight.dll
Decompiled 4 hours agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Pass-os")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Deixa a luz da Wisplight forte o suficiente para enxergar. So luz.")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1+89bfa956d6149d4719bc244bdd6c8fc28c84acbe")] [assembly: AssemblyProduct("Brighter Wisplight")] [assembly: AssemblyTitle("BrighterWisplight")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BrighterWisplight { internal static class ModConfig { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> IntensityMultiplier; internal static ConfigEntry<float> RangeMultiplier; internal static ConfigEntry<bool> CastShadows; internal static ConfigEntry<bool> SkipCreatures; internal static ConfigEntry<string> NameFilter; internal static ConfigEntry<bool> VerboseLogging; internal static bool Active { get { if (Enabled != null) { return Enabled.Value; } return false; } } internal static void Init(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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 Enabled = config.Bind<bool>("1 - Geral", "Enabled", true, "Liga/desliga o mod inteiro. Desligar restaura os valores originais."); IntensityMultiplier = config.Bind<float>("2 - Luz", "IntensityMultiplier", 1.127699f, new ConfigDescription("Multiplicador do brilho da wisp. 1 = vanilla. Teto baixo de proposito: passar muito de 1 estoura a imagem.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1.5f), Array.Empty<object>())); RangeMultiplier = config.Bind<float>("2 - Luz", "RangeMultiplier", 4.397653f, new ConfigDescription("Multiplicador do alcance da luz (quao longe ela ilumina). 1 = vanilla. Aumentar aqui e o jeito seguro de enxergar mais, sem estourar o brilho.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); CastShadows = config.Bind<bool>("2 - Luz", "CastShadows", false, "Faz a wisp projetar sombras, como uma tocha de verdade. Fica bonito, mas custa FPS — por isso vem desligado."); SkipCreatures = config.Bind<bool>("3 - Avancado", "SkipCreatures", true, "Nao mexe em wisps presas a criaturas. Hugin, Munin e a Mistwalker carregam Demister; sem isto, a luz deles muda junto."); NameFilter = config.Bind<string>("3 - Avancado", "NameFilter", "", "Vazio = afeta a wisp carregada e as tochas de wisp. Preencha com parte do nome do objeto para afetar so ele. Nomes reais: 'Demister' (wisp equipada), '_enabled' (tocha de wisp), 'Mistwalker'. Ligue VerboseLogging para descobrir os nomes reais no seu jogo."); VerboseLogging = config.Bind<bool>("3 - Avancado", "VerboseLogging", false, "Loga no console cada objeto afetado, com os valores antes e depois. Use para descobrir nomes para o NameFilter."); } } [BepInPlugin("com.pass-os.brighterwisplight", "Brighter Wisplight", "1.2.1")] [BepInProcess("valheim.exe")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ModConfig.Init(((BaseUnityPlugin)this).Config); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { WispTweaks.ApplyToAll(); }; _harmony = new Harmony("com.pass-os.brighterwisplight"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"Brighter Wisplight v1.2.1 carregado."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class WispTweaks { private sealed class LightState { internal Light Light; internal LightFlicker Flicker; internal LightLod Lod; internal float BaseIntensity; internal float BaseRange; internal LightShadows BaseShadows; } private sealed class WispState { internal List<LightState> Lights = new List<LightState>(); internal string RootName; } private static readonly ConditionalWeakTable<GameObject, WispState> Originals = new ConditionalWeakTable<GameObject, WispState>(); private const int MaxClimb = 3; internal static void Apply(Demister demister) { if ((Object)(object)demister == (Object)null) { return; } try { Transform root = FindVisualRoot(demister); if ((Object)(object)root == (Object)null) { if (ModConfig.VerboseLogging.Value) { Plugin.Log.LogInfo((object)("Nenhuma luz encontrada a partir de '" + ((Object)((Component)demister).gameObject).name + "' " + $"(subindo ate {3} niveis). Ignorando.")); } } else { if (!MatchesFilter(root) || (ModConfig.SkipCreatures.Value && IsCreature(root))) { return; } WispState value = Originals.GetValue(((Component)root).gameObject, (GameObject _) => Capture(root)); if (!ModConfig.Active) { Restore(value); return; } ApplyLights(value); if (ModConfig.VerboseLogging.Value) { LogState(demister, value); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Falha ao aplicar em '{((Object)demister).name}': {arg}"); } } internal static void ApplyToAll() { List<Demister> demisters = Demister.GetDemisters(); if (demisters != null) { Demister[] array = demisters.ToArray(); for (int i = 0; i < array.Length; i++) { Apply(array[i]); } } } private static Transform FindVisualRoot(Demister demister) { Transform val = ((Component)demister).transform; for (int i = 0; i <= 3; i++) { if (!((Object)(object)val != (Object)null)) { break; } if (((Component)val).GetComponentsInChildren<Light>(true).Length != 0) { return val; } Transform parent = val.parent; if ((Object)(object)parent == (Object)null || (Object)(object)((Component)parent).GetComponent<Character>() != (Object)null) { break; } val = parent; } return null; } private static WispState Capture(Transform root) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) WispState wispState = new WispState { RootName = ((Object)root).name }; Light[] componentsInChildren = ((Component)root).GetComponentsInChildren<Light>(true); foreach (Light val in componentsInChildren) { LightFlicker component = ((Component)val).GetComponent<LightFlicker>(); LightLod component2 = ((Component)val).GetComponent<LightLod>(); wispState.Lights.Add(new LightState { Light = val, Flicker = component, Lod = component2, BaseIntensity = (((Object)(object)component != (Object)null && (Object)(object)component.m_light != (Object)null) ? component.m_baseIntensity : val.intensity), BaseRange = (((Object)(object)component2 != (Object)null && (Object)(object)component2.m_light != (Object)null) ? component2.m_baseRange : val.range), BaseShadows = val.shadows }); } return wispState; } private static void ApplyLights(WispState state) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) float value = ModConfig.IntensityMultiplier.Value; float value2 = ModConfig.RangeMultiplier.Value; foreach (LightState light in state.Lights) { if (!((Object)(object)light.Light == (Object)null)) { float num = light.BaseIntensity * value; float num2 = light.BaseRange * value2; light.Light.intensity = num; light.Light.range = num2; if ((Object)(object)light.Flicker != (Object)null) { light.Flicker.m_baseIntensity = num; } if ((Object)(object)light.Lod != (Object)null) { light.Lod.m_baseRange = num2; } light.Light.shadows = (LightShadows)(ModConfig.CastShadows.Value ? 2 : ((int)light.BaseShadows)); } } } private static void Restore(WispState state) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) foreach (LightState light in state.Lights) { if (!((Object)(object)light.Light == (Object)null)) { light.Light.intensity = light.BaseIntensity; light.Light.range = light.BaseRange; light.Light.shadows = light.BaseShadows; if ((Object)(object)light.Flicker != (Object)null) { light.Flicker.m_baseIntensity = light.BaseIntensity; } if ((Object)(object)light.Lod != (Object)null) { light.Lod.m_baseRange = light.BaseRange; } } } } private static bool MatchesFilter(Transform root) { string value = ModConfig.NameFilter.Value; if (string.IsNullOrEmpty(value)) { return true; } return ((Object)root).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0; } private static bool IsCreature(Transform root) { if (!((Object)(object)((Component)root).GetComponentInParent<Character>() != (Object)null) && !((Object)(object)((Component)root).GetComponentInParent<Raven>() != (Object)null)) { return (Object)(object)((Component)root).GetComponentInParent<BaseAI>() != (Object)null; } return true; } private static void LogState(Demister demister, WispState state) { Plugin.Log.LogInfo((object)("Wisp '" + ((Object)((Component)demister).gameObject).name + "' -> raiz visual '" + state.RootName + "': " + $"{state.Lights.Count} luz(es).")); foreach (LightState light in state.Lights) { if (!((Object)(object)light.Light == (Object)null)) { Plugin.Log.LogInfo((object)(" luz '" + ((Object)light.Light).name + "': " + $"intensidade {light.BaseIntensity:0.##} -> {light.Light.intensity:0.##}, " + $"alcance {light.BaseRange:0.##} -> {light.Light.range:0.##}")); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.pass-os.brighterwisplight"; public const string PLUGIN_NAME = "Brighter Wisplight"; public const string PLUGIN_VERSION = "1.2.1"; } } namespace BrighterWisplight.Patches { [HarmonyPatch(typeof(Demister))] internal static class DemisterPatches { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(Demister __instance) { WispTweaks.Apply(__instance); } [HarmonyPostfix] [HarmonyPatch("OnEnable")] private static void OnEnable_Postfix(Demister __instance) { WispTweaks.Apply(__instance); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } [EditorBrowsable(EditorBrowsableState.Never)] internal static class IsExternalInit { } }