Decompiled source of Oops All Jammed v1.0.5

OopsAllJammed.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Gunfiguration;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using OopsAllJammed;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 OopsAllJammed
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("SimplyFenton.etg.oopsalljammed", "Oops All Jammed", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "SimplyFenton.etg.oopsalljammed";

		public const string NAME = "Oops All Jammed";

		public const string VERSION = "1.0.5";

		public const string TEXT_COLOR = "#00FFFF";

		public static bool AllJammed;

		public static bool PreventUnJam;

		public void Start()
		{
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
			Init();
		}

		private void makeJammed(AIActor enemy)
		{
			if (AllJammed && enemy.IsNormalEnemy)
			{
				enemy.ForceBlackPhantom = true;
			}
		}

		public static void reJamHook(Action<AIActor> orig, AIActor self)
		{
			orig(self);
			if (AllJammed)
			{
				self.ForceBlackPhantom = true;
				self.BecomeBlackPhantom();
			}
		}

		public static void forceJam(AIActor actor)
		{
			if (AllJammed && actor.IsNormalEnemy && PreventUnJam)
			{
				actor.ForceBlackPhantom = true;
				actor.BecomeBlackPhantom();
			}
		}

		public void SetAllJammed(bool jammed)
		{
			AllJammed = jammed;
		}

		public void SetPreventUnJam(bool prevent)
		{
			PreventUnJam = prevent;
		}

		public void Exit()
		{
			AllJammed = false;
		}

		public void Init()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			AIActor.OnBlackPhantomnessCheck = (Action<AIActor>)Delegate.Combine(AIActor.OnBlackPhantomnessCheck, new Action<AIActor>(makeJammed));
			AIActor.OnPreStart = (Action<AIActor>)Delegate.Combine(AIActor.OnPreStart, new Action<AIActor>(forceJam));
			new Hook((MethodBase)typeof(AIActor).GetMethod("UnbecomeBlackPhantom", BindingFlags.Instance | BindingFlags.Public), typeof(Plugin).GetMethod("reJamHook"));
		}

		public void GMStart(GameManager g)
		{
			Log("Oops All Jammed v1.0.5 started successfully.", "#00FFFF");
			JammedConfig.Init(this);
		}

		public static void Log(string text, string color = "#FFFFFF")
		{
			ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
		}
	}
}
namespace Gunfiguration
{
	public static class JammedConfig
	{
		internal static Gunfig _Gunfig;

		internal const string AllJammed = "Make All Enemies In The Game Jammed";

		internal const string PreventUnJam = "Prevent Enemies From Being Un-Jammed";

		internal static void Init(Plugin parent)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			_Gunfig = Gunfig.Get(GunfigHelpers.WithColor("All Jammed", Color.white));
			parent.SetAllJammed(_Gunfig.Enabled("Make All Enemies In The Game Jammed"));
			parent.SetPreventUnJam(_Gunfig.Enabled("Prevent Enemies From Being Un-Jammed"));
			_Gunfig.AddToggle("Make All Enemies In The Game Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetAllJammed((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("Prevent Enemies From Being Un-Jammed", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetPreventUnJam((optionValue == "1") ? true : false);
			}, (Update)1);
		}
	}
}