using System;
using System.Collections.Generic;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using com.github.zehsteam.RemoveInteriorFog.Dependencies;
using com.github.zehsteam.RemoveInteriorFog.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.RemoveInteriorFog")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+b66a2dd2456e27a31348b0384a968f6016bae6c1")]
[assembly: AssemblyProduct("RemoveInteriorFog")]
[assembly: AssemblyTitle("com.github.zehsteam.RemoveInteriorFog")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 com.github.zehsteam.RemoveInteriorFog
{
internal static class ConfigHelper
{
public static void SkipAutoGen()
{
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.SkipAutoGen();
}
}
public static void AddButton(string section, string name, string description, string buttonText, Action callback)
{
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.AddButton(section, name, description, buttonText, callback);
}
}
public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, bool requiresRestart, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
if (configFile == null)
{
configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
}
ConfigEntry<T> configEntry = ((acceptableValues == null) ? configFile.Bind<T>(section, key, defaultValue, description) : configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())));
if (settingChanged != null)
{
configEntry.SettingChanged += delegate
{
settingChanged?.Invoke(configEntry.Value);
};
}
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart);
}
return configEntry;
}
public static Dictionary<ConfigDefinition, string> GetOrphanedConfigEntries(ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
}
PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
return (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
}
public static void SetConfigEntryValue<T>(ConfigEntry<T> configEntry, string value)
{
if (typeof(T) == typeof(int) && int.TryParse(value, out var result))
{
configEntry.Value = (T)(object)result;
return;
}
if (typeof(T) == typeof(float) && float.TryParse(value, out var result2))
{
configEntry.Value = (T)(object)result2;
return;
}
if (typeof(T) == typeof(double) && double.TryParse(value, out var result3))
{
configEntry.Value = (T)(object)result3;
return;
}
if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result4))
{
configEntry.Value = (T)(object)result4;
return;
}
if (typeof(T) == typeof(string))
{
configEntry.Value = (T)(object)value;
return;
}
throw new InvalidOperationException($"Unsupported type: {typeof(T)}");
}
public static void ClearUnusedEntries(ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
}
Dictionary<ConfigDefinition, string> orphanedConfigEntries = GetOrphanedConfigEntries(configFile);
if (orphanedConfigEntries != null)
{
orphanedConfigEntries.Clear();
configFile.Save();
}
}
}
internal class ConfigManager
{
public ConfigEntry<bool> DisableVanillaInteriorFog { get; private set; }
public ConfigEntry<bool> DisableOtherInteriorFog { get; private set; }
public ConfigManager()
{
BindConfigs();
}
private void BindConfigs()
{
ConfigHelper.SkipAutoGen();
DisableVanillaInteriorFog = ConfigHelper.Bind("General", "DisableVanillaInteriorFog", defaultValue: true, requiresRestart: false, "If enabled, the vanilla interior fog added in v67 will be removed.");
DisableOtherInteriorFog = ConfigHelper.Bind("General", "DisableOtherInteriorFog", defaultValue: false, requiresRestart: false, "If enabled, other interior fog will be removed. Works with modded interior fog.");
ConfigHelper.AddButton("General", "Remove Vanilla Interior Fog", "Will remove the vanilla interior fog added in v67 for the current moon.", "Remove", RoundManagerPatch.RemoveVanillaInteriorFog);
ConfigHelper.AddButton("General", "Remove Other Interior Fog", "Will remove other interior fog for the current moon. Works with modded interior fog.", "Remove", RoundManagerPatch.RemoveOtherInteriorFog);
}
}
[BepInPlugin("com.github.zehsteam.RemoveInteriorFog", "RemoveInteriorFog", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("com.github.zehsteam.RemoveInteriorFog");
internal static Plugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static ConfigManager ConfigManager { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Logger = Logger.CreateLogSource("com.github.zehsteam.RemoveInteriorFog");
Logger.LogInfo((object)"RemoveInteriorFog has awoken!");
_harmony.PatchAll(typeof(RoundManagerPatch));
ConfigManager = new ConfigManager();
}
}
internal static class Utils
{
public static string GetHierarchyPath(Transform transform)
{
if ((Object)(object)transform == (Object)null)
{
return string.Empty;
}
string text = ((Object)transform).name;
Transform val = transform;
while ((Object)(object)val.parent != (Object)null)
{
val = val.parent;
text = ((Object)val).name + "/" + text;
}
return text;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.zehsteam.RemoveInteriorFog";
public const string PLUGIN_NAME = "RemoveInteriorFog";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace com.github.zehsteam.RemoveInteriorFog.Patches
{
[HarmonyPatch(typeof(RoundManager))]
internal static class RoundManagerPatch
{
[HarmonyPatch("RefreshEnemiesList")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void RefreshEnemiesListPatch()
{
if (Plugin.ConfigManager.DisableVanillaInteriorFog.Value)
{
RemoveVanillaInteriorFog();
}
}
[HarmonyPatch("FinishGeneratingLevel")]
[HarmonyPostfix]
private static void FinishGeneratingLevelPatch()
{
if (Plugin.ConfigManager.DisableOtherInteriorFog.Value)
{
RemoveOtherInteriorFog();
}
}
public static void RemoveVanillaInteriorFog()
{
if (!((Object)(object)RoundManager.Instance == (Object)null) && !((Object)(object)RoundManager.Instance.indoorFog == (Object)null))
{
DisableLocalVolumetricFog(RoundManager.Instance.indoorFog, "Vanilla interior fog has been disabled.");
}
}
public static void RemoveOtherInteriorFog()
{
DisableFogOnDungeonTiles();
DisableFogBelowMoonSurface();
}
private static void DisableFogOnDungeonTiles()
{
Tile[] array = Object.FindObjectsByType<Tile>((FindObjectsSortMode)0);
foreach (Tile val in array)
{
LocalVolumetricFog[] componentsInChildren = ((Component)val).GetComponentsInChildren<LocalVolumetricFog>();
foreach (LocalVolumetricFog localVolumetricFog in componentsInChildren)
{
DisableLocalVolumetricFog(localVolumetricFog);
}
}
}
private static void DisableFogBelowMoonSurface()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//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_00ad: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)RoundManager.Instance == (Object)null || (Object)(object)RoundManager.Instance.dungeonGenerator == (Object)null || (Object)(object)RoundManager.Instance.dungeonGenerator.Root == (Object)null)
{
return;
}
float num = RoundManager.Instance.dungeonGenerator.Root.transform.position.y + 10f;
LocalVolumetricFog[] array = Object.FindObjectsByType<LocalVolumetricFog>((FindObjectsSortMode)0);
foreach (LocalVolumetricFog val in array)
{
if (!((Object)(object)val == (Object)(object)RoundManager.Instance.indoorFog))
{
Vector3 bottomPosition = GetBottomPosition(val);
if (bottomPosition.y <= num)
{
DisableLocalVolumetricFog(val);
}
}
}
}
private static Vector3 GetBottomPosition(LocalVolumetricFog localVolumetricFog)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)localVolumetricFog == (Object)null)
{
return Vector3.zero;
}
Vector3 position = ((Component)localVolumetricFog).transform.position;
position.y -= localVolumetricFog.parameters.size.y / 2f;
return position;
}
private static void DisableLocalVolumetricFog(LocalVolumetricFog localVolumetricFog, string message = "")
{
if (!((Object)(object)localVolumetricFog == (Object)null))
{
((Component)localVolumetricFog).gameObject.SetActive(false);
if (!string.IsNullOrWhiteSpace(message))
{
Plugin.Logger.LogInfo((object)message);
}
else
{
Plugin.Logger.LogInfo((object)("Disabled LocalVolumetricFog \"" + Utils.GetHierarchyPath(((Component)localVolumetricFog).transform) + "\"."));
}
}
}
}
}
namespace com.github.zehsteam.RemoveInteriorFog.Dependencies
{
internal static class LethalConfigProxy
{
public const string PLUGIN_GUID = "ainavt.lc.lethalconfig";
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void SkipAutoGen()
{
LethalConfigManager.SkipAutoGen();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
if (acceptableValues != null)
{
if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>)
{
AddConfigSlider<T>(configEntry, requiresRestart);
return;
}
if (acceptableValues is AcceptableValueList<string>)
{
AddConfigDropdown<T>(configEntry, requiresRestart);
return;
}
}
if (!(configEntry is ConfigEntry<string> val))
{
if (!(configEntry is ConfigEntry<bool> val2))
{
if (!(configEntry is ConfigEntry<float> val3))
{
if (!(configEntry is ConfigEntry<int> val4))
{
throw new NotSupportedException($"Unsupported type: {typeof(T)}");
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart));
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart));
}
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart));
}
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart));
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
if (!(configEntry is ConfigEntry<float> val))
{
if (!(configEntry is ConfigEntry<int> val2))
{
throw new NotSupportedException($"Slider not supported for type: {typeof(T)}");
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart));
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart));
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
if (configEntry is ConfigEntry<string> val)
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart));
return;
}
throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}");
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddButton(string section, string name, string description, string buttonText, Action callback)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
{
callback?.Invoke();
}));
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}