using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Peak.Afflictions;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mystic Cheaters Compass")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mystic Cheaters Compass")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("75e2a56e-f2f3-42c5-8ef5-46ee3a6e5657")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Mystic_Cheaters_Compass;
[BepInPlugin("tony4twentys.Mystic_Cheaters_Compass", "Mystic Cheaters Compass", "1.0.0")]
public class MysticCheatersCompassPlugin : BaseUnityPlugin
{
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Mystic Cheaters Compass is loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied successfully!");
}
}
[HarmonyPatch]
public class ItemPatches
{
[HarmonyPatch(typeof(Item), "Awake")]
[HarmonyPostfix]
public static void ItemAwake_Postfix(Item __instance)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!((Object)((Component)__instance).gameObject).name.Contains("Cheat Compass") && !((Object)((Component)__instance).gameObject).name.Contains("Compass"))
{
return;
}
__instance.totalUses = 1;
__instance.itemTags = (ItemTags)(__instance.itemTags | 1);
Action_WarpToBiome component = ((Component)__instance).GetComponent<Action_WarpToBiome>();
if ((Object)(object)component != (Object)null)
{
MapHandler instance = Singleton<MapHandler>.Instance;
if ((Object)(object)instance != (Object)null)
{
Segment currentSegment = instance.GetCurrentSegment();
Segment nextSegment = GetNextSegment(currentSegment);
component.segmentToWarpTo = nextSegment;
}
}
}
catch (Exception)
{
}
}
private static Segment GetNextSegment(Segment currentSegment)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
List<Segment> list = new List<Segment>
{
(Segment)1,
(Segment)2,
(Segment)3,
(Segment)4
};
int num = list.IndexOf(currentSegment);
if (num == -1)
{
return (Segment)1;
}
if (num >= list.Count - 1)
{
return currentSegment;
}
return list[num + 1];
}
private static void SetItemUIName(Item item, string name)
{
if (!Object.op_Implicit((Object)(object)item))
{
return;
}
try
{
Type type = AccessTools.Inner(typeof(Item), "ItemUIData");
if (type == null)
{
return;
}
FieldInfo fieldInfo = null;
foreach (FieldInfo declaredField in AccessTools.GetDeclaredFields(typeof(Item)))
{
if (declaredField.FieldType == type)
{
fieldInfo = declaredField;
break;
}
}
if (fieldInfo == null)
{
return;
}
object obj = fieldInfo.GetValue(item);
if (obj == null)
{
obj = Activator.CreateInstance(type);
}
FieldInfo fieldInfo2 = AccessTools.Field(type, "itemName");
if (!(fieldInfo2 == null))
{
if (type.IsValueType)
{
object obj2 = obj;
fieldInfo2.SetValue(obj2, name);
fieldInfo.SetValue(item, obj2);
}
else
{
fieldInfo2.SetValue(obj, name);
fieldInfo.SetValue(item, obj);
}
}
}
catch (Exception)
{
}
}
}
[HarmonyPatch]
public class WarpInvincibilityPatches
{
[HarmonyPatch(typeof(MapHandler), "JumpToSegmentLogic")]
[HarmonyPostfix]
public static void MapHandlerJumpToSegmentLogic_Postfix(Segment segment)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Invalid comparison between Unknown and I4
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
try
{
if ((int)segment == 3)
{
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter != (Object)null)
{
Affliction_BingBongShield val = new Affliction_BingBongShield();
((Affliction)val).totalTime = 5f;
localCharacter.refs.afflictions.AddAffliction((Affliction)(object)val, false);
}
}
}
catch (Exception)
{
}
}
}
[HarmonyPatch]
public class ItemNamePatches
{
[HarmonyPatch(typeof(Item), "GetName")]
[HarmonyPrefix]
public static bool ItemGetName_Prefix(Item __instance, ref string __result)
{
try
{
if (((Object)((Component)__instance).gameObject).name.Contains("Cheat Compass") || ((Object)((Component)__instance).gameObject).name.Contains("Compass"))
{
__result = "Cheaters Compass";
return false;
}
}
catch (Exception)
{
}
return true;
}
}
[HarmonyPatch]
public class LootDataPatches
{
[HarmonyPatch(typeof(LootData), "IsValidToSpawn")]
[HarmonyPrefix]
public static bool LootDataIsValidToSpawn_Prefix(LootData __instance, ref bool __result)
{
try
{
Item component = ((Component)__instance).GetComponent<Item>();
if ((Object)(object)component != (Object)null && (((Object)((Component)component).gameObject).name.Contains("Cheat Compass") || ((Object)((Component)component).gameObject).name.Contains("Compass")))
{
__result = true;
return false;
}
}
catch (Exception)
{
}
return true;
}
}