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 InstantBuy v0.1.0
InstantBuy.dll
Decompiled 4 days agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("InstantBuy")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InstantBuy")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fef3cb85-467f-4bdb-9463-a21c054b8456")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace InstantBuy; [BepInPlugin("nexor.InstantBuy", "InstantBuy", "0.1.0")] public class InstantBuy : BaseUnityPlugin { [HarmonyPatch(typeof(Terminal))] internal class Terminal_Patch { private static List<int> instantItems; [HarmonyPatch("SyncGroupCreditsClientRpc")] [HarmonyPrefix] public static void Prefix(Terminal __instance, int newGroupCredits, ref int numItemsInShip) { if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { return; } NetworkManager networkManager = ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkManager; if (!networkManager.IsServer) { return; } bool flag = false; if (StartOfRound.Instance.currentLevel.PlanetName == "Gordion" || StartOfRound.Instance.currentLevel.PlanetName == "Galetry") { flag = true; Logger.LogInfo((object)"Company Moon + Config option detected"); } else { Logger.LogInfo((object)("Skipping prevention of instant items since the current level is: " + StartOfRound.Instance.currentLevel.PlanetName)); } if (!Instance.companyOnly.Value || flag) { List<int> orderedItemsFromTerminal = __instance.orderedItemsFromTerminal; List<int> ignoredItem_list = Instance.ignored_item.Value.Trim(new char[1] { ',' }).Split(new char[1] { ',' }).Select(int.Parse) .ToList(); instantItems = orderedItemsFromTerminal.Where((int item) => !ignoredItem_list.Contains(item)).ToList(); numItemsInShip = __instance.orderedItemsFromTerminal.Count - instantItems.Count; } } [HarmonyPatch("SyncGroupCreditsClientRpc")] [HarmonyPostfix] public static void Postfix(Terminal __instance, int newGroupCredits, int numItemsInShip) { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { return; } NetworkManager networkManager = ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).NetworkManager; if (!networkManager.IsServer) { return; } bool flag = false; if (StartOfRound.Instance.currentLevel.PlanetName == "Gordion" || StartOfRound.Instance.currentLevel.PlanetName == "Galetry") { flag = true; Logger.LogInfo((object)"Company Moon + Config option detected"); } else { Logger.LogInfo((object)("Skipping prevention of instant items since the current level is: " + StartOfRound.Instance.currentLevel.PlanetName)); } if (Instance.companyOnly.Value && !flag) { return; } List<int> orderedItemsFromTerminal = __instance.orderedItemsFromTerminal; List<int> ignoredItem_list = Instance.ignored_item.Value.Trim(new char[1] { ',' }).Split(new char[1] { ',' }).Select(int.Parse) .ToList(); instantItems = orderedItemsFromTerminal.Where((int item) => !ignoredItem_list.Contains(item)).ToList(); Vector3 position = StartOfRound.Instance.insideShipPositions[10].position; position.z += 1.5f; foreach (int instantItem in instantItems) { GameObject val = Object.Instantiate<GameObject>(__instance.buyableItemsList[instantItem].spawnPrefab, new Vector3(position.x + Random.Range(0f - Instance.offset.Value, Instance.offset.Value), position.y, position.z + Random.Range(0f - Instance.offset.Value, Instance.offset.Value)), Quaternion.identity, StartOfRound.Instance.propsContainer); val.GetComponent<GrabbableObject>().fallTime = 0f; val.GetComponent<GrabbableObject>().isInShipRoom = true; ((Component)val.GetComponent<GrabbableObject>()).transform.parent = GameObject.Find("/Environment/HangarShip").transform; val.GetComponent<NetworkObject>().Spawn(false); } __instance.orderedItemsFromTerminal = orderedItemsFromTerminal.Where((int item) => ignoredItem_list.Contains(item)).ToList(); } } private const string modGUID = "nexor.InstantBuy"; private const string modName = "InstantBuy"; private const string modVersion = "0.1.0"; private readonly Harmony harmony = new Harmony("nexor.InstantBuy"); public ConfigEntry<float> offset; public ConfigEntry<string> ignored_item; public ConfigEntry<bool> companyOnly; public static InstantBuy Instance; public static ManualLogSource Logger; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } offset = ((BaseUnityPlugin)this).Config.Bind<float>("InstantBuy Config", "offset 偏移", 0.2f, "Controls the offset of where purchased items are generated 控制购买物品生成位置的偏移"); ignored_item = ((BaseUnityPlugin)this).Config.Bind<string>("InstantBuy Config", "ignored_item 不会触发该mod的物品名单", "-1,", "Numbers are separated by commas, e.g. -1,0,1,2 -1 is used as a placeholder, please go to the mod introduction page in the ThunderStore to check which number corresponds to which item. 数字使用逗号隔开,如-1,0,1,2 -1是用来占位的,具体哪个数字对应哪个物品请到雷电商城的mod介绍页查看"); companyOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("InstantBuy Config", "Company Only", true, "Restricts this mod to only Company Moons (Gordion & Galetry)"); Logger = ((BaseUnityPlugin)this).Logger; harmony.PatchAll(); Logger.LogInfo((object)"InstantBuy 0.1.0 loaded."); } }