Decompiled source of CheatStatusHud v0.1.0

plugins/CheatStatusHud.dll

Decompiled 7 hours ago
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 HarmonyLib;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CheatStatusHud")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CheatStatusHud")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("04131380-3460-4fdf-8f05-28559b2221b1")]
[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")]
namespace CheatStatusHud;

[HarmonyPatch(typeof(Achievements), "IsCheatedAtAll")]
public static class Patch_IgnoreModdedFlag
{
	private static bool Prefix(ref bool __result)
	{
		bool flag = (Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile().m_usedCheats;
		bool flag2 = Achievements.IsWorldCheated();
		bool flag3 = (Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetInventory().AnyCheatedItem();
		__result = flag || flag2 || flag3;
		return false;
	}
}
[BepInPlugin("vince.cheatstatushud", "CheatStatusHud", "0.1.0")]
public class CheatStatusHud : BaseUnityPlugin
{
	public const string PluginGUID = "vince.cheatstatushud";

	public const string PluginName = "CheatStatusHud";

	public const string PluginVersion = "0.1.0";

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		_harmony = new Harmony("vince.cheatstatushud");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"CheatStatusHud v0.1.0 loaded.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private void OnGUI()
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		if (!Hud.IsUserHidden() && InventoryGui.IsVisible())
		{
			bool flag = (Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile().m_usedCheats;
			bool flag2 = Achievements.IsWorldCheated();
			bool flag3 = (Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetInventory().AnyCheatedItem();
			string text = ((flag || flag2 || flag3) ? "CHEATED" : "Clean");
			GUI.Label(new Rect(10f, 10f, 300f, 30f), "Cheat status: " + text);
		}
	}
}
internal class HudPatch
{
}
[HarmonyPatch(typeof(FejdStartup), "UpdateCharacterList")]
public static class Patch_CharacterListCheatTag
{
	private static void Postfix(FejdStartup __instance)
	{
		List<PlayerProfile> value = Traverse.Create((object)__instance).Field("m_profiles").GetValue<List<PlayerProfile>>();
		int value2 = Traverse.Create((object)__instance).Field("m_profileIndex").GetValue<int>();
		if (value != null && value2 >= 0 && value2 < value.Count && value[value2].m_usedCheats && !__instance.m_csName.text.Contains("CHEATED"))
		{
			TMP_Text csName = __instance.m_csName;
			csName.text += " <color=red>[CHEATED]</color>";
		}
	}
}
[HarmonyPatch(typeof(FejdStartup), "UpdateWorldList")]
public static class Patch_WorldListCheatTag
{
	private static void Postfix(FejdStartup __instance)
	{
		List<World> value = Traverse.Create((object)__instance).Field("m_worlds").GetValue<List<World>>();
		List<GameObject> value2 = Traverse.Create((object)__instance).Field("m_worldListElements").GetValue<List<GameObject>>();
		for (int i = 0; i < value.Count && i < value2.Count; i++)
		{
			ServerOptionsGUI.m_instance.ReadKeys(value[i]);
			bool flag = ServerOptionsGUI.WorldContainsCheatedModifiers(value[i]);
			Transform obj = value2[i].transform.Find("modifiers");
			TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
			if ((Object)(object)val != (Object)null && flag && !val.text.Contains("CHEATED"))
			{
				val.text += " <color=red>[CHEATED]</color>";
			}
		}
	}
}