using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EnemyPoint")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnemyPoint")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1BB229CB-E03B-4010-A922-EFD160632355")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EnemyPoint;
[BepInPlugin("wzk.lingxi.plugin.enemylocation", "Enemy Location", "1.0")]
public class PatchClass : BaseUnityPlugin
{
public class EnemyLocationClass
{
private readonly Dictionary<EnemyParent, MapCustom> _enemyLocationList = new Dictionary<EnemyParent, MapCustom>();
public bool EnemyDespawn(EnemyParent enemy)
{
if (_enemyLocationList.TryGetValue(enemy, out var value))
{
Object.Destroy((Object)(object)((Component)value.mapCustomEntity).gameObject);
_enemyLocationList.Remove(enemy);
return true;
}
return false;
}
public void AddEnemyLocation(EnemyParent enemy)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if (!_enemyLocationList.ContainsKey(enemy) && GameDirector.instance.PlayerList.Count != 0)
{
Enemy value = Traverse.Create((object)enemy).Field("Enemy").GetValue<Enemy>();
if (!((Object)(object)value == (Object)null))
{
MapCustom val = ((Component)value).gameObject.AddComponent<MapCustom>();
((Object)val).name = "Enemy_Point_" + enemy.enemyName;
val.color = Color.red;
val.sprite = GameDirector.instance.PlayerList[0].playerDeathHead.mapCustom.sprite;
_enemyLocationList[enemy] = val;
}
}
}
}
private static ConfigEntry<bool> _configEntry;
private static readonly ManualLogSource logger = Logger.CreateLogSource("Enemy Location");
public static EnemyLocationClass EnemyLocation;
private void Awake()
{
EnemyLocation = new EnemyLocationClass();
_configEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enemy Location", true, "True is Enable Enemy Location");
Harmony.CreateAndPatchAll(typeof(PatchClass), (string)null);
logger.LogInfo((object)"Plugin Enemy Location is loaded!");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyParent), "SpawnRPC")]
public static void EnemySpawn_POST(ref EnemyParent __instance)
{
if (_configEntry.Value)
{
while (GameDirector.instance.PlayerList.Count == 0)
{
}
EnemyLocation.AddEnemyLocation(__instance);
logger.LogInfo((object)"Add One Enemy Point");
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyParent), "DespawnRPC")]
public static void EnemyDespawn_POST(ref EnemyParent __instance)
{
if (_configEntry.Value && EnemyLocation.EnemyDespawn(__instance))
{
logger.LogInfo((object)"Remove One Enemy Point");
}
}
}