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 LethalAPI v0.3.0
BepInEx/plugins/LethalAPI.dll
Decompiled 2 years agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalAPI.Comp; using LethalAPI.DataTypes; using LethalAPI.Patches; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("LethalAPI")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Modded Lethal Company API")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+1e6924c15028406315e4095d841a2a1c5e705f20")] [assembly: AssemblyProduct("LethalAPI")] [assembly: AssemblyTitle("LethalAPI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.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 LethalAPI { public class AssetLoaderAPI { public delegate void OnLoadedAssetsDelegate(); public static ConcurrentDictionary<string, Object> Assets; public static OnLoadedAssetsDelegate OnLoadedAssets; public static void LoadAssets() { Assets = new ConcurrentDictionary<string, Object>(); Plugin.Log.LogMessage((object)"[LethalAPI] AssetLoaderAPI - Started loading custom assets..."); string path = Path.Combine(Paths.BepInExRootPath, "Assets"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string[] array = (from x in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !x.EndsWith(".manifest", StringComparison.CurrentCultureIgnoreCase) select x).ToArray(); if (array.Length == 0) { Plugin.Log.LogMessage((object)"[LethalAPI] AssetLoaderAPI - No assets to load!"); return; } Plugin.Log.LogMessage((object)("[LethalAPI] AssetLoaderAPI - Loading " + array.Length + " asset(s)!")); for (int i = 0; i < array.Length; i++) { try { SaveAsset(array[i]); } catch (Exception ex) { Plugin.Log.LogError((object)("[LethalAPI] AssetLoaderAPI - Failed to load asset with path: " + array[i])); Plugin.Log.LogError((object)("[LethalAPI] AssetLoaderAPI - Exception: " + ex.ToString())); } } OnLoadedAssets = (OnLoadedAssetsDelegate)Delegate.Combine(OnLoadedAssets, new OnLoadedAssetsDelegate(LoadAssetsCompleted)); OnLoadedAssets(); } public static void SaveAsset(string path) { AssetBundle val = AssetBundle.LoadFromFile(path); string[] allAssetNames = val.GetAllAssetNames(); string[] array = allAssetNames; foreach (string text in array) { Plugin.Log.LogMessage((object)("[LethalAPI] AssetLoaderAPI - Loading asset: " + text)); Object val2 = val.LoadAsset(text); if (val2 == (Object)null) { Plugin.Log.LogError((object)("[LethalAPI] AssetLoaderAPI - Skipped loading asset: " + text)); continue; } string key = text.ToUpper(); if (Assets.ContainsKey(key)) { Plugin.Log.LogError((object)("[LethalAPI] AssetLoaderAPI - Duplicate asset! Asset: " + text)); break; } Assets.TryAdd(key, val2); } } public static AssetType GetLoadedAsset<AssetType>(string itemPath) where AssetType : Object { Assets.TryGetValue(itemPath.ToUpper(), out var value); Object val = value; return (AssetType)(object)val; } public static AssetType GetLoadedAssetByName<AssetType>(string assetName) where AssetType : Object { Assets.TryGetValue(assetName.ToUpper(), out var value); if (value == (Object)null) { return default(AssetType); } Object val = value; return (AssetType)(object)val; } private static void LoadAssetsCompleted() { Plugin.Log.LogMessage((object)"[LethalAPI] AssetLoaderAPI - Finished loading all the custom assets"); } } internal class CustomInputAPI { internal class CustomAction { public CustomAction(string id, Key config, string decription, int slot = 0) { } } public static CustomAction[] AllDefinedACtions = new CustomAction[0]; public bool onKeyDown(Key key) { return false; } } public class InventoryAPI { public static void SetInventorySize(int size, PlayerControllerB specificPlayer = null) { if ((Object)(object)specificPlayer != (Object)null) { GrabbableObject[] itemSlots = specificPlayer.ItemSlots; GrabbableObject[] array = (GrabbableObject[])(object)new GrabbableObject[size]; for (int i = 0; i < itemSlots.Length; i++) { array[i] = itemSlots[i]; } specificPlayer.ItemSlots = array; ResizeInventoryGUI(size, specificPlayer); return; } PlayerControllerB[] array2 = Object.FindObjectsOfType<PlayerControllerB>(); foreach (PlayerControllerB val in array2) { GrabbableObject[] itemSlots2 = val.ItemSlots; GrabbableObject[] array3 = (GrabbableObject[])(object)new GrabbableObject[size]; for (int k = 0; k < itemSlots2.Length; k++) { array3[k] = itemSlots2[k]; } val.ItemSlots = array3; ResizeInventoryGUI(size, val); } } public static GrabbableObject[] GetInventorySlots(PlayerControllerB playerController) { return playerController.ItemSlots; } public static int GetInventorySlotsCount(PlayerControllerB playerController) { return playerController.ItemSlots.Length; } public static void ResizeInventoryGUI(int newSize, PlayerControllerB specificPlayerController) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory"); if (val.transform.childCount != GetInventorySlotsCount(specificPlayerController)) { Image[] array = (Image[])(object)new Image[newSize]; Image[] array2 = (Image[])(object)new Image[newSize]; for (int i = 0; i < 4; i++) { array[i] = HUDManager.Instance.itemSlotIconFrames[i]; array2[i] = HUDManager.Instance.itemSlotIcons[i]; } GameObject val2 = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory/Slot3"); GameObject val3 = val2; for (int j = 0; j < newSize - 4; j++) { GameObject val4 = Object.Instantiate<GameObject>(val2); ((Object)val4).name = $"Slot{4 + j}"; val4.transform.parent = val.transform; Vector3 localPosition = val3.transform.localPosition; val4.transform.SetLocalPositionAndRotation(new Vector3(localPosition.x + 50f, localPosition.y, localPosition.z), val3.transform.localRotation); val3 = val4; array[4 + j] = val4.GetComponent<Image>(); array2[4 + j] = ((Component)val4.transform.GetChild(0)).GetComponent<Image>(); } HUDManager.Instance.itemSlotIconFrames = array; HUDManager.Instance.itemSlotIcons = array2; float num = 50f; float num2 = newSize / 2; for (int k = 0; k < newSize; k++) { Vector3 localPosition2 = val3.transform.localPosition; val.transform.GetChild(k).SetLocalPositionAndRotation(new Vector3(num * ((float)k - num2 - 0.5f), localPosition2.y, localPosition2.z), val3.transform.localRotation); } } } } public class ItemAPI : NetworkBehaviour { public delegate void OnStoreBuyableLoadedDelegate(); public class BuyablePlayerUnlock { public Item item; public int price; public BuyablePlayerUnlock(Item item, int price) { this.item = item; this.price = price; } } public class BuyableStoreItem { public Item item; public TerminalNode terminalNodeFirst; public TerminalNode terminalNodeSecond; public TerminalNode ShopItemNode; public int price; public BuyableStoreItem(Item item, TerminalNode terminalNodeFirst = null, TerminalNode terminalNodeSecond = null, TerminalNode ShopItemNode = null, int price = -1) { this.item = item; this.price = price; if ((Object)(object)terminalNodeFirst != (Object)null) { this.terminalNodeFirst = terminalNodeFirst; } if ((Object)(object)terminalNodeSecond != (Object)null) { this.terminalNodeSecond = terminalNodeSecond; } if ((Object)(object)ShopItemNode != (Object)null) { this.ShopItemNode = ShopItemNode; } } } public class ScrapItem { public Item item; public int rarity; public Levels.LevelTypes spawnLevels; public ScrapItem(Item item, int rarity, Levels.LevelTypes spawnLevels) { this.item = item; this.rarity = rarity; this.spawnLevels = spawnLevels; } } public static OnStoreBuyableLoadedDelegate OnLoadedStoreBuyables; public static OnStoreBuyableLoadedDelegate OnLoadedPlayerUnlocks; private static Terminal terminal; private static StartOfRound StartOfRound; internal static List<ScrapItem> scrapItems = new List<ScrapItem>(); internal static List<BuyableStoreItem> buyableStoreItems = new List<BuyableStoreItem>(); internal static List<BuyablePlayerUnlock> playerUnlocksItems = new List<BuyablePlayerUnlock>(); public static void Init() { StartOfRound = Object.FindAnyObjectByType<StartOfRound>(); LoadPlayerUnlockables(); } private static void LoadStoreBuyables() { //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Expected O, but got Unknown //IL_0463: 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_0470: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Expected O, but got Unknown //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Expected O, but got Unknown Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 1"); terminal = Object.FindAnyObjectByType<Terminal>(); List<Item> list = terminal.buyableItemsList.ToList(); Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 2"); TerminalKeyword val = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy"); TerminalNode result = val.compatibleNouns[0].result.terminalOptions[1].result; TerminalKeyword val2 = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info"); Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 3"); Plugin.Log.LogMessage((object)string.Format("[{0}] ItemLoaderAPI - Adding {1} item(s) to the store!", "LethalAPI", buyableStoreItems.Count)); if (buyableStoreItems.Count == 0) { Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - No buyable items to add"); return; } Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 4"); foreach (BuyableStoreItem buyableStoreItem in buyableStoreItems) { if (buyableStoreItem.price == -1) { buyableStoreItem.price = buyableStoreItem.item.creditsWorth; } else { buyableStoreItem.item.creditsWorth = buyableStoreItem.price; } Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 5"); list.Add(buyableStoreItem.item); string itemName = buyableStoreItem.item.itemName; char c = itemName[itemName.Length - 1]; string text = itemName; Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 6"); TerminalNode val3; if ((Object)(object)buyableStoreItem.terminalNodeSecond == (Object)null) { val3 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val3).name = itemName.Replace(" ", "-") + "TerminalNode2"; val3.displayText = "Ordered [variableAmount] " + text + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n"; val3.clearPreviousText = true; val3.maxCharactersToType = 15; val3.buyItemIndex = list.Count - 1; val3.itemCost = buyableStoreItem.price; } else { val3 = buyableStoreItem.terminalNodeSecond; val3.buyItemIndex = list.Count - 1; val3.itemCost = buyableStoreItem.price; } Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 7"); TerminalNode val4; if ((Object)(object)buyableStoreItem.terminalNodeFirst == (Object)null) { val4 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val4).name = itemName.Replace(" ", "-") + "terminalNodeFirst"; val4.displayText = "You have placed an order of " + text + " Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n"; val4.clearPreviousText = true; val4.maxCharactersToType = 35; } else { val4 = buyableStoreItem.terminalNodeFirst; } val4.buyItemIndex = buyableStoreItems.Count - 1; val4.itemCost = buyableStoreItem.price; val4.isConfirmationNode = true; val4.overrideOptions = true; val4.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { new CompatibleNoun { noun = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "confirm"), result = val3 }, new CompatibleNoun { noun = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "deny"), result = result } }; Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 8"); TerminalKeyword val5 = TerminalUtilities.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val); List<TerminalKeyword> list2 = terminal.terminalNodes.allKeywords.ToList(); list2.Add(val5); terminal.terminalNodes.allKeywords = list2.ToArray(); Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 9"); List<CompatibleNoun> list3 = val.compatibleNouns.ToList(); list3.Add(new CompatibleNoun { noun = val5, result = val4 }); val.compatibleNouns = list3.ToArray(); Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 10"); TerminalNode val6 = buyableStoreItem.ShopItemNode; if ((Object)(object)val6 == (Object)null) { val6 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val6).name = itemName.Replace(" ", "-") + "InfoNode"; val6.displayText = "[No information about this object was found.]\n\n"; val6.clearPreviousText = true; val6.maxCharactersToType = 25; } terminal.terminalNodes.allKeywords = list2.ToArray(); Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 11"); List<CompatibleNoun> list4 = val2.compatibleNouns.ToList(); list4.Add(new CompatibleNoun { noun = val5, result = val6 }); val2.compatibleNouns = list4.ToArray(); Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - 12"); } terminal.buyableItemsList = list.ToArray(); OnLoadedStoreBuyables = (OnStoreBuyableLoadedDelegate)Delegate.Combine(OnLoadedStoreBuyables, new OnStoreBuyableLoadedDelegate(LoadStoreItemsCompleted)); OnLoadedStoreBuyables(); } private static void LoadStoreItemsCompleted() { Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - Finished loading all the store buyable items!"); } private static void LoadUnlocksCompleted() { Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - Finished loading all the unlock items!"); } private static void LoadPlayerUnlockables() { //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_0225: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown TerminalKeyword val = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy"); TerminalNode result = val.compatibleNouns[0].result.terminalOptions[1].result; Plugin.Log.LogMessage((object)string.Format("[{0}] ItemLoaderAPI - Adding {1} unlockable item(s) to the store!", "LethalAPI", playerUnlocksItems.Count)); List<Item> list = terminal.buyableItemsList.ToList(); if (playerUnlocksItems.Count == 0) { Plugin.Log.LogMessage((object)"[LethalAPI] ItemLoaderAPI - No unlockables to add"); return; } foreach (BuyablePlayerUnlock playerUnlocksItem in playerUnlocksItems) { list.Add(playerUnlocksItem.item); string itemName = playerUnlocksItem.item.itemName; char c = itemName[itemName.Length - 1]; string text = itemName; TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val2).name = itemName.Replace(" ", "-") + "TerminalNode2"; val2.clearPreviousText = true; val2.shipUnlockableID = playerUnlocksItems.Count - 1; val2.itemCost = playerUnlocksItem.price; TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val3).name = itemName.Replace(" ", "-") + "terminalNodeFirst"; val3.displayText = "You have placed an order of " + text + " Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n"; val3.clearPreviousText = true; val3.shipUnlockableID = playerUnlocksItems.Count - 1; val3.itemCost = playerUnlocksItem.price; val3.isConfirmationNode = true; val3.overrideOptions = true; val3.maxCharactersToType = 15; val3.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { new CompatibleNoun { noun = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "confirm"), result = val2 }, new CompatibleNoun { noun = terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "deny"), result = result } }; TerminalKeyword val4 = TerminalUtilities.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val); List<TerminalKeyword> list2 = terminal.terminalNodes.allKeywords.ToList(); list2.Add(val4); terminal.terminalNodes.allKeywords = list2.ToArray(); List<CompatibleNoun> list3 = val.compatibleNouns.ToList(); list3.Add(new CompatibleNoun { noun = val4, result = val3 }); val.compatibleNouns = list3.ToArray(); } terminal.buyableItemsList = list.ToArray(); OnLoadedPlayerUnlocks = (OnStoreBuyableLoadedDelegate)Delegate.Combine(OnLoadedPlayerUnlocks, new OnStoreBuyableLoadedDelegate(LoadUnlocksCompleted)); OnLoadedPlayerUnlocks(); } private static void RegisterScrapToLevel(StartOfRound __instance) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown StartOfRound = __instance; if ((Object)(object)StartOfRound == (Object)null) { Plugin.Log.LogError((object)"[LethalAPI] ItemLoaderAPI - An error has occured! StartOfRound was null! Report this as a bug!"); return; } SelectableLevel[] levels = StartOfRound.levels; foreach (SelectableLevel val in levels) { string name = ((Object)val).name; if (!Enum.IsDefined(typeof(Levels.LevelTypes), name)) { continue; } Levels.LevelTypes levelTypes = (Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name); foreach (ScrapItem item in scrapItems) { if (item.spawnLevels.HasFlag(levelTypes)) { SpawnableItemWithRarity item2 = new SpawnableItemWithRarity { spawnableItem = item.item, rarity = item.rarity }; Plugin.Log.LogMessage((object)("[LethalAPI] ItemLoaderAPI - Checking if " + ((Object)item.item).name + " is already in " + name)); if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)item.item)) { val.spawnableScrap.Add(item2); Plugin.Log.LogMessage((object)("[LethalAPI] ItemLoaderAPI - Added scrapItem " + ((Object)item.item).name + " to " + name)); } } } } foreach (ScrapItem scrapItem in scrapItems) { if (!StartOfRound.allItemsList.itemsList.Contains(scrapItem.item)) { Plugin.Log.LogMessage((object)("[LethalAPI] ItemLoaderAPI - Registering scrapItem: " + ((Object)scrapItem.item).name)); StartOfRound.allItemsList.itemsList.Add(scrapItem.item); } } } public static bool HasItem(string itemName) { if (string.IsNullOrEmpty(itemName)) { return false; } return false; } public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags) { ScrapItem item = new ScrapItem(spawnableItem, rarity, levelFlags); scrapItems.Add(item); } public static void RegisterShopItem(Item shopItem, TerminalNode terminalNodeFirst, TerminalNode terminalNodeSecond, TerminalNode ShopItemNode, int price = -1) { buyableStoreItems.Add(new BuyableStoreItem(shopItem, terminalNodeFirst, terminalNodeSecond, ShopItemNode, price)); } public static void RegisterUnlockable(Item shopItem, int price) { playerUnlocksItems.Add(new BuyablePlayerUnlock(shopItem, price)); } public static Item StandardItem() { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) Item val = ScriptableObject.CreateInstance<Item>(); val.itemId = 0; val.itemName = null; val.spawnPositionTypes = new List<ItemGroup>(); val.twoHanded = false; val.twoHandedAnimation = false; val.canBeGrabbedBeforeGameStart = false; val.weight = 1f; val.itemIsTrigger = false; val.holdButtonUse = false; val.itemSpawnsOnGround = true; val.isConductiveMetal = false; val.isScrap = false; val.creditsWorth = 0; val.lockedInDemo = false; val.highestSalePercentage = 80; val.maxValue = 0; val.minValue = 0; val.spawnPrefab = null; val.requiresBattery = true; val.batteryUsage = 15f; val.automaticallySetUsingPower = true; val.itemIcon = null; val.grabAnim = null; val.useAnim = null; val.pocketAnim = null; val.throwAnim = null; val.grabAnimationTime = 0f; val.grabSFX = null; val.dropSFX = null; val.pocketSFX = null; val.throwSFX = null; val.syncGrabFunction = true; val.syncUseFunction = true; val.syncDiscardFunction = true; val.syncInteractLRFunction = true; val.saveItemVariable = false; val.isDefensiveWeapon = false; val.toolTips = null; val.verticalOffset = 0f; val.floorYOffset = 0; val.allowDroppingAheadOfPlayer = true; val.restingRotation = new Vector3(0f, 0f, 90f); val.rotationOffset = Vector3.zero; val.positionOffset = Vector3.zero; val.meshOffset = true; val.meshVariants = null; val.materialVariants = null; val.usableInSpecialAnimations = false; val.canBeInspected = true; return val; } public static void DropItemInSlot(int slot, bool itemsFall, PlayerControllerB playerController) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) StartOfRound val = Object.FindFirstObjectByType<StartOfRound>(); GrabbableObject val2 = InventoryAPI.GetInventorySlots(playerController)[slot]; if ((Object)(object)val2 == (Object)null) { return; } if (itemsFall) { val2.parentObject = null; val2.heldByPlayerOnServer = false; if (playerController.isInElevator) { ((Component)val2).transform.SetParent(val.elevatorTransform, true); } else { ((Component)val2).transform.SetParent(val.propsContainer, true); } playerController.SetItemInElevator(playerController.isInHangarShipRoom, playerController.isInElevator, val2); val2.EnablePhysics(true); val2.EnableItemMeshes(true); ((Component)val2).transform.localScale = val2.originalScale; val2.isHeld = false; val2.isPocketed = false; val2.startFallingPosition = ((Component)val2).transform.parent.InverseTransformPoint(((Component)val2).transform.position); val2.FallToGround(true); val2.fallTime = Random.Range(-0.3f, 0.05f); if (((NetworkBehaviour)playerController).IsOwner) { val2.DiscardItemOnClient(); } else if (!val2.itemProperties.syncDiscardFunction) { val2.playerHeldBy = null; } } if (((NetworkBehaviour)playerController).IsOwner) { ((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false; ((Behaviour)HUDManager.Instance.itemSlotIcons[slot]).enabled = false; HUDManager.Instance.ClearControlTips(); playerController.activatingItem = false; } playerController.ItemSlots[slot] = null; if (playerController.isHoldingObject) { playerController.isHoldingObject = false; playerController.playerBodyAnimator.SetBool("cancelHolding", true); playerController.playerBodyAnimator.SetTrigger("Throw"); } } public static void DropItemInSlots(int[] slotsIndex, bool itemsFall, PlayerControllerB playerController) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) StartOfRound val = Object.FindFirstObjectByType<StartOfRound>(); for (int i = 0; i < slotsIndex.Length; i++) { GrabbableObject val2 = InventoryAPI.GetInventorySlots(playerController)[slotsIndex[i]]; if ((Object)(object)val2 == (Object)null) { break; } if (itemsFall) { val2.parentObject = null; val2.heldByPlayerOnServer = false; if (playerController.isInElevator) { ((Component)val2).transform.SetParent(val.elevatorTransform, true); } else { ((Component)val2).transform.SetParent(val.propsContainer, true); } playerController.SetItemInElevator(playerController.isInHangarShipRoom, playerController.isInElevator, val2); val2.EnablePhysics(true); val2.EnableItemMeshes(true); ((Component)val2).transform.localScale = val2.originalScale; val2.isHeld = false; val2.isPocketed = false; val2.startFallingPosition = ((Component)val2).transform.parent.InverseTransformPoint(((Component)val2).transform.position); val2.FallToGround(true); val2.fallTime = Random.Range(-0.3f, 0.05f); if (((NetworkBehaviour)playerController).IsOwner) { val2.DiscardItemOnClient(); } else if (!val2.itemProperties.syncDiscardFunction) { val2.playerHeldBy = null; } } if (((NetworkBehaviour)playerController).IsOwner) { ((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false; ((Behaviour)HUDManager.Instance.itemSlotIcons[slotsIndex[i]]).enabled = false; HUDManager.Instance.ClearControlTips(); playerController.activatingItem = false; } playerController.ItemSlots[slotsIndex[i]] = null; if (playerController.isHoldingObject) { playerController.isHoldingObject = false; playerController.playerBodyAnimator.SetBool("cancelHolding", true); playerController.playerBodyAnimator.SetTrigger("Throw"); } } } } internal class LevelAPI { private static StartOfRound startOfRound; private static List<SelectableLevel> moddedLevelList = new List<SelectableLevel>(); public void Init() { startOfRound = Object.FindAnyObjectByType<StartOfRound>(); } private static void onStartOfRoundAwake(StartOfRound __instance) { List<SelectableLevel> list = new List<SelectableLevel>(); if (moddedLevelList.Count <= 0) { return; } foreach (SelectableLevel moddedLevel in moddedLevelList) { list.Add(moddedLevel); } startOfRound.levels = list.ToArray(); } public void AddLevel(SelectableLevel levelToAdd) { moddedLevelList.Add(levelToAdd); } } public class NetworkingAPI { public delegate void receivedStringEventDelegate(string data, string signature); public delegate void receivedIntEventDelegate(int data, string signature); public delegate void receivedFloatEventDelegate(float data, string signature); public delegate void receivedVector3EventDelegate(Vector3 data, string signature); public static receivedStringEventDelegate receiveString = receivedString; public static receivedIntEventDelegate receiveInt = receivedInt; public static receivedFloatEventDelegate receiveFloat = receivedFloat; public static receivedVector3EventDelegate receiveVector3 = receivedVector3; public static void Send(string data, string signature) { Broadcast(data, signature); } public static void Send(int data, string signature) { Broadcast(data, signature); } public static void Send(float data, string signature) { Broadcast(data, signature); } public static void Send(Vector3 data, string signature) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Broadcast(data, signature); } public static void Broadcast(string data, string signature) { if (data.Contains("/")) { Plugin.Log.LogError((object)"Broadcasted string contains an invalid character! ( / )"); return; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkingDataTypes.NetworkingString.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(int data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkingDataTypes.NetworkingInt.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(float data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkingDataTypes.NetworkingFloat.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(Vector3 data, string signature) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; string[] obj = new string[9] { "<size=0>NWE/", null, null, null, null, null, null, null, null }; Vector3 val = data; obj[1] = ((object)(Vector3)(ref val)).ToString(); obj[2] = "/"; obj[3] = signature; obj[4] = "/"; obj[5] = NetworkingDataTypes.NetworkingVector3.ToString(); obj[6] = "/"; obj[7] = GameNetworkManager.Instance.localPlayerController.playerClientId.ToString(); obj[8] = "/</size>"; instance.AddTextToChatOnServer(string.Concat(obj), -1); } private static void receivedString(string data, string signature) { } private static void receivedInt(int data, string signature) { } private static void receivedFloat(float data, string signature) { } private static void receivedVector3(Vector3 data, string signature) { } } public class ServerAPI { private static bool onlyModdedClients; public static bool setModdedClientsOnly; public static bool OnlyModdedClients => onlyModdedClients; public static void SetModdedClientsOnly() { onlyModdedClients = true; } internal static void OnSceneLoaded() { if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance) && onlyModdedClients) { GameNetworkManager instance = GameNetworkManager.Instance; instance.gameVersionNum += 3000; setModdedClientsOnly = true; } } } internal class TerminalUtilities { public static TerminalKeyword CreateTerminalKeyword(string word, bool isVerb = false, CompatibleNoun[] compatibleNouns = null, TerminalNode specialKeywordResult = null, TerminalKeyword defaultVerb = null, bool accessTerminalObjects = false) { TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val).name = word; val.word = word; val.isVerb = isVerb; val.compatibleNouns = compatibleNouns; val.specialKeywordResult = specialKeywordResult; val.defaultVerb = defaultVerb; val.accessTerminalObjects = accessTerminalObjects; return val; } } [BepInPlugin("LethalAPI", "LethalAPI", "0.3.0")] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; private ConfigEntry<bool> config_ForceModdedServers; private void Awake() { config_ForceModdedServers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ForcedModdedBrowser", false, (ConfigDescription)null); Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalAPI Initializing..."); if (config_ForceModdedServers.Value) { ServerAPI.SetModdedClientsOnly(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Forced only modded servers and clients!"); } Hook(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalAPI is loaded!"); } private void Hook() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown Harmony val = new Harmony("LethalAPI"); MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(GameNetworkManager), "LobbyDataIsJoinable", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuManager), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(Terminal), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(StartOfRound), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo7 = AccessTools.Method(typeof(ServerPatch), "OnLobbyCreate", (Type[])null, (Type[])null); MethodInfo methodInfo8 = AccessTools.Method(typeof(ServerPatch), "Vers", (Type[])null, (Type[])null); MethodInfo methodInfo9 = AccessTools.Method(typeof(ServerPatch), "ChatInterpreter", (Type[])null, (Type[])null); MethodInfo methodInfo10 = AccessTools.Method(typeof(ItemPatch), "OnTerminalAwake", (Type[])null, (Type[])null); MethodInfo methodInfo11 = AccessTools.Method(typeof(ItemPatch), "OnRoundAwake", (Type[])null, (Type[])null); MethodInfo methodInfo12 = AccessTools.Method(typeof(ItemAPI), "RegisterScrapToLevel", (Type[])null, (Type[])null); MethodInfo methodInfo13 = AccessTools.Method(typeof(ItemAPI), "LoadStoreBuyables", (Type[])null, (Type[])null); MethodInfo methodInfo14 = AccessTools.Method(typeof(LevelAPI), "onStartOfRoundAwake", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo4, new HarmonyMethod(methodInfo9), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo7), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo10), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo13), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo6, new HarmonyMethod(methodInfo11), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo6, new HarmonyMethod(methodInfo12), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo6, new HarmonyMethod(methodInfo14), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private void OnDestroy() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown AssetLoaderAPI.LoadAssets(); GameObject val = new GameObject("API"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<SVAPI>(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LethalAPI"; public const string PLUGIN_NAME = "LethalAPI"; public const string PLUGIN_VERSION = "0.3.0"; } } namespace LethalAPI.Patches { internal class ItemPatch { public static Terminal terminalObject; public static StartOfRound startOfRoundObject; private static bool OnTerminalAwake(Terminal __instance) { Plugin.Log.LogMessage((object)"[LethalAPI] ItemPatch - Loaded terminal awake"); terminalObject = __instance; return true; } private static bool OnRoundAwake(StartOfRound __instance) { Plugin.Log.LogMessage((object)"[LethalAPI] ItemPatch - Loaded on round awake"); startOfRoundObject = __instance; return true; } public static Terminal GetTerminal() { return terminalObject; } } internal class ServerPatch { private static bool OnLobbyCreate(GameNetworkManager __instance, Result result, Lobby lobby) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 1) { Debug.LogError((object)$"The lobby could not be created! {result}", (Object)(object)__instance); } __instance.lobbyHostSettings.lobbyName = "[MODDED SERVER]" + __instance.lobbyHostSettings.lobbyName.ToString(); return true; } private static bool Vers(MenuManager __instance) { SVAPI.MenuManager = __instance; return true; } private static bool ChatInterpreter(HUDManager __instance, string chatMessage) { //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if (chatMessage == null) { return false; } if (chatMessage.Contains("NWE") && chatMessage.Contains("<size=0>")) { string[] array = chatMessage.Split(new char[1] { '/' }); if (array.Length < 3) { Plugin.Log.LogError((object)"Chat Message Fail! Report this as a bug!"); return false; } if (!int.TryParse(array[4], out var result)) { Plugin.Log.LogError((object)"Failed to parse the players id from the chat message!"); return false; } if (result == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) { return false; } NetworkingDataTypes result2 = NetworkingDataTypes.NetworkingString; Enum.TryParse<NetworkingDataTypes>(array[3], out result2); switch (result2) { case NetworkingDataTypes.NetworkingString: NetworkingAPI.receiveString(array[1], array[2]); break; case NetworkingDataTypes.NetworkingInt: NetworkingAPI.receiveInt(int.Parse(array[1]), array[2]); break; case NetworkingDataTypes.NetworkingFloat: NetworkingAPI.receiveFloat(float.Parse(array[1]), array[2]); break; case NetworkingDataTypes.NetworkingVector3: { string[] array2 = array[1].Replace("(", "").Replace(")", "").Split(new char[1] { ',' }); Vector3 data = default(Vector3); float result3; float result4; float result5; if (array2.Length != 3) { Plugin.Log.LogError((object)"Vector3 recieved from chat is not a 3D vector! It doesn't contain 3 components (x, y, z)"); } else if (float.TryParse(array2[0], out result3) && float.TryParse(array2[1], out result4) && float.TryParse(array2[2], out result5)) { data.x = result3; data.y = result4; data.z = result5; } else { Plugin.Log.LogError((object)"API Failure when parsing a Vector3, report this!"); } NetworkingAPI.receiveVector3(data, array[2]); break; } } return false; } return true; } } } namespace LethalAPI.DataTypes { public class Levels { [Flags] public enum LevelTypes { None = 1, ExperimentationLevel = 2, AssuranceLevel = 4, VowLevel = 8, OffenseLevel = 0x10, MarchLevel = 0x20, RendLevel = 0x40, DineLevel = 0x80, TitanLevel = 0x100, All = 0x1FE } } public enum NetworkingDataTypes { NetworkingString, NetworkingInt, NetworkingFloat, NetworkingVector3 } } namespace LethalAPI.Comp { internal class SVAPI : MonoBehaviour { public static MenuManager MenuManager; public bool netTester; public void Update() { if (!ServerAPI.setModdedClientsOnly) { ServerAPI.OnSceneLoaded(); } else if (ServerAPI.OnlyModdedClients && (Object)(object)MenuManager != (Object)null && Object.op_Implicit((Object)(object)MenuManager.versionNumberText)) { ((TMP_Text)MenuManager.versionNumberText).text = $"v{GameNetworkManager.Instance.gameVersionNum - 3000}\nMOD"; } } } }