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 KuchQOL Server v1.5.1
KuchQOL_Server.dll
Decompiled 2 months agousing System; using System.Collections; 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.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using KuchQOL_Server.NetcodePatcher; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 LethalKuchQOL.Lobby { [HarmonyPatch] public static class ControlTips { private enum Ctx { Line, Hover, Vote } private class Rule { public string Action; public string Kbm; public string Pad; public Rule(string a, string k, string p) { Action = a; Kbm = k; Pad = p; } } private static readonly Regex Token = new Regex("\\[\\s*([A-Za-z][A-Za-z0-9-]*)\\s*\\]", RegexOptions.Compiled); private static readonly Regex CtrlPath = new Regex("^<([A-Za-z0-9]+)>/([A-Za-z0-9/]+)$", RegexOptions.Compiled); private static readonly Regex BuildConfirm = new Regex("Confirm: \\[\\s*\\w+\\s*\\]", RegexOptions.Compiled); private static readonly Regex BuildStore = new Regex("Store: \\[\\s*\\w+\\s*\\]", RegexOptions.Compiled); private static readonly Rule ConfirmRule = new Rule("ConfirmBuildMode", "<Keyboard>/v", null); private static readonly Rule StoreRule = new Rule("Delete", "<Keyboard>/x", null); private static readonly Dictionary<string, Rule> LineRules = new Dictionary<string, Rule> { ["G"] = new Rule("Discard", "<Keyboard>/g", "<Gamepad>/buttonEast"), ["E"] = new Rule("QEItemInteract", "<Keyboard>/e", "<Gamepad>/dpad/up"), ["Q"] = new Rule("QEItemInteract", "<Keyboard>/q", "<Gamepad>/dpad/down"), ["LMB"] = new Rule("Use", "<Mouse>/leftButton", "<Gamepad>/rightTrigger"), ["RMB"] = new Rule("ActivateItem", "<Mouse>/leftButton", "<Gamepad>/rightTrigger"), ["TAB"] = new Rule("UseUtilitySlot", "<Keyboard>/tab", "<Gamepad>/leftShoulder"), ["START"] = new Rule("OpenMenu", "<Keyboard>/escape", "<Gamepad>/start"), ["R-TRIGGER"] = new Rule("PingScan", "<Mouse>/rightButton", "<Gamepad>/rightShoulder") }; private static readonly Dictionary<string, Rule> HoverRules = new Dictionary<string, Rule> { ["G"] = new Rule("Discard", "<Keyboard>/g", "<Gamepad>/buttonEast"), ["E"] = new Rule("Interact", "<Keyboard>/e", "<Gamepad>/buttonWest"), ["LMB"] = new Rule("Interact", "<Keyboard>/e", "<Gamepad>/buttonWest"), ["RMB"] = new Rule("PingScan", "<Mouse>/rightButton", "<Gamepad>/rightShoulder"), ["Q"] = new Rule("QEItemInteract", "<Keyboard>/q", "<Gamepad>/dpad/down"), ["TAB"] = new Rule("UseUtilitySlot", "<Keyboard>/tab", "<Gamepad>/leftShoulder"), ["START"] = new Rule("OpenMenu", "<Keyboard>/escape", "<Gamepad>/start"), ["R-TRIGGER"] = new Rule("PingScan", "<Mouse>/rightButton", "<Gamepad>/rightShoulder") }; private static readonly Dictionary<string, Rule> VoteRules = new Dictionary<string, Rule> { ["RMB"] = new Rule("PingScan", "<Mouse>/rightButton", "<Gamepad>/rightShoulder"), ["R-TRIGGER"] = new Rule("PingScan", "<Mouse>/rightButton", "<Gamepad>/rightShoulder") }; private static readonly Dictionary<string, string> MouseNames = new Dictionary<string, string> { ["leftButton"] = "LMB", ["rightButton"] = "RMB", ["middleButton"] = "MMB", ["forwardButton"] = "Mouse4", ["backButton"] = "Mouse5", ["scroll/up"] = "Scroll Up", ["scroll/down"] = "Scroll Down", ["scroll/y"] = "Scroll" }; private static readonly Dictionary<string, string> KeyNames = new Dictionary<string, string> { ["tab"] = "TAB", ["space"] = "SPACE", ["escape"] = "ESC", ["enter"] = "ENTER", ["leftShift"] = "LSHIFT", ["rightShift"] = "RSHIFT", ["leftCtrl"] = "LCTRL", ["rightCtrl"] = "RCTRL", ["leftAlt"] = "LALT", ["rightAlt"] = "RALT", ["upArrow"] = "UP", ["downArrow"] = "DOWN", ["leftArrow"] = "LEFT", ["rightArrow"] = "RIGHT", ["slash"] = "/", ["comma"] = ",", ["period"] = ".", ["semicolon"] = ";", ["quote"] = "'", ["backquote"] = "`", ["minus"] = "-", ["equals"] = "=", ["leftBracket"] = "[", ["rightBracket"] = "]", ["backslash"] = "\\", ["backspace"] = "BACKSPACE", ["capsLock"] = "CAPS", ["delete"] = "DEL", ["home"] = "HOME", ["end"] = "END", ["pageUp"] = "PGUP", ["pageDown"] = "PGDN", ["insert"] = "INS" }; private static readonly Dictionary<string, string> PadNames = new Dictionary<string, string> { ["buttonSouth"] = "A", ["buttonEast"] = "B", ["buttonWest"] = "X", ["buttonNorth"] = "Y", ["dpad/up"] = "D-pad up", ["dpad/down"] = "D-pad down", ["dpad/left"] = "D-pad left", ["dpad/right"] = "D-pad right", ["rightTrigger"] = "R-Trigger", ["leftTrigger"] = "L-Trigger", ["rightShoulder"] = "R-shoulder", ["leftShoulder"] = "L-shoulder", ["start"] = "Start", ["select"] = "Select", ["leftStickPress"] = "L-stick", ["rightStickPress"] = "R-stick" }; private static bool Pad { get { if ((Object)(object)StartOfRound.Instance != (Object)null) { return StartOfRound.Instance.localPlayerUsingController; } return false; } } private static string Replace(string text, Ctx ctx) { if (string.IsNullOrEmpty(text) || text.IndexOf('[') < 0) { return text; } Dictionary<string, Rule> rules = ctx switch { Ctx.Vote => VoteRules, Ctx.Hover => HoverRules, _ => LineRules, }; bool pad = Pad; return Token.Replace(text, delegate(Match m) { if (!rules.TryGetValue(m.Groups[1].Value.ToUpperInvariant(), out var value)) { return m.Value; } string text2 = Display(value, pad); return (text2 != null) ? ("[" + text2 + "]") : m.Value; }); } private static string Display(Rule rule, bool pad) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) try { InputActionAsset actions = InputSystem.actions; InputAction val = ((actions != null) ? actions.FindAction(rule.Action, false) : null); if (val == null) { return null; } string text = (pad ? rule.Pad : rule.Kbm); InputBinding? val2 = null; Enumerator<InputBinding> enumerator = val.bindings.GetEnumerator(); try { while (enumerator.MoveNext()) { InputBinding current = enumerator.Current; if (((InputBinding)(ref current)).isComposite) { continue; } string effectivePath = ((InputBinding)(ref current)).effectivePath; if (!string.IsNullOrEmpty(effectivePath) && !(effectivePath == "[Disabled]") && effectivePath.StartsWith("<Gamepad>", StringComparison.OrdinalIgnoreCase) == pad) { if (text != null && string.Equals(((InputBinding)(ref current)).path, text, StringComparison.OrdinalIgnoreCase)) { val2 = current; break; } if (!val2.HasValue) { val2 = current; } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } object result; if (!val2.HasValue) { result = null; } else { InputBinding value = val2.Value; result = Normalize(((InputBinding)(ref value)).effectivePath); } return (string)result; } catch { return null; } } private static string Normalize(string path) { if (string.IsNullOrEmpty(path)) { return null; } Match match = CtrlPath.Match(path); if (match.Success) { string value = match.Groups[1].Value; string value2 = match.Groups[2].Value; switch (value) { case "Mouse": { if (!MouseNames.TryGetValue(value2, out var value5)) { return null; } return value5; } case "Keyboard": { if (!KeyNames.TryGetValue(value2, out var value4)) { if (value2.Length != 1) { return null; } return value2.ToUpperInvariant(); } return value4; } case "Gamepad": { if (!PadNames.TryGetValue(value2, out var value3)) { return null; } return value3; } } } string text = InputControlPath.ToHumanReadableString(path, (HumanReadableStringOptions)2, (InputControl)null); if (!string.IsNullOrWhiteSpace(text)) { return text.Trim(); } return null; } [HarmonyPatch(typeof(HUDManager), "ChangeControlTipMultiple")] [HarmonyPrefix] private static void TipMulti(ref string[] allLines) { if (Cfg.ControlTips.Value && allLines != null) { string[] array = (string[])allLines.Clone(); for (int i = 0; i < array.Length; i++) { array[i] = Replace(array[i], Ctx.Line); } allLines = array; } } [HarmonyPatch(typeof(HUDManager), "ChangeControlTipMultiple")] [HarmonyPostfix] private static void TipMultiPost(bool holdingItem) { if (Cfg.ControlTips.Value && holdingItem) { TextMeshProUGUI[] array = HUDManager.Instance?.controlTipLines; if (array != null && array.Length != 0 && (Object)(object)array[0] != (Object)null) { ((TMP_Text)array[0]).text = Replace(((TMP_Text)array[0]).text, Ctx.Line); } } } [HarmonyPatch(typeof(HUDManager), "ChangeControlTip")] [HarmonyPrefix] private static void Tip(ref string changeTo) { if (Cfg.ControlTips.Value && changeTo != null) { changeTo = Replace(changeTo, Ctx.Line); } } [HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")] [HarmonyPostfix] private static void Hover(PlayerControllerB __instance) { if (Cfg.HoverTips.Value) { TextMeshProUGUI cursorTip = __instance.cursorTip; if ((Object)(object)cursorTip != (Object)null && !string.IsNullOrEmpty(((TMP_Text)cursorTip).text) && ((TMP_Text)cursorTip).text.IndexOf('[') >= 0) { ((TMP_Text)cursorTip).text = Replace(((TMP_Text)cursorTip).text, Ctx.Hover); } } } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] private static void HudUpdate(HUDManager __instance) { if (Cfg.VotingTips.Value) { Fix(__instance.holdButtonToEndGameEarlyText, Ctx.Vote); } } [HarmonyPatch(typeof(HUDManager), "DisplaySpectatorVoteTip")] [HarmonyPostfix] private static void SpectatorTip(HUDManager __instance) { if (Cfg.VotingTips.Value) { Fix(__instance.spectatorTipText, Ctx.Vote); } } private static void Fix(TextMeshProUGUI t, Ctx c) { if (!((Object)(object)t == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)t).text) && ((TMP_Text)t).text.IndexOf('[') >= 0) { string text = Replace(((TMP_Text)t).text, c); if (text != ((TMP_Text)t).text) { ((TMP_Text)t).text = text; } } } [HarmonyPatch(typeof(ShipBuildModeManager), "CreateGhostObjectAndHighlight")] [HarmonyPostfix] private static void BuildTip() { if (!Cfg.BuildModeTips.Value || Pad) { return; } TextMeshProUGUI val = HUDManager.Instance?.buildModeControlTip; if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)val).text)) { string text = ((TMP_Text)val).text; string text2 = Display(ConfirmRule, pad: false); if (text2 != null) { text = BuildConfirm.Replace(text, "Confirm: [" + text2 + "]"); } string text3 = Display(StoreRule, pad: false); if (text3 != null) { text = BuildStore.Replace(text, "Store: [" + text3 + "]"); } if (text != ((TMP_Text)val).text) { ((TMP_Text)val).text = text; } } } [HarmonyPatch(typeof(IngamePlayerSettings), "UpdateGameToMatchSettings")] [HarmonyPostfix] private static void RefreshAfterRebind() { if (Cfg.ControlTips.Value) { PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if ((Object)(object)val != (Object)null && (Object)(object)val.currentlyHeldObjectServer != (Object)null) { val.currentlyHeldObjectServer.SetControlTipsForItem(); } } } } [HarmonyPatch(typeof(ItemDropship), "Update")] public static class FastDelivery { private static readonly FieldRef<ItemDropship, Terminal> TerminalRef = AccessTools.FieldRefAccess<ItemDropship, Terminal>("terminalScript"); [HarmonyPrefix] private static void Prefix(ItemDropship __instance) { if (Plugin.CfgDeliverySeconds.Value >= 40f || !((NetworkBehaviour)__instance).IsServer || __instance.deliveringOrder) { return; } Terminal val = TerminalRef.Invoke(__instance); if (!((Object)(object)val == (Object)null) && (val.orderedItemsFromTerminal.Count > 0 || val.orderedVehicleFromTerminal != -1) && !((Object)(object)StartOfRound.Instance == (Object)null) && StartOfRound.Instance.shipHasLanded) { float num = 40f - Plugin.CfgDeliverySeconds.Value; if (__instance.shipTimer < num) { __instance.shipTimer = num; } __instance.playersFirstOrder = false; } } } [HarmonyPatch] public static class FlashlightToggle { [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] private static void Clear(PlayerControllerB __instance) { if (Cfg.FlashlightToggle.Value) { __instance.pocketedFlashlight = null; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void ReadInput(PlayerControllerB __instance) { if (!Cfg.FlashlightToggle.Value || ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer) || __instance.inTerminalMenu || __instance.isTypingChat || !Application.isFocused) { return; } if (__instance.currentlyHeldObjectServer is FlashlightItem && (Object)(object)__instance.currentlyHeldObjectServer != (Object)(object)__instance.pocketedFlashlight) { __instance.pocketedFlashlight = __instance.currentlyHeldObjectServer; } if (LobbyPanel.IsOpen) { return; } GrabbableObject pocketedFlashlight = __instance.pocketedFlashlight; FlashlightItem val = (FlashlightItem)(object)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null); if (val == null || !((GrabbableObject)val).isHeld || !KeyInput.Pressed(Cfg.KeyFlashlight)) { return; } try { ((GrabbableObject)val).UseItemOnClient(true); if (!(__instance.currentlyHeldObjectServer is FlashlightItem)) { ((Behaviour)val.flashlightBulbGlow).enabled = false; ((Behaviour)val.flashlightBulb).enabled = false; bool isBeingUsed = ((GrabbableObject)val).isBeingUsed; ((Behaviour)__instance.helmetLight).enabled = isBeingUsed; val.usingPlayerHelmetLight = isBeingUsed; val.PocketFlashlightServerRpc(isBeingUsed); } } catch { } } } public static class KeyInput { private static readonly Dictionary<string, Key> cache = new Dictionary<string, Key>(); public static Key Resolve(string name) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(name) || name == "None") { return (Key)0; } if (cache.TryGetValue(name, out var value)) { return value; } value = (Key)(Enum.TryParse<Key>(name, ignoreCase: true, out Key result) ? ((int)result) : 0); cache[name] = value; return value; } public static bool Pressed(ConfigEntry<string> bind) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null) { return false; } Key val = Resolve(bind.Value); if ((int)val != 0) { return ((ButtonControl)current[val]).wasPressedThisFrame; } return false; } public static Key AnyPressed() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current.anyKey).wasPressedThisFrame) { Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyControl current2 = enumerator.Current; if (((ButtonControl)current2).wasPressedThisFrame) { return current2.keyCode; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return (Key)0; } return (Key)0; } public unsafe static string Pretty(string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Key val = Resolve(name); if ((int)val == 0) { return "unbound"; } string text = ((object)(*(Key*)(&val))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Digit")) { return text.Substring(5); } if (text.StartsWith("Numpad")) { return "Num " + text.Substring(6); } return text; } } public class KuchNet : NetworkBehaviour { public static KuchNet Instance { get; private set; } public override void OnNetworkSpawn() { if (!((Component)this).gameObject.activeSelf) { ((Component)this).gameObject.SetActive(true); } Instance = this; Plugin.Log.LogInfo((object)("KuchNet ready (" + (((NetworkBehaviour)this).IsServer ? "host" : "client") + ").")); ((NetworkBehaviour)this).OnNetworkSpawn(); } public override void OnNetworkDespawn() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } ((NetworkBehaviour)this).OnNetworkDespawn(); } public void RequestSell(List<GrabbableObject> items) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) NetworkObjectReference[] array = (from g in items where (Object)(object)g != (Object)null select ((Component)g).GetComponent<NetworkObject>() into n where (Object)(object)n != (Object)null select n).Select((Func<NetworkObject, NetworkObjectReference>)((NetworkObject n) => new NetworkObjectReference(n))).ToArray(); if (array.Length != 0) { SellServerRpc(array); } } [ServerRpc(RequireOwnership = false)] private void SellServerRpc(NetworkObjectReference[] refs, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1458917724u, rpc, (RpcDelivery)0); bool flag = refs != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(refs, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val, 1458917724u, rpc, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = rpc.Receive.SenderClientId; Plugin.Log.LogInfo((object)$"Sell request from client {senderClientId}: {refs.Length} items"); DepositItemsDesk val2 = Object.FindObjectOfType<DepositItemsDesk>(); if ((Object)(object)val2 == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.inShipPhase) { Plugin.Log.LogWarning((object)$"Sell aborted: desk={(Object)(object)val2 != (Object)null} inShipPhase={StartOfRound.Instance?.inShipPhase}"); return; } List<GrabbableObject> list = new List<GrabbableObject>(); NetworkObject val4 = default(NetworkObject); for (int i = 0; i < refs.Length; i++) { NetworkObjectReference val3 = refs[i]; if (((NetworkObjectReference)(ref val3)).TryGet(ref val4, (NetworkManager)null)) { GrabbableObject componentInChildren = ((Component)val4).GetComponentInChildren<GrabbableObject>(); if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.isHeld && componentInChildren.itemProperties.isScrap) { list.Add(componentInChildren); } } } if (list.Count == 0) { Plugin.Log.LogWarning((object)"Sell aborted: none of the items could be resolved on the host"); } else { ((MonoBehaviour)this).StartCoroutine(SellRoutine(val2, list, refs, senderClientId)); } } private IEnumerator SellRoutine(DepositItemsDesk desk, List<GrabbableObject> items, NetworkObjectReference[] refs, ulong sender) { HideItemsClientRpc(refs); int value = (int)((float)items.Sum((GrabbableObject g) => g.scrapValue) * StartOfRound.Instance.companyBuyingRate); foreach (GrabbableObject item in items) { NetworkObject component = ((Component)item).GetComponent<NetworkObject>(); if (!((Object)(object)component == (Object)null) && !desk.itemsOnCounter.Contains(item)) { desk.itemsOnCounter.Add(item); desk.itemsOnCounterNetworkObjects.Add(component); desk.AddObjectToDeskClientRpc(NetworkObjectReference.op_Implicit(component)); } } int creditsBefore = Object.FindObjectOfType<Terminal>().groupCredits; Plugin.Log.LogInfo((object)$"Placed {items.Count} items on the desk (counter now {desk.itemsOnCounter.Count}), selling for ~${value}"); yield return (object)new WaitForSeconds(0.5f); desk.SellItemsOnServer(); Plugin.Log.LogInfo((object)$"Sold. Credits {creditsBefore} -> {Object.FindObjectOfType<Terminal>().groupCredits}"); PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.actualClientId == sender)); AnnounceClientRpc(((Object)(object)val != (Object)null) ? val.playerUsername : "Someone", items.Count, value); } [ClientRpc] private void HideItemsClientRpc(NetworkObjectReference[] refs) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_017c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(755129494u, val2, (RpcDelivery)0); bool flag = refs != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(refs, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 755129494u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; DepositItemsDesk val3 = Object.FindObjectOfType<DepositItemsDesk>(); if ((Object)(object)val3 == (Object)null) { return; } NetworkObject val5 = default(NetworkObject); for (int i = 0; i < refs.Length; i++) { NetworkObjectReference val4 = refs[i]; if (((NetworkObjectReference)(ref val4)).TryGet(ref val5, (NetworkManager)null)) { GrabbableObject componentInChildren = ((Component)val5).GetComponentInChildren<GrabbableObject>(); if (!((Object)(object)componentInChildren == (Object)null)) { componentInChildren.EnablePhysics(false); componentInChildren.EnableItemMeshes(false); ((Component)componentInChildren).transform.SetParent(((Component)val3.deskObjectsContainer).transform); ((Component)componentInChildren).transform.localPosition = Vector3.zero; } } } } [ClientRpc] private void AnnounceClientRpc(string who, int count, int value) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4231591934u, val2, (RpcDelivery)0); bool flag = who != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(who, false); } BytePacker.WriteValueBitPacked(val, count); BytePacker.WriteValueBitPacked(val, value); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 4231591934u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Scrap sold", $"{who} sold {count} items for ${value}.", false, false, "LC_Tip1"); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1458917724u, new RpcReceiveHandler(__rpc_handler_1458917724), "SellServerRpc"); ((NetworkBehaviour)this).__registerRpc(755129494u, new RpcReceiveHandler(__rpc_handler_755129494), "HideItemsClientRpc"); ((NetworkBehaviour)this).__registerRpc(4231591934u, new RpcReceiveHandler(__rpc_handler_4231591934), "AnnounceClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1458917724(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); NetworkObjectReference[] refs = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref refs, default(ForNetworkSerializable)); } ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((KuchNet)(object)target).SellServerRpc(refs, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_755129494(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); NetworkObjectReference[] refs = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref refs, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((KuchNet)(object)target).HideItemsClientRpc(refs); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4231591934(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string who = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref who, false); } int count = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref count); int value = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref value); target.__rpc_exec_stage = (__RpcExecStage)1; ((KuchNet)(object)target).AnnounceClientRpc(who, count, value); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "KuchNet"; } } public class LobbyPanel : MonoBehaviour { private static readonly string[] Tabs = new string[2] { "Controls", "Server" }; private int tab; private Vector2 scroll; private GUIStyle panel; private GUIStyle title; private GUIStyle label; private GUIStyle hint; private GUIStyle section; private GUIStyle tabOn; private GUIStyle tabOff; private GUIStyle on; private GUIStyle off; private GUIStyle keyOn; private GUIStyle keyOff; private bool styled; private CursorLockMode prevLock; private ConfigEntry<string> capturing; public static bool IsOpen { get; private set; } private static int MenusOpen { get { object data = AppDomain.CurrentDomain.GetData("KuchQOL.MenusOpen"); if (data is int) { return (int)data; } return 0; } set { AppDomain.CurrentDomain.SetData("KuchQOL.MenusOpen", value); } } private unsafe void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 if (capturing != null) { Key val = KeyInput.AnyPressed(); if ((int)val != 0) { if ((int)val != 60) { capturing.Value = (((int)val == 65) ? "None" : ((object)(*(Key*)(&val))/*cast due to .constrained prefix*/).ToString()); } capturing = null; } } else { Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current.f10Key).wasPressedThisFrame) { SetOpen(!IsOpen); } } } private void SetOpen(bool o) { IsOpen = o; capturing = null; PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (o) { MenusOpen++; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)val != (Object)null) { val.disableLookInput = true; } return; } MenusOpen = Mathf.Max(0, MenusOpen - 1); if (MenusOpen == 0 && (Object)(object)val != (Object)null) { val.disableLookInput = false; if (!val.quickMenuManager.isMenuOpen && !val.inTerminalMenu && !val.inSpecialMenu && !val.isTypingChat) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } Plugin.Save(); } private void LateUpdate() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { if ((int)Cursor.lockState != 0) { Cursor.lockState = (CursorLockMode)0; } if (!Cursor.visible) { Cursor.visible = true; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val != (Object)null && !val.disableLookInput) { val.disableLookInput = true; } } } private static Texture2D Solid(Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, c); val.Apply(); return val; } private void Style() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00c9: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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_0276: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Expected O, but got Unknown //IL_035a: 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_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_038a: 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_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Expected O, but got Unknown //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Expected O, but got Unknown if (!styled) { styled = true; Texture2D background = Solid(new Color(0.45f, 0.75f, 1f)); Texture2D background2 = Solid(new Color(0.22f, 0.25f, 0.3f)); Texture2D background3 = Solid(new Color(0.14f, 0.19f, 0.25f)); Texture2D background4 = Solid(new Color(0.08f, 0.11f, 0.14f)); GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.background = Solid(new Color(0.06f, 0.09f, 0.12f, 0.96f)); val.padding = new RectOffset(18, 18, 14, 14); panel = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 20, fontStyle = (FontStyle)1 }; val2.normal.textColor = new Color(0.45f, 0.75f, 1f); title = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 14, alignment = (TextAnchor)3 }; val3.normal.textColor = new Color(0.92f, 0.94f, 0.97f); label = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 11, wordWrap = true }; val4.normal.textColor = new Color(0.55f, 0.62f, 0.7f); hint = val4; GUIStyle val5 = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)1, margin = new RectOffset(0, 0, 10, 2) }; val5.normal.textColor = new Color(0.6f, 0.68f, 0.78f); section = val5; GUIStyle val6 = new GUIStyle(GUI.skin.button) { fontSize = 14, fontStyle = (FontStyle)1, fixedHeight = 30f }; val6.normal.background = background3; val6.normal.textColor = new Color(0.45f, 0.75f, 1f); val6.hover.background = background3; val6.hover.textColor = new Color(0.45f, 0.75f, 1f); val6.active.background = background3; tabOn = val6; GUIStyle val7 = new GUIStyle(tabOn) { fontStyle = (FontStyle)0 }; val7.normal.background = background4; val7.normal.textColor = new Color(0.7f, 0.74f, 0.8f); val7.hover.background = background3; val7.hover.textColor = Color.white; tabOff = val7; GUIStyle val8 = new GUIStyle(GUI.skin.button) { fixedWidth = 54f, fixedHeight = 24f, fontSize = 11, fontStyle = (FontStyle)1 }; val8.normal.background = background; val8.normal.textColor = Color.black; val8.hover.background = background; val8.hover.textColor = Color.black; val8.active.background = background; on = val8; GUIStyle val9 = new GUIStyle(on); val9.normal.background = background2; val9.normal.textColor = new Color(0.85f, 0.85f, 0.9f); val9.hover.background = background2; val9.hover.textColor = Color.white; val9.active.background = background2; off = val9; keyOn = new GUIStyle(on) { fixedWidth = 130f, fontSize = 12 }; keyOff = new GUIStyle(off) { fixedWidth = 130f, fontSize = 12 }; } } private void OnGUI() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } Style(); float num = 520f; float num2 = 560f; Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2); GUI.Box(val, GUIContent.none, panel); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 14f, num - 36f, num2 - 28f)); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("KuchQOL", title, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label("v1.5.1 F10 to close", hint, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < Tabs.Length; i++) { if (GUILayout.Button(Tabs[i], (i == tab) ? tabOn : tabOff, Array.Empty<GUILayoutOption>())) { if (tab != i) { scroll = Vector2.zero; } tab = i; } } GUILayout.EndHorizontal(); GUILayout.Space(8f); scroll = GUILayout.BeginScrollView(scroll, false, false, Array.Empty<GUILayoutOption>()); if (tab == 0) { Controls(); } else { ServerTab(); } GUILayout.EndScrollView(); GUILayout.EndArea(); } private void Controls() { GUILayout.Label("HOTKEYS", section, Array.Empty<GUILayoutOption>()); Toggle(Cfg.SlotHotkeys, "Item slot hotkeys", "Jump straight to an inventory slot."); Toggle(Cfg.FlashlightToggle, "Flashlight toggle key", "Toggle a pocketed flashlight."); GUILayout.Label("KEYBINDS (click, then press a key. Esc cancels, Backspace unbinds)", section, Array.Empty<GUILayoutOption>()); KeyRow(Cfg.KeySlot1, "Item slot 1"); KeyRow(Cfg.KeySlot2, "Item slot 2"); KeyRow(Cfg.KeySlot3, "Item slot 3"); KeyRow(Cfg.KeySlot4, "Item slot 4"); KeyRow(Cfg.KeyFlashlight, "Flashlight"); GUILayout.Label("CONTROL TIPS", section, Array.Empty<GUILayoutOption>()); Toggle(Cfg.ControlTips, "Control tip lines", "Bottom-left tips show your real binds."); Toggle(Cfg.HoverTips, "Hover prompts", "Crosshair prompts like Grab : [E]."); Toggle(Cfg.VotingTips, "Vote prompts", "Leave-early and spectator vote prompts."); Toggle(Cfg.BuildModeTips, "Build mode prompt", "Confirm / Store keys in ship build mode."); } private void ServerTab() { NetworkManager singleton = NetworkManager.Singleton; KuchNet instance = KuchNet.Instance; bool flag = (Object)(object)singleton != (Object)null && singleton.IsListening; bool flag2 = flag && singleton.IsHost; string obj = ((!flag) ? "Not in a lobby" : ((!((Object)(object)instance == (Object)null)) ? (flag2 ? "Synced. You are the host." : "Synced with host.") : (flag2 ? "Starting..." : "Host does not have KuchQOL"))); GUILayout.Label("STATUS", section, Array.Empty<GUILayoutOption>()); GUILayout.Label(obj, label, Array.Empty<GUILayoutOption>()); bool flag3 = flag2 || !flag; GUILayout.Label(flag3 ? "ITEM DELIVERY" : "ITEM DELIVERY (set by the host)", section, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Label("Delivery time", label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); GUI.enabled = flag3; float num = Mathf.Round(GUILayout.HorizontalSlider(Plugin.CfgDeliverySeconds.Value, 0f, 40f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) })); GUI.enabled = true; GUILayout.Label((num >= 40f) ? "40 s (vanilla)" : (num + " s"), label, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); if (flag3 && !Mathf.Approximately(num, Plugin.CfgDeliverySeconds.Value)) { Plugin.CfgDeliverySeconds.Value = num; } GUILayout.Label("SELLING", section, Array.Empty<GUILayoutOption>()); GUILayout.Label("At the Company, type SELL in the terminal: sell <amount>, sell quota, sell all, sell list, then CONFIRM. Anyone in the lobby can sell and everyone sees what was sold.", hint, Array.Empty<GUILayoutOption>()); GUILayout.Label("SUITS", section, Array.Empty<GUILayoutOption>()); GUILayout.Label("8 extra colored suits hang on the ship's suit rack for everyone.", hint, Array.Empty<GUILayoutOption>()); } private void Toggle(ConfigEntry<bool> e, string name, string desc) { GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label(name, label, Array.Empty<GUILayoutOption>()); GUILayout.Label(desc, hint, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); if (GUILayout.Button(e.Value ? "ON" : "OFF", e.Value ? on : off, Array.Empty<GUILayoutOption>())) { e.Value = !e.Value; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } private void KeyRow(ConfigEntry<string> e, string name) { GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.Label(name, label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); GUILayout.FlexibleSpace(); bool flag = capturing == e; if (GUILayout.Button(flag ? "press a key..." : KeyInput.Pretty(e.Value), flag ? keyOn : keyOff, Array.Empty<GUILayoutOption>())) { capturing = (flag ? null : e); } GUILayout.EndHorizontal(); } } public static class Cfg { public static ConfigEntry<bool> SlotHotkeys; public static ConfigEntry<bool> FlashlightToggle; public static ConfigEntry<bool> ControlTips; public static ConfigEntry<bool> HoverTips; public static ConfigEntry<bool> VotingTips; public static ConfigEntry<bool> BuildModeTips; public static ConfigEntry<string> KeySlot1; public static ConfigEntry<string> KeySlot2; public static ConfigEntry<string> KeySlot3; public static ConfigEntry<string> KeySlot4; public static ConfigEntry<string> KeyFlashlight; public static ConfigEntry<string> DontSellList; public static void Bind(ConfigFile c) { SlotHotkeys = c.Bind<bool>("Controls", "SlotHotkeys", false, "Number keys jump straight to item slots."); FlashlightToggle = c.Bind<bool>("Controls", "FlashlightToggle", false, "Toggle a pocketed flashlight with a key."); KeySlot1 = c.Bind<string>("Keys", "Slot1", "Digit1", "Unity InputSystem Key name. Rebind in the F10 menu."); KeySlot2 = c.Bind<string>("Keys", "Slot2", "Digit2", ""); KeySlot3 = c.Bind<string>("Keys", "Slot3", "Digit3", ""); KeySlot4 = c.Bind<string>("Keys", "Slot4", "Digit4", ""); KeyFlashlight = c.Bind<string>("Keys", "Flashlight", "F", ""); ControlTips = c.Bind<bool>("ControlTips", "ControlTipLines", false, "Bottom-left control tips show your real binds."); HoverTips = c.Bind<bool>("ControlTips", "HoverPrompts", false, "Crosshair prompts (Grab : [E]) show your real binds."); VotingTips = c.Bind<bool>("ControlTips", "VotingTips", false, "Leave-early / spectator vote prompts show your real binds."); BuildModeTips = c.Bind<bool>("ControlTips", "BuildModeTip", false, "Ship build-mode prompt shows your real binds."); DontSellList = c.Bind<string>("Selling", "DontSell", "", "Comma-separated item names the sell commands never pick."); } } [BepInPlugin("ishred.LethalKuchServer", "KuchQOL_Server", "1.5.1")] public class Plugin : BaseUnityPlugin { [HarmonyPatch] private static class Patches { [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void RegisterPrefab() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (!((Object)(object)Prefab != (Object)null)) { GameObject val = new GameObject("ishred.LethalKuchServer Prefabs"); val.SetActive(false); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); Prefab = new GameObject("ishred.LethalKuchServer Prefab"); ((Object)Prefab).hideFlags = (HideFlags)61; Prefab.transform.SetParent(val.transform); NetworkObject obj = Prefab.AddComponent<NetworkObject>(); typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, Hash("ishred.LethalKuchServer")); Prefab.AddComponent<KuchNet>(); NetworkManager.Singleton.AddNetworkPrefab(Prefab); Log.LogInfo((object)"Network prefab registered."); } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void SpawnOnHost() { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsHost && !((Object)(object)Prefab == (Object)null)) { Object.Instantiate<GameObject>(Prefab).GetComponent<NetworkObject>().Spawn(false); Log.LogInfo((object)"KuchNet spawned by host."); } } } public const string GUID = "ishred.LethalKuchServer"; public const string NAME = "KuchQOL_Server"; public const string VERSION = "1.5.1"; internal static ManualLogSource Log; internal static GameObject Prefab; internal static ConfigEntry<float> CfgDeliverySeconds; private static Plugin inst; internal static void Save() { Plugin plugin = inst; if (plugin != null) { ((BaseUnityPlugin)plugin).Config.Save(); } } private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0063: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) inst = this; Log = ((BaseUnityPlugin)this).Logger; CfgDeliverySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Host", "DeliveryTime", 40f, new ConfigDescription("Host only: seconds of landed time before the item dropship arrives. 40 = vanilla (first order 20).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 40f), Array.Empty<object>())); Cfg.Bind(((BaseUnityPlugin)this).Config); NetcodeInit(); Harmony val = new Harmony("ishred.LethalKuchServer"); val.PatchAll(typeof(Patches)); val.PatchAll(typeof(FastDelivery)); val.PatchAll(typeof(SuitColors)); val.PatchAll(typeof(FlashlightToggle)); val.PatchAll(typeof(ControlTips)); val.PatchAll(typeof(SellCommands)); GameObject val2 = new GameObject("KuchQOL Server"); Object.DontDestroyOnLoad((Object)val2); ((Object)val2).hideFlags = (HideFlags)61; val2.AddComponent<SlotHotkeys>(); val2.AddComponent<LobbyPanel>(); val2.AddComponent<ConfigLiveReload>().Init(((BaseUnityPlugin)this).Config, Log); Log.LogInfo((object)"KuchQOL_Server 1.5.1 loaded. F10 opens the menu."); } private static void NetcodeInit() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } private static uint Hash(string s) { return s.Aggregate(17u, (uint c, char ch) => (c * 31) ^ ch); } } public class ConfigLiveReload : MonoBehaviour { private ConfigFile cfg; private ManualLogSource log; private FileSystemWatcher watcher; private volatile bool changed; private float changedAt; private string lastSeen; public void Init(ConfigFile c, ManualLogSource l) { cfg = c; log = l; try { lastSeen = File.ReadAllText(c.ConfigFilePath); } catch { } try { watcher = new FileSystemWatcher(Path.GetDirectoryName(c.ConfigFilePath), Path.GetFileName(c.ConfigFilePath)) { NotifyFilter = (NotifyFilters.Size | NotifyFilters.LastWrite), EnableRaisingEvents = true }; watcher.Changed += delegate { changed = true; }; } catch (Exception ex) { log.LogWarning((object)("Live config reload unavailable: " + ex.Message)); } } private void Update() { if (!changed) { return; } if (changedAt == 0f) { changedAt = Time.unscaledTime; } else { if (Time.unscaledTime - changedAt < 0.5f) { return; } changed = false; changedAt = 0f; if (LobbyPanel.IsOpen) { return; } try { string text = File.ReadAllText(cfg.ConfigFilePath); if (!(text == lastSeen)) { lastSeen = text; bool saveOnConfigSet = cfg.SaveOnConfigSet; cfg.SaveOnConfigSet = false; try { cfg.Reload(); } finally { cfg.SaveOnConfigSet = saveOnConfigSet; } log.LogInfo((object)"Config file changed, settings reloaded."); } } catch (Exception ex) { log.LogWarning((object)("Config reload failed: " + ex.Message)); } } } private void OnDestroy() { watcher?.Dispose(); } } [HarmonyPatch] public static class SellCommands { private static List<GrabbableObject> pending; private static float Rate => StartOfRound.Instance.companyBuyingRate; private static string[] DontSell => (from s in Cfg.DontSellList.Value.Split(',') select s.Trim() into s where s.Length > 0 select s).ToArray(); private static TerminalNode Node(string msg) { TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>(); obj.displayText = msg; obj.clearPreviousText = true; obj.maxCharactersToType = 50; return obj; } private static int Real(int v) { return (int)((float)v * Rate); } [HarmonyPatch(typeof(Terminal), "QuitTerminal")] [HarmonyPostfix] private static void OnQuit() { pending = null; } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool Parse(Terminal __instance, ref TerminalNode __result) { string text = __instance.screenText.text; string[] array = text.Substring(Mathf.Max(0, text.Length - __instance.textAdded)).Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { return true; } if (pending != null) { string value = array[0].ToLowerInvariant(); if ("confirm".StartsWith(value)) { __result = Confirm(); return false; } if ("deny".StartsWith(value)) { pending = null; __result = Node("Sell request cancelled.\n\n"); return false; } pending = null; return true; } if (!array[0].Equals("sell", StringComparison.OrdinalIgnoreCase)) { return true; } try { __result = Run(array.Skip(1).ToArray()); } catch (Exception ex) { Plugin.Log.LogError((object)ex); __result = Node("Sell command failed: " + ex.Message + "\n\n"); } return false; } private static TerminalNode Run(string[] a) { if (a.Length == 0 || a[0].Equals("help", StringComparison.OrdinalIgnoreCase)) { return Node("KuchQOL Client selling\n\n>SELL <amount>\nSell scrap worth at least <amount>.\n\n>SELL QUOTA\nSell just enough to meet the quota.\n\n>SELL ALL\nSell every scrap item on the ship.\n\n>SELL LIST\nShow sellable scrap on the ship.\n\n"); } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.inShipPhase) { return Node("You must be landed at The Company to sell.\n\n"); } if ((Object)(object)Object.FindObjectOfType<DepositItemsDesk>() == (Object)null) { return Node("You cannot sell on this moon.\n\n"); } List<GrabbableObject> list = ShipScrap(); if (a[0].Equals("list", StringComparison.OrdinalIgnoreCase)) { return Node($"Sellable scrap on ship: {list.Count} items, ${Real(list.Sum((GrabbableObject g) => g.scrapValue))} at {(int)(Rate * 100f)}%\n\n{ItemList(list)}\n\n"); } if (!NetworkManager.Singleton.IsHost && (Object)(object)KuchNet.Instance == (Object)null) { return Node("Lobby sync is not active yet. Try again in a moment.\n\n"); } if (list.Count == 0) { return Node("No sellable scrap found on the ship.\n\n"); } int result; if (a[0].Equals("all", StringComparison.OrdinalIgnoreCase)) { result = int.MaxValue; } else if (a[0].Equals("quota", StringComparison.OrdinalIgnoreCase)) { result = TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled; if (result <= 0) { return Node("Quota already fulfilled.\n\n"); } } else if (!int.TryParse(a[0], out result) || result <= 0) { return Node("Usage: sell <amount> | sell quota | sell all | sell list\n\n"); } List<GrabbableObject> list2 = ((result == int.MaxValue) ? list : Pick(list, result)); int num = Real(list2.Sum((GrabbableObject g) => g.scrapValue)); pending = list2; StringBuilder stringBuilder = new StringBuilder(); string arg = ((result == int.MaxValue || num >= result) ? "green" : "red"); stringBuilder.AppendLine($"Found {list2.Count} items worth <color={arg}>${num}</color>"); if (result != int.MaxValue) { stringBuilder.AppendLine($"Requested: ${result}"); } stringBuilder.AppendLine($"The Company is buying at {(int)(Rate * 100f)}%\n"); stringBuilder.AppendLine(ItemList(list2) + "\n"); stringBuilder.AppendLine("Please CONFIRM or DENY.\n\n"); return Node(stringBuilder.ToString()); } private static TerminalNode Confirm() { List<GrabbableObject> list = pending; pending = null; DepositItemsDesk val = Object.FindObjectOfType<DepositItemsDesk>(); if ((Object)(object)val == (Object)null || list == null) { return Node("Nothing to sell.\n\n"); } list = list.Where((GrabbableObject g) => (Object)(object)g != (Object)null && !g.isHeld).ToList(); if (list.Count == 0) { return Node("Items are gone.\n\n"); } Plugin.Log.LogInfo((object)string.Format("Sell confirmed: {0} items, path={1}", list.Count, ((Object)(object)KuchNet.Instance != (Object)null) ? "server mod" : "host-only")); if ((Object)(object)KuchNet.Instance != (Object)null) { KuchNet.Instance.RequestSell(list); } else { if (!NetworkManager.Singleton.IsHost) { return Node("Only the host can sell without KuchQOL Server.\n\n"); } ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(SellRoutine(val, list)); } return Node($"Selling {list.Count} items for ${Real(list.Sum((GrabbableObject g) => g.scrapValue))}...\n\n"); } private static IEnumerator SellRoutine(DepositItemsDesk desk, List<GrabbableObject> items) { foreach (GrabbableObject item in items) { NetworkObject component = ((Component)item).GetComponent<NetworkObject>(); if (!((Object)(object)component == (Object)null)) { item.EnablePhysics(false); item.EnableItemMeshes(false); ((Component)item).transform.SetParent(((Component)desk.deskObjectsContainer).transform); ((Component)item).transform.localPosition = Vector3.zero; if (!desk.itemsOnCounter.Contains(item)) { desk.itemsOnCounter.Add(item); desk.itemsOnCounterNetworkObjects.Add(component); desk.AddObjectToDeskClientRpc(NetworkObjectReference.op_Implicit(component)); } } } Plugin.Log.LogInfo((object)$"Host-only sell: {items.Count} items on desk (counter {desk.itemsOnCounter.Count})"); yield return (object)new WaitForSeconds(0.5f); desk.SellItemsOnServer(); } private static List<GrabbableObject> ShipScrap() { List<GrabbableObject> list = new List<GrabbableObject>(((Component)StartOfRound.Instance.elevatorTransform).GetComponentsInChildren<GrabbableObject>()); AutoParentToShip[] array = Object.FindObjectsByType<AutoParentToShip>((FindObjectsSortMode)0); foreach (AutoParentToShip val in array) { if ((Object)(object)((Component)val).transform.parent == (Object)null) { list.AddRange(((Component)val).GetComponentsInChildren<GrabbableObject>()); } } string[] ban = DontSell; return (from g in list.Distinct() where (Object)(object)g != (Object)null && (Object)(object)g.itemProperties != (Object)null && g.itemProperties.isScrap && !g.isHeld && g.grabbable && g.scrapValue > 0 && !ban.Any((string b) => b.Equals(g.itemProperties.itemName, StringComparison.OrdinalIgnoreCase)) select g).ToList(); } private static List<GrabbableObject> Pick(List<GrabbableObject> scrap, int target) { int num = scrap.Sum((GrabbableObject g) => g.scrapValue); if (Real(num) < target) { return scrap; } int[] array = new int[num + 1]; array[0] = -1; for (int num2 = 0; num2 < scrap.Count; num2++) { int scrapValue = scrap[num2].scrapValue; for (int num3 = num; num3 >= scrapValue; num3--) { if (array[num3] == 0 && array[num3 - scrapValue] != 0) { array[num3] = num2 + 1; } } } int num4 = num; for (int num5 = 0; num5 <= num; num5++) { if (array[num5] != 0 && Real(num5) >= target) { num4 = num5; break; } } List<GrabbableObject> list = new List<GrabbableObject>(); int num6 = num4; while (num6 > 0) { int index = array[num6] - 1; list.Add(scrap[index]); num6 -= scrap[index].scrapValue; } return list; } private static string ItemList(List<GrabbableObject> items) { return string.Join("\n", from g in items group g by g.itemProperties.itemName into gr orderby gr.Sum((GrabbableObject x) => x.scrapValue) descending select string.Format("{0}{1}: ${2}", gr.Key, (gr.Count() > 1) ? $" x{gr.Count()}" : "", Real(gr.Sum((GrabbableObject x) => x.scrapValue)))); } } public class SlotHotkeys : MonoBehaviour { private static readonly MethodInfo SwitchToItemSlot = AccessTools.Method(typeof(PlayerControllerB), "SwitchToItemSlot", (Type[])null, (Type[])null); private static readonly MethodInfo SwitchItemSlotsServerRpc = AccessTools.Method(typeof(PlayerControllerB), "SwitchItemSlotsServerRpc", (Type[])null, (Type[])null); private static readonly FieldInfo TimeSinceSwitchingSlots = AccessTools.Field(typeof(PlayerControllerB), "timeSinceSwitchingSlots"); private static readonly FieldInfo ThrowingObject = AccessTools.Field(typeof(PlayerControllerB), "throwingObject"); private void Update() { if (Cfg.SlotHotkeys.Value && !LobbyPanel.IsOpen && Application.isFocused) { if (KeyInput.Pressed(Cfg.KeySlot1)) { Select(0); } else if (KeyInput.Pressed(Cfg.KeySlot2)) { Select(1); } else if (KeyInput.Pressed(Cfg.KeySlot3)) { Select(2); } else if (KeyInput.Pressed(Cfg.KeySlot4)) { Select(3); } } } private static void Select(int target) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || target < 0 || target >= val.ItemSlots.Length || ((!((NetworkBehaviour)val).IsOwner || !val.isPlayerControlled || (((NetworkBehaviour)val).IsServer && !val.isHostPlayerObject)) && !val.isTestingPlayer) || (float)TimeSinceSwitchingSlots.GetValue(val) < 0.3f || val.isGrabbingObjectAnimation || val.quickMenuManager.isMenuOpen || val.inSpecialInteractAnimation || (bool)ThrowingObject.GetValue(val) || val.isTypingChat || val.twoHanded || val.activatingItem || val.inTerminalMenu || ((val.jetpackControls || val.disablingJetpackControls) && (Object)(object)val.currentlyHeldObjectServer != (Object)null && val.currentlyHeldObjectServer.itemProperties.itemId == 13)) { return; } int currentItemSlot = val.currentItemSlot; int num = val.ItemSlots.Length; if (currentItemSlot != target) { int num2 = ((target - currentItemSlot) % num + num) % num; int num3 = num - num2; bool flag = num2 <= num3; int num4 = (flag ? num2 : num3); ShipBuildModeManager.Instance.CancelBuildMode(true); val.playerBodyAnimator.SetBool("GrabValidated", false); SwitchToItemSlot.Invoke(val, new object[2] { target, null }); for (int i = 0; i < num4; i++) { SwitchItemSlotsServerRpc.Invoke(val, new object[1] { flag }); } if ((Object)(object)val.currentlyHeldObjectServer != (Object)null) { ((Component)val.currentlyHeldObjectServer).gameObject.GetComponent<AudioSource>().PlayOneShot(val.currentlyHeldObjectServer.itemProperties.grabSFX, 0.6f); } TimeSinceSwitchingSlots.SetValue(val, 0f); } } } [HarmonyPatch] public static class SuitColors { private static readonly (string name, float hue)[] Suits = new(string, float)[8] { ("Red suit", 0f), ("Yellow suit", 0.15f), ("Lime suit", 0.28f), ("Cyan suit", 0.5f), ("Blue suit", 0.62f), ("Pink suit", 0.9f), ("White suit", -1f), ("Black suit", -2f) }; private static readonly Dictionary<string, Material> cache = new Dictionary<string, Material>(); private const int RackFit = 13; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] private static void AddSuits(StartOfRound __instance) { try { List<UnlockableItem> list = __instance.unlockablesList?.unlockables; if (list == null) { return; } UnlockableItem val = ((IEnumerable<UnlockableItem>)list).FirstOrDefault((Func<UnlockableItem, bool>)((UnlockableItem u) => u.unlockableType == 0 && u.alreadyUnlocked && (Object)(object)u.suitMaterial != (Object)null)); if (val == null) { Plugin.Log.LogWarning((object)"Suits: vanilla orange suit not found, no colored suits added."); return; } int num = 0; (string, float)[] suits = Suits; for (int num2 = 0; num2 < suits.Length; num2++) { var (name, hue) = suits[num2]; if (!list.Any((UnlockableItem u) => u.unlockableName == name)) { Material val2 = MakeMaterial(val.suitMaterial, name, hue); if (!((Object)(object)val2 == (Object)null)) { UnlockableItem val3 = Copy(val); val3.unlockableName = name; val3.suitMaterial = val2; val3.alreadyUnlocked = true; val3.hasBeenUnlockedByPlayer = false; val3.shopSelectionNode = null; val3.alwaysInStock = false; val3.unlockedInChallengeFile = false; val3.headCostumeObject = null; val3.lowerTorsoCostumeObject = null; list.Add(val3); num++; } } } if (num > 0) { Plugin.Log.LogInfo((object)$"Suits: added {num} colored suits (rack now has {list.Count((UnlockableItem u) => u.unlockableType == 0 && u.alreadyUnlocked)} free suits)."); } } catch (Exception ex) { Plugin.Log.LogError((object)("Suits: failed to add colored suits: " + ex)); } } [HarmonyPatch(typeof(StartOfRound), "PositionSuitsOnRack")] [HarmonyPostfix] private static void FitRack(StartOfRound __instance) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008c: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) UnlockableSuit[] array = (from s in Object.FindObjectsOfType<UnlockableSuit>() orderby s.syncedSuitID.Value select s).ToArray(); if (array.Length <= 13) { return; } float num = 2.3400002f / (float)array.Length; for (int num2 = 0; num2 < array.Length; num2++) { AutoParentToShip component = ((Component)array[num2]).GetComponent<AutoParentToShip>(); if (!((Object)(object)component == (Object)null)) { component.overrideOffset = true; component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + __instance.rightmostSuitPosition.forward * num * (float)num2; component.rotationOffset = new Vector3(0f, 90f, 0f); } } } private static UnlockableItem Copy(UnlockableItem src) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown UnlockableItem val = new UnlockableItem(); FieldInfo[] fields = typeof(UnlockableItem).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(val, fieldInfo.GetValue(src)); } return val; } private static Material MakeMaterial(Material orange, string name, float hue) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00e4: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (cache.TryGetValue(name, out var value) && (Object)(object)value != (Object)null) { return value; } Material val = new Material(orange) { name = "KuchQOL " + name }; Texture mainTexture = orange.mainTexture; if ((Object)(object)mainTexture != (Object)null) { Texture2D val2 = Recolor(mainTexture, hue); ((Object)val2).name = "KuchQOL " + name; val.mainTexture = (Texture)(object)val2; string[] array = new string[2] { "_BaseColorMap", "_MainTex" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)val2); } } } else { Color val3 = (Color)((hue == -1f) ? Color.white : ((hue == -2f) ? new Color(0.12f, 0.12f, 0.12f) : Color.HSVToRGB(hue, 0.85f, 1f))); string[] array = new string[2] { "_BaseColor", "_Color" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetColor(text2, val3); } } } Object.DontDestroyOnLoad((Object)(object)val); cache[name] = val; return val; } private static Texture2D Recolor(Texture src, float hue) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) int w = src.width; int height = src.height; RenderTexture temporary = RenderTexture.GetTemporary(w, height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); Graphics.Blit(src, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(w, height, (TextureFormat)4, true); val.ReadPixels(new Rect(0f, 0f, (float)w, (float)height), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color32[] px = val.GetPixels32(); Parallel.For(0, height, delegate(int y) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_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_00b4: 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) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) int i = y * w; float num2 = default(float); float num3 = default(float); float num4 = default(float); for (int num = i + w; i < num; i++) { Color32 val2 = px[i]; Color.RGBToHSV(Color32.op_Implicit(val2), ref num2, ref num3, ref num4); if (num3 > 0.25f && num4 > 0.08f && (num2 < 0.14f || num2 > 0.97f)) { Color val3 = ((hue == -1f) ? Color.HSVToRGB(0f, 0f, Mathf.Clamp01(num4 * 1.05f + 0.15f)) : ((hue != -2f) ? Color.HSVToRGB(hue, num3, num4) : Color.HSVToRGB(0f, 0f, num4 * 0.22f))); px[i] = new Color32((byte)(val3.r * 255f), (byte)(val3.g * 255f), (byte)(val3.b * 255f), val2.a); } } }); val.SetPixels32(px); val.Apply(true, true); return val; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace KuchQOL_Server.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }