Decompiled source of BingBongActivator v1.0.1

BingBongMod.dll

Decompiled a week ago
using System;
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 BingBongMod.Behaviors;
using BingBongMod.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BingBongMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ff83d61ffeac8d8de5d2844e8a3de9992c7bbf36")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("BingBongMod")]
[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 BingBongMod
{
	public static class BingBongUtils
	{
		public static void UpdateTip(GameObject gameObject)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			BingBongPowers component = gameObject.GetComponent<BingBongPowers>();
			if (!((Object)(object)BingBongPowersPatches.PowersStartPatch.Tip == (Object)null))
			{
				TextMeshProUGUI componentInChildren = BingBongPowersPatches.PowersStartPatch.Tip.GetComponentInChildren<TextMeshProUGUI>();
				BingBongForceAbilities component2 = ((Component)component).GetComponent<BingBongForceAbilities>();
				BingBongTimeControl component3 = ((Component)component).GetComponent<BingBongTimeControl>();
				BingBongStatus component4 = ((Component)component).GetComponent<BingBongStatus>();
				if (((Behaviour)component4).enabled)
				{
					string[] names = Enum.GetNames(typeof(STATUSTYPE));
					FieldInfo field = ((object)component4).GetType().GetField("currentStatusTarget", BindingFlags.Instance | BindingFlags.NonPublic);
					STATUSTYPE val = (STATUSTYPE)field.GetValue(component4);
					((TMP_Text)componentInChildren).text = names[(byte)val];
				}
				else if (((Behaviour)component2).enabled)
				{
					((TMP_Text)componentInChildren).text = $"{component2.physicsType} ({component2.force})";
				}
				else if (((Behaviour)component3).enabled)
				{
					((TMP_Text)componentInChildren).text = component3.currentTimeScale.ToString();
				}
				else
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
	}
	[BepInPlugin("BingBongMod", "My first plugin", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("BingBongMod");
			val.PatchAll();
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin BingBongMod is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BingBongMod";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BingBongMod.Patches
{
	public class BingBongForceAbilitiesPatches
	{
		[HarmonyPatch(typeof(BingBongForceAbilities), "Start")]
		private class ForceStartPatch
		{
			private static void Prefix(BingBongForceAbilities __instance)
			{
				__instance.RPCA_BingBongInitObj(((Component)__instance).GetComponent<PhotonView>().ViewID);
			}
		}

		[HarmonyPatch(typeof(BingBongForceAbilities), "Update")]
		private class ForceUpdatePatch
		{
			private static bool Prefix()
			{
				return false;
			}
		}
	}
	public class BingBongPatches
	{
		[HarmonyPatch(typeof(BingBong), "Start")]
		private class BingBongStartPatch
		{
			private static void Prefix(BingBong __instance)
			{
				((Component)__instance).gameObject.AddComponent<BingBongDestroyWatcher>();
				((Component)__instance).gameObject.AddComponent<BingBongRPC>();
				Item component = ((Component)__instance).GetComponent<Item>();
				if ((Object)(object)component.holderCharacter == (Object)null)
				{
					BingBongPowersPatches.HideBingBongUI();
					return;
				}
				((Component)__instance).gameObject.AddComponent<BingBongPowers>();
				BingBongTimeControl val = ((Component)__instance).gameObject.AddComponent<BingBongTimeControl>();
				BingBongPhysics val2 = ((Component)__instance).gameObject.AddComponent<BingBongPhysics>();
				BingBongStatus val3 = ((Component)__instance).gameObject.AddComponent<BingBongStatus>();
				BingBongForceAbilities val4 = ((Component)__instance).gameObject.AddComponent<BingBongForceAbilities>();
				((Behaviour)val).enabled = false;
				((Behaviour)val2).enabled = false;
				((Behaviour)val3).enabled = false;
				((Behaviour)val4).enabled = false;
			}
		}
	}
	public class BingBongPhysicsPatches
	{
		[HarmonyPatch(typeof(BingBongPhysics), "DoEffect")]
		private class BingBongPhysicsEffectsPatch
		{
			private static bool Prefix()
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(BingBongPhysics), "SetState")]
		private class SetStatePatch
		{
			private static bool Prefix(BingBongPhysics __instance, PhysicsType setType)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				__instance.physicsType = setType;
				BingBongUtils.UpdateTip(((Component)__instance).gameObject);
				return false;
			}
		}

		[HarmonyPatch(typeof(BingBongPhysics), "CheckInuput")]
		private class InputPatch
		{
			private static void Postfix(BingBongPhysics __instance)
			{
				BingBongForceAbilities component = ((Component)__instance).GetComponent<BingBongForceAbilities>();
				float force = component.force;
				float num = 5f;
				if (Input.GetKey((KeyCode)304))
				{
					num = 10f;
				}
				if (Input.GetKey((KeyCode)306))
				{
					num = 50f;
				}
				if (Input.GetAxis("Mouse ScrollWheel") > 0f)
				{
					component.force += num;
				}
				else if (Input.GetAxis("Mouse ScrollWheel") < 0f)
				{
					component.force -= num;
				}
				if (component.force != force)
				{
					BingBongUtils.UpdateTip(((Component)__instance).gameObject);
					PhotonView component2 = ((Component)__instance).GetComponent<PhotonView>();
					component2.RPC("BingBongMod__SetForce", (RpcTarget)0, new object[2] { component2.ViewID, component.force });
				}
			}
		}

		[HarmonyPatch(typeof(BingBongPhysics), "SetState")]
		private class BingBongPhysicsSetStatePatch
		{
			private static void Postfix(BingBongPhysics __instance)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				((Component)__instance).GetComponent<BingBongForceAbilities>().physicsType = __instance.physicsType;
				BingBongUtils.UpdateTip(((Component)__instance).gameObject);
				PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
				component.RPC("BingBongMod__SetState", (RpcTarget)0, new object[2] { component.ViewID, __instance.physicsType });
			}
		}
	}
	public class BingBongPowersPatches
	{
		[HarmonyPatch(typeof(BingBongPowers), "Start")]
		public class PowersStartPatch
		{
			public static GameObject Title;

			public static GameObject SubTitle;

			public static GameObject Tip;

			private static bool Prefix(BingBongPowers __instance)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD/Prompts");
				if ((Object)(object)Title == (Object)null)
				{
					Title = Object.Instantiate<GameObject>(GameObject.Find("GAME/GUIManager/Canvas_HUD/Prompts/InteractName"), val.transform);
					Title.transform.localPosition = new Vector3(553f, -300f, 0f);
				}
				if ((Object)(object)SubTitle == (Object)null)
				{
					SubTitle = Object.Instantiate<GameObject>(GameObject.Find("GAME/GUIManager/Canvas_HUD/Prompts/InteractName"), val.transform);
					SubTitle.transform.localPosition = new Vector3(0f, -350f, 0f);
					SubTitle.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
				}
				if ((Object)(object)Tip == (Object)null)
				{
					Tip = Object.Instantiate<GameObject>(GameObject.Find("GAME/GUIManager/Canvas_HUD/Prompts/InteractName"), val.transform);
					Tip.transform.localPosition = new Vector3(0f, 250f, 0f);
					Tip.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
				}
				Item component = ((Component)__instance).GetComponent<Item>();
				if ((Object)(object)component.holderCharacter == (Object)(object)Character.localCharacter)
				{
					Title.SetActive(true);
					SubTitle.SetActive(true);
					Tip.SetActive(true);
					BingBongUtils.UpdateTip(((Component)__instance).gameObject);
				}
				__instance.titleText = Title.GetComponentInChildren<TextMeshProUGUI>();
				__instance.descriptionText = SubTitle.GetComponentInChildren<TextMeshProUGUI>();
				__instance.SetTexts("Dormant", "");
				__instance.SetTip("", 0);
				return false;
			}
		}

		[HarmonyPatch(typeof(BingBongPowers), "SetTexts")]
		private class SetTextsPatch
		{
			private static bool Prefix(BingBongPowers __instance)
			{
				if ((Object)(object)__instance.titleText == (Object)null || (Object)(object)__instance.descriptionText == (Object)null)
				{
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(BingBongPowers), "SetTip")]
		private class SetTipPatch
		{
			private static bool Prefix(BingBongPowers __instance, string tip)
			{
				if ((Object)(object)PowersStartPatch.Tip == (Object)null)
				{
					return false;
				}
				BingBongUtils.UpdateTip(((Component)__instance).gameObject);
				return false;
			}
		}

		[HarmonyPatch(typeof(BingBongPowers), "ToggleID")]
		private class ToggleIDPatch
		{
			private static bool Prefix()
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(BingBongPowers), "LateUpdate")]
		private class LateUpdatePatch
		{
			private static bool Prefix(BingBongPowers __instance)
			{
				if ((Object)(object)((Component)__instance).GetComponent<Item>().holderCharacter != (Object)(object)Character.localCharacter)
				{
					return false;
				}
				if (!Input.GetKeyDown((KeyCode)282) && !Input.GetKeyDown((KeyCode)283) && !Input.GetKeyDown((KeyCode)284))
				{
					return false;
				}
				((Behaviour)((Component)__instance).GetComponent<BingBongStatus>()).enabled = false;
				((Behaviour)((Component)__instance).GetComponent<BingBongPhysics>()).enabled = false;
				((Behaviour)((Component)__instance).GetComponent<BingBongTimeControl>()).enabled = false;
				((Behaviour)((Component)__instance).GetComponent<BingBongForceAbilities>()).enabled = false;
				PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
				component.RPC("BingBongMod__SetForceEnabled", (RpcTarget)0, new object[2] { component.ViewID, false });
				if (Input.GetKeyDown((KeyCode)282))
				{
					((Behaviour)((Component)__instance).GetComponent<BingBongStatus>()).enabled = true;
					BingBongUtils.UpdateTip(((Component)__instance).gameObject);
					return false;
				}
				if (Input.GetKeyDown((KeyCode)283))
				{
					((Behaviour)((Component)__instance).GetComponent<BingBongTimeControl>()).enabled = true;
					BingBongUtils.UpdateTip(((Component)__instance).gameObject);
					return false;
				}
				if (Input.GetKeyDown((KeyCode)284))
				{
					((Behaviour)((Component)__instance).GetComponent<BingBongPhysics>()).enabled = true;
					((Behaviour)((Component)__instance).GetComponent<BingBongForceAbilities>()).enabled = true;
					BingBongUtils.UpdateTip(((Component)__instance).gameObject);
					component.RPC("BingBongMod__SetForceEnabled", (RpcTarget)0, new object[2] { component.ViewID, true });
					return false;
				}
				return false;
			}
		}

		public static void HideBingBongUI()
		{
			if (Object.op_Implicit((Object)(object)PowersStartPatch.Title) && Object.op_Implicit((Object)(object)PowersStartPatch.SubTitle) && Object.op_Implicit((Object)(object)PowersStartPatch.Tip))
			{
				PowersStartPatch.Title.SetActive(false);
				PowersStartPatch.SubTitle.SetActive(false);
				PowersStartPatch.Tip.SetActive(false);
			}
		}

		public static void UpdateBingBongUI()
		{
		}
	}
	public class BingBongStatusPatches
	{
		[HarmonyPatch(typeof(BingBongStatus), "RPCA_AddStatusBingBing")]
		private class AddStatusPatch
		{
			private static bool Prefix(int target, int statusID, int mult)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				Character component = ((Component)PhotonView.Find(target)).GetComponent<Character>();
				STATUSTYPE val = (STATUSTYPE)statusID;
				if (component.IsLocal)
				{
					if (mult > 0)
					{
						if (statusID == -1)
						{
							component.refs.afflictions.AddStatus((STATUSTYPE)0, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)1, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)2, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)3, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)5, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)6, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)7, 1f, false);
							component.refs.afflictions.AddStatus((STATUSTYPE)8, 1f, false);
							return false;
						}
						component.refs.afflictions.AddStatus(val, 0.2f, false);
						return false;
					}
					if (statusID == -1)
					{
						component.refs.afflictions.SubtractStatus((STATUSTYPE)0, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)1, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)2, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)3, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)5, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)6, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)7, 1f, false);
						component.refs.afflictions.SubtractStatus((STATUSTYPE)8, 1f, false);
						return false;
					}
					component.refs.afflictions.SubtractStatus(val, 0.2f, false);
				}
				return false;
			}
		}
	}
}
namespace BingBongMod.Behaviors
{
	public class BingBongDestroyWatcher : MonoBehaviour
	{
		private void OnDestroy()
		{
			BingBongPowersPatches.HideBingBongUI();
		}
	}
	public class BingBongRPC : MonoBehaviour
	{
		[PunRPC]
		public void BingBongMod__SetState(int viewID, PhysicsType newPhysicsType)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			BingBongForceAbilities component = ((Component)PhotonView.Find(viewID)).gameObject.GetComponent<BingBongForceAbilities>();
			component.physicsType = newPhysicsType;
		}

		[PunRPC]
		public void BingBongMod__SetForceEnabled(int viewID, bool newState)
		{
			BingBongForceAbilities component = ((Component)PhotonView.Find(viewID)).gameObject.GetComponent<BingBongForceAbilities>();
			((Behaviour)component).enabled = newState;
		}

		[PunRPC]
		public void BingBongMod__SetForce(int viewID, float newforceValue)
		{
			BingBongForceAbilities component = ((Component)PhotonView.Find(viewID)).gameObject.GetComponent<BingBongForceAbilities>();
			component.force = newforceValue;
		}
	}
}