using System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.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 SupplyDrop { public static class Amount { public const int Max = 999999999; public static int Parse(string text) { if (!int.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out var result) || result <= 0) { return 0; } return Math.Min(result, 999999999); } public static string Format(long n) { return n.ToString("N0", CultureInfo.InvariantCulture); } } [BepInPlugin("bug.dsp.supplydrop", "SupplyDrop", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static UnityAction <0>__Hide; public static UnityAction <1>__Pick; public static UnityAction <2>__Give; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__37_0; internal void b__37_0() { if (selected == null) { Status("Choose an item first.", error: true); } else { amountField.text = Math.Max(1, selected.StackSize).ToString(CultureInfo.InvariantCulture); } } internal void <.cctor>b__46_0(ItemProto p) { if (p != null) { Select(p); } } } private const int SandId = 1099; private const float Width = 340f; private const float Height = 292f; private const float Left = 20f; private const float Inner = 300f; private static readonly int[] Presets = new int[4] { 1, 10, 100, 1000 }; private static readonly Color Ink = Color32.op_Implicit(new Color32((byte)232, (byte)246, (byte)252, byte.MaxValue)); private static readonly Color Soft = Color32.op_Implicit(new Color32((byte)176, (byte)208, (byte)220, byte.MaxValue)); private static readonly Color Accent = Color32.op_Implicit(new Color32((byte)253, (byte)150, (byte)94, byte.MaxValue)); private static readonly Color AccentInk = Color32.op_Implicit(new Color32((byte)28, (byte)14, (byte)6, byte.MaxValue)); private static readonly Color Scrim = Color32.op_Implicit(new Color32((byte)4, (byte)22, (byte)30, (byte)168)); private static readonly Color Well = Color32.op_Implicit(new Color32((byte)0, (byte)10, (byte)16, (byte)120)); private static readonly Color Bad = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)150, (byte)130, byte.MaxValue)); private static readonly Color[] Glass = (Color[])(object)new Color[4] { Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)56)), Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)92)), Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)32)), Ink }; private static readonly Color[] Give_ = (Color[])(object)new Color[4] { Accent, Color32.op_Implicit(new Color32(byte.MaxValue, (byte)174, (byte)128, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)226, (byte)128, (byte)76, byte.MaxValue)), AccentInk }; private static ConfigEntry hotkey; private static GameObject win; private static RectTransform root; private static Image icon; private static Text nameText; private static Text infoText; private static Text statusText; private static InputField amountField; private static ItemProto selected; private static readonly Action OnPicked = delegate(ItemProto p) { if (p != null) { Select(p); } }; public static bool Open { get { if ((Object)(object)win != (Object)null) { return win.activeInHierarchy; } return false; } } private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) hotkey = ((BaseUnityPlugin)this).Config.Bind("General", "Hotkey", new KeyboardShortcut((KeyCode)103, (KeyCode[])(object)new KeyCode[2] { (KeyCode)306, (KeyCode)304 }), "Opens and closes the SupplyDrop window."); new Harmony("bug.dsp.supplydrop").PatchAll(typeof(Patches)); } private void Update() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!GameMain.isRunning || DSPGame.IsMenuDemo || GameMain.isPaused || !((ManualBehaviour)UIRoot.instance.uiGame).active) { if (Open) { Hide(); } return; } GameObject val = (((Object)(object)EventSystem.current == (Object)null) ? null : EventSystem.current.currentSelectedGameObject); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent() != (Object)null) { InputField obj = amountField; if ((Object)(object)val != (Object)(object)((obj != null) ? ((Component)obj).gameObject : null)) { goto IL_00a8; } } KeyboardShortcut value = hotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (Open) { Hide(); } else { Show(); } } goto IL_00a8; IL_00a8: if (Open) { ShowState(); } } private static void Show() { if ((Object)(object)win == (Object)null) { Build(); } win.SetActive(true); win.transform.SetAsLastSibling(); statusText.text = ""; if (selected == null) { Pick(); } } public static void Hide() { win.SetActive(false); if (UIItemPicker.isOpened && UIRoot.instance.uiGame.itemPicker.onReturn == OnPicked) { UIItemPicker.Close(); } } private static void Pick() { //IL_0013: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if (!UIItemPicker.isOpened) { UIItemPicker.showAll = false; UIItemPicker.Popup(root.anchoredPosition, OnPicked); if (UIItemPicker.isOpened) { RectTransform pickerTrans = UIRoot.instance.uiGame.itemPicker.pickerTrans; Vector3[] array = (Vector3[])(object)new Vector3[4]; Vector3[] array2 = (Vector3[])(object)new Vector3[4]; pickerTrans.GetWorldCorners(array); root.GetWorldCorners(array2); float num = 10f * ((Transform)root).lossyScale.x; ((Transform)pickerTrans).position = ((Transform)pickerTrans).position + new Vector3(array2[1].x - num - array[2].x, array2[1].y - array[1].y, 0f); } } } private static void Select(ItemProto proto) { selected = proto; icon.sprite = proto.iconSprite; ((Behaviour)icon).enabled = true; nameText.text = ((Proto)proto).name; statusText.text = ""; } private static void ShowState() { infoText.text = ((selected == null) ? "Click the slot to choose an item" : ("In inventory: " + Amount.Format(Count(((Proto)selected).ID)))); } private static long Count(int id) { if (id != 1099) { return GameMain.mainPlayer.package.GetItemCount(id); } return GameMain.mainPlayer.sandCount; } private static void Status(string text, bool error) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) statusText.text = text; ((Graphic)statusText).color = (error ? Bad : Soft); } private static void Give() { if (selected == null) { Status("Choose an item first.", error: true); return; } int num = Amount.Parse(amountField.text); if (num == 0) { Status("Enter an amount of 1 or more.", error: true); return; } if (!GameMain.history.ItemUnlocked(((Proto)selected).ID)) { Status(((Proto)selected).name + " is not unlocked yet.", error: true); return; } Player mainPlayer = GameMain.mainPlayer; int num2; if (((Proto)selected).ID == 1099) { mainPlayer.SetSandCount(mainPlayer.sandCount + num, (ESandSource)3); num2 = num; } else { int num3 = default(int); num2 = mainPlayer.package.AddItemStacked(((Proto)selected).ID, num, 0, ref num3); if (num2 > 0) { mainPlayer.NotifyPackageAddItem(((Proto)selected).ID, num2, 0); UIItemup.Up(((Proto)selected).ID, num2); } } if (num2 == num) { Status("Added " + Amount.Format(num2) + " × " + ((Proto)selected).name + ".", error: false); } else if (num2 == 0) { Status("Inventory is full.", error: true); } else { Status("Inventory full: added " + Amount.Format(num2) + " of " + Amount.Format(num) + ".", error: true); } } private static void Build() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Expected O, but got Unknown //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Expected O, but got Unknown //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Expected O, but got Unknown Transform transform = ((Component)UIRoot.instance.uiGame.generatorWindow).transform; GameObject gameObject = ((Component)transform.Find("ray-receiver/switch-button-1")).gameObject; Text component = ((Component)transform.Find("power-network-desc/desc-group/label-1")).GetComponent(); Text component2 = ((Component)transform.Find("power-network-desc/desc-group/value-1")).GetComponent(); win = Object.Instantiate(((Component)transform).gameObject, transform.parent, false); ((Object)win).name = "SupplyDrop"; Object.DestroyImmediate((Object)(object)win.GetComponent()); foreach (Transform item in win.transform) { Transform val = item; if (((Object)val).name != "panel-bg") { Object.Destroy((Object)(object)((Component)val).gameObject); } } RectTransform val2 = (RectTransform)win.transform.Find("panel-bg/btn-box"); Object.DestroyImmediate((Object)(object)((Component)((Transform)val2).Find("menu-wnd-btn")).gameObject); val2.sizeDelta = new Vector2(32f, val2.sizeDelta.y); val2.anchoredPosition += new Vector2(16f, 0f); ((RectTransform)((Transform)val2).Find("close-wnd-btn")).anchoredPosition = Vector2.zero; StripLocalizers(win); Backdrop(win.transform.Find("panel-bg")); Button component3 = ((Component)win.transform.Find("panel-bg/btn-box/close-wnd-btn")).GetComponent