Decompiled source of FunkyLittleMod v0.2.1

FunkyLittleMod.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DefaultNamespace;
using ExitGames.Client.Photon;
using HarmonyLib;
using MyFirstPlugin.patches;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("FunkyLittleMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("FunkyLittleMod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FunkyLittleMod")]
[assembly: AssemblyTitle("FunkyLittleMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MyFirstPlugin
{
	[BepInPlugin("FunkyLittleMod", "FunkyLittleMod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class AudioLoader
		{
			public static AudioClip LoadAudioClip(string path)
			{
				if (File.Exists(path))
				{
					byte[] data = File.ReadAllBytes(path);
					return WavUtility.ToAudioClip(data, 2, "customSound");
				}
				Debug.LogError((object)("Audio file not found at " + path));
				return null;
			}
		}

		public static class WavUtility
		{
			public static AudioClip ToAudioClip(byte[] data, int channels, string name)
			{
				int num = data.Length / 2;
				float[] array = new float[num];
				int num2 = 0;
				for (int i = 0; i < num; i++)
				{
					array[i] = (float)BitConverter.ToInt16(data, num2) / 32768f;
					num2 += 2;
				}
				AudioClip val = AudioClip.Create(name, num / channels, channels, 44100, false);
				val.SetData(array, 0);
				return val;
			}

			public static AudioClip GetAudioClipFromPath(string name)
			{
				string text = "FunkyLittleMod";
				text += ".dll";
				string location = Assembly.GetExecutingAssembly().Location;
				string path = Path.Combine(location.Remove(location.Length - text.Length), name);
				return AudioLoader.LoadAudioClip(path);
			}
		}

		public static List<AudioClip> clips = new List<AudioClip>();

		public static AudioClip dansen = WavUtility.GetAudioClipFromPath("dansen.wav");

		public List<GameObject> Prefabs;

		private static readonly Random _random = new Random();

		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("FunkyLittleMod");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FunkyLittleMod is loaded!");
			string[] array = new string[10] { "SFX_StreamerVoice_Notice9.wav", "SFX_Voice_Knivo6.wav", "SFX_CageMove.wav", "SFX_Ultraknivo5.wav", "SFX_UltraknivoNotice2.wav", "SFX_BarnacleGas.wav", "SFX_BombFuse.wav", "SFX_Cark_Aim.wav", "SFX_ToolKit_Whisk_Start.wav", "SFX_UltraknivoNotice3.wav" };
			string[] array2 = array;
			foreach (string name in array2)
			{
				clips.Add(WavUtility.GetAudioClipFromPath(name));
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		public void Start()
		{
			MyFirstPlugin.patches.EventHandler eventHandler = new MyFirstPlugin.patches.EventHandler();
			eventHandler = ((Component)this).gameObject.AddComponent<MyFirstPlugin.patches.EventHandler>();
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
			if (((Scene)(ref scene)).name == "SurfaceScene")
			{
				RunAfterSceneLoad(scene);
			}
		}

		private void RunAfterSceneLoad(Scene scene)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			GameObject val = GameObject.Find("Misc/DiveBell/Tools/TravelButton");
			if (Object.op_Implicit((Object)(object)val))
			{
				val = Object.Instantiate<GameObject>(val);
				Object.Destroy((Object)(object)val.GetComponent<UseDivingBellButton>());
				((Object)val).name = "Party button";
				val.AddComponent<PartyButton>();
				val.transform.position = new Vector3(-22.9487f, 1.2f, 16.8624f);
				val.transform.rotation = Quaternion.Euler(new Vector3(90f, 50f, 0f));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Running code after scene load: " + ((Scene)(ref scene)).name));
		}

		private void Update()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			//IL_00c3: 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_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			if (Input.GetKeyDown((KeyCode)104))
			{
				PhotonNetwork.Instantiate("Slurper", GameObject.Find("Main Camera").transform.position, Quaternion.identity, (byte)0, (object[])null);
			}
			if (Input.GetKeyDown((KeyCode)257))
			{
				PhotonNetwork.Instantiate("Dog", GameObject.Find("Main Camera").transform.position, Quaternion.identity, (byte)0, (object[])null);
			}
			if (Input.GetKeyDown((KeyCode)256))
			{
				PhotonNetwork.Instantiate("ButtonRobot", GameObject.Find("Main Camera").transform.position, Quaternion.identity, (byte)0, (object[])null);
			}
			if (Input.GetKeyDown((KeyCode)260))
			{
				PhotonNetwork.Instantiate("Mouthe", GameObject.Find("Main Camera").transform.position, Quaternion.identity, (byte)0, (object[])null);
			}
			if (Input.GetKeyDown((KeyCode)261))
			{
			}
			if (Input.GetKeyDown((KeyCode)259))
			{
				string text = "FunkyLittleMod";
				text += ".dll";
				string location = Assembly.GetExecutingAssembly().Location;
				Debug.Log((object)location.Remove(location.Length - text.Length));
			}
			if (Input.GetKeyDown((KeyCode)265))
			{
				try
				{
					for (byte b = 0; b < byte.MaxValue; b++)
					{
						Item val = new Item();
						ItemDatabase.TryGetItemFromID(b, ref val);
						((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " " + val.id));
						Item.SpawnItem(val);
					}
				}
				catch (Exception)
				{
				}
			}
			if (Input.GetKeyDown((KeyCode)107))
			{
				Item val2 = new Item();
				ItemDatabase.TryGetItemFromID((byte)8, ref val2);
				Item.SpawnItem(val2);
			}
			if (Input.GetKeyDown((KeyCode)112))
			{
				Vector3 position = ((Component)((Component)PlayerHandler.instance.playersAlive[0]).gameObject.transform.GetChild(0)).gameObject.transform.position;
				object[] array = new object[1] { position };
				RaiseEventOptions val3 = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				PhotonNetwork.RaiseEvent((byte)87, (object)array, val3, SendOptions.SendReliable);
			}
		}

		public static int Next(int minValue, int maxValue)
		{
			lock (_random)
			{
				return _random.Next(minValue, maxValue);
			}
		}

		public static dynamic InvokeInternalMethod(object instance, string methodName)
		{
			MethodInfo method = instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
			if (method != null)
			{
				Debug.Log((object)"method invoked");
				return method.Invoke(instance, null);
			}
			Debug.LogError((object)"oh nows the internal method envoked unsuccesfully");
			return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FunkyLittleMod";

		public const string PLUGIN_NAME = "FunkyLittleMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MyFirstPlugin.patches
{
	[HarmonyPatch(typeof(Attacks_SnailSpawner))]
	internal class Attacks_SnailSpawnerPatch
	{
		[HarmonyPatch("Spawn")]
		[HarmonyPrefix]
		private static bool Prefix(Attacks_SnailSpawner __instance, ref PhotonView ___view)
		{
			//IL_0041: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)((Component)__instance).gameObject.transform.parent).gameObject).name.Contains("Fire"))
			{
				Transform val = __instance.spawns[Random.Range(0, __instance.spawns.Length)];
				Vector3 position = val.position;
				Vector3 forward = val.forward;
				forward += Random.onUnitSphere * __instance.spread;
				forward.y -= 0.15f;
				___view.RPC("RPCA_SnailSpawn", (RpcTarget)0, new object[2] { position, forward });
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Bot))]
	internal class BotPatch
	{
		public static int annoyCount;

		[HarmonyPatch("LookForBetterTarget")]
		[HarmonyPrefix]
		private static bool Prefix(Bot __instance, ref Vector3 headPosition, ref float maxRange, ref float maxAngle)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)((Component)__instance).gameObject.transform.parent).gameObject).name.Contains("Fire"))
			{
				Player val = null;
				int num = 0;
				int num2 = 0;
				foreach (Player item in PlayerHandler.instance.playersAlive)
				{
					if (Vector3.Distance(((Component)__instance).gameObject.transform.position, ((Component)((Component)item).gameObject.transform.GetChild(0)).gameObject.transform.position) > 100f)
					{
						continue;
					}
					foreach (Player item2 in PlayerHandler.instance.playersAlive)
					{
						if (Vector3.Distance(((Component)((Component)item2).gameObject.transform.GetChild(0)).gameObject.transform.position, ((Component)((Component)item).gameObject.transform.GetChild(0)).gameObject.transform.position) > maxRange / 5f)
						{
							num++;
						}
					}
					if (num > num2)
					{
						num2 = num;
						val = item;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					((Component)__instance).GetComponentInParent<PlayerController>().movementForce = 10f;
					return false;
				}
				__instance.syncData.targetPlayerId = val.refs.view.ViewID;
				((Component)__instance).GetComponentInParent<PlayerController>().movementForce = 10f + 8f * (float)(num2 - 1);
				return false;
			}
			return true;
		}

		[HarmonyPatch("OnNoisePlayed")]
		[HarmonyPrefix]
		private static void BotPreFix(Bot __instance, out Vector3 __state)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			__state = __instance.lastNoisePos;
		}

		[HarmonyPatch("OnNoisePlayed")]
		[HarmonyPostfix]
		private static void BotFix(Bot __instance, Vector3 __state)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)((Component)((Component)__instance).gameObject.transform.parent).gameObject).name.Contains("Dog") || !PhotonNetwork.IsMasterClient || Vector3.Distance(__instance.lastNoisePos, __state) > 10f)
			{
				return;
			}
			Vector3 position = default(Vector3);
			((Vector3)(ref position))..ctor(999f, 999f, 999f);
			foreach (Player item in PlayerHandler.instance.playersAlive)
			{
				if (Vector3.Distance(((Component)((Component)item).gameObject.gameObject.transform.GetChild(0)).gameObject.transform.position, ((Component)__instance).gameObject.transform.position) < Vector3.Distance(position, ((Component)__instance).gameObject.transform.position))
				{
					position = ((Component)((Component)item).gameObject.gameObject.transform.GetChild(0)).gameObject.transform.position;
				}
			}
			if (annoyCount++ > 160 || Vector3.Distance(position, ((Component)__instance).gameObject.transform.position) > 30f)
			{
				annoyCount--;
			}
			if (annoyCount >= 160 && Vector3.Distance(position, ((Component)__instance).gameObject.transform.position) < 20f)
			{
				annoyCount -= 160;
				Vector3 val = position;
				val.y -= 4f;
				object[] array = new object[1] { val };
				RaiseEventOptions val2 = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				PhotonNetwork.RaiseEvent((byte)87, (object)array, val2, SendOptions.SendReliable);
			}
		}
	}
	[HarmonyPatch(typeof(SpawnObject))]
	internal class ButtonRobotPatch
	{
		[HarmonyPatch("DoSpawn")]
		[HarmonyPrefix]
		private static bool PreFix(SpawnObject __instance)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)__instance).transform.root).name.Contains("ButtonRobot"))
			{
				object[] array = new object[2]
				{
					((Component)__instance).transform.position,
					((Component)__instance).transform.rotation
				};
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				PhotonNetwork.RaiseEvent((byte)88, (object)array, val, SendOptions.SendReliable);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Bot))]
	internal class Dog
	{
		[HarmonyPatch("LookForBetterTarget")]
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return true;
		}
	}
	[HarmonyPatch(typeof(Drone))]
	public class DronePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void Prefix(Drone __instance)
		{
			((Collider)((Component)((Component)__instance).transform.GetChild(1)).GetComponent<BoxCollider>()).enabled = false;
		}

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void Postfix(Drone __instance, ref bool ___done)
		{
			if (___done && (Object)(object)((Component)__instance).transform.GetChild(1) != (Object)null)
			{
				((Collider)((Component)((Component)__instance).transform.GetChild(1)).GetComponent<BoxCollider>()).enabled = true;
			}
		}
	}
	internal class EventHandler : MonoBehaviour, IOnEventCallback
	{
		private void OnEnable()
		{
			PhotonNetwork.AddCallbackTarget((object)this);
		}

		private void OnDisable()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		public void OnEvent(EventData photonEvent)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_014d: 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)
			byte code = photonEvent.Code;
			if (code == 87)
			{
				object[] array = (object[])photonEvent.CustomData;
				Vector3 val = (Vector3)array[0];
				Item[] array2 = (Item[])(object)new Item[1];
				ItemDatabase.TryGetItemFromID((byte)68, ref array2[0]);
				Object.Instantiate<GameObject>(ShopHandler.Instance.droneObject, val, Quaternion.Euler(new Vector3(0f, -30f, 0f))).GetComponent<Drone>().items = array2;
			}
			if (code == 88)
			{
				object[] array3 = (object[])photonEvent.CustomData;
				Vector3 position = (Vector3)array3[0];
				Quaternion rotation = (Quaternion)array3[1];
				string text = "FunkyLittleMod";
				text += ".dll";
				string location = Assembly.GetExecutingAssembly().Location;
				string path = Path.Combine(location.Remove(location.Length - text.Length), "FunnyScream.wav");
				AudioClip val2 = Plugin.AudioLoader.LoadAudioClip(path);
				Debug.Log((object)val2.length);
				GameObject val3 = new GameObject();
				val3.AddComponent<RemoveAfterSeconds>().seconds = 10f;
				AudioSource val4 = val3.AddComponent<AudioSource>();
				val4.clip = val2;
				val4.playOnAwake = false;
				val4.volume = 0.03f;
				val3.transform.position = position;
				val3.transform.rotation = rotation;
				Debug.Log((object)val2.length);
				val4.Play();
			}
			if (code == 89)
			{
				GameObject val5 = GameObject.Find("/House/Lights");
				if (Object.op_Implicit((Object)(object)val5))
				{
					Light[] componentsInChildren = val5.GetComponentsInChildren<Light>(true);
					foreach (Light val6 in componentsInChildren)
					{
						if (Object.op_Implicit((Object)(object)((Component)val6).gameObject.GetComponent<RainbowLight>()))
						{
							((Component)val6).gameObject.GetComponent<RainbowLight>().Start();
						}
						else
						{
							((Component)val6).gameObject.AddComponent<RainbowLight>().Start();
						}
					}
					AudioLoop component = val5.GetComponent<AudioLoop>();
					if ((Object)(object)component == (Object)null)
					{
						component = val5.AddComponent<AudioLoop>();
						component.clip = Plugin.dansen;
						component.maxDistance = 100f;
						component.volume = 0.1f;
						((Behaviour)component).enabled = true;
					}
					else
					{
						((Behaviour)component).enabled = true;
					}
				}
			}
			if (code != 90)
			{
				return;
			}
			GameObject val7 = GameObject.Find("/House/Lights");
			if (Object.op_Implicit((Object)(object)val7))
			{
				Light[] componentsInChildren2 = val7.GetComponentsInChildren<Light>(true);
				foreach (Light val8 in componentsInChildren2)
				{
					((Component)val8).gameObject.GetComponent<RainbowLight>().Stop();
				}
				((Behaviour)val7.GetComponent<AudioLoop>()).enabled = false;
			}
		}
	}
	[HarmonyPatch(typeof(RemoveAfterSeconds))]
	internal class FireShotPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool Prefix(RemoveAfterSeconds __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_007a: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.seconds == 5f)
			{
				float num = 999f;
				((Object)((Component)__instance).gameObject).name = "temp";
				Object[] array = Object.FindObjectsOfType(typeof(GameObject));
				for (int i = 0; i < array.Length; i++)
				{
					GameObject val = (GameObject)array[i];
					if (((Object)val).name == "Fire(Clone)" && val.transform.childCount == 3 && Vector3.Distance(((Component)__instance).gameObject.transform.position, val.transform.position) < num)
					{
						num = Vector3.Distance(((Component)__instance).transform.position, val.transform.position);
					}
				}
				((Object)((Component)__instance).gameObject).name = "Fire(Clone)";
				Debug.Log((object)num);
				if (num <= 4.5f)
				{
					((Component)__instance).GetComponent<RemoveAfterSeconds>().seconds = 0f;
					Debug.Log((object)"Delete");
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Flare))]
	internal class FlarePatch
	{
		private static float musicTime;

		private static float currentHue;

		[HarmonyPatch("ConfigItem")]
		[HarmonyPrefix]
		private static bool PreFix(Flare __instance)
		{
			__instance.maxLifeTime *= 10f;
			AudioLoop component = ((Component)((Component)__instance).transform.GetChild(5).GetChild(3)).GetComponent<AudioLoop>();
			component.SetTime(musicTime);
			component.clip = Plugin.dansen;
			component.maxDistance *= 3f;
			component.volume = 0.3f;
			return true;
		}

		[HarmonyPatch("ConfigItem")]
		[HarmonyPostfix]
		private static void Postfix1(Flare __instance)
		{
			Light light = __instance.m_light;
			light.range *= 2f;
			Light light2 = __instance.m_light;
			light2.intensity *= 1.5f;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Postfix(Flare __instance)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			currentHue += 1E-08f + Time.deltaTime;
			if (currentHue > 1f)
			{
				currentHue -= 1f;
			}
			__instance.m_light.color = Color.HSVToRGB(currentHue, 1f, 1f);
			if (((Behaviour)__instance.m_light).enabled)
			{
				musicTime += Time.deltaTime;
			}
		}
	}
	[HarmonyPatch(typeof(ItemGooBall))]
	internal class GooBall
	{
		public static int randomNumber;

		[HarmonyPatch("SpawnExplosive")]
		[HarmonyPrefix]
		private static bool Prefix(ItemGooBall __instance, ref bool ___exploded)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			randomNumber = Plugin.Next(0, 10);
			if (randomNumber == 9)
			{
				PhotonNetwork.Instantiate("Jello", ((Component)__instance).gameObject.transform.position, Quaternion.identity, (byte)0, (object[])null);
				PhotonNetwork.Destroy(((Component)((Component)__instance).GetComponentInParent<PhotonView>()).gameObject);
				___exploded = true;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemHugger))]
	internal class Hugger
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static bool Prefix(ItemHugger __instance)
		{
			__instance.fullHealTime = 50f;
			return true;
		}
	}
	[HarmonyPatch(typeof(Bot_Mouth))]
	internal class MouthePatch
	{
		[HarmonyPatch("Combat")]
		[HarmonyPrefix]
		private static bool PreFix(Bot_Mouth __instance, ref Bot ___bot)
		{
			float num = 20f;
			if (___bot.distanceToTarget < num)
			{
				Bot obj = ___bot;
				obj.distanceToTarget -= num - 3f;
			}
			return true;
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static bool PreFixStart(Bot_Mouth __instance)
		{
			AudioClip val = Plugin.clips[Plugin.Next(0, Plugin.clips.Count - 1)];
			AudioLoop[] componentsInChildren = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<AudioLoop>(true);
			AudioLoop[] array = componentsInChildren;
			foreach (AudioLoop val2 in array)
			{
				Debug.Log((object)((Object)val2.clip).name);
				if (((Object)val2.clip).name != "SFX_Screamo_Scream2")
				{
					if ((Object)(object)val != (Object)null)
					{
						val2.clip = val;
						val2.volume = 0.3f;
					}
					else
					{
						Debug.LogError((object)"nah mate, clip is null");
					}
				}
			}
			return true;
		}
	}
	internal class PartyButton : Interactable
	{
		private bool PartyStarted = false;

		private void Start()
		{
			base.hoverText = "Start Party?";
		}

		public override void Interact(Player player)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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)
			//IL_0032: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (PartyStarted)
			{
				PartyStarted = false;
				base.hoverText = "Start Party?";
				object[] array = new object[0];
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				PhotonNetwork.RaiseEvent((byte)90, (object)array, val, SendOptions.SendReliable);
			}
			else
			{
				PartyStarted = true;
				base.hoverText = "Stop Party?";
				object[] array2 = new object[0];
				RaiseEventOptions val2 = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				PhotonNetwork.RaiseEvent((byte)89, (object)array2, val2, SendOptions.SendReliable);
			}
		}

		public override void OnStartHover(Player player)
		{
			((Interactable)this).OnStartHover(player);
		}

		public override void OnEndHover(Player player)
		{
			((Interactable)this).OnEndHover(player);
		}
	}
	public class RainbowLight : MonoBehaviour
	{
		private float currentHue = 0f;

		private Light a = null;

		private Color aColor = Color.white;

		private bool danceMode = false;

		private float[] originalData = new float[2];

		private void Awake()
		{
			//IL_0014: 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)
			a = ((Component)this).GetComponent<Light>();
			aColor = a.color;
			originalData[0] = a.intensity;
			originalData[1] = a.range;
		}

		private void Update()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (danceMode)
			{
				currentHue += 1E-08f + Time.deltaTime;
				if (currentHue > 1f)
				{
					currentHue -= 1f;
				}
				a.color = Color.HSVToRGB(currentHue, 1f, 1f);
			}
		}

		public void Start()
		{
			Light obj = a;
			obj.intensity *= 3f;
			Light obj2 = a;
			obj2.range *= 3f;
			danceMode = true;
		}

		public void Stop()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			a.intensity = originalData[0];
			a.range = originalData[1];
			danceMode = false;
			a.color = aColor;
		}
	}
	public class EditedSlurper : MonoBehaviour
	{
		private static Dictionary<Renderer, Material[]> originalMaterials = new Dictionary<Renderer, Material[]>();

		public void ReleaseFix(Bot_Slurper __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.playerAttached) && originalMaterials != null)
			{
				RestoreOriginalMaterials(((Component)__instance.playerAttached).gameObject);
			}
		}

		public void CaptureFix(Bot_Slurper __instance)
		{
			originalMaterials = new Dictionary<Renderer, Material[]>();
			if (Object.op_Implicit((Object)(object)__instance.playerAttached))
			{
				StoreOriginalMaterials(((Component)__instance.playerAttached).gameObject);
				ChangeMaterials(((Component)__instance.playerAttached).gameObject, __instance.hiddenMaterial);
			}
		}

		private static void StoreOriginalMaterials(GameObject obj)
		{
			SkinnedMeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				originalMaterials[(Renderer)(object)val] = ((Renderer)val).materials;
			}
		}

		private static void ChangeMaterials(GameObject obj, Material newMaterial)
		{
			((Component)obj.transform.Find("RigCreator/Rig/Armature/Hip/Torso/Head/")).gameObject.SetActive(false);
			SkinnedMeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				Material[] array2 = (Material[])(object)new Material[((Renderer)val).materials.Length];
				for (int j = 0; j < array2.Length; j++)
				{
					array2[j] = newMaterial;
				}
				((Renderer)val).materials = array2;
			}
		}

		private static void RestoreOriginalMaterials(GameObject obj)
		{
			((Component)obj.transform.Find("RigCreator/Rig/Armature/Hip/Torso/Head/")).gameObject.SetActive(true);
			SkinnedMeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				if (originalMaterials.ContainsKey((Renderer)(object)val))
				{
					((Renderer)val).materials = originalMaterials[(Renderer)(object)val];
				}
			}
			originalMaterials = null;
		}
	}
	[HarmonyPatch(typeof(Bot_Slurper))]
	internal class Slurper
	{
		[HarmonyPatch("RPCA_ReleasePlayer")]
		[HarmonyPrefix]
		public static bool ReleaseFix(Bot_Slurper __instance)
		{
			((Component)__instance).gameObject.GetComponent<EditedSlurper>().ReleaseFix(__instance);
			return true;
		}

		[HarmonyPatch("RPCA_AttachBlob")]
		[HarmonyPostfix]
		public static void CaptureFix(Bot_Slurper __instance)
		{
			((Component)__instance).gameObject.GetComponent<EditedSlurper>().CaptureFix(__instance);
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void HideFix(Bot_Slurper __instance)
		{
			((Renderer)((Component)((Component)__instance).transform.GetChild(0).GetChild(0).GetChild(1)).GetComponent<SkinnedMeshRenderer>()).material = __instance.hiddenMaterial;
			((Component)__instance).gameObject.AddComponent<EditedSlurper>();
		}

		[HarmonyPatch("Show")]
		[HarmonyPrefix]
		public static bool ShowFix(Bot_Slurper __instance)
		{
			return false;
		}
	}
}