Decompiled source of Something Neighborly This Way Comes v1.1.0

SomethingNeighbourlyThisWayComes.dll

Decompiled 3 weeks ago
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 BepInEx.Logging;
using PluginConfig.API;
using PluginConfig.API.Fields;
using Ultrapit;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SomethingNeighbourlyThisWayComes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SomethingNeighbourlyThisWayComes")]
[assembly: AssemblyTitle("SomethingNeighbourlyThisWayComes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Neighbor
{
	[BepInPlugin("Neighbor.draghtnim.ultrakill", "Neighbor", "1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private AssetBundle terminal;

		public static bool IsCustomLevel = false;

		private static Plugin _instance;

		private static string assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		private GameObject[] prefabs = PitBundle.LoadAllAssets<GameObject>();

		private AudioClip[] sounds = PitBundle.LoadAllAssets<AudioClip>();

		private static AssetBundle PitBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "Neighbor.resource"));

		private PluginConfigurator config;

		private bool freddymode = false;

		public static Plugin Instance => _instance;

		private async void Awake()
		{
			string assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			config = PluginConfigurator.Create("Something neighborly this way comes.", "HELLOIMYOURNEIGHBOR");
			config.presetButtonHidden = true;
			BoolField freddy = new BoolField(config.rootPanel, "FredBear Mode", "freddy", false);
			if (freddy.value)
			{
				config.SetIconWithURL(Path.Combine(assemblyLocation, "icon2.png"));
			}
			else
			{
				config.SetIconWithURL(Path.Combine(assemblyLocation, "icon.png"));
			}
			_instance = this;
			freddymode = freddy.value;
			freddy.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
			{
				freddymode = e.value;
				if (e.value)
				{
					config.SetIconWithURL(Path.Combine(assemblyLocation, "icon2.png"));
				}
				else
				{
					config.SetIconWithURL(Path.Combine(assemblyLocation, "icon.png"));
				}
			};
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
			Scene activeScene = SceneManager.GetActiveScene();
			logger.LogInfo((object)((Scene)(ref activeScene)).name);
		}

		private GameObject getobject(string name)
		{
			GameObject[] array = prefabs;
			foreach (GameObject val in array)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			return null;
		}

		private AudioClip getsound(string name)
		{
			AudioClip[] array = sounds;
			foreach (AudioClip val in array)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			return null;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)SceneHelper.CurrentScene);
			string currentScene = SceneHelper.CurrentScene;
			string text = currentScene;
			if (!(text == "Level 0-S"))
			{
				return;
			}
			GameObject val = GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked/SomethingWicked/");
			foreach (Transform item in val.transform)
			{
				Transform val2 = item;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"testN");
				if ((Object)(object)((Component)val2).gameObject.GetComponent<SkinnedMeshRenderer>() != (Object)null)
				{
					((Renderer)((Component)val2).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false;
				}
			}
			GameObject val3 = null;
			if (!freddymode)
			{
				val3 = Object.Instantiate<GameObject>(getobject("1SWReplacement"));
				GenericHelper.FindObjectEvenIfDisabled("MessageParent", "Hint").GetComponent<HudMessage>().message = "Something neighborly this way comes.";
			}
			else
			{
				val3 = Object.Instantiate<GameObject>(getobject("FredbearTEST2"));
				GenericHelper.FindObjectEvenIfDisabled("Scream").GetComponent<AudioSource>().clip = getsound("Laugh_Giggle_Girl_8d");
				((Behaviour)GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked/ForceRunWarning/").GetComponent<SoundPitch>()).enabled = false;
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked/ForceRunWarning/").GetComponent<AudioSource>().clip = getsound("Laugh_Giggle_Girl_2d");
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked/ForceRunWarning/").GetComponent<AudioSource>().pitch = 1f;
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked").GetComponent<AudioSource>().clip = getsound("Laugh_Giggle_Girl_1d");
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked").GetComponent<AudioSource>().pitch = 1f;
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked").GetComponent<EnemyIdentifier>().totalSpeedModifier = 5f;
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked").GetComponent<EnemyIdentifier>().speedBuff = true;
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked").GetComponent<Wicked>().hitSound = getobject("WickedHit2");
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked/RadiationField").SetActive(false);
				GenericHelper.FindObjectEvenIfDisabled("Enemy", "Wicked/Ambiance").SetActive(false);
				GenericHelper.FindObjectEvenIfDisabled("MessageParent", "Hint").GetComponent<HudMessage>().message = "Good Luck.";
				((Behaviour)GenericHelper.FindObjectEvenIfDisabled("Lights", "Audio Source").GetComponent<SoundPitch>()).enabled = false;
				GenericHelper.FindObjectEvenIfDisabled("Lights", "Audio Source").GetComponent<AudioSource>().pitch = 0.6f;
				GenericHelper.FindObjectEvenIfDisabled("Lights", "Audio Source").GetComponent<AudioSource>().volume = 0.8f;
				GenericHelper.FindObjectEvenIfDisabled("Lights", "Audio Source").GetComponent<AudioSource>().clip = getsound("Laugh_Giggle_Girl_8d");
			}
			val3.transform.parent = val.transform;
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localScale = new Vector3(1f, 1f, 1f);
		}
	}
}
namespace Ultrapit
{
	public class GenericHelper : BaseUnityPlugin
	{
		public static bool IsCustomLevel = false;

		private static GameObject pref = null;

		private static Dictionary<string, GameObject> BundleDictionary = new Dictionary<string, GameObject>();

		public static GameObject FindObjectEvenIfDisabled(string rootName, string objPath = null, int childNum = 0, bool useChildNum = false)
		{
			//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)
			GameObject val = null;
			Scene activeScene = SceneManager.GetActiveScene();
			GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
			bool flag = false;
			GameObject[] array = rootGameObjects;
			foreach (GameObject val2 in array)
			{
				if (((Object)val2).name == rootName)
				{
					val = val2;
					flag = true;
				}
			}
			if (flag)
			{
				GameObject val3 = val;
				if (objPath != null)
				{
					val3 = ((Component)val.transform.Find(objPath)).gameObject;
					if (!useChildNum)
					{
						val = val3;
					}
				}
				if (useChildNum)
				{
					GameObject gameObject = ((Component)val3.transform.GetChild(childNum)).gameObject;
					val = gameObject;
				}
			}
			return val;
		}
	}
}