Decompiled source of EmotesSprayFix v1.1.0

BepInEx/plugins/EmotesSprayFix.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EmotesSprayFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmotesSprayFix")]
[assembly: AssemblyTitle("EmotesSprayFix")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 EmotesSprayFix
{
	[BepInPlugin("it.vritris.emotessprayfix", "EmotesSprayFix", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			if (!Chainloader.PluginInfos.ContainsKey("com.weliveinasociety.CustomEmotesAPI"))
			{
				Log.LogInfo((object)"LethalEmotesAPI non attivo: EmotesSprayFix disabilitato automaticamente (Vanilla intatto).");
				return;
			}
			Harmony.CreateAndPatchAll(typeof(PlayerLateUpdateFix), (string)null);
			Log.LogInfo((object)"LethalEmotesAPI rilevato: EmotesSprayFix attivato!");
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
	internal static class PlayerLateUpdateFix
	{
		private struct SavedTransform
		{
			public GrabbableObject Item;

			public Vector3 Pos;

			public Quaternion Rot;
		}

		[HarmonyPrefix]
		private static void Prefix(PlayerControllerB __instance, out SavedTransform __state)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			__state = default(SavedTransform);
			if (!((Object)(object)__instance == (Object)null) && __instance.isHoldingObject)
			{
				GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer;
				SprayPaintItem val = (SprayPaintItem)(object)((currentlyHeldObjectServer is SprayPaintItem) ? currentlyHeldObjectServer : null);
				if (val != null && (Object)(object)__instance.localItemHolder != (Object)null && (Object)(object)((Component)val).transform.parent != (Object)(object)__instance.localItemHolder)
				{
					__state = new SavedTransform
					{
						Item = (GrabbableObject)(object)val,
						Pos = ((Component)val).transform.position,
						Rot = ((Component)val).transform.rotation
					};
				}
			}
		}

		[HarmonyPostfix]
		private static void Postfix(SavedTransform __state)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__state.Item != (Object)null)
			{
				((Component)__state.Item).transform.SetPositionAndRotation(__state.Pos, __state.Rot);
			}
		}
	}
}