using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Munta")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LovePotionPatch")]
[assembly: AssemblyTitle("LovePotionPatch")]
[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.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]
[Microsoft.CodeAnalysis.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]
[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 LovePotionPatch
{
[BepInPlugin("Munta.LoveFixation", "LoveFixation", "1.0.0")]
public class LoveFixation : BaseUnityPlugin
{
internal static ConfigEntry<float> cameraStrength;
internal static ConfigEntry<float> cameraStrengthNoAim;
internal static ConfigEntry<int> noObjectHeldMultiplier;
internal static LoveFixation Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
cameraStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Strength", 0.5f, new ConfigDescription("The strength of the camera aim when a player is possessed by a Love Potion.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
cameraStrengthNoAim = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "StrengthNoAim", 1f, new ConfigDescription("The strength of the camera aim when a player is possessed by a Love Potion but not moving the mouse.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
noObjectHeldMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("Camera", "NoObjectHeldMultiplier", 3, new ConfigDescription("The multiplier for the camera aim strength when the player is not holding an object.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll(typeof(ChatManagerPatch));
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
[HarmonyPatch(typeof(ChatManager))]
internal static class ChatManagerPatch
{
private static PlayerAvatar? targetPlayer;
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void Update_Postfix()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
PlayerAvatar instance = PlayerAvatar.instance;
bool flag = Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.voiceChat) && Object.op_Implicit((Object)(object)instance.voiceChat.ttsVoice) && instance.voiceChat.ttsVoice.isSpeaking;
bool flag2 = Object.op_Implicit((Object)(object)PhysGrabber.instance) && PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject);
if (ChatManager.instance.IsPossessed((PossessChatID)1) && flag)
{
PostProcessing.Instance.VignetteOverride(Color.magenta, 0.5f, 1f, 1f, 0.5f, 0.1f, ((Component)ChatManager.instance).gameObject);
if ((Object)(object)targetPlayer != (Object)null)
{
float num = (flag2 ? LoveFixation.cameraStrength.Value : (LoveFixation.cameraStrength.Value * (float)LoveFixation.noObjectHeldMultiplier.Value));
float num2 = (flag2 ? LoveFixation.cameraStrengthNoAim.Value : (LoveFixation.cameraStrengthNoAim.Value * (float)LoveFixation.noObjectHeldMultiplier.Value));
Vector3 position = SemiFunc.PlayerGetFaceEyeTransform(targetPlayer).position;
SemiFunc.PlayerEyesOverride(instance, position, 0.1f, ((Component)ChatManager.instance).gameObject);
CameraAim.Instance.AimTargetSoftSet(position, 0.5f, num, num2, ((Component)targetPlayer).gameObject, 50);
}
}
}
[HarmonyPostfix]
[HarmonyPatch("StartPossessMessage")]
private static void UpdateTargetPlayer(PossessMessage message)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
PossessMessage message2 = message;
if ((int)message2.possessChatID == 1)
{
List<PlayerAvatar> list = (from p in SemiFunc.PlayerGetList()
where message2.message.Contains(p.playerName)
select p).ToList();
if (list.Count == 0)
{
targetPlayer = null;
}
else
{
targetPlayer = (PlayerAvatar?)((list.Count == 1) ? ((object)list[0]) : ((object)GetClosestPlayer()));
}
}
}
private static PlayerAvatar? GetClosestPlayer()
{
//IL_0010: 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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask));
PlayerAvatar result = null;
float num = float.MaxValue;
foreach (PlayerAvatar item in list)
{
if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
{
float num2 = Vector3.Distance(((Component)PhysGrabber.instance).transform.position, ((Component)item).transform.position);
if (num2 < num)
{
num = num2;
result = item;
}
}
}
return result;
}
}
}