using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HG; using Microsoft.CodeAnalysis; using On.RoR2; using RoR2; using UnityEngine; using UnityEngine.Networking; [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("SpawnBox")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+a061323394e7c2baf284655782bc2fb05658dd45")] [assembly: AssemblyProduct("SpawnBox")] [assembly: AssemblyTitle("SpawnBox")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 SpawnBox { internal static class AllySpawnerTab { private class Row { public GameObject MasterPrefab; public string DisplayName; } private const int MaxQuantity = 20; private static readonly List allRows = new List(); private static string search = ""; private static string quantityText = "1"; private static Vector2 scroll; private const string ExcludedMasterName = "HaulerDroneMaster"; public static void BuildList() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 allRows.Clear(); foreach (CharacterMaster allAiMaster in MasterCatalog.allAiMasters) { if (!((Object)(object)allAiMaster == (Object)null) && !((Object)(object)allAiMaster.bodyPrefab == (Object)null) && (int)allAiMaster.teamIndex == 1 && !(((Object)((Component)allAiMaster).gameObject).name == "HaulerDroneMaster")) { CharacterBody component = allAiMaster.bodyPrefab.GetComponent(); if (!((Object)(object)component == (Object)null) && !string.IsNullOrEmpty(component.baseNameToken)) { allRows.Add(new Row { MasterPrefab = ((Component)allAiMaster).gameObject, DisplayName = Language.GetString(component.baseNameToken) }); } } } allRows.Sort((Row a, Row b) => string.Compare(a.DisplayName, b.DisplayName)); SpawnBoxPlugin.Log.LogInfo((object)$"SpawnBox: {allRows.Count} allies available."); } public static void Draw() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); search = GUILayout.TextField(search, Array.Empty()); GUILayout.Label("Qty:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); quantityText = GUILayout.TextField(quantityText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); GUILayout.EndHorizontal(); GUILayout.Label("High values may impact performance - capped at 20.", Array.Empty()); scroll = GUILayout.BeginScrollView(scroll, Array.Empty()); foreach (Row allRow in allRows) { if (string.IsNullOrEmpty(search) || allRow.DisplayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(allRow.DisplayName, Array.Empty()); if (GUILayout.Button("Spawn", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })) { SpawnMany(allRow.MasterPrefab, ParseQuantity()); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); } private static int ParseQuantity() { if (!int.TryParse(quantityText, out var result) || result <= 0) { return 1; } if (result > 20) { return 20; } return result; } private static void SpawnMany(GameObject masterPrefab, int count) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0075: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a0: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); if (!((Object)(object)val == (Object)null)) { for (int i = 0; i < count; i++) { float num = 360f / (float)count * (float)i; Vector3 val2 = Quaternion.Euler(0f, num, 0f) * (val.transform.forward * 5f); Vector3 position = val.transform.position + val2; new MasterSummon { masterPrefab = masterPrefab, position = position, rotation = Quaternion.identity, teamIndexOverride = (TeamIndex)1, useAmbientLevel = true }.Perform(); } } } } internal static class EnemySpawnerTab { private class Row { public GameObject MasterPrefab; public string DisplayName; } private const int MaxQuantity = 20; private static readonly List allRows = new List(); private static string search = ""; private static string quantityText = "1"; private static Vector2 scroll; public static void BuildList() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 allRows.Clear(); foreach (CharacterMaster allAiMaster in MasterCatalog.allAiMasters) { if (!((Object)(object)allAiMaster == (Object)null) && !((Object)(object)allAiMaster.bodyPrefab == (Object)null) && ((int)allAiMaster.teamIndex == 2 || (int)allAiMaster.teamIndex == 4)) { CharacterBody component = allAiMaster.bodyPrefab.GetComponent(); if (!((Object)(object)component == (Object)null) && !string.IsNullOrEmpty(component.baseNameToken)) { allRows.Add(new Row { MasterPrefab = ((Component)allAiMaster).gameObject, DisplayName = Language.GetString(component.baseNameToken) }); } } } allRows.Sort((Row a, Row b) => string.Compare(a.DisplayName, b.DisplayName)); SpawnBoxPlugin.Log.LogInfo((object)$"SpawnBox: {allRows.Count} enemies available."); } public static void Draw() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); search = GUILayout.TextField(search, Array.Empty()); GUILayout.Label("Qty:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); quantityText = GUILayout.TextField(quantityText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); GUILayout.EndHorizontal(); GUILayout.Label("High values may impact performance - capped at 20.", Array.Empty()); scroll = GUILayout.BeginScrollView(scroll, Array.Empty()); foreach (Row allRow in allRows) { if (string.IsNullOrEmpty(search) || allRow.DisplayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(allRow.DisplayName, Array.Empty()); if (GUILayout.Button("Spawn", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })) { SpawnMany(allRow.MasterPrefab, ParseQuantity()); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); } private static int ParseQuantity() { if (!int.TryParse(quantityText, out var result) || result <= 0) { return 1; } if (result > 20) { return 20; } return result; } private static void SpawnMany(GameObject masterPrefab, int count) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0075: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a0: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); if (!((Object)(object)val == (Object)null)) { for (int i = 0; i < count; i++) { float num = 360f / (float)count * (float)i; Vector3 val2 = Quaternion.Euler(0f, num, 0f) * (val.transform.forward * 5f); Vector3 position = val.transform.position + val2; new MasterSummon { masterPrefab = masterPrefab, position = position, rotation = Quaternion.identity, teamIndexOverride = (TeamIndex)2, useAmbientLevel = true }.Perform(); } } } } internal static class EquipmentSpawnerTab { private class Row { public EquipmentIndex Index; public string DisplayName; } private static readonly List allRows = new List(); private static string search = ""; private static Vector2 scroll; public unsafe static void BuildList() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) allRows.Clear(); AllEquipmentEnumerator enumerator = EquipmentCatalog.allEquipment.GetEnumerator(); try { while (((AllEquipmentEnumerator)(ref enumerator)).MoveNext()) { EquipmentIndex current = ((AllEquipmentEnumerator)(ref enumerator)).Current; EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(current); if (!((Object)(object)equipmentDef == (Object)null) && equipmentDef.canDrop) { allRows.Add(new Row { Index = current, DisplayName = Language.GetString(equipmentDef.nameToken) }); } } } finally { ((IDisposable)(*(AllEquipmentEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } allRows.Sort((Row a, Row b) => string.Compare(a.DisplayName, b.DisplayName)); SpawnBoxPlugin.Log.LogInfo((object)$"SpawnBox: {allRows.Count} equipment available."); } public static void Draw() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); search = GUILayout.TextField(search, Array.Empty()); GUILayout.EndHorizontal(); scroll = GUILayout.BeginScrollView(scroll, Array.Empty()); foreach (Row allRow in allRows) { if (string.IsNullOrEmpty(search) || allRow.DisplayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(allRow.DisplayName, Array.Empty()); if (GUILayout.Button("Give", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { GiveEquipment(allRow.Index); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); } private static void GiveEquipment(EquipmentIndex index) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); Inventory val2 = (((Object)(object)val != (Object)null) ? val.inventory : null); if (!((Object)(object)val2 == (Object)null)) { val2.SetEquipmentIndex(index, false); } } } } internal static class ItemSpawnerTab { private class Row { public ItemIndex Index; public string DisplayName; } private static readonly List allRows = new List(); private static string search = ""; private static string quantityText = "1"; private static Vector2 scroll; public static void BuildList() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) allRows.Clear(); Enumerator enumerator = ItemCatalog.allItemDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemDef current = enumerator.Current; if (!((Object)(object)current == (Object)null) && !current.hidden && CategoryOf(current.tier) && current.DoesNotContainTag((ItemTag)9)) { allRows.Add(new Row { Index = current.itemIndex, DisplayName = Language.GetString(current.nameToken) }); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } allRows.Sort((Row a, Row b) => string.Compare(a.DisplayName, b.DisplayName)); SpawnBoxPlugin.Log.LogInfo((object)$"SpawnBox: {allRows.Count} items available."); } private static bool CategoryOf(ItemTier tier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)tier <= 4 || tier - 6 <= 3) { return true; } return false; } public static void Draw() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); search = GUILayout.TextField(search, Array.Empty()); GUILayout.Label("Qty:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }); quantityText = GUILayout.TextField(quantityText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }); GUILayout.EndHorizontal(); scroll = GUILayout.BeginScrollView(scroll, Array.Empty()); foreach (Row allRow in allRows) { if (string.IsNullOrEmpty(search) || allRow.DisplayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(allRow.DisplayName, Array.Empty()); if (GUILayout.Button("Give", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { GiveQuantity(allRow.Index, ParseQuantity()); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); } private static int ParseQuantity() { if (!int.TryParse(quantityText, out var result) || result <= 0) { return 1; } return result; } private static void GiveQuantity(ItemIndex index, int count) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); Inventory val2 = (((Object)(object)val != (Object)null) ? val.inventory : null); if (!((Object)(object)val2 == (Object)null)) { val2.GiveItemPermanent(index, count); } } } } [BepInPlugin("dileppy.spawnbox", "SpawnBox", "1.1.0")] public class SpawnBoxPlugin : BaseUnityPlugin { public const string PluginGUID = "dileppy.spawnbox"; public const string PluginName = "SpawnBox"; public const string PluginVersion = "1.1.0"; internal static SpawnBoxPlugin Instance; internal static ManualLogSource Log; private bool windowOpen; private int activeTab; private Rect windowRect = new Rect(100f, 100f, 420f, 500f); private KeyCode toggleKey; private void Awake() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; toggleKey = ((BaseUnityPlugin)this).Config.Bind("General", "ToggleKey", (KeyCode)283, "Key that opens the SpawnBox window.").Value; ItemCatalog.Init += new hook_Init(ItemCatalog_Init); MasterCatalog.Init += new hook_Init(MasterCatalog_Init); EquipmentCatalog.Init += new hook_Init(EquipmentCatalog_Init); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SpawnBox v1.1.0 online."); } private void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown ItemCatalog.Init -= new hook_Init(ItemCatalog_Init); MasterCatalog.Init -= new hook_Init(MasterCatalog_Init); EquipmentCatalog.Init -= new hook_Init(EquipmentCatalog_Init); } private void ItemCatalog_Init(orig_Init orig) { orig.Invoke(); ItemSpawnerTab.BuildList(); } private void MasterCatalog_Init(orig_Init orig) { orig.Invoke(); EnemySpawnerTab.BuildList(); AllySpawnerTab.BuildList(); } private void EquipmentCatalog_Init(orig_Init orig) { orig.Invoke(); EquipmentSpawnerTab.BuildList(); } private void Update() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(toggleKey)) { windowOpen = !windowOpen; } } private void OnGUI() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (windowOpen) { windowRect = GUILayout.Window(((Object)this).GetInstanceID(), windowRect, new WindowFunction(DrawWindow), "SpawnBox", Array.Empty()); } } private void DrawWindow(int id) { GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Toggle(activeTab == 0, "Items", GUIStyle.op_Implicit("button"), Array.Empty())) { activeTab = 0; } if (GUILayout.Toggle(activeTab == 1, "Equipment", GUIStyle.op_Implicit("button"), Array.Empty())) { activeTab = 1; } if (GUILayout.Toggle(activeTab == 2, "Allies", GUIStyle.op_Implicit("button"), Array.Empty())) { activeTab = 2; } if (GUILayout.Toggle(activeTab == 3, "Enemies", GUIStyle.op_Implicit("button"), Array.Empty())) { activeTab = 3; } GUILayout.EndHorizontal(); if (activeTab == 0) { ItemSpawnerTab.Draw(); } else if (activeTab == 1) { EquipmentSpawnerTab.Draw(); } else if (activeTab == 2) { AllySpawnerTab.Draw(); } else { EnemySpawnerTab.Draw(); } GUI.DragWindow(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "SpawnBox"; public const string PLUGIN_NAME = "SpawnBox"; public const string PLUGIN_VERSION = "1.1.0"; } }