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 DarkRepo v1.3.0
DarkRepo.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("linkoid")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+e5d7c20f3a3ef7ab124143d814c6bebc48eaf694")] [assembly: AssemblyProduct("DarkRepo")] [assembly: AssemblyTitle("DarkRepo")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 DarkRepo { public static class MyPluginInfo { public const string PLUGIN_GUID = "DarkRepo"; public const string PLUGIN_NAME = "DarkRepo"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } } namespace Linkoid.Repo.DarkRepo { internal readonly struct AdjustmentCurve { private const float x_0 = -1f; private const float x_1 = 0f; private const float x_2 = 1f; private const float y_0 = 0f; private const float y_2 = 1f; private readonly float y_1; private readonly float dydx_0; private readonly float dydx_1; private readonly float dydx_2; private readonly float ddydx_1_0; private readonly float ddydx_1_1; private readonly float ddydx_2_1; private readonly float ddydx_2_2; private readonly float a_1; private readonly float b_1; private readonly float c_1; private readonly float d_1; private readonly float a_2; private readonly float b_2; private readonly float c_2; private readonly float d_2; public AdjustmentCurve(float yIntercept) { y_1 = yIntercept; dydx_1 = 2f / (1f / (1f - y_1) + 1f / (y_1 - 0f)); if (dydx_1 < 0f) { dydx_1 = 0f; dydx_2 = 0f; } else { dydx_2 = 3f * (1f - y_1) / 2f * 1f - dydx_1 / 2f; } dydx_0 = 3f * (y_1 - 0f) / 2f * 1f - dydx_1 / 2f; ddydx_1_0 = -2f * (dydx_1 + 2f * dydx_0) / 1f + 6f * (y_1 - 0f) / 1f; ddydx_1_1 = 2f * (2f * dydx_1 + dydx_0) / 1f - 6f * (y_1 - 0f) / 1f; ddydx_2_1 = -2f * (dydx_2 + 2f * dydx_1) / 1f + 6f * (1f - y_1) / 1f; ddydx_2_2 = 2f * (2f * dydx_2 + dydx_1) / 1f - 6f * (1f - y_1) / 1f; d_1 = (ddydx_1_1 - ddydx_1_0) / 6f; c_1 = (0f * ddydx_1_0 - -1f * ddydx_1_1) / 2f; b_1 = (y_1 - 0f - c_1 * -1f - d_1 * 1f) / 1f; a_1 = 0f - b_1 * -1f - c_1 * 1f - d_1 * -1f; d_2 = (ddydx_2_2 - ddydx_2_1) / 6f; c_2 = (1f * ddydx_2_1 - 0f * ddydx_2_2) / 2f; b_2 = (1f - y_1 - c_2 * 1f - d_2 * 1f) / 1f; a_2 = y_1 - b_2 * 0f - c_2 * 0f - d_2 * 0f; } public float Evaluate(float x) { if (x <= 0f) { return a_1 + b_1 * x + c_1 * x * x + d_1 * x * x * x; } return a_2 + b_2 * x + c_2 * x * x + d_2 * x * x * x; } } internal static class ConfigFileExtensions { private static readonly MethodInfo prop_OrphanedEntries = AccessTools.DeclaredPropertyGetter(typeof(ConfigFile), "OrphanedEntries"); public static IReadOnlyCollection<ConfigDefinition> GetOrphanedDefinitions(this ConfigFile configFile) { Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)prop_OrphanedEntries.Invoke(configFile, Array.Empty<object>()); return dictionary.Keys; } public static bool TryGetOrphanedEntry<T>(this ConfigFile configFile, ConfigDefinition configDefinition, [NotNullWhen(true)] out ConfigEntry<T>? entry, T defaultValue = default(T), ConfigDescription? configDescription = null) { entry = null; if (!configFile.GetOrphanedDefinitions().Contains(configDefinition)) { return false; } entry = configFile.Bind<T>(configDefinition, defaultValue, configDescription); return true; } public static bool TryGetOrphanedEntry<T>(this ConfigFile configFile, string section, string key, [NotNullWhen(true)] out ConfigEntry<T>? entry, T defaultValue = default(T), ConfigDescription? configDescription = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return configFile.TryGetOrphanedEntry(new ConfigDefinition(section, key), out entry, defaultValue, configDescription); } public static bool TryGetOrphanedEntry<T>(this ConfigFile configFile, string section, string key, [NotNullWhen(true)] out ConfigEntry<T>? entry, T defaultValue, string description) { //IL_0003: 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_001d: Expected O, but got Unknown //IL_001d: Expected O, but got Unknown return configFile.TryGetOrphanedEntry(new ConfigDefinition(section, key), out entry, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } } internal record ConfigModel(ConfigFile ConfigFile) { internal const string GeneralSection = "General"; public readonly ConfigEntry<float> AmbientFactor = ConfigFile.Bind<float>("General", "AmbientFactor", 0.4f, new ConfigDescription("General environment brightness", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>())); public readonly ConfigEntry<float> LightFactor = ConfigFile.Bind<float>("General", "LightFactor", 0.45f, new ConfigDescription("Dynamic lighting intensity", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>())); public readonly ConfigEntry<float> EmissiveFactor = ConfigFile.Bind<float>("General", "EmissiveFactor", 0.85f, new ConfigDescription("Glowing texture intensity", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>())); public readonly ConfigEntry<float> FlashlightFactor = ConfigFile.Bind<float>("General", "FlashlightFactor", 2f, new ConfigDescription("Flashlight intensity", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 8f), Array.Empty<object>())); internal const string LevelsSection = "Levels"; internal static readonly ConfigDescription LevelConfigDescription = new ConfigDescription("<-- Darker | 0 = Use General Settings | Lighter --> | 1 = Game Default", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.99f, 2f), Array.Empty<object>()); public readonly Dictionary<string, ConfigEntry<float>> Levels = new Dictionary<string, ConfigEntry<float>> { ["MainMenu"] = ConfigFile.Bind<float>("Levels", "MainMenu", 0f, LevelConfigDescription), ["LobbyMenu"] = ConfigFile.Bind<float>("Levels", "LobbyMenu", 0f, LevelConfigDescription), ["ServiceStation"] = ConfigFile.Bind<float>("Levels", "ServiceStation", 0f, LevelConfigDescription), ["Truck"] = ConfigFile.Bind<float>("Levels", "Truck", 0f, LevelConfigDescription), ["DisposalArena"] = ConfigFile.Bind<float>("Levels", "DisposalArena", 0f, LevelConfigDescription), ["HeadmanManor"] = ConfigFile.Bind<float>("Levels", "HeadmanManor", 0f, LevelConfigDescription), ["McJannekStation"] = ConfigFile.Bind<float>("Levels", "McJannekStation", 0f, LevelConfigDescription), ["SwiftbroomAcademy"] = ConfigFile.Bind<float>("Levels", "SwiftbroomAcademy", 0f, LevelConfigDescription) }; public void RunMigrations() { ConfigFile.SaveOnConfigSet = false; try { Migrate_1_3(); ConfigFile.Save(); } catch (Exception ex) { DarkRepo.Logger.LogWarning((object)("An error occured during config migration. Please delete the config file.\n" + ex.Message + "\n" + ex.StackTrace)); } ConfigFile.SaveOnConfigSet = true; } public void LoadExtraLevelConfigs() { MethodInfo methodInfo = AccessTools.DeclaredPropertyGetter(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)methodInfo.Invoke(ConfigFile, Array.Empty<object>()); foreach (ConfigDefinition item in new List<ConfigDefinition>(ConfigFile.GetOrphanedDefinitions())) { if (!(item.Section != "Levels") && !Levels.ContainsKey(item.Key)) { Levels[item.Key] = ConfigFile.Bind<float>(item, 0f, LevelConfigDescription); } } } private bool Migrate_1_3() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown bool flag = false; flag |= ConfigFile.TryGetOrphanedEntry(new ConfigDefinition("DarkRepoConfig", "AmbientFactor"), out ConfigEntry<float> entry, 0f); flag |= ConfigFile.TryGetOrphanedEntry(new ConfigDefinition("DarkRepoConfig", "LightFactor"), out ConfigEntry<float> entry2, 0f); flag |= ConfigFile.TryGetOrphanedEntry(new ConfigDefinition("DarkRepoConfig", "EmissiveFactor"), out ConfigEntry<float> entry3, 0f); if (!(flag | ConfigFile.TryGetOrphanedEntry(new ConfigDefinition("DarkRepoConfig", "FlashlightFactor"), out ConfigEntry<float> entry4, 0f))) { return false; } DarkRepo.Logger.LogMessage((object)"Migrating config from v1.3 to v1.4"); if ((entry != null && entry.Value != 0.2f) || (entry2 != null && entry2.Value != 0.25f)) { AmbientFactor.Value = entry?.Value ?? 0.2f; LightFactor.Value = entry2?.Value ?? 0.25f; } if (entry3 != null && entry3.Value != 0.75f) { EmissiveFactor.Value = entry3.Value; } if (entry4 != null && entry4.Value != 2f) { FlashlightFactor.Value = entry4.Value; } ConfigFile.Remove((entry != null) ? ((ConfigEntryBase)entry).Definition : null); ConfigFile.Remove((entry2 != null) ? ((ConfigEntryBase)entry2).Definition : null); ConfigFile.Remove((entry3 != null) ? ((ConfigEntryBase)entry3).Definition : null); ConfigFile.Remove((entry4 != null) ? ((ConfigEntryBase)entry4).Definition : null); return true; } [CompilerGenerated] protected ConfigModel(ConfigModel original) { ConfigFile = original.ConfigFile; AmbientFactor = original.AmbientFactor; LightFactor = original.LightFactor; EmissiveFactor = original.EmissiveFactor; FlashlightFactor = original.FlashlightFactor; Levels = original.Levels; } } [BepInPlugin("Linkoid.Repo.DarkRepo", "Dark REPO", "1.3")] public class DarkRepo : BaseUnityPlugin { internal static DarkRepo Instance; private ConfigModel ConfigModel; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Instance = this; new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll(); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ConfigModel = new ConfigModel(((BaseUnityPlugin)this).Config); ConfigModel.RunMigrations(); ConfigModel.LoadExtraLevelConfigs(); LevelAdjustment.ConfigDictionary = ConfigModel.Levels; FetchConfigValues(); ((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged; Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } private void OnSettingChanged(object sender, SettingChangedEventArgs args) { if (args.ChangedSetting == null) { return; } if (args.ChangedSetting == ConfigModel.AmbientFactor) { EnvironmentDirectorPatches.AmbientColorAdaptationFactorCurve = (EnvironmentDirectorPatches.AmbientColorFactorCurve = (EnvironmentDirectorPatches.FogColorFactorCurve = new AdjustmentCurve(ConfigModel.AmbientFactor.Value))); EnvironmentDirector instance = EnvironmentDirector.Instance; if (instance != null) { instance.Setup(); } } else if (args.ChangedSetting == ConfigModel.LightFactor) { LightManagerPatches.LightFactorCurve = new AdjustmentCurve(ConfigModel.LightFactor.Value); UpdateLightsInstant(); } else if (args.ChangedSetting == ConfigModel.EmissiveFactor) { LightManagerPatches.EmissiveFactorCurve = new AdjustmentCurve(ConfigModel.EmissiveFactor.Value); UpdateLightsInstant(); } else if (args.ChangedSetting == ConfigModel.FlashlightFactor) { FlashlightControllerPatches.FlashlightFactor = ConfigModel.FlashlightFactor.Value; FlashlightController instance2 = FlashlightController.Instance; if (instance2 != null && instance2.LightActive) { FlashlightController.Instance.lightOnLerp = 1f; FlashlightController.Instance.LightOn(); } } else if (!LevelAdjustment.BindingNewConfig && args.ChangedSetting == LevelAdjustment.CurrentConfig) { Logger.LogDebug((object)args.ChangedSetting.Definition.Key); EnvironmentDirector instance3 = EnvironmentDirector.Instance; if (instance3 != null) { instance3.Setup(); } UpdateLightsInstant(); } } private void FetchConfigValues() { EnvironmentDirectorPatches.AmbientColorAdaptationFactorCurve = (EnvironmentDirectorPatches.AmbientColorFactorCurve = (EnvironmentDirectorPatches.FogColorFactorCurve = new AdjustmentCurve(ConfigModel.AmbientFactor.Value))); LightManagerPatches.LightFactorCurve = new AdjustmentCurve(ConfigModel.LightFactor.Value); LightManagerPatches.EmissiveFactorCurve = new AdjustmentCurve(ConfigModel.EmissiveFactor.Value); FlashlightControllerPatches.FlashlightFactor = ConfigModel.FlashlightFactor.Value; } private void UpdateLightsInstant() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)LightManager.instance == (Object)null)) { Transform lightCullTarget = LightManager.instance.lightCullTarget; if (!((Object)(object)lightCullTarget == (Object)null)) { ((Component)this).gameObject.transform.position = lightCullTarget.position + new Vector3(1f, 1f, 1f) * GraphicsManager.instance.lightDistance * 100f; LightManager.instance.lightCullTarget = ((Component)this).gameObject.transform; LightManager.instance.UpdateInstant(); LightManager.instance.lightCullTarget = lightCullTarget; LightManager.instance.UpdateInstant(); ((Component)this).gameObject.transform.position = Vector3.zero; } } } } [HarmonyPatch(typeof(EnvironmentDirector))] internal static class EnvironmentDirectorPatches { internal static AdjustmentCurve FogColorFactorCurve = new AdjustmentCurve(0.2f); internal static AdjustmentCurve AmbientColorFactorCurve = new AdjustmentCurve(0.2f); internal static AdjustmentCurve AmbientColorAdaptationFactorCurve = new AdjustmentCurve(0.2f); internal static float FogColorFactor => FogColorFactorCurve.Evaluate(LevelAdjustment.CurrentValue); internal static float AmbientColorFactor => AmbientColorFactorCurve.Evaluate(LevelAdjustment.CurrentValue); internal static float AmbientColorAdaptationFactor => AmbientColorAdaptationFactorCurve.Evaluate(LevelAdjustment.CurrentValue); [HarmonyPostfix] [HarmonyPatch("Setup")] private static void Setup_Postfix(EnvironmentDirector __instance) { //IL_0010: 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_0027: 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) float num = FogColorFactorCurve.Evaluate(LevelAdjustment.CurrentValue); RenderSettings.fogColor *= num; Camera mainCamera = __instance.MainCamera; mainCamera.backgroundColor *= num; } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Color), "op_Multiply", new Type[2] { typeof(Color), typeof(float) }, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(Level), "AmbientColor"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(Level), "AmbientColorAdaptation"); MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(EnvironmentDirectorPatches), "AmbientColorFactor"); MethodInfo methodInfo3 = AccessTools.PropertyGetter(typeof(EnvironmentDirectorPatches), "AmbientColorAdaptationFactor"); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null) }; val.MatchForward(true, array); val.ThrowIfInvalid("Could not match ambientColorMatch"); val.Advance(1); DarkRepo.Logger.LogDebug((object)val.Instruction.opcode); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Call, (object)methodInfo2), new CodeInstruction(OpCodes.Call, (object)methodInfo) }); CodeMatch[] array2 = (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo2, (string)null) }; val.MatchForward(true, array2); val.ThrowIfInvalid("Could not match ambientColorAdaptationMatch"); val.Advance(1); DarkRepo.Logger.LogDebug((object)val.Instruction.opcode); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Call, (object)methodInfo3), new CodeInstruction(OpCodes.Call, (object)methodInfo) }); return val.InstructionEnumeration(); } } [HarmonyPatch(typeof(FlashlightController))] internal class FlashlightControllerPatches { internal static float FlashlightFactor = 2f; [HarmonyPostfix] [HarmonyPatch("LightOn")] private static void LightOn_Prefix(FlashlightController __instance) { __instance.baseIntensity *= FlashlightFactor; } } internal static class LevelAdjustment { internal static Dictionary<string, ConfigEntry<float>> ConfigDictionary; public static float CurrentValue => CurrentConfig?.Value ?? 0f; internal static bool BindingNewConfig { get; private set; } public static ConfigEntry<float>? CurrentConfig { get { if (LevelGenerator.Instance?.Level?.NarrativeName == null) { return null; } string text = LevelGenerator.Instance.Level.NarrativeName.Replace(" ", ""); if (string.IsNullOrWhiteSpace(text)) { return null; } if (!ConfigDictionary.TryGetValue(text, out ConfigEntry<float> value)) { BindingNewConfig = true; value = ((BaseUnityPlugin)DarkRepo.Instance).Config.Bind<float>("Levels", text, 0f, ConfigModel.LevelConfigDescription); ConfigDictionary.Add(text, value); BindingNewConfig = false; } return value; } } } [HarmonyPatch(typeof(LightManager))] internal class LightManagerPatches { internal static AdjustmentCurve LightFactorCurve = new AdjustmentCurve(0.25f); internal static AdjustmentCurve EmissiveFactorCurve = new AdjustmentCurve(0.75f); internal static float LightFactor => LightFactorCurve.Evaluate(LevelAdjustment.CurrentValue); internal static float EmissiveFactor => EmissiveFactorCurve.Evaluate(LevelAdjustment.CurrentValue); [HarmonyPrefix] [HarmonyPatch("FadeLightIntensity")] private static void FadeLightIntensity_Prefix(PropLight propLight, ref float targetIntensity) { targetIntensity *= LightFactor; } [HarmonyPrefix] [HarmonyPatch("FadeEmissionIntensity")] private static void FadeEmissionIntensity_Prefix(ref Color targetColor) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) targetColor *= EmissiveFactor; } } }