Decompiled source of LobbyCharacterInspect v1.0.0

LobbyCharacterInspect.dll

Decompiled 3 days ago
using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
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("LobbyCharacterInspect")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0363fdfc4dcd005f30ad4e22b60a794bd913bbaa")]
[assembly: AssemblyProduct("LobbyCharacterInspect")]
[assembly: AssemblyTitle("LobbyCharacterInspect")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ExamplePlugin
{
	[BepInPlugin("com.espadon.LobbyCharacterInspect", "Lobby Character Inspect", "1.0.0")]
	public class LobbyRotatorPlugin : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			try
			{
				Harmony val = new Harmony("com.espadon.LobbyCharacterInspect");
				Type type = null;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					Type[] types = assembly.GetTypes();
					type = Array.Find(types, (Type t) => t.Name == "SurvivorManikinSlotController" || t.Name == "SurvivorMannequinSlotController");
					if (type != null)
					{
						break;
					}
				}
				if (type != null)
				{
					MethodInfo method = type.GetMethod("Update", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					MethodInfo method2 = typeof(LobbyRotatorPlugin).GetMethod("PedestalUpdatePostfix", BindingFlags.Static | BindingFlags.NonPublic);
					if (method != null && method2 != null)
					{
						val.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Lobby Rotator successfully configured for Local Player Only protection!");
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Lobby Rotator initialization block failed: " + ex.Message));
			}
		}

		private static void PedestalUpdatePostfix(MonoBehaviour __instance)
		{
			try
			{
				if (!((Object)(object)__instance != (Object)null) || Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<OnlyMyCharacterRotator>()))
				{
					return;
				}
				bool flag = false;
				FieldInfo field = ((object)__instance).GetType().GetField("isLocalPlayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					flag = (bool)field.GetValue(__instance);
				}
				else
				{
					PropertyInfo property = ((object)__instance).GetType().GetProperty("networkUser", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null)
					{
						object value = property.GetValue(__instance);
						if (value != null)
						{
							PropertyInfo property2 = value.GetType().GetProperty("isLocalPlayer", BindingFlags.Instance | BindingFlags.Public);
							if (property2 != null)
							{
								flag = (bool)property2.GetValue(value);
							}
						}
					}
					else
					{
						FieldInfo field2 = ((object)__instance).GetType().GetField("slotIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field2 != null && (int)field2.GetValue(__instance) == 0)
						{
							flag = true;
						}
					}
				}
				if (flag)
				{
					((Component)__instance).gameObject.AddComponent<OnlyMyCharacterRotator>();
				}
			}
			catch
			{
			}
		}
	}
	public class OnlyMyCharacterRotator : MonoBehaviour
	{
		private float rotationSpeed = 350f;

		private bool isDragging = false;

		private Vector3 lastMousePosition;

		private float defaultMenuAngleOffset = -35f;

		private float currentRotationalOffset = -35f;

		private float currentVelocity = 0f;

		private float frictionCoefficient = 0.95f;

		private float minVelocityCutoff = 0.05f;

		public void Start()
		{
			currentRotationalOffset = defaultMenuAngleOffset;
		}

		public void Update()
		{
			//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)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetMouseButtonDown(0))
			{
				isDragging = true;
				lastMousePosition = Input.mousePosition;
				currentVelocity = 0f;
			}
			if (Input.GetMouseButtonUp(0))
			{
				isDragging = false;
			}
			if (isDragging && Input.GetMouseButton(0))
			{
				Vector3 mousePosition = Input.mousePosition;
				Vector3 val = mousePosition - lastMousePosition;
				currentVelocity = (0f - val.x) * rotationSpeed * Time.deltaTime;
				currentRotationalOffset += currentVelocity;
				lastMousePosition = mousePosition;
			}
			else if (Mathf.Abs(currentVelocity) > minVelocityCutoff)
			{
				currentVelocity *= frictionCoefficient;
				currentRotationalOffset += currentVelocity;
			}
			else
			{
				currentVelocity = 0f;
			}
			if (Input.GetMouseButtonDown(1))
			{
				currentRotationalOffset = defaultMenuAngleOffset;
				currentVelocity = 0f;
			}
		}

		public void LateUpdate()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.localRotation = Quaternion.Euler(0f, currentRotationalOffset, 0f);
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
}