Decompiled source of BlindBirdStringEnjoyersImprovements v1.9.0

BlindBirdStringEnjoyersImprovements.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
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 BlindBirdStringEnjoyersImprovements.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: AssemblyCompany("BlindBirdStringEnjoyersImprovements")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("General game improvements")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3aabb7677e961e81040ef9a5948193713cbf73d5")]
[assembly: AssemblyProduct("BlindBirdStringEnjoyersImprovements")]
[assembly: AssemblyTitle("BlindBirdStringEnjoyersImprovements")]
[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 BlindBirdStringEnjoyersImprovements
{
	[BepInPlugin("BlindBirdStringEnjoyersImprovements", "BlindBirdStringEnjoyersImprovements", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("BlindBirdStringEnjoyersImprovements");

		public static ManualLogSource LogSource;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BlindBirdStringEnjoyersImprovements is loaded!");
			LogSource = Logger.CreateLogSource("BlindBirdStringEnjoyersImprovements");
			harmony.PatchAll(typeof(EntranceTeleportPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
			harmony.PatchAll(typeof(StormyWeatherPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(PreInitSceneScriptPatch));
			LogSource.LogInfo((object)"Patched!");
		}
	}
	public static class Utils
	{
		public static void CreateScanNodeOnObject(GameObject obj, int nodeType, int minRange, int maxRange, string headerText)
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ScanNode", new Type[2]
			{
				typeof(ScanNodeProperties),
				typeof(BoxCollider)
			})
			{
				layer = LayerMask.NameToLayer("ScanNode")
			};
			val.transform.parent = obj.transform;
			val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
			ScanNodeProperties component = val.GetComponent<ScanNodeProperties>();
			component.nodeType = nodeType;
			component.minRange = minRange;
			component.maxRange = maxRange;
			component.headerText = headerText;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BlindBirdStringEnjoyersImprovements";

		public const string PLUGIN_NAME = "BlindBirdStringEnjoyersImprovements";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BlindBirdStringEnjoyersImprovements.Patches
{
	public static class EntranceTeleportPatch
	{
		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")]
		[HarmonyPostfix]
		private static void TeleportPlayer(EntranceTeleport __instance)
		{
			if (__instance.entranceId != 0 && __instance.isEntranceToBuilding)
			{
				FlipPlayer(__instance, GameNetworkManager.Instance.localPlayerController);
			}
		}

		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerClientRpc")]
		[HarmonyPostfix]
		private static void TeleportPlayerClientRpc(EntranceTeleport __instance, int playerObj)
		{
			if (__instance.entranceId != 0 && __instance.isEntranceToBuilding)
			{
				PlayerControllerB val = __instance.playersManager.allPlayerScripts[playerObj];
				if (!((NetworkBehaviour)val).IsOwner)
				{
					FlipPlayer(__instance, val);
				}
			}
		}

		private static void FlipPlayer(EntranceTeleport instance, PlayerControllerB player)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			Vector3 eulerAngles = instance.exitPoint.eulerAngles;
			((Component)player).transform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y + 180f, eulerAngles.z);
		}
	}
	public class GrabbableObjectPatch
	{
		private static HashSet<GrabbableObject> _itemsToKeepInPlace = new HashSet<GrabbableObject>();

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPrefix]
		private static void Start_Pre(GrabbableObject __instance)
		{
			List<Type> obj = new List<Type>
			{
				typeof(BoomboxItem),
				typeof(ExtensionLadderItem),
				typeof(FlashlightItem),
				typeof(JetpackItem),
				typeof(LockPicker),
				typeof(RadarBoosterItem),
				typeof(Shovel),
				typeof(SprayPaintItem),
				typeof(StunGrenadeItem),
				typeof(TetraChemicalItem),
				typeof(WalkieTalkie),
				typeof(PatcherTool),
				typeof(BeltBagItem)
			};
			if (!__instance.itemProperties.isScrap)
			{
				ScanNodeProperties componentInChildren = ((Component)__instance).GetComponentInChildren<ScanNodeProperties>();
				if (componentInChildren != null)
				{
					string subText = componentInChildren.subText;
					__instance.SetScrapValue(0);
					if (subText != null && !subText.ToLower().StartsWith("value"))
					{
						componentInChildren.subText = subText;
					}
				}
				else
				{
					__instance.scrapValue = 0;
				}
			}
			if (obj.Contains(((object)__instance).GetType()) && (Object)(object)((Component)__instance).GetComponentInChildren<ScanNodeProperties>() == (Object)null)
			{
				Utils.CreateScanNodeOnObject(((Component)__instance).gameObject, 0, 1, 13, __instance.itemProperties.itemName);
			}
		}
	}
	public static class HUDManagerPatch
	{
		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		private static void Update(HUDManager __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < __instance.itemSlotIcons.Length; i++)
			{
				StartOfRound instance = StartOfRound.Instance;
				GrabbableObject val = ((instance != null) ? instance.localPlayerController.ItemSlots[i] : null);
				if ((Object)(object)val == (Object)null || (Object)(object)StormyWeatherPatch.Instance == (Object)null)
				{
					((Graphic)__instance.itemSlotIcons[i]).color = Color.white;
					continue;
				}
				Traverse obj = Traverse.Create((object)StormyWeatherPatch.Instance);
				GameObject val2 = ((obj != null) ? obj.Field("setStaticToObject").GetValue<GameObject>() : null);
				GrabbableObject val3 = null;
				try
				{
					if ((Object)(object)val2 != (Object)null)
					{
						val3 = val2.GetComponent<GrabbableObject>();
					}
				}
				catch
				{
				}
				StartOfRound instance2 = StartOfRound.Instance;
				if (instance2 != null && !instance2.localPlayerController.isInsideFactory)
				{
					StartOfRound instance3 = StartOfRound.Instance;
					if (instance3 != null && !instance3.localPlayerController.isInElevator && (Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)val)
					{
						((Graphic)__instance.itemSlotIcons[i]).color = Color.red;
						continue;
					}
				}
				if ((Object)(object)StormyWeatherPatch.Instance != (Object)null && val.itemProperties.isConductiveMetal)
				{
					((Graphic)__instance.itemSlotIcons[i]).color = Color.yellow;
				}
				else
				{
					((Graphic)__instance.itemSlotIcons[i]).color = Color.white;
				}
			}
		}
	}
	public static class PreInitSceneScriptPatch
	{
		[HarmonyPatch(typeof(PreInitSceneScript), "SkipToFinalSetting")]
		[HarmonyPrefix]
		private static bool SkipToFinalSetting(PreInitSceneScript __instance)
		{
			__instance.ChooseLaunchOption(true);
			return false;
		}
	}
	public static class StormyWeatherPatch
	{
		public static StormyWeather Instance { get; private set; }

		[HarmonyPatch(typeof(StormyWeather), "OnEnable")]
		[HarmonyPostfix]
		private static void OnEnable(StormyWeather __instance)
		{
			if ((Object)(object)Instance != (Object)(object)__instance)
			{
				Instance = __instance;
			}
		}

		[HarmonyPatch(typeof(StormyWeather), "OnDisable")]
		[HarmonyPostfix]
		private static void OnDisable()
		{
			Instance = null;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}