using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CrestShuffler")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+952311aab8c48555d680f142bbea612a65afa7b4")]
[assembly: AssemblyProduct("CrestShuffler")]
[assembly: AssemblyTitle("CrestShuffler")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[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 CrestShuffler
{
[BepInPlugin("com.cometcake575.crestshuffler", "Crest Shuffler", "1.0.4")]
public class CrestShufflerPlugin : BaseUnityPlugin
{
private enum ToolMode
{
Off,
Unlocked,
All
}
[CompilerGenerated]
private sealed class <>c__DisplayClass6_0
{
public HeroController hc;
internal bool <RandomCrest>b__0()
{
return !hc.controlReqlinquished && !hc.cState.dashing && !hc.cState.downAttacking && !hc.cState.downSpikeAntic && !hc.cState.airDashing;
}
}
[CompilerGenerated]
private sealed class <RandomCrest>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private <>c__DisplayClass6_0 <>8__1;
private List<ToolCrest> <crests>5__2;
private ToolCrest <crest>5__3;
private List<ToolItem> <tools>5__4;
private int <i>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RandomCrest>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<crests>5__2 = null;
<crest>5__3 = null;
<tools>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass6_0();
<>8__1.hc = HeroController.instance;
<>2__current = (object)new WaitUntil((Func<bool>)(() => !<>8__1.hc.controlReqlinquished && !<>8__1.hc.cState.dashing && !<>8__1.hc.cState.downAttacking && !<>8__1.hc.cState.downSpikeAntic && !<>8__1.hc.cState.airDashing));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<crests>5__2 = (from crest in ToolItemManager.GetAllCrests()
where crest.name != PlayerData.instance.CurrentCrestID
select crest).ToList();
<crest>5__3 = <crests>5__2[Random.Range(0, <crests>5__2.Count)];
PlayerData.instance.IsCurrentCrestTemp = true;
ToolItemManager.AutoEquip(<crest>5__3, false, false);
HeroController.instance.UpdateSilkCursed();
if (_toolShuffle != 0)
{
<tools>5__4 = ((_toolShuffle == ToolMode.Unlocked) ? ToolItemManager.GetUnlockedTools() : ToolItemManager.GetAllTools()).ToList();
<i>5__5 = 0;
while (<i>5__5 < 30)
{
ToolItemManager.AutoEquip(<tools>5__4[Random.Range(0, <tools>5__4.Count)]);
<i>5__5++;
}
<tools>5__4 = null;
}
<>2__current = null;
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>8__1.hc.RegainControl();
<>8__1.hc.StartAnimationControl();
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();
}
}
internal static ManualLogSource Logger;
private static int _rerollTime;
private static float _timeUntilReroll;
private static ToolMode _toolShuffle;
private void Awake()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Crest Shuffler has loaded!");
new Hook((MethodBase)typeof(InventoryToolCrest).GetProperty("IsHidden").GetGetMethod(), (Delegate)(Func<Func<InventoryToolCrest, bool>, InventoryToolCrest, bool>)((Func<InventoryToolCrest, bool> _, InventoryToolCrest _) => true));
_rerollTime = ((BaseUnityPlugin)this).Config.Bind<int>("Options", "Reroll Time", 60, "How often the crest should be rerolled in seconds (-1 to disable the timer)").Value;
_timeUntilReroll = _rerollTime;
if (((BaseUnityPlugin)this).Config.Bind<bool>("Options", "Reroll on transition", false, "Whether to reroll the crest when going through a scene transition").Value)
{
new Hook((MethodBase)typeof(HeroController).GetMethod("SceneInit"), (Delegate)(Action<Action<HeroController>, HeroController>)delegate(Action<HeroController> orig, HeroController self)
{
orig(self);
((MonoBehaviour)this).StartCoroutine(RandomCrest());
});
}
if (((BaseUnityPlugin)this).Config.Bind<bool>("Options", "Reroll on death", false, "Whether to reroll the crest when dying").Value)
{
new Hook((MethodBase)typeof(HeroController).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic), (Delegate)(Action<Action<HeroController>, HeroController>)delegate(Action<HeroController> orig, HeroController self)
{
orig(self);
self.OnDeath += delegate
{
((MonoBehaviour)this).StartCoroutine(RandomCrest());
};
});
}
_toolShuffle = ((BaseUnityPlugin)this).Config.Bind<ToolMode>("Options", "Shuffle Tools", ToolMode.Off, "Whether to shuffle tools as well as the crest.\n'Unlocked' will give the player random tools they have unlocked.\n'All' will give the player random tools, including ones they do not have.").Value;
}
private void Update()
{
if (Object.op_Implicit((Object)(object)HeroController.instance) && _rerollTime > 0)
{
_timeUntilReroll -= Time.deltaTime;
if (_timeUntilReroll <= 0f)
{
((MonoBehaviour)this).StartCoroutine(RandomCrest());
_timeUntilReroll += _rerollTime;
}
}
}
[IteratorStateMachine(typeof(<RandomCrest>d__6))]
private static IEnumerator RandomCrest()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RandomCrest>d__6(0);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CrestShuffler";
public const string PLUGIN_NAME = "CrestShuffler";
public const string PLUGIN_VERSION = "1.1.0";
}
}