Decompiled source of YieldDmgTweak v1.1.0

YieldDmgTweak.dll

Decompiled 7 months ago
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 UnityEngine;
using YieldDmgTweak.Patches;

[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 = "")]
[assembly: AssemblyCompany("YieldDmgTweak")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Tweaks the yield sign to do a propotionally bit more damage due to its weight")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YieldDmgTweak")]
[assembly: AssemblyTitle("YieldDmgTweak")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace YieldDmgTweak
{
	[BepInPlugin("YieldDmgTweak", "YieldDmgTweak", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private bool _patched;

		public static ConfigEntry<int> dmgConfig;

		public static int dmg;

		public static ManualLogSource Logger { get; set; }

		private void Awake()
		{
			if (_patched)
			{
				Logger.LogWarning((object)"Already Patched");
				return;
			}
			dmgConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Damage", 2, "The damage a yield sign will do, a normal shovel does 1.");
			dmg = dmgConfig.Value;
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(YieldPatch), "YieldDmgTweak");
			Logger.LogInfo((object)string.Format("{0} is loaded! Shovel damage is set to {1}", "YieldDmgTweak", dmg));
			_patched = true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "YieldDmgTweak";

		public const string PLUGIN_NAME = "YieldDmgTweak";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace YieldDmgTweak.Patches
{
	internal class YieldPatch
	{
		[HarmonyPatch(typeof(RoundManager), "Update")]
		[HarmonyPostfix]
		private static void YieldTweak()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			try
			{
				GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
				for (int i = 0; i < array.Length; i++)
				{
					if (Object.op_Implicit((Object)(object)((Component)array[i]).GetComponent<Shovel>()))
					{
						Shovel val = (Shovel)array[i];
						if (((GrabbableObject)val).itemProperties.itemName == "Yield sign")
						{
							val.shovelHitForce = Plugin.dmg;
						}
					}
				}
			}
			catch
			{
			}
		}
	}
}