using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using _1000QuotaStare.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("1000QuotaStare")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("1000QuotaStare")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e4a99a02-498d-40d2-8c80-b9a664a1e9ac")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace _1000QuotaStare
{
public class Config
{
public static ConfigEntry<bool> configSoundsEnabled;
public static ConfigEntry<bool> configImageEnabled;
public static ConfigEntry<float> configImageOpacityMultiplier;
public Config(ConfigFile cfg)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
configSoundsEnabled = cfg.Bind<bool>("General", "Sounds Enabled", true, "Determines if the sounds in the mod are enabled");
configImageEnabled = cfg.Bind<bool>("General", "Image Enabled", true, "Determines if the image in the mod is enabled");
configImageOpacityMultiplier = cfg.Bind<float>("General", "Image Opacity Multiplier", 2.7f, new ConfigDescription("Determines how transparent the 1000 yard stare image is (if image is enabled). A higher value results in a more visible image. (0.1 is barely visible, 5 will make the image fully visible when fear level is high enough)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
}
}
[BepInPlugin("MagnusMakesGames.1000QuotaStare", "1000 Quota Stare", "1.0.2")]
public class QuotaStareMain : BaseUnityPlugin
{
private const string modGUID = "MagnusMakesGames.1000QuotaStare";
private const string modName = "1000 Quota Stare";
private const string modVersion = "1.0.2";
private readonly Harmony harmony = new Harmony("MagnusMakesGames.1000QuotaStare");
public static QuotaStareMain Instance;
internal static List<AudioClip> soundFX;
internal static AssetBundle bundle;
internal static ManualLogSource mls;
public static Config MyConfig { get; internal set; }
private void Awake()
{
MyConfig = new Config(((BaseUnityPlugin)this).Config);
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("MagnusMakesGames.1000QuotaStare");
mls.LogInfo((object)"Loaded 1000 Quota Stare mod");
harmony.PatchAll(typeof(SoundManagerPatch));
soundFX = new List<AudioClip>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("1000QuotaStare.dll".ToCharArray());
bundle = AssetBundle.LoadFromFile(location + "thousandyardstare");
if ((Object)(object)bundle != (Object)null)
{
mls.LogInfo((object)"Thousand Quota Stare mod loaded yeaaaah!!1!");
soundFX = bundle.LoadAllAssets<AudioClip>().ToList();
}
else
{
mls.LogError((object)"awwwwww shucks thousand Quota Stare mod didnt load :bowomp:");
}
}
public static void PrintMessage(string message)
{
mls.LogInfo((object)message);
}
}
}
namespace _1000QuotaStare.Patches
{
[HarmonyPatch(typeof(SoundManager))]
internal class SoundManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void OverrideStartMethod(SoundManager __instance)
{
if (Config.configSoundsEnabled.Value)
{
__instance.highAction2.clip = QuotaStareMain.soundFX[1];
__instance.lowAction.clip = QuotaStareMain.soundFX[0];
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void OverrideUpdateMethod(SoundManager __instance)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
if (!Config.configImageEnabled.Value)
{
return;
}
float fearLevel = StartOfRound.Instance.fearLevel;
GameObject val = null;
if (!Object.op_Implicit((Object)(object)GameObject.Find("ThousandYardStareCanvas")))
{
QuotaStareMain.PrintMessage("Thousand Yard Stare Canvas not found, creating a new one");
Object val2 = QuotaStareMain.bundle.LoadAsset("ThousandYardStareCanvas");
val = Object.Instantiate<GameObject>((GameObject)val2);
((Object)val).name = "ThousandYardStareCanvas";
Object.DontDestroyOnLoad((Object)(object)val);
return;
}
val = GameObject.Find("ThousandYardStareCanvas");
GameObject gameObject = ((Component)val.transform.Find("ThousandYardStareImage")).gameObject;
Image component = gameObject.GetComponent<Image>();
if ((Object)(object)component != (Object)null)
{
((Graphic)component).color = new Color(((Graphic)component).color.r, ((Graphic)component).color.g, ((Graphic)component).color.b, Mathf.Clamp01((Mathf.Clamp01(fearLevel) - 0.7f) * Config.configImageOpacityMultiplier.Value));
}
}
}
}