Decompiled source of FlashingGrenades v1.0.0

FlashingGrenades.dll

Decompiled a week 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.Logging;
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 = ".NET Framework 4.6")]
[assembly: AssemblyCompany("FlashingGrenades")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f21a1999bf8bc844de0a100361476054cc05c394")]
[assembly: AssemblyProduct("FlashingGrenades")]
[assembly: AssemblyTitle("FlashingGrenades")]
[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 FlashingGrenades
{
	[BepInPlugin("lofen.flashinggrenades", "Flashing Grenades", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin Flashing Grenades is loaded!");
			Harmony val = new Harmony("lofen.flashinggrenades");
			val.PatchAll(typeof(Patch));
		}
	}
	[HarmonyPatch]
	public class Patch
	{
		private static readonly Dictionary<Grenade, Fix> elapsedTimes = new Dictionary<Grenade, Fix>();

		private static readonly Dictionary<Grenade, Fix> switchTimes = new Dictionary<Grenade, Fix>();

		private static readonly Color OnColor = Color.gray;

		private static readonly Color OffColor = Color.white;

		public static Fix GetElapsedTime(Grenade instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Fix value;
			return elapsedTimes.TryGetValue(instance, out value) ? value : Fix.Zero;
		}

		public static void SetElapsedTime(Grenade instance, Fix elapsedTime)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			elapsedTimes[instance] = elapsedTime;
		}

		public static Fix GetSwitchTime(Grenade instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Fix value;
			return switchTimes.TryGetValue(instance, out value) ? value : Fix.Zero;
		}

		public static void SetSwitchTime(Grenade instance, Fix switchTime)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			switchTimes[instance] = switchTime;
		}

		[HarmonyPatch(typeof(Grenade), "Init")]
		[HarmonyPostfix]
		public static void GrenadePostInit(ref Grenade __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			SpriteRenderer component = ((Component)__instance).GetComponent<SpriteRenderer>();
			component.color = OffColor;
			SetSwitchTime(__instance, __instance.detonationTime - (Fix)2.0);
		}

		[HarmonyPatch(typeof(Grenade), "UpdateSim")]
		[HarmonyPostfix]
		public static void GrenadePostUpdateSim(Fix simDeltaTime, ref Grenade __instance, ref Fix ___detonationTime)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			SetElapsedTime(__instance, GetElapsedTime(__instance) + simDeltaTime * GameTime.PlayerTimeScale);
			Fix elapsedTime = GetElapsedTime(__instance);
			if (elapsedTime >= GetSwitchTime(__instance))
			{
				SpriteRenderer component = ((Component)__instance).GetComponent<SpriteRenderer>();
				if (component.color == OnColor)
				{
					component.color = OffColor;
				}
				else
				{
					component.color = OnColor;
				}
				Fix val = __instance.detonationTime - elapsedTime;
				if (val <= (Fix)0.25)
				{
					SetSwitchTime(__instance, elapsedTime + (Fix)0.025);
				}
				else if (val <= (Fix)0.5)
				{
					SetSwitchTime(__instance, elapsedTime + (Fix)0.05);
				}
				else if (val <= (Fix)1.0)
				{
					SetSwitchTime(__instance, elapsedTime + (Fix)0.1);
				}
				else if (val <= (Fix)2.0)
				{
					SetSwitchTime(__instance, elapsedTime + (Fix)0.2);
				}
				else
				{
					SetSwitchTime(__instance, __instance.detonationTime - (Fix)2.0);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FlashingGrenades";

		public const string PLUGIN_NAME = "FlashingGrenades";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}