Decompiled source of GarageDoorFix v1.0.0

GarageDoorFix.dll

Decompiled 11 months ago
using System;
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;
using UnityEngine.SceneManagement;

[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("EliteMasterEric")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Rework the Performance Report with new info, including cause of death.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+35a1f8a4c8f54bad8d6a7fb4d03e5372c79ed9ef")]
[assembly: AssemblyProduct("GarageDoorFix")]
[assembly: AssemblyTitle("GarageDoorFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GarageDoorFix
{
	public static class PluginInfo
	{
		public const string PLUGIN_ID = "GarageDoorFix";

		public const string PLUGIN_NAME = "GarageDoorFix";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string PLUGIN_GUID = "com.elitemastereric.garagedoorfix";
	}
	[BepInPlugin("com.elitemastereric.garagedoorfix", "GarageDoorFix", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public ManualLogSource PluginLogger;

		public PluginConfig PluginConfig;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Instance = this;
			PluginLogger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("com.elitemastereric.garagedoorfix");
			val.PatchAll();
			PluginLogger.LogInfo((object)"Plugin GarageDoorFix (com.elitemastereric.garagedoorfix) is loaded!");
			LoadConfig();
		}

		private void LoadConfig()
		{
			PluginConfig = new PluginConfig();
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
		}
	}
	public class PluginConfig
	{
		private ConfigEntry<int> GarageDoorChance;

		private ConfigEntry<bool> DoorDropOnlyOnce;

		public void BindConfig(ConfigFile _config)
		{
			GarageDoorChance = _config.Bind<int>("General", "GarageDoorChance", 3, "The chance for the garage door to drop, as a percentage.");
			DoorDropOnlyOnce = _config.Bind<bool>("General", "DoorDropOnlyOnce", true, "If true, the garage door will only drop once per round.");
		}

		public int GetGarageDoorChance()
		{
			return GarageDoorChance.Value;
		}

		public bool ShouldDoorDropOnlyOnce()
		{
			return DoorDropOnlyOnce.Value;
		}
	}
}
namespace GarageDoorFix.Patch
{
	[HarmonyPatch(typeof(InteractTrigger))]
	[HarmonyPatch("Start")]
	internal class InteractTriggerStartPatch
	{
		private const string GARAGE_TRIGGER_SCENE = "Level1Experimentation";

		private const string GARAGE_TRIGGER_NAME = "Cube";

		private const string GARAGE_TRIGGER_PARENT_NAME = "Cutscenes";

		public static void Postfix(InteractTrigger __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Plugin.Instance.PluginLogger.LogDebug((object)"Interact Trigger spawned, querying...");
				GameObject gameObject = ((Component)__instance).gameObject;
				Scene scene = gameObject.scene;
				if (((Scene)(ref scene)).name == "Level1Experimentation")
				{
					Plugin.Instance.PluginLogger.LogDebug((object)"Current stage is Experimentation, querying...");
					if (((Object)gameObject).name == "Cube" && ((Object)gameObject.transform.parent).name == "Cutscenes")
					{
						Plugin.Instance.PluginLogger.LogInfo((object)"Found garage trigger! Modifying...");
						__instance.triggerOnce = Plugin.Instance.PluginConfig.ShouldDoorDropOnlyOnce();
						__instance.randomChancePercentage = Plugin.Instance.PluginConfig.GetGarageDoorChance();
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Instance.PluginLogger.LogError((object)("Error in InteractTriggerStartPatch.Postfix: " + ex));
				Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace);
			}
		}
	}
}