using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Assets.Scripts.Game.Spawning;
using Assets.Scripts.Steam.LeaderboardsNew;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BalanceShrine")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4515d5122281211c3030861dfb02c1ac3cef1e7b")]
[assembly: AssemblyProduct("BalanceShrine")]
[assembly: AssemblyTitle("BalanceShrine")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BalanceShrine
{
[BepInPlugin("BalanceShrineForBepInEx", "BalanceShrineForBepInEx", "1.0.0")]
public class Core : BasePlugin
{
public class Spawn : MonoBehaviour
{
public Spawn(IntPtr ptr)
: base(ptr)
{
}
}
[CompilerGenerated]
private sealed class <SpawnShrines>d__23 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Core <>4__this;
private Random <random>5__1;
private int <numShrines>5__2;
private int <i>5__3;
private Vector3 <shrinePosition>5__4;
private GameObject <BalanceShrine>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnShrines>d__23(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<random>5__1 = null;
<BalanceShrine>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
goto IL_00e4;
}
<>1__state = -1;
<random>5__1 = new Random();
<numShrines>5__2 = <random>5__1.Next(MinShrines, MaxShrines);
<>4__this.print($"{<numShrines>5__2} shrines are to be spawned!");
<i>5__3 = 0;
goto IL_01ae;
IL_00e4:
if (<>4__this.LastValue == <shrinePosition>5__4)
{
<shrinePosition>5__4 = SpawnPositions.GetRandomSpawnPositionOnMap(0f);
<>4__this.print<Vector3>(<shrinePosition>5__4);
<>2__current = (object)new WaitForSeconds(0.01f);
<>1__state = 1;
return true;
}
<>4__this.print("Spawning a shrine...");
<BalanceShrine>5__5 = Object.Instantiate<GameObject>(ShrineBal);
SceneManager.MoveGameObjectToScene(<BalanceShrine>5__5, SceneManager.GetActiveScene());
<BalanceShrine>5__5.SetActive(true);
<BalanceShrine>5__5.transform.position = <shrinePosition>5__4;
((Component)<BalanceShrine>5__5.transform.Find("MinimapIcon (1)")).gameObject.SetActive(true);
((Component)<BalanceShrine>5__5.transform.Find("AltarIcon (1)")).gameObject.SetActive(true);
<BalanceShrine>5__5 = null;
<i>5__3++;
goto IL_01ae;
IL_01ae:
if (<i>5__3 < <numShrines>5__2)
{
<shrinePosition>5__4 = SpawnPositions.GetRandomSpawnPositionOnMap(0f);
goto IL_00e4;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string PluginGuid = "BalanceShrineForBepInEx";
public const string PluginName = "BalanceShrineForBepInEx";
public const string PluginVersion = "1.0.0";
public static int CMaxShrines = 6;
public static int CMinShrines = 0;
private Spawn _coroutineRunner;
private const string __mapSceneName = "GeneratedMap";
private static readonly string ShrineBalance = "ShrineBalance";
private static GameObject ShrineBal;
public Vector3 LastValue;
internal static Core Instance { get; private set; }
internal static int MaxShrines => CMaxShrines;
internal static int MinShrines => CMinShrines;
public override void Load()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Expected O, but got Unknown
Instance = this;
Harmony val = new Harmony("BalanceShrineForBepInEx");
val.PatchAll();
SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded);
((BasePlugin)this).Log.LogWarning((object)"THIS IS A CHEAT MOD!!!");
((BasePlugin)this).Log.LogWarning((object)"Leaderboards should be disabled.");
((BasePlugin)this).Log.LogWarning((object)"To stay on the safe side, disable leaderboard uploading in settings!");
_coroutineRunner = ((BasePlugin)this).AddComponent<Spawn>();
((BasePlugin)this).Log.LogInfo((object)"BalanceShrineForBepInEx initialized!");
ConfigDefinition val2 = new ConfigDefinition("General", "Min Shrines");
CMinShrines = ((BasePlugin)this).Config.Bind<int>(val2, 0, new ConfigDescription("Minimum amount of balance shrines to spawn", (AcceptableValueBase)new AcceptableValueRange<int>(0, 999), Array.Empty<object>())).Value;
ConfigDefinition val3 = new ConfigDefinition("General", "Max Shrines");
CMaxShrines = ((BasePlugin)this).Config.Bind<int>(val3, 6, new ConfigDescription("Maximum amount of balance shrines to spawn, (MAKE SURE TO HAVE MAX MORE THAN OR EQUAL TO MIN)", (AcceptableValueBase)new AcceptableValueRange<int>(0, 999), Array.Empty<object>())).Value;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
print("Scene " + ((Scene)(ref scene)).name + " loaded");
if (((Scene)(ref scene)).name == "MainMenu" && (Object)(object)ShrineBal == (Object)null)
{
print("In MainMenu, running initial search for ShrineBalance...");
GameObject val = GameObject.Find(ShrineBalance);
if ((Object)(object)val != (Object)null)
{
print("Found ShrineBalance object in MainMenu!");
ShrineBal = Object.Instantiate<GameObject>(val);
Object.DontDestroyOnLoad((Object)(object)ShrineBal);
((Object)ShrineBal).name = "NewBalShrine";
ShrineBal.transform.position = new Vector3(5000f, 5000f, 5000f);
ShrineBal.SetActive(false);
print("Instantiated and prepared NewBalShrine for later use.");
}
else
{
((BasePlugin)this).Log.LogError((object)"Could not find ShrineBalance in MainMenu! The mod will most likely not work.");
}
}
if (((Scene)(ref scene)).name.Contains("GeneratedMap"))
{
print("Level loaded");
OnLevelLoaded();
}
}
public void print<T>(T msg)
{
((BasePlugin)this).Log.LogDebug((object)msg);
}
public void OnLevelLoaded()
{
if ((Object)(object)ShrineBal != (Object)null)
{
print("Balance Shrine base object found. Spawning shrines...");
MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)_coroutineRunner, SpawnShrines());
}
else
{
((BasePlugin)this).Log.LogError((object)"Could not find 'ShrineBalance' from MainMenu. Shrine spawning aborted.");
}
}
[IteratorStateMachine(typeof(<SpawnShrines>d__23))]
private IEnumerator SpawnShrines()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnShrines>d__23(0)
{
<>4__this = this
};
}
}
[HarmonyPatch(typeof(Sus), "CheckMods")]
public static class EditSusPatch2
{
public static void Postfix(ref bool __result, ref string reason)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (__result)
{
ManualLogSource log = ((BasePlugin)Core.Instance).Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("The internal anti-cheat considers you sus, reason: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
}
log.LogWarning(val);
}
else
{
((BasePlugin)Core.Instance).Log.LogMessage((object)"The internal anti-cheat hasn't found anything sus");
}
}
}
[HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "UploadLeaderboardScore", new Type[]
{
typeof(string),
typeof(int),
typeof(Il2CppStructArray<int>),
typeof(bool)
})]
internal static class DisableSteamLeaderboardUploading
{
public static bool Prefix(string leaderboardName, int score, Il2CppStructArray<int> details, bool isFriendsLb)
{
((BasePlugin)Core.Instance).Log.LogInfo((object)"Uploading is disabled.");
return false;
}
}
}