Decompiled source of TalkFromAnySide v0.2.2

Mods/TalkFromAnySide.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppScheduleOne.Interaction;
using Il2CppScheduleOne.NPCs;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TalkFromAnySide;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(TalkFromAnySideMod), "Talk From Any Side", "0.2.2", "SeaDoge", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonPlatformDomain(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TalkFromAnySide")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2")]
[assembly: AssemblyProduct("TalkFromAnySide")]
[assembly: AssemblyTitle("TalkFromAnySide")]
[assembly: AssemblyVersion("0.2.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 TalkFromAnySide
{
	public sealed class TalkFromAnySideMod : MelonMod
	{
		public override void OnInitializeMelon()
		{
			((MelonBase)this).HarmonyInstance.PatchAll(typeof(TalkFromAnySideMod).Assembly);
			((MelonBase)this).LoggerInstance.Msg("Initialized for IL2CPP. NPC interactions are targetable from any side.");
		}
	}
	[HarmonyPatch(typeof(NPC), "Start")]
	internal static class NpcStartPatch
	{
		private const float WorldTargetRadius = 0.27f;

		private const float WorldTargetHeight = 1.45f;

		private const float MinimumScale = 0.0001f;

		private static void Postfix(NPC __instance)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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)
			try
			{
				foreach (InteractableObject componentsInChild in ((Component)((Component)__instance).transform.root).GetComponentsInChildren<InteractableObject>(true))
				{
					if (string.Equals(((Object)componentsInChild).name, "Interaction", StringComparison.OrdinalIgnoreCase))
					{
						componentsInChild.LimitInteractionAngle = false;
						CapsuleCollider val = ((Component)componentsInChild).gameObject.AddComponent<CapsuleCollider>();
						((Collider)val).isTrigger = true;
						val.direction = 1;
						val.center = ((Component)componentsInChild).transform.InverseTransformPoint(__instance.CenterPoint);
						Vector3 lossyScale = ((Component)componentsInChild).transform.lossyScale;
						float num = Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z));
						float num2 = Mathf.Abs(lossyScale.y);
						val.radius = 0.27f / Mathf.Max(num, 0.0001f);
						val.height = Mathf.Max(1.45f / Mathf.Max(num2, 0.0001f), val.radius * 2f);
					}
				}
			}
			catch (Exception value)
			{
				Melon<TalkFromAnySideMod>.Logger.Error($"Failed to patch an NPC: {value}");
			}
		}
	}
}