Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of AbilityRoundRobin v1.0.0
AbilityRoundRobin.dll
Decompiled 16 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")] [assembly: AssemblyCompany("AbilityRoundRobin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AbilityRoundRobin")] [assembly: AssemblyTitle("AbilityRoundRobin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 AbilityRoundRobin { [BepInPlugin("com.maxgamertyper1.abilityroundrobin", "Ability Round Robin", "1.0.0")] [BepInIncompatibility("com.unluckycrafter.abilitystorm")] public class AbilityRoundRobin : BaseUnityPlugin { internal static ConfigFile config; public void Log(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } private void Awake() { Patches.PluginReference = this; Log("Plugin AbilityRoundRobin is loaded!"); config = ((BaseUnityPlugin)this).Config; Patches.StartingAbilityRotationIndex = config.Bind<int>("Universal Config", "Pickup Index", 0, "The slot where the first ability pickup will happen (0 is the left-most ability, 1 is the middle ability, 2 is the right-most ability)").Value; Patches.DoingRoundRobin = config.Bind<bool>("Round-Robin", "Round Robin Enabled?", true, "Whether or not the Round Robin is enabled, if not it will use the 'Pickup Index' as the slot; if so, it will use the pickup index as the starting index for the round robin").Value; Log("Round-Robin Enabled? " + Patches.DoingRoundRobin); Log("UnchangedStartingIndex? " + Patches.StartingAbilityRotationIndex); DoPatching(); } private void DoPatching() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony harmony = new Harmony("com.maxgamertyper1.abilityroundrobin"); Patch(harmony, typeof(GameSessionHandler), "StartSpawnPlayersRoutine", "StartMatch", prefix: true, transpiler: false); Patch(harmony, typeof(SlimeController), "AddAdditionalAbility", "PlayerAdditionalAbilityPickup", prefix: false, transpiler: true); } private void Patch(Harmony harmony, Type OriginalClass, string OriginalMethod, string PatchMethod, bool prefix, bool transpiler) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(OriginalClass, OriginalMethod, (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), PatchMethod, (Type[])null, (Type[])null); if (prefix) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else if (transpiler) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Log("Patched " + OriginalMethod + " in " + OriginalClass.ToString()); } } public class Patches { [CompilerGenerated] private sealed class <PlayerAdditionalAbilityPickup>d__8 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private FieldInfo <playerNumberField>5__1; private MethodInfo <GetPlayerAbilityIndexMethod>5__2; private MethodInfo <IncrementPlayerAbilityIndexMehtod>5__3; private FieldInfo <abilitiesField>5__4; private bool? <abilitiesEqualsThreeBranch>5__5; private bool <finished>5__6; private IEnumerator<CodeInstruction> <>s__7; private CodeInstruction <instr>5__8; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <PlayerAdditionalAbilityPickup>d__8(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 8u) { try { } finally { <>m__Finally1(); } } <playerNumberField>5__1 = null; <GetPlayerAbilityIndexMethod>5__2 = null; <IncrementPlayerAbilityIndexMehtod>5__3 = null; <abilitiesField>5__4 = null; <>s__7 = null; <instr>5__8 = null; <>1__state = -2; } private bool MoveNext() { //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <playerNumberField>5__1 = AccessTools.Field(typeof(SlimeController), "playerNumber"); <GetPlayerAbilityIndexMethod>5__2 = AccessTools.Method(typeof(Patches), "GetPlayerAbilityIndex", (Type[])null, (Type[])null); <IncrementPlayerAbilityIndexMehtod>5__3 = AccessTools.Method(typeof(Patches), "IncrementPlayerAbilityIndex", (Type[])null, (Type[])null); <abilitiesField>5__4 = AccessTools.Field(typeof(SlimeController), "abilities"); <abilitiesEqualsThreeBranch>5__5 = null; <finished>5__6 = false; <>s__7 = instructions.GetEnumerator(); <>1__state = -3; goto IL_03c3; case 1: <>1__state = -3; goto IL_03c3; case 2: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Ldfld, (object)<playerNumberField>5__1); <>1__state = 3; return true; case 3: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)<IncrementPlayerAbilityIndexMehtod>5__3); <>1__state = 4; return true; case 4: <>1__state = -3; goto IL_026b; case 5: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Ldfld, (object)<playerNumberField>5__1); <>1__state = 6; return true; case 6: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)<GetPlayerAbilityIndexMethod>5__2); <>1__state = 7; return true; case 7: <>1__state = -3; goto IL_03c3; case 8: <>1__state = -3; goto IL_03c3; case 9: { <>1__state = -3; <instr>5__8 = null; goto IL_03c3; } IL_03c3: if (<>s__7.MoveNext()) { <instr>5__8 = <>s__7.Current; if (<finished>5__6) { <>2__current = <instr>5__8; <>1__state = 1; return true; } if (<instr>5__8.opcode == OpCodes.Bne_Un_S || <instr>5__8.opcode == OpCodes.Bne_Un) { <abilitiesEqualsThreeBranch>5__5 = true; } if (<instr>5__8.opcode == OpCodes.Br && <abilitiesEqualsThreeBranch>5__5.GetValueOrDefault()) { if (DoingRoundRobin) { PluginReference.Log("Adding Ability Index Updating Function"); <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_026b; } goto IL_0280; } <>m__Finally1(); <>s__7 = null; return false; IL_026b: <abilitiesEqualsThreeBranch>5__5 = false; <finished>5__6 = true; goto IL_0280; IL_0280: if (<abilitiesEqualsThreeBranch>5__5.GetValueOrDefault() && <instr>5__8.opcode == OpCodes.Ldc_I4_2) { if (DoingRoundRobin) { PluginReference.Log("Overriding Constants With Function call in 3-ability-Branch"); <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 5; return true; } PluginReference.Log("Overriding Constants With another constant in 3-ability-Branch"); <>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)LeftToRightHashMap3Abilities[StartingAbilityRotationIndex]); <>1__state = 8; return true; } <>2__current = <instr>5__8; <>1__state = 9; return true; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__7 != null) { <>s__7.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <PlayerAdditionalAbilityPickup>d__8 <PlayerAdditionalAbilityPickup>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <PlayerAdditionalAbilityPickup>d__ = this; } else { <PlayerAdditionalAbilityPickup>d__ = new <PlayerAdditionalAbilityPickup>d__8(0); } <PlayerAdditionalAbilityPickup>d__.instructions = <>3__instructions; return <PlayerAdditionalAbilityPickup>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } public static int StartingAbilityRotationIndex; public static bool DoingRoundRobin; public static Dictionary<int, int> PlayerAbilityIndex = new Dictionary<int, int>(); public static AbilityRoundRobin PluginReference; public static readonly Dictionary<int, int> LeftToRightHashMap3Abilities = new Dictionary<int, int> { { 0, 0 }, { 1, 2 }, { 2, 1 } }; public static void StartMatch(GameSessionHandler __instance) { List<Player> list = PlayerHandler.Get().PlayerList(); PlayerAbilityIndex.Clear(); foreach (Player item in list) { PlayerAbilityIndex.Add(item.Id, StartingAbilityRotationIndex); } } public static int GetPlayerAbilityIndex(int PlayerId) { int value = StartingAbilityRotationIndex; PlayerAbilityIndex.TryGetValue(PlayerId, out value); return LeftToRightHashMap3Abilities[value]; } public static void IncrementPlayerAbilityIndex(int PlayerId) { float num = StartingAbilityRotationIndex; if (PlayerAbilityIndex[PlayerId] >= 2) { PlayerAbilityIndex[PlayerId] = -1; } PlayerAbilityIndex[PlayerId]++; } [IteratorStateMachine(typeof(<PlayerAdditionalAbilityPickup>d__8))] public static IEnumerable<CodeInstruction> PlayerAdditionalAbilityPickup(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PlayerAdditionalAbilityPickup>d__8(-2) { <>3__instructions = instructions }; } } public static class PluginInfo { public const string PLUGIN_GUID = "AbilityRoundRobin"; public const string PLUGIN_NAME = "AbilityRoundRobin"; public const string PLUGIN_VERSION = "1.0.0"; } }