using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using KillCountEvolution.Config;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("KillCountEvolution")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MobLevelSystem")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b0de67da-3bbf-4641-bf42-71bdb5d846ed")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
internal class EnemyHudPatch
{
private static void Postfix(EnemyHud __instance)
{
if (!(AccessTools.Field(typeof(EnemyHud), "m_huds").GetValue(__instance) is IDictionary dictionary))
{
return;
}
foreach (DictionaryEntry item in dictionary)
{
object key = item.Key;
Character val = (Character)((key is Character) ? key : null);
if ((Object)(object)val == (Object)null)
{
continue;
}
int level = val.GetLevel();
if (level <= 3)
{
continue;
}
object value = item.Value;
if (value == null)
{
continue;
}
FieldInfo fieldInfo = AccessTools.Field(value.GetType(), "m_name");
if (!(fieldInfo == null))
{
object? value2 = fieldInfo.GetValue(value);
TMP_Text val2 = (TMP_Text)((value2 is TMP_Text) ? value2 : null);
if (!((Object)(object)val2 == (Object)null) && !val2.text.Contains("★"))
{
int count = level - 1;
string text = new string('★', count);
val2.text = val2.text + " " + text + "";
}
}
}
}
}
namespace KillCountEvolution
{
[BepInPlugin("com.basicMods.KillCountEvolution", "Kill Count Evolution", "1.0.0")]
public class KillCountEvolution : BaseUnityPlugin
{
public static KillCountEvolution Instance;
public MobSpawnConfig mobConfig;
public PlayerData localPlayerData;
private string saveFolder;
private Dictionary onlinePeerContributions = new Dictionary();
private int globalTotalKills;
private void Awake()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
saveFolder = Path.Combine(Paths.BepInExRootPath, "plugins", "KillCountEvolution");
Directory.CreateDirectory(saveFolder);
mobConfig = new MobSpawnConfig((BaseUnityPlugin)(object)this);
new Harmony("com.basicMods.KillCountEvolution").PatchAll();
}
public void SetupRPCs()
{
ZRoutedRpc.instance.Register("RPC_SubmitInitialKills", (Action)RPC_SubmitInitialKills);
ZRoutedRpc.instance.Register("RPC_SyncGlobalKills", (Action)RPC_SyncGlobalKills);
ZRoutedRpc.instance.Register("RPC_AddOneKill", (Action)RPC_AddOneKill);
}
private void RPC_SubmitInitialKills(long sender, int kills)
{
if (ZNet.instance.IsServer())
{
onlinePeerContributions[sender] = kills;
UpdateGlobalTotal();
}
}
private void RPC_AddOneKill(long sender)
{
if (ZNet.instance.IsServer())
{
if (onlinePeerContributions.ContainsKey(sender))
{
onlinePeerContributions[sender]++;
}
else
{
onlinePeerContributions[sender] = 1;
}
UpdateGlobalTotal();
}
}
private void RPC_SyncGlobalKills(long sender, int total)
{
globalTotalKills = total;
}
private void UpdateGlobalTotal()
{
globalTotalKills = onlinePeerContributions.Values.Sum();
ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_SyncGlobalKills", new object[1] { globalTotalKills });
SaveMasterJson();
}
public void OnPlayerDisconnect(long peerID)
{
if (ZNet.instance.IsServer() && onlinePeerContributions.ContainsKey(peerID))
{
onlinePeerContributions.Remove(peerID);
UpdateGlobalTotal();
}
}
public void LoadLocalData()
{
if (!((Object)(object)Player.m_localPlayer == (Object)null))
{
string worldName = ZNet.instance.GetWorldName();
string playerName = Player.m_localPlayer.GetPlayerName();
string path = Path.Combine(saveFolder, worldName + "_" + playerName + ".json");
if (File.Exists(path))
{
string text = File.ReadAllText(path);
localPlayerData = JsonUtility.FromJson(text);
Debug.Log((object)$"[KillCountEvolution] Betöltve: {playerName} - {localPlayerData.TotalKills} ölés.");
}
else
{
localPlayerData = new PlayerData
{
PlayerName = playerName,
TotalKills = 0
};
Debug.Log((object)"[KillCountEvolution] Új player adat létrehozva.");
}
ZRoutedRpc.instance.InvokeRoutedRPC(0L, "RPC_SubmitInitialKills", new object[1] { localPlayerData.TotalKills });
}
}
public void RegisterLocalKill()
{
localPlayerData.TotalKills++;
SaveLocalJson();
ZRoutedRpc.instance.InvokeRoutedRPC(0L, "RPC_AddOneKill", Array.Empty