using System;
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.Configuration;
using CommonAPI;
using CommonAPI.Systems;
using DysonSphereMods.Shared;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("Valoneu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyDescription("Multiplies the maximum stack size of all items.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fff002bf4a0615efcc0df0628343cf424d7a013d")]
[assembly: AssemblyProduct("DysonSphereMods")]
[assembly: AssemblyTitle("StacksizeMultiplier")]
[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 StacksizeMultiplier
{
[BepInPlugin("com.Valoneu.StacksizeMultiplier", "StacksizeMultiplier", "1.0.0")]
[BepInProcess("DSPGAME.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "CustomKeyBindSystem" })]
public class StacksizeMultiplierPlugin : BaseUnityPlugin
{
public const string MOD_GUID = "com.Valoneu.StacksizeMultiplier";
public const string MOD_NAME = "StacksizeMultiplier";
public const string MOD_VERSION = "1.0.0";
public static ConfigEntry<float> GlobalItemMultiplier;
public static ConfigEntry<float> GlobalBuildingMultiplier;
public static ConfigEntry<float> GlobalUsefulMultiplier;
public static ConfigEntry<string> ItemOverridesRaw;
public static ConfigEntry<float> WindowX;
public static ConfigEntry<float> WindowY;
public static ConfigEntry<float> WindowW;
public static ConfigEntry<float> WindowH;
private bool _showWindow;
private Rect _windowRect = new Rect(100f, 100f, 450f, 600f);
private bool _isResizing;
private Vector2 _resizeStartMouse;
private Vector2 _resizeStartSize;
private Vector2 _scrollPos;
private string _searchText = "";
private static Dictionary<int, int> _originalStackSizes = new Dictionary<int, int>();
private static Dictionary<int, float> _itemOverrides = new Dictionary<int, float>();
private bool _lastKeyState;
private List<ItemProto> _displayItems = new List<ItemProto>();
private int _displayColumns = 1;
private string _lastSearch;
private float _lastWidth;
private void Awake()
{
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
GlobalItemMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Internal", "GlobalItemMultiplier", 1f, "Global multiplier for non-building items.");
GlobalBuildingMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Internal", "GlobalBuildingMultiplier", 1f, "Global multiplier for buildings/facilities.");
GlobalUsefulMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Internal", "GlobalUsefulMultiplier", 1f, "Global multiplier for drones and vessels.");
ItemOverridesRaw = ((BaseUnityPlugin)this).Config.Bind<string>("Internal", "ItemOverrides", "", "Stored per-item overrides (ID:Value,ID:Value)");
WindowX = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "WindowX", 100f, "Window X position.");
WindowY = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "WindowY", 100f, "Window Y position.");
WindowW = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "WindowW", 450f, "Window width.");
WindowH = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "WindowH", 600f, "Window height.");
((Rect)(ref _windowRect)).x = WindowX.Value;
((Rect)(ref _windowRect)).y = WindowY.Value;
((Rect)(ref _windowRect)).width = WindowW.Value;
((Rect)(ref _windowRect)).height = WindowH.Value;
LoadOverrides();
RegisterKeyBinds();
Log.Init(((BaseUnityPlugin)this).Logger);
new Harmony("com.Valoneu.StacksizeMultiplier").PatchAll(typeof(StacksizeMultiplierPlugin));
Log.Info((object)"StacksizeMultiplier v1.0.0 loaded!");
}
private void RegisterKeyBinds()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (!CustomKeyBindSystem.HasKeyBind("ToggleStacksizeUI"))
{
BuiltinKey val = default(BuiltinKey);
val.id = 1230;
val.key = new CombineKey(258, (byte)2, (ECombineKeyAction)0, false);
val.conflictGroup = 0;
val.name = "ToggleStacksizeUI";
val.canOverride = true;
CustomKeyBindSystem.RegisterKeyBind<PressKeyBind>(val);
}
ProtoRegistry.RegisterString("ToggleStacksizeUI", "Toggle Stacksize Multiplier UI");
}
private void LoadOverrides()
{
_itemOverrides.Clear();
string value = ItemOverridesRaw.Value;
if (string.IsNullOrEmpty(value))
{
return;
}
string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < array.Length; i++)
{
string[] array2 = array[i].Split(':');
if (array2.Length == 2 && int.TryParse(array2[0], out var result) && float.TryParse(array2[1], out var result2))
{
_itemOverrides[result] = result2;
}
}
}
private void SaveOverrides()
{
string value = string.Join(",", _itemOverrides.Select((KeyValuePair<int, float> kvp) => $"{kvp.Key}:{kvp.Value:F1}"));
ItemOverridesRaw.Value = value;
((BaseUnityPlugin)this).Config.Save();
}
private void Update()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: 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)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
bool keyValue = CustomKeyBindSystem.GetKeyBind("ToggleStacksizeUI").keyValue;
if (keyValue && !_lastKeyState)
{
Log.Info((object)"ToggleStacksizeUI keybind pressed!");
_showWindow = !_showWindow;
}
_lastKeyState = keyValue;
if (_isResizing)
{
if (Input.GetMouseButtonUp(0))
{
_isResizing = false;
WindowW.Value = ((Rect)(ref _windowRect)).width;
WindowH.Value = ((Rect)(ref _windowRect)).height;
((BaseUnityPlugin)this).Config.Save();
}
else
{
Vector2 val = Vector2.op_Implicit(Input.mousePosition) - _resizeStartMouse;
((Rect)(ref _windowRect)).width = Mathf.Max(400f, _resizeStartSize.x + val.x);
((Rect)(ref _windowRect)).height = Mathf.Max(300f, _resizeStartSize.y - val.y);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
public static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
{
ApplyMultiplier();
}
public static void ApplyMultiplier()
{
if ((Object)(object)LDB.items == (Object)null)
{
return;
}
ItemProto[] dataArray;
if (_originalStackSizes.Count == 0)
{
dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
foreach (ItemProto val in dataArray)
{
if (val != null)
{
_originalStackSizes[((Proto)val).ID] = val.StackSize;
}
}
Log.Info((object)$"Captured {_originalStackSizes.Count} original stack sizes.");
}
float value = GlobalItemMultiplier.Value;
float value2 = GlobalBuildingMultiplier.Value;
float value3 = GlobalUsefulMultiplier.Value;
int num = 0;
dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
foreach (ItemProto val2 in dataArray)
{
if (val2 != null && _originalStackSizes.TryGetValue(((Proto)val2).ID, out var value4))
{
float num2 = ((!IsUsefulItem(val2)) ? (val2.CanBuild ? value2 : value) : value3);
float value5;
float num3 = (_itemOverrides.TryGetValue(((Proto)val2).ID, out value5) ? value5 : num2);
int num4 = Mathf.RoundToInt((float)value4 * num3);
if (num4 < 1)
{
num4 = 1;
}
if (num4 > 1000000)
{
num4 = 1000000;
}
if (val2.StackSize != num4)
{
val2.StackSize = num4;
num++;
}
if (StorageComponent.itemStackCount != null && ((Proto)val2).ID < StorageComponent.itemStackCount.Length)
{
StorageComponent.itemStackCount[((Proto)val2).ID] = num4;
}
}
}
Log.Info((object)$"Applied multiplier to {num} items.");
if (GameMain.mainPlayer != null && GameMain.mainPlayer.package != null)
{
StorageComponent package = GameMain.mainPlayer.package;
for (int j = 0; j < package.size; j++)
{
int itemId = package.grids[j].itemId;
if (itemId > 0)
{
ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(itemId);
if (val3 != null)
{
package.grids[j].stackSize = val3.StackSize;
}
}
}
package.NotifyStorageChange();
}
if ((Object)(object)UIRoot.instance != (Object)null && (Object)(object)UIRoot.instance.uiGame != (Object)null && (Object)(object)UIRoot.instance.uiGame.inventoryWindow != (Object)null && ((ManualBehaviour)UIRoot.instance.uiGame.inventoryWindow).active)
{
((ManualBehaviour)UIRoot.instance.uiGame.inventoryWindow)._OnUpdate();
}
}
private static bool IsUsefulItem(ItemProto item)
{
if (((Proto)item).ID == 5001 || ((Proto)item).ID == 5002)
{
return true;
}
if (((Proto)item).ID >= 5101 && ((Proto)item).ID <= 5111)
{
return true;
}
return false;
}
private void OnGUI()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
if (_showWindow && (!((Object)(object)Camera.current != (Object)null) || (int)Camera.current.cameraType == 1) && !GameMain.isPaused && (int)UIGame.viewMode != 6)
{
GUI.backgroundColor = new Color(0.12f, 0.15f, 0.2f, 0.95f);
_windowRect = GUI.Window(9933, _windowRect, new WindowFunction(WindowFunc), "Stacksize Multiplier");
if (Mathf.Abs(((Rect)(ref _windowRect)).x - WindowX.Value) > 0.1f || Mathf.Abs(((Rect)(ref _windowRect)).y - WindowY.Value) > 0.1f)
{
WindowX.Value = ((Rect)(ref _windowRect)).x;
WindowY.Value = ((Rect)(ref _windowRect)).y;
}
}
}
private void WindowFunc(int id)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Expected O, but got Unknown
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
//IL_07be: Unknown result type (might be due to invalid IL or missing references)
//IL_0826: Unknown result type (might be due to invalid IL or missing references)
//IL_0837: Unknown result type (might be due to invalid IL or missing references)
//IL_0845: Unknown result type (might be due to invalid IL or missing references)
//IL_0859: Unknown result type (might be due to invalid IL or missing references)
//IL_085e: Unknown result type (might be due to invalid IL or missing references)
//IL_0863: Unknown result type (might be due to invalid IL or missing references)
//IL_087f: Unknown result type (might be due to invalid IL or missing references)
//IL_0884: Unknown result type (might be due to invalid IL or missing references)
//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
//IL_073b: Unknown result type (might be due to invalid IL or missing references)
float num = 280f;
if ((int)Event.current.type == 8 && (_lastSearch != _searchText || Mathf.Abs(_lastWidth - ((Rect)(ref _windowRect)).width) > 5f || _displayItems.Count == 0))
{
_lastSearch = _searchText;
_lastWidth = ((Rect)(ref _windowRect)).width;
if ((Object)(object)LDB.items != (Object)null && ((ProtoSet<ItemProto>)(object)LDB.items).dataArray != null)
{
List<ItemProto> list = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray.Where((ItemProto i) => i != null && ((Proto)i).ID > 0).ToList();
string searchLower = _searchText?.ToLower() ?? "";
if (!string.IsNullOrEmpty(searchLower))
{
_displayItems = list.Where((ItemProto i) => ((Proto)i).name.ToLower().Contains(searchLower)).ToList();
}
else
{
_displayItems = list;
}
}
_displayColumns = Mathf.Max(1, Mathf.FloorToInt((((Rect)(ref _windowRect)).width - 40f) / num));
}
GUIStyle val = new GUIStyle(GUI.skin.label)
{
richText = true
};
GUIStyle val2 = new GUIStyle(val)
{
fontStyle = (FontStyle)1
};
val2.normal.textColor = new Color(0.4f, 0.7f, 1f);
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("GLOBAL SETTINGS", val2, Array.Empty<GUILayoutOption>());
GUILayout.FlexibleSpace();
GUI.backgroundColor = new Color(0.2f, 0.8f, 0.2f, 0.8f);
if (GUILayout.Button("REFRESH ALL STACKS", (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(150f),
GUILayout.Height(22f)
}))
{
ApplyMultiplier();
}
GUI.backgroundColor = new Color(0.12f, 0.15f, 0.2f, 0.95f);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label($"Items Multiplier: {GlobalItemMultiplier.Value:F1}x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
float num2 = GUILayout.HorizontalSlider(GlobalItemMultiplier.Value, 1f, 10f, Array.Empty<GUILayoutOption>());
if (Mathf.Abs(num2 - GlobalItemMultiplier.Value) > 0.01f)
{
GlobalItemMultiplier.Value = Mathf.Round(num2 * 2f) / 2f;
ApplyMultiplier();
((BaseUnityPlugin)this).Config.Save();
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label($"Buildings Multiplier: {GlobalBuildingMultiplier.Value:F1}x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
float num3 = GUILayout.HorizontalSlider(GlobalBuildingMultiplier.Value, 1f, 10f, Array.Empty<GUILayoutOption>());
if (Mathf.Abs(num3 - GlobalBuildingMultiplier.Value) > 0.01f)
{
GlobalBuildingMultiplier.Value = Mathf.Round(num3 * 2f) / 2f;
ApplyMultiplier();
((BaseUnityPlugin)this).Config.Save();
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label($"Useful Items Multiplier: {GlobalUsefulMultiplier.Value:F1}x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
float num4 = GUILayout.HorizontalSlider(GlobalUsefulMultiplier.Value, 1f, 10f, Array.Empty<GUILayoutOption>());
if (Mathf.Abs(num4 - GlobalUsefulMultiplier.Value) > 0.01f)
{
GlobalUsefulMultiplier.Value = Mathf.Round(num4 * 2f) / 2f;
ApplyMultiplier();
((BaseUnityPlugin)this).Config.Save();
}
GUILayout.EndHorizontal();
GUILayout.Space(10f);
GUILayout.Label("INDIVIDUAL OVERRIDES", val2, Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
_searchText = GUILayout.TextField(_searchText, Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
{
_searchText = "";
}
GUILayout.EndHorizontal();
GUILayout.Space(5f);
_scrollPos = GUILayout.BeginScrollView(_scrollPos, GUI.skin.box);
for (int j = 0; j < _displayItems.Count; j += _displayColumns)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
for (int k = 0; j + k < _displayItems.Count && k < _displayColumns; k++)
{
ItemProto val3 = _displayItems[j + k];
if (!_originalStackSizes.TryGetValue(((Proto)val3).ID, out var value))
{
continue;
}
float value2;
bool flag = _itemOverrides.TryGetValue(((Proto)val3).ID, out value2);
bool flag2 = IsUsefulItem(val3);
float num5 = (flag2 ? GlobalUsefulMultiplier.Value : (val3.CanBuild ? GlobalBuildingMultiplier.Value : GlobalItemMultiplier.Value));
float num6 = (flag ? value2 : num5);
GUILayout.BeginHorizontal(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) });
Sprite iconSprite = val3.iconSprite;
if ((Object)(object)((iconSprite != null) ? iconSprite.texture : null) != (Object)null)
{
GUI.DrawTexture(GUILayoutUtility.GetRect(32f, 32f), (Texture)(object)val3.iconSprite.texture);
}
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
string text = (flag2 ? "<color=#ffff00>[U]</color>" : (val3.CanBuild ? "<color=#00ffaa>[B]</color>" : "<color=#aaaaaa>[I]</color>"));
GUILayout.Label("<b>" + ((Proto)val3).name + "</b> " + text, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(num - 60f) });
GUILayout.Label($"<color=#aaaaaa>{value} -> </color><color=#66b2ff><b>{val3.StackSize}</b></color>", val, Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
float num7 = Mathf.Round(GUILayout.HorizontalSlider(num6, 1f, 10f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }) * 2f) / 2f;
if (Mathf.Abs(num7 - num6) > 0.01f)
{
_itemOverrides[((Proto)val3).ID] = num7;
ApplyMultiplier();
SaveOverrides();
}
GUILayout.Label($"{num6:F1}x", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
if (flag)
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(25f) }))
{
_itemOverrides.Remove(((Proto)val3).ID);
ApplyMultiplier();
SaveOverrides();
}
GUI.backgroundColor = new Color(0.12f, 0.15f, 0.2f, 0.95f);
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
GUILayout.Space(5f);
GUI.backgroundColor = new Color(0.8f, 0.4f, 0.1f, 0.8f);
if (GUILayout.Button("CLOSE", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
{
_showWindow = false;
}
GUILayout.EndVertical();
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(((Rect)(ref _windowRect)).width - 20f, ((Rect)(ref _windowRect)).height - 20f, 20f, 20f);
GUI.Box(val4, "///");
if ((int)Event.current.type == 0 && ((Rect)(ref val4)).Contains(Event.current.mousePosition))
{
_isResizing = true;
_resizeStartMouse = Vector2.op_Implicit(Input.mousePosition);
_resizeStartSize = new Vector2(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height);
Event.current.Use();
}
GUI.DragWindow();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.Valoneu.StacksizeMultiplier";
public const string PLUGIN_NAME = "StacksizeMultiplier";
public const string PLUGIN_VERSION = "1.0.0";
}
}