Decompiled source of Flamethrower v1.0.0

flammenwerfer.dll

Decompiled 2 months ago
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.Configuration;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("flammenwerfer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("flammenwerfer")]
[assembly: AssemblyTitle("flammenwerfer")]
[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 flammenwerfer
{
	[BepInPlugin("com.mintysharky.flammenwerfer", "flammenwerfer", "1.0.0")]
	public class flammenwerfer : BaseUnityPlugin
	{
		public class EngineAdpater
		{
			public float timetilldet = 0f;
		}

		public class Patches
		{
			public static Dictionary<RocketEngine, EngineAdpater> engineAdpater = new Dictionary<RocketEngine, EngineAdpater>();

			public static void flammenwerferinit(ref RocketEngine __instance)
			{
				EngineAdpater value = new EngineAdpater();
				engineAdpater[__instance] = value;
			}

			public static void flammenwerferupdate(ref RocketEngine __instance)
			{
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					EngineAdpater engineAdpater = Patches.engineAdpater[__instance];
					if (engineAdpater.timetilldet <= flamethrowertime.Value)
					{
						engineAdpater.timetilldet += Time.deltaTime;
					}
					else
					{
						if (!__instance.isEngineOn || !(engineAdpater.timetilldet >= flamethrowertime.Value))
						{
							return;
						}
						Explosion val = new Explosion();
						Explosion[] array = Resources.FindObjectsOfTypeAll(typeof(Explosion)) as Explosion[];
						Explosion[] array2 = array;
						Explosion[] array3 = array2;
						foreach (Explosion val2 in array3)
						{
							if (((Object)val2).name == "MineExplosion")
							{
								val = val2;
							}
						}
						Explosion val3 = FixTransform.InstantiateFixed<Explosion>(val, (Vec2)((Component)__instance).transform.position);
						((Component)val3).GetComponent<IPhysicsCollider>().Scale = (Fix)((Component)__instance).transform.lossyScale.x;
					}
				}
				catch
				{
				}
			}
		}

		internal static ConfigFile config;

		internal static ConfigEntry<float> flamethrowertime;

		internal static ConfigEntry<float> Explosioncooldown;

		private void Log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}

		private void Awake()
		{
			config = ((BaseUnityPlugin)this).Config;
			flamethrowertime = config.Bind<float>("Monten Flamethrower Patches", "Time Until Flamethrower Activated", 0.01f, "The multiplier of time that it will take until the engine starts to blow up");
			Log("Plugin flammenwerfer is loaded!");
			DoPatching();
		}

		private void DoPatching()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony harmony = new Harmony("com.mintysharky.flammenwerfer");
			Patch(harmony, typeof(RocketEngine), "UpdateSim", "flammenwerferupdate");
			Patch(harmony, typeof(RocketEngine), "RocketEngineInit", "flammenwerferinit");
		}

		private void OnDestroy()
		{
			Log("Bye Bye From flammenwerfer");
		}

		private void Patch(Harmony harmony, Type OriginalClass, string OriginalMethod, string PatchMethod, bool postfix = true)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(OriginalClass, OriginalMethod, (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), PatchMethod, (Type[])null, (Type[])null);
			if (!postfix)
			{
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			Log("Patched " + OriginalMethod + " in " + OriginalClass.ToString());
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "flammenwerfer";

		public const string PLUGIN_NAME = "flammenwerfer";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}