Decompiled source of WhoNeedsEyes v1.0.1

GWYF.WhoNeedsEyes.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Extensions;
using HarmonyLib;
using Mirror;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GWYF.WhoNeedsEyes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+5eccf4497523c44ca3be04f9dfe2c041e7a53d3d")]
[assembly: AssemblyProduct("GWYF.WhoNeedsEyes")]
[assembly: AssemblyTitle("GWYF.WhoNeedsEyes")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace GWYF.WhoNeedsEyes
{
	[BepInProcess("Gamble With Your Friends.exe")]
	[BepInPlugin("GWYF.Epoch.WhoNeedsEyes", "Who Needs Eyes!", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			new Harmony("GWYF.Epoch.WhoNeedsEyes").PatchAll();
			Logger.LogInfo((object)"Plugin GWYF.Epoch.WhoNeedsEyes is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GWYF.Epoch.WhoNeedsEyes";

		public const string PLUGIN_NAME = "Who Needs Eyes!";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace GWYF.WhoNeedsEyes.Code
{
	[HarmonyPatch(typeof(BodyShreddingMachine), "TryShredEye")]
	public class BodyShreddingMachine_TryShredEye_Patch
	{
		private static bool Prefix(BodyShreddingMachine __instance, PlayerOrgans po, PlayerOrganData data, ref bool __result)
		{
			if (!NetworkServer.active)
			{
				__result = false;
				return false;
			}
			if (!data.leftEye && !data.rightEye)
			{
				__result = false;
				return false;
			}
			if (data.leftEye && data.rightEye)
			{
				NetworkSingleton<OrganManager>.Instance.ServerToggleOrgan(po, (OrganType)(Random.value > 0.5f), false);
			}
			else if (data.rightEye)
			{
				NetworkSingleton<OrganManager>.Instance.ServerToggleOrgan(po, (OrganType)1, false);
			}
			else
			{
				NetworkSingleton<OrganManager>.Instance.ServerToggleOrgan(po, (OrganType)0, false);
			}
			NetworkSingleton<MoneyManager>.Instance.TryChangeTicketBalance((long)Traverse.Create((object)__instance).Field<int>("_eyePrice").Value);
			Traverse.Create((object)__instance).Method("RpcOnEyeShredded", Array.Empty<object>()).GetValue();
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(QuotaGun), "TryRemoveRandomOrgan")]
	public class QuotaGun_TryRemoveRandomOrgan_Patch
	{
		private static bool Prefix(QuotaGun __instance, PlayerController pc)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			int value = Traverse.Create((object)__instance).Field<int>("_removedOrganCount").Value;
			int value2 = Traverse.Create((object)__instance).Field<int>("removableOrganCount").Value;
			if (value >= value2 || (int)NetworkSingleton<GameManager>.Instance.state != 1 || NetworkSingleton<MoneyManager>.Instance.balance >= NetworkSingleton<GameManager>.Instance.currentQuota)
			{
				return false;
			}
			PlayerOrgans component = ((Component)pc).GetComponent<PlayerOrgans>();
			PlayerOrganData organData = NetworkSingleton<OrganManager>.Instance.GetOrganData(component);
			if (organData == null)
			{
				return false;
			}
			List<OrganType> list = new List<OrganType>();
			if (organData.body)
			{
				list.Add((OrganType)2);
			}
			if (organData.mouth)
			{
				list.Add((OrganType)3);
			}
			if (organData.leftEye || organData.rightEye)
			{
				if (organData.leftEye)
				{
					list.Add((OrganType)0);
				}
				if (organData.rightEye)
				{
					list.Add((OrganType)1);
				}
			}
			if (list.Count > 0)
			{
				NetworkSingleton<OrganManager>.Instance.ServerToggleOrgan(component, FathF.GetRandomElement<OrganType>(list), false);
				value++;
				Traverse.Create((object)__instance).Field<int>("_removedOrganCount").Value = value;
				Traverse.Create((object)__instance).Method("RpcSetRemovedOrganIndicator", new object[1] { value }).GetValue();
				Traverse.Create((object)__instance).Method("AwardQuotaFraction", Array.Empty<object>()).GetValue();
			}
			return false;
		}
	}
}