Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BackpackMod v0.4.0
BackpackMod.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("BackpackMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BackpackMod")] [assembly: AssemblyTitle("BackpackMod")] [assembly: AssemblyVersion("1.0.0.0")] [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 BackpackMod { [BepInPlugin("lch.backpack", "BackpackMod", "0.4.0")] public class BackpackPlugin : BaseUnityPlugin { private class BackpackItem { public GameObject go; public int cells; public float value; } public const string GUID = "lch.backpack"; public const string MODNAME = "BackpackMod"; public const string VERSION = "0.4.0"; private bool _open; private readonly List<BackpackItem> _items = new List<BackpackItem>(); private float _totalWeight; private int _usedCells; private float _baseMove; private float _baseSprint; private float _baseDrain; private bool _gotBase; private ConfigEntry<KeyboardShortcut> _toggleKey; private ConfigEntry<KeyboardShortcut> _storeKey; private ConfigEntry<KeyboardShortcut> _takeKey; private ConfigEntry<bool> _enabled; private const int TotalCells = 9; private void Awake() { //IL_0039: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable backpack mod"); _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleKey", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), "Open/close backpack"); _storeKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "StoreKey", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), "Store held valuable"); _takeKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "TakeKey", new KeyboardShortcut((KeyCode)109, Array.Empty<KeyCode>()), "Take first item out"); try { new Harmony("lch.backpack").PatchAll(); } catch { } } private void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (_enabled.Value && !((Object)(object)PlayerController.instance == (Object)null)) { KeyboardShortcut value = _toggleKey.Value; if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey)) { _open = !_open; } value = _storeKey.Value; if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey)) { StoreHeld(); } value = _takeKey.Value; if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey)) { TakeOutFirst(); } PlayerController instance = PlayerController.instance; if (!_gotBase) { _baseMove = instance.MoveSpeed; _baseSprint = instance.SprintSpeed; _baseDrain = instance.EnergySprintDrain; _gotBase = true; } float num = Mathf.Clamp(_totalWeight * 0.08f, 0f, 0.7f); instance.MoveSpeed = _baseMove * (1f - num); instance.SprintSpeed = _baseSprint * (1f - num); instance.EnergySprintDrain = _baseDrain * (1f + num * 2f); } } private void OnGUI() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (_enabled.Value && _open && !((Object)(object)PlayerController.instance == (Object)null)) { int num = 260; int num2 = 220; int num3 = (Screen.width - num) / 2; int num4 = (Screen.height - num2) / 2; GUI.Box(new Rect((float)num3, (float)num4, (float)num, (float)num2), "Backpack"); for (int i = 0; i < 9; i++) { int num5 = num3 + 10 + i % 3 * 70; int num6 = num4 + 40 + i / 3 * 60; GUI.Box(new Rect((float)num5, (float)num6, 60f, 50f), ""); } GUI.Label(new Rect((float)(num3 + 10), (float)(num4 + 190), 240f, 20f), $"Cells: {_usedCells}/9 Weight: {_totalWeight:0}kg"); } } private void StoreHeld() { PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null) { return; } object? obj = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject")?.GetValue(instance); PhysGrabObject val = (PhysGrabObject)((obj is PhysGrabObject) ? obj : null); if ((Object)(object)val == (Object)null) { return; } ValuableObject component = ((Component)val).GetComponent<ValuableObject>(); if ((Object)(object)component == (Object)null) { return; } float num = (float)AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent")?.GetValue(component); int num2 = ((num >= 15000f) ? 9 : ((num >= 7000f) ? 6 : ((!(num >= 4100f)) ? 1 : 3))); if (_usedCells + num2 <= 9) { instance.ReleaseObject(0, 0f); GameObject gameObject = ((Component)val).gameObject; gameObject.SetActive(false); Rigidbody component2 = gameObject.GetComponent<Rigidbody>(); _items.Add(new BackpackItem { go = gameObject, cells = num2, value = num }); _usedCells += num2; if ((Object)(object)component2 != (Object)null) { _totalWeight += component2.mass; } } } private void TakeOutFirst() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (_items.Count == 0) { return; } BackpackItem backpackItem = _items[0]; _items.RemoveAt(0); if (!((Object)(object)backpackItem.go == (Object)null)) { Transform transform = ((Component)Camera.main).transform; backpackItem.go.transform.position = transform.position + transform.forward * 1.5f; backpackItem.go.SetActive(true); _usedCells -= backpackItem.cells; Rigidbody component = backpackItem.go.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { _totalWeight -= component.mass; } } } } }