Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ItemEveryStage v1.0.2
ItemEveryStage.dll
Decompiled 8 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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.Configuration; using BepInEx.Logging; using HG; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ItemEveryStage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1eaeea6d4153f85b1ec31020bf8a134c25a90ee3")] [assembly: AssemblyProduct("ItemEveryStage")] [assembly: AssemblyTitle("ItemEveryStage")] [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 ItemEveryStage { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Lawlzee.ItemEveryStage", "ItemEveryStage", "1.0.2")] public class ItemEveryStagePlugin : BaseUnityPlugin { private class ItemGift { public ItemIndex ItemIndex { get; } public int Quantity { get; } public ItemGift(ItemIndex itemIndex, int quantity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) ItemIndex = itemIndex; Quantity = quantity; } } [CompilerGenerated] private sealed class <GetItemGifts>d__15 : IEnumerable<ItemGift>, IEnumerable, IEnumerator<ItemGift>, IEnumerator, IDisposable { private int <>1__state; private ItemGift <>2__current; private int <>l__initialThreadId; public ItemEveryStagePlugin <>4__this; private string[] <>7__wrap1; private int <>7__wrap2; private string <item>5__4; private int <quantityValue>5__5; private Enumerator<ItemDef> <>7__wrap5; ItemGift IEnumerator<ItemGift>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GetItemGifts>d__15(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <item>5__4 = null; <>7__wrap5 = default(Enumerator<ItemDef>); <>1__state = -2; } private bool MoveNext() { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; ItemEveryStagePlugin itemEveryStagePlugin = <>4__this; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; goto IL_0113; } <>1__state = -1; string[] array = itemEveryStagePlugin._itemsToGive.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); <>7__wrap1 = array; <>7__wrap2 = 0; goto IL_0147; IL_0147: if (<>7__wrap2 < <>7__wrap1.Length) { string[] array2 = <>7__wrap1[<>7__wrap2].Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length == 2) { string s = array2[0].Trim(); <item>5__4 = array2[1].Trim(); if (int.TryParse(s, out <quantityValue>5__5)) { <>7__wrap5 = ItemCatalog.allItemDefs.GetEnumerator(); <>1__state = -3; goto IL_0113; } goto IL_0132; } goto IL_0139; } <>7__wrap1 = null; return false; IL_0113: while (<>7__wrap5.MoveNext()) { ItemDef current = <>7__wrap5.Current; if (<item>5__4.Equals(((Object)current).name, StringComparison.OrdinalIgnoreCase)) { <>2__current = new ItemGift(current.itemIndex, <quantityValue>5__5); <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap5 = default(Enumerator<ItemDef>); goto IL_0132; IL_0132: <item>5__4 = null; goto IL_0139; IL_0139: <>7__wrap2++; goto IL_0147; } 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; ((IDisposable)<>7__wrap5).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<ItemGift> IEnumerable<ItemGift>.GetEnumerator() { <GetItemGifts>d__15 result; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; result = this; } else { result = new <GetItemGifts>d__15(0) { <>4__this = <>4__this }; } return result; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<ItemGift>)this).GetEnumerator(); } } public const string PluginGUID = "Lawlzee.ItemEveryStage"; public const string PluginAuthor = "Lawlzee"; public const string PluginName = "ItemEveryStage"; public const string PluginVersion = "1.0.2"; private const string _itemsToGiveDescription = "Controls which items are given at every stage.\r\n\r\nFormat:\r\n<count>:<item>,<count>:<item>...\r\n\r\nExamples:\r\n2:hoof\r\n1:clover,3:firework\r\n\r\nAll the items are:\r\n"; private ConfigEntry<bool> _modEnabled; private ConfigEntry<string> _itemsToGive; private StringInputFieldOption _itemsToGiveOption; private int _oldStageCount; public void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); _modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Configuration", "Mod enabled", true, "Mod enabled"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_modEnabled)); _itemsToGive = ((BaseUnityPlugin)this).Config.Bind<string>("Configuration", "Items given at every stage", "1:Hoof", "Controls which items are given at every stage.\r\n\r\nFormat:\r\n<count>:<item>,<count>:<item>...\r\n\r\nExamples:\r\n2:hoof\r\n1:clover,3:firework\r\n\r\nAll the items are:\r\n"); _itemsToGiveOption = new StringInputFieldOption(_itemsToGive); ModSettingsManager.AddOption((BaseOption)(object)_itemsToGiveOption); Texture2D val = LoadTexture("icon.png"); ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f))); Run.onRunStartGlobal += Run_onRunStartGlobal; Stage.onServerStageBegin += Stage_onServerStageBegin; ItemCatalog.Init += new hook_Init(ItemCatalog_Init); } private void ItemCatalog_Init(orig_Init orig) { //IL_0014: 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_008e: Expected O, but got Unknown orig.Invoke(); if (_modEnabled.Value) { IOrderedEnumerable<string> values = from x in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs select Language.GetString(x.nameToken) + ": '" + ((Object)x).name + "'" into x orderby x select x; string text = string.Join(Environment.NewLine, values); ((BaseOption)_itemsToGiveOption).SetDescription("Controls which items are given at every stage.\r\n\r\nFormat:\r\n<count>:<item>,<count>:<item>...\r\n\r\nExamples:\r\n2:hoof\r\n1:clover,3:firework\r\n\r\nAll the items are:\r\n" + text, new BaseOptionConfig()); } } private Texture2D LoadTexture(string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002a: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), name))); return val; } private void Run_onRunStartGlobal(Run obj) { if (_modEnabled.Value) { _oldStageCount = -1; Log.Debug("Run_onRunStartGlobal"); } } private void Stage_onServerStageBegin(Stage obj) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //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) if (!_modEnabled.Value) { return; } Log.Debug("Stage_onServerStageBegin"); int stageClearCount = Run.instance.stageClearCount; if (_oldStageCount != stageClearCount) { foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList) { if (!Object.op_Implicit((Object)(object)readOnlyInstances.playerCharacterMasterController) || !Object.op_Implicit((Object)(object)readOnlyInstances.playerCharacterMasterController.networkUser)) { continue; } foreach (ItemGift itemGift in GetItemGifts()) { readOnlyInstances.inventory.GiveItem(itemGift.ItemIndex, itemGift.Quantity); GenericPickupController.SendPickupMessage(readOnlyInstances, PickupCatalog.FindPickupIndex(itemGift.ItemIndex)); } } } _oldStageCount = stageClearCount; } [IteratorStateMachine(typeof(<GetItemGifts>d__15))] private IEnumerable<ItemGift> GetItemGifts() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GetItemGifts>d__15(-2) { <>4__this = this }; } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } }