using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BaboonAPI.Hooks.Initializer;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TootTallyCore;
using TootTallyCore.Utils.TootTallyModules;
using TootTallySettings;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TootTallyBackgroundDim")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Make the background darker")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("TootTallyBackgroundDim")]
[assembly: AssemblyTitle("TootTallyBackgroundDim")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 TootTallyBackgroundDim
{
public class BackgroundDimController : MonoBehaviour
{
private static readonly Vector2 DEFAULT_RESOLUTION = new Vector2(1920f, 1080f);
private static GameObject _backgroundDimGameObject;
private static Image _backgroundDimImage;
private static CanvasScaler _backgroundDimCanvasScaler;
private static float _alpha;
private static GameController _currentGCInstance;
[HarmonyPatch(typeof(GameController), "Start")]
[HarmonyPostfix]
public static void BackgroundDim(GameController __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("BGCameraObj");
_alpha = Plugin.Instance.DimAmount.Value;
_backgroundDimGameObject = Object.Instantiate<GameObject>(new GameObject(), val.transform);
_backgroundDimGameObject.transform.position = new Vector3(0f, 0f, 100f);
_backgroundDimImage = _backgroundDimGameObject.AddComponent<Image>();
((Graphic)_backgroundDimImage).color = new Color(0f, 0f, 0f, _alpha);
_backgroundDimCanvasScaler = _backgroundDimGameObject.AddComponent<CanvasScaler>();
_backgroundDimCanvasScaler.uiScaleMode = (ScaleMode)1;
_backgroundDimCanvasScaler.referenceResolution = DEFAULT_RESOLUTION;
RectTransform component = _backgroundDimGameObject.GetComponent<RectTransform>();
component.sizeDelta = DEFAULT_RESOLUTION;
((Component)__instance.topbreath.transform.parent.parent).gameObject.SetActive(false);
_currentGCInstance = __instance;
}
[HarmonyPatch(typeof(BGController), "setUpBGControllerRefsDelayed")]
[HarmonyPostfix]
public static void OnLoadAssetBundleActivateBreathMeterCanvas()
{
if (!OptionalGameplayUIReducer.ShouldHideBreathMeter())
{
((Component)_currentGCInstance.topbreath.transform.parent.parent).gameObject.SetActive(true);
}
}
}
public static class OptionalGameplayUIReducer
{
public static bool ShouldHideBreathMeter()
{
try
{
Type type = Type.GetType("GameplayUIReducer.Plugin, GameplayUIReducer");
if (type == null)
{
return false;
}
FieldInfo field = type.GetField("ConfigEntries", BindingFlags.Static | BindingFlags.NonPublic);
Dictionary<string, ConfigEntry<bool>> dictionary = (Dictionary<string, ConfigEntry<bool>>)field.GetValue(null);
if (!dictionary.TryGetValue("Breath Meter", out var value))
{
return false;
}
return value.Value;
}
catch (Exception ex)
{
Plugin.LogError("Exception trying to get GameplayUIReducer settings");
Plugin.LogError(ex.Message);
Plugin.LogError(ex.StackTrace);
return false;
}
}
}
[BepInPlugin("TootTallyBackgroundDim", "TootTallyBackgroundDim", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin, ITootTallyModule
{
public static Plugin Instance;
private const string CONFIG_NAME = "BackgroundDim.cfg";
private Harmony _harmony;
public static TootTallySettingPage settingPage;
public ConfigEntry<bool> ModuleConfigEnabled { get; set; }
public bool IsConfigInitialized { get; set; }
public string Name
{
get
{
return "TootTallyBackgroundDim";
}
set
{
Name = value;
}
}
public ConfigEntry<float> DimAmount { get; set; }
public ConfigEntry<bool> ShowBGOnBreak { get; set; }
public static void LogInfo(string msg)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
}
public static void LogError(string msg)
{
((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
}
private void Awake()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
if (!((Object)(object)Instance != (Object)null))
{
Instance = this;
_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
GameInitializationEvent.Register(((BaseUnityPlugin)this).Info, (Action)TryInitialize);
}
}
private void TryInitialize()
{
ModuleConfigEnabled = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Modules", "Background Dim", true, "Enable reducing background brightness");
TootTallyModuleManager.AddModule((ITootTallyModule)(object)this);
Plugin.Instance.AddModuleToSettingPage((ITootTallyModule)(object)this);
}
public void LoadModule()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(Paths.BepInExRootPath, "config/");
ConfigFile val = new ConfigFile(text + "BackgroundDim.cfg", true);
DimAmount = val.Bind<float>("General", "Background Dim Amount", 0.75f, "The amount to dim the background by as a percentage.");
settingPage = TootTallySettingsManager.AddNewPage("Background Dim", "Background Dim", 40f, new Color(0f, 0f, 0f, 0f));
TootTallySettingPage obj = settingPage;
if (obj != null)
{
obj.AddSlider("DimSlider", 0f, 1f, 350f, "Dim Amount", DimAmount, false);
}
Plugin.TryAddThunderstoreIconToPageButton(((BaseUnityPlugin)Instance).Info.Location, Name, settingPage);
_harmony.PatchAll(typeof(BackgroundDimController));
LogInfo("Module loaded!");
}
public void UnloadModule()
{
_harmony.UnpatchSelf();
settingPage.Remove();
LogInfo("Module unloaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TootTallyBackgroundDim";
public const string PLUGIN_NAME = "TootTallyBackgroundDim";
public const string PLUGIN_VERSION = "1.0.1";
}
}