Decompiled source of NPCInteract360 Mono v1.0.0

Mods/NPCInteract360_Mono.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using NPCInteract360;
using ScheduleOne.AvatarFramework;
using ScheduleOne.Interaction;
using ScheduleOne.NPCs;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "NPCInteract360", "1.0.0", "j0ckinjz", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyMetadata("NexusModID", "1001")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("NPCInteract360_Mono")]
[assembly: AssemblyConfiguration("MONO")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NPCInteract360_Mono")]
[assembly: AssemblyTitle("NPCInteract360_Mono")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 NPCInteract360
{
	public class Core : MelonMod
	{
		public override void OnInitializeMelon()
		{
			Harmony.CreateAndPatchAll(typeof(Core).Assembly, (string)null);
			Log.Msg("Mod Initialized. Version " + ((MelonBase)this).Info.Version);
			Log.Msg("Angle and capsule patches active.");
		}
	}
	[HarmonyPatch(typeof(InteractableObject), "CheckAngleLimit")]
	public static class Patch_CheckAngleLimit
	{
		private static readonly HashSet<Transform> angleLimitPatched = new HashSet<Transform>();

		private static bool Prefix(InteractableObject __instance, Vector3 interactionSource, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).transform == (Object)null)
			{
				__result = true;
				return false;
			}
			Transform root = ((Component)__instance).transform.root;
			if ((Object)(object)root == (Object)null || angleLimitPatched.Contains(((Component)__instance).transform))
			{
				__result = true;
				return false;
			}
			if ((Object)(object)((Component)root).GetComponentInChildren<NPC>() == (Object)null)
			{
				__result = true;
				return true;
			}
			string text = ((Object)__instance).name.ToLowerInvariant();
			if (text.Contains("pickpocket"))
			{
				__result = true;
				return true;
			}
			__instance.LimitInteractionAngle = false;
			__instance.AngleLimit = 180f;
			angleLimitPatched.Add(((Component)__instance).transform);
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(Avatar), "LateUpdate")]
	public static class Patch_Avatar_LateUpdate
	{
		private static readonly HashSet<Transform> capsuleColliderAdjusted = new HashSet<Transform>();

		private static void Postfix(Avatar __instance)
		{
			Transform transform = ((Component)__instance).transform;
			Transform val = ((transform != null) ? transform.root : null);
			if ((Object)(object)val == (Object)null || capsuleColliderAdjusted.Contains(val))
			{
				return;
			}
			Transform val2 = val.Find("Capsule");
			if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy)
			{
				CapsuleCollider component = ((Component)val2).GetComponent<CapsuleCollider>();
				if ((Object)(object)component != (Object)null)
				{
					component.height = 0f;
					capsuleColliderAdjusted.Add(val);
				}
			}
		}
	}
	internal static class Log
	{
		public static void Msg(string msg)
		{
			Melon<Core>.Logger.Msg(msg);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}