using System;
using System.Diagnostics;
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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnemyLove")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("EnemyLove")]
[assembly: AssemblyTitle("EnemyLove")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 EnemyLove
{
[BepInPlugin("EnemyLove", "EnemyLove", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(ValuableLovePotion))]
public class PatchLovePotion
{
[HarmonyPatch("GenerateAffectionateSentence")]
[HarmonyPrefix]
private static void GenerateAffectionateSentencePrefix(ValuableLovePotion __instance)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)PhysGrabber.instance).transform.position;
Enemy val = SemiFunc.EnemyGetNearest(((Component)PhysGrabber.instance).transform.position, 10f, false);
if (val == null)
{
Logger.LogInfo((object)"No enemies found nearby");
return;
}
PlayerAvatar val2 = null;
float num = float.MaxValue;
foreach (PlayerAvatar item in SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask)))
{
if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
{
float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)PhysGrabber.instance).transform.position);
if (num2 < num)
{
num = num2;
val2 = item;
}
}
}
object? value = AccessTools.Field(typeof(Enemy), "EnemyParent").GetValue(val);
EnemyParent val3 = (EnemyParent)((value is EnemyParent) ? value : null);
if (val3 == null)
{
Logger.LogError((object)"Failed to get enemy parent object.");
return;
}
Vector3 position2 = val.CenterTransform.position;
float num3 = Vector3.Distance(position2, position);
Logger.LogInfo((object)$"Found nearest enemy to the player at {position2}");
if (val2 != null && Vector3.Distance(((Component)val2).transform.position, position) < num3)
{
Logger.LogInfo((object)"Player was closer than the enemy. Dropping.");
return;
}
string enemyName = val3.enemyName;
Logger.LogInfo((object)$"LovePotion found nearest enemy: {enemyName} @ {position2}");
AccessTools.Field(typeof(ValuableLovePotion), "playerName").SetValue(__instance, enemyName);
}
}
public const string modGUID = "sunryze.EnemyLove";
public const string modName = "EnemyLove";
public const string modVersion = "1.0.0";
public static Plugin PluginInstance;
public static ManualLogSource LoggerInstance;
private readonly Harmony harmony = new Harmony("sunryze.EnemyLove");
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
if ((Object)(object)PluginInstance == (Object)null)
{
PluginInstance = this;
}
LoggerInstance = Logger;
harmony.PatchAll();
Logger.LogInfo((object)"Plugin sunryze.EnemyLove is loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "EnemyLove";
public const string PLUGIN_NAME = "EnemyLove";
public const string PLUGIN_VERSION = "1.0.1";
}
}