Please disclose if your mod was created primarily 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 HQoL v1.0.12
OreoM.HQoL.72.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HQoL.Network; using HQoL.Patches; using HQoL.Util; using HarmonyLib; using Microsoft.CodeAnalysis; using OreoM.HQoL.72.NetcodePatcher; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("OreoM.HQoL.72")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.12.0")] [assembly: AssemblyInformationalVersion("1.0.12+8192d70c26f5eff58384fba668009dc70cc53d3d")] [assembly: AssemblyProduct("HQoL_backport")] [assembly: AssemblyTitle("OreoM.HQoL.72")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.12.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<ItemReference>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<ItemReference>(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 HQoL { [BepInPlugin("OreoM.HQoL.72", "HQoL_backport", "1.0.12")] public class HQoL : BaseUnityPlugin { internal static SellModule sellModule; internal static HQoLConfig modConfig; private const string UnityVersion = "2022.3.9"; public static HQoL Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; if (!Application.unityVersion.StartsWith("2022.3.9", StringComparison.OrdinalIgnoreCase)) { Logger.LogInfo((object)"Skipping OreoM.HQoL.72, no patches will be loaded."); return; } sellModule = new SellModule(); modConfig = new HQoLConfig(((BaseUnityPlugin)this).Config); Patch(); NetcodePatch(); Logger.LogInfo((object)"OreoM.HQoL.72 v1.0.12 has loaded!"); } internal static void NetcodePatch() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (Exception arg) { Logger.LogWarning((object)$"Netcode patch failed, but it's likely intended: {arg}"); } } } } } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("OreoM.HQoL.72"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public class HQoLConfig { public HashSet<string> storageException; public readonly ConfigEntry<string> storageExceptionConfig; public HQoLConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; storageExceptionConfig = cfg.Bind<string>("General", "Dont store list", "Shotgun, Knife", "What items should not be stored automatically"); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; storageException = new HashSet<string>(from s in storageExceptionConfig.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) select s.Trim().ToLower()); } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "OreoM.HQoL.72"; public const string PLUGIN_NAME = "HQoL_backport"; public const string PLUGIN_VERSION = "1.0.12"; } } namespace HQoL.Util { internal class SellModule { public int sellValue; public List<int> itemReferenceIndexToSell; public Dictionary<string, int> itemTypesToSell; public SellModule() { itemTypesToSell = new Dictionary<string, int>(); itemReferenceIndexToSell = new List<int>(); } public bool FindItemsWithTotalValue(int value, bool useOvertime) { int num = value; int num2 = 0; int num3 = 10 * value; int profitQuota = TimeOfDay.Instance.profitQuota; int num4 = ((TimeOfDay.Instance.daysUntilDeadline == 0) ? (-1) : TimeOfDay.Instance.daysUntilDeadline); float companyBuyingRate = StartOfRound.Instance.companyBuyingRate; while (useOvertime) { int num5 = num; num = (num2 + num3) / 2; int num6 = Math.Max(((int)((float)num * companyBuyingRate) - profitQuota) / 5 + 15 * num4, 0); if ((int)((float)num * companyBuyingRate) + num6 >= value) { num3 = num; } else { num2 = num; } if ((int)((float)num * companyBuyingRate) + num6 == value) { break; } if (num5 == num) { num++; break; } } int num7 = num; int num8 = 0; foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { num8 += item.value; } if (num7 > num8) { return FindAllItems(); } if (num7 < 1) { return false; } bool[,] array = new bool[num8 + 1, HQoLNetwork.Instance.netStorage.Count + 1]; for (int i = 0; i < num8 + 1; i++) { for (int j = 0; j < HQoLNetwork.Instance.netStorage.Count + 1; j++) { array[i, j] = false; } } array[0, 0] = true; for (int k = 0; k < num8 + 1; k++) { for (int l = 0; l < HQoLNetwork.Instance.netStorage.Count; l++) { if (k >= HQoLNetwork.Instance.netStorage[l].value) { array[k, l + 1] = array[k, l] || array[k - HQoLNetwork.Instance.netStorage[l].value, l]; } else { array[k, l + 1] = array[k, l]; } if (k >= num7 && array[k, HQoLNetwork.Instance.netStorage.Count]) { goto end_IL_020b; } } continue; end_IL_020b: break; } itemReferenceIndexToSell.Clear(); itemTypesToSell.Clear(); int m = num7; int num9; for (num9 = HQoLNetwork.Instance.netStorage.Count; !array[m, num9]; m++) { } sellValue = m; while (m != 0) { while (array[m, num9 - 1]) { num9--; } num9--; m -= HQoLNetwork.Instance.netStorage[num9].value; itemReferenceIndexToSell.Add(num9); Dictionary<string, int> dictionary = itemTypesToSell; ItemReference itemReference = HQoLNetwork.Instance.netStorage[num9]; if (dictionary.ContainsKey(((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString())) { Dictionary<string, int> dictionary2 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[num9]; dictionary2[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()]++; } else { Dictionary<string, int> dictionary3 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[num9]; dictionary3[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()] = 1; } } return true; } public bool FindAllItems() { sellValue = HQoLNetwork.Instance.totalStorageValue.Value; itemReferenceIndexToSell.Clear(); itemTypesToSell.Clear(); for (int i = 0; i < HQoLNetwork.Instance.netStorage.Count; i++) { itemReferenceIndexToSell.Add(i); Dictionary<string, int> dictionary = itemTypesToSell; ItemReference itemReference = HQoLNetwork.Instance.netStorage[i]; if (dictionary.ContainsKey(((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString())) { Dictionary<string, int> dictionary2 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[i]; dictionary2[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()]++; } else { Dictionary<string, int> dictionary3 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[i]; dictionary3[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()] = 1; } } return true; } public void ClearSellModule() { sellValue = 0; itemTypesToSell.Clear(); itemReferenceIndexToSell.Clear(); } } public struct ItemReference : INetworkSerializable, IEquatable<ItemReference> { public FixedString32Bytes itemName; public int value; public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //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_0020: 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) ((BufferSerializer<FixedString32Bytes>*)(&serializer))->SerializeValue<FixedString32Bytes>(ref itemName, default(ForFixedStrings)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref value, default(ForPrimitives)); } public bool Equals(ItemReference other) { if ((ref itemName) == (ref other.itemName)) { return value == other.value; } return false; } } } namespace HQoL.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(GameNetworkManager __instance) { HQoLNetwork.CreateAndRegisterPrefab(); } [HarmonyPatch("Disconnect")] [HarmonyPrefix] private static void PreDisconnect(GameNetworkManager __instance) { bool flag = false; if (StartOfRoundPatches.hasChallengeFile) { flag = StartOfRoundPatches.isChallengeFileRef.Invoke(StartOfRound.Instance); } if (HQoLNetwork.Instance.storageHasBeenModified && __instance.isHostingGame && StartOfRound.Instance.inShipPhase && !flag) { try { List<ItemReference> list = new List<ItemReference>(); foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { list.Add(item); } ES3.Save<List<ItemReference>>("HQoL.ScrapList", list, GameNetworkManager.Instance.currentSaveFileName); HQoLNetwork.Instance.storageHasBeenModified = false; } catch (Exception arg) { HQoL.Logger.LogError((object)$"Error while trying to save game values when disconnecting as host: {arg}"); } } HQoLNetwork.DespawnNetworkHandler(); } private static void NewCodeFromV81() { ES3.DeleteKey("shipGrabbableItemIDs", GameNetworkManager.Instance.currentSaveFileName); ES3.DeleteKey("shipGrabbableItemPos", GameNetworkManager.Instance.currentSaveFileName); ES3.DeleteKey("shipScrapValues", GameNetworkManager.Instance.currentSaveFileName); ES3.DeleteKey("shipItemSaveData", GameNetworkManager.Instance.currentSaveFileName); } [HarmonyPatch("SaveItemsInShip")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileSaveItemsInShip(IEnumerable<CodeInstruction> codes) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(codes, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(List<int>), "Count"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Bgt, (object)null, (string)null) }); CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GameNetworkManagerPatches), "NewCodeFromV81", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Ret, (object)null) }; val.Advance(6); if (val.Opcode != OpCodes.Ret) { HQoL.Logger.LogInfo((object)"0 item save bug already fix, this is likely v80+"); return codes; } List<Label> labels = val.Labels; return val.Advance(-2).RemoveInstructions(3).Insert(array) .AddLabels((IEnumerable<Label>)labels) .InstructionEnumeration(); } } [HarmonyPatch(typeof(ItemDropship))] internal class ItemDropshipPatches { private static FieldRef<ItemDropship, int> refPreOrderedVehicle = null; private static bool hasCruiser = false; private static int preOrderedVehicle = -1; private static int preOrderedItemCount = 0; private static DepositItemsDesk? deskReference; [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(ItemDropship __instance) { FieldInfo fieldInfo = AccessTools.Field(typeof(ItemDropship), "orderedVehicleFromTerminal"); if (fieldInfo != null) { refPreOrderedVehicle = AccessTools.FieldRefAccess<ItemDropship, int>(fieldInfo); hasCruiser = true; } __instance.shipAnimator.speed = 1f; deskReference = Object.FindObjectOfType<DepositItemsDesk>(); if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { __instance.playersFirstOrder = false; } } [HarmonyPatch("LandShipClientRpc")] [HarmonyPrefix] private static void PreLandShipClientRpc(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { __instance.shipAnimator.speed = 5f; } } [HarmonyPatch("OpenShipDoorsOnServer")] [HarmonyPostfix] private static void PostOpenShipDoorsOnServer(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { __instance.ShipLeaveClientRpc(); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void PostUpdate(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { int num = -1; if (hasCruiser) { num = refPreOrderedVehicle.Invoke(__instance); } if (!__instance.deliveringOrder && (preOrderedItemCount != __instance.terminalScript.numberOfItemsInDropship || preOrderedVehicle < num)) { __instance.shipTimer = 34f; } preOrderedItemCount = __instance.terminalScript.numberOfItemsInDropship; preOrderedVehicle = num; } } } [HarmonyPatch(typeof(ItemDropship))] internal class ItemDropshipLandVehiclePatch { private static MethodBase refDeliverVehicleClientRpc; private static bool Prepare() { refDeliverVehicleClientRpc = AccessTools.Method(typeof(ItemDropship), "DeliverVehicleClientRpc", (Type[])null, (Type[])null); if (refDeliverVehicleClientRpc == null) { HQoL.Logger.LogInfo((object)"Method DeliverVehicleClientRpc in ItemDropship not found, skipping..."); return false; } return true; } private static MethodBase TargetMethod() { return refDeliverVehicleClientRpc; } private static void Prefix(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)Object.FindObjectOfType<DepositItemsDesk>() == (Object)null)) { __instance.shipAnimator.speed = 1f; } } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatches { [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyPostfix] private static void PostDespawnPropsAtEndOfRound(RoundManager __instance) { if (StartOfRound.Instance.allPlayersDead && ((NetworkBehaviour)__instance).IsServer) { HQoLNetwork.Instance.ClearItems(); } } } [HarmonyPatch] internal class ShotgunItemPatches { private static PropertyInfo transformInfo; private static MethodBase refLoadItemSaveData; private static bool Prepare() { Type type = AccessTools.TypeByName("ShotgunItem"); if (type == null) { HQoL.Logger.LogInfo((object)"Class ShotgunItem not found, skipping..."); return false; } transformInfo = AccessTools.Property(type, "transform"); refLoadItemSaveData = AccessTools.Method(type, "LoadItemSaveData", (Type[])null, (Type[])null); if (refLoadItemSaveData == null) { HQoL.Logger.LogInfo((object)"Method LoadItemSaveData in ShotgunItem not found, skipping..."); return false; } return true; } private static MethodBase TargetMethod() { return refLoadItemSaveData; } private static void Prefix(object __instance, int saveData) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001f: 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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (GameNetworkManager.Instance.isHostingGame) { Transform val = (Transform)transformInfo.GetValue(__instance); Vector3 position = val.position; position += new Vector3(1f - (float)saveData / 2f, 0f, 0f); val.position = position; } } } [HarmonyPatch] internal class SprayPaintItemPatches { private static PropertyInfo transformInfo; private static FieldInfo isWeedKillerSprayBottleInfo; private static MethodBase refLoadItemSaveData; private static bool Prepare() { Type type = AccessTools.TypeByName("SprayPaintItem"); if (type == null) { HQoL.Logger.LogInfo((object)"Class SprayPaintItem not found, skipping..."); return false; } transformInfo = AccessTools.Property(type, "transform"); isWeedKillerSprayBottleInfo = AccessTools.Field(type, "isWeedKillerSprayBottle"); if (isWeedKillerSprayBottleInfo == null) { HQoL.Logger.LogInfo((object)"Property isWeedKillerSprayBottleInfo in SprayPaintItem not found, skipping..."); return false; } refLoadItemSaveData = AccessTools.Method(type, "LoadItemSaveData", (Type[])null, (Type[])null); if (refLoadItemSaveData == null) { HQoL.Logger.LogInfo((object)"Method LoadItemSaveData in SprayPaintItem not found, skipping..."); return false; } return true; } private static MethodBase TargetMethod() { return refLoadItemSaveData; } private static void Prefix(object __instance, int saveData) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_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_005c: 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) if (GameNetworkManager.Instance.isHostingGame) { bool flag = (bool)isWeedKillerSprayBottleInfo.GetValue(__instance); Transform val = (Transform)transformInfo.GetValue(__instance); if (flag) { Vector3 position = val.position; position += new Vector3(-3f - (float)saveData / 50f, 0f, -2f); val.position = position; } } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatches { public static FieldRef<StartOfRound, bool> isChallengeFileRef; public static bool hasChallengeFile; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void PreAwake(StartOfRound __instance) { HQoLNetwork.SpawnNetworkHandler(); } [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(StartOfRound __instance) { FieldInfo fieldInfo = AccessTools.Field(typeof(StartOfRound), "isChallengeFile"); if (fieldInfo != null) { isChallengeFileRef = AccessTools.FieldRefAccess<StartOfRound, bool>(fieldInfo); hasChallengeFile = true; } else { hasChallengeFile = false; HQoL.Logger.LogInfo((object)"Variable isChallengeFile not found, skipping..."); } } [HarmonyPatch("SetTimeAndPlanetToSavedSettings")] [HarmonyPostfix] private static void PostSetTimeAndPlanetToSavedSettings(StartOfRound __instance) { List<ItemReference> itemRefs = ES3.Load<List<ItemReference>>("HQoL.ScrapList", GameNetworkManager.Instance.currentSaveFileName, new List<ItemReference>()); HQoLNetwork.Instance.AddItems(itemRefs); } [HarmonyPatch("PlayFirstDayShipAnimation")] [HarmonyPrefix] private static void PrePlayFirstDayShipAnimation(StartOfRound __instance) { __instance.shipIntroSpeechSFX = __instance.disableSpeakerSFX; } [HarmonyPatch("PassTimeToNextDay")] [HarmonyPostfix] private static void PostPassTimeToNextDay(StartOfRound __instance) { bool flag = false; if (hasChallengeFile) { _ = ref isChallengeFileRef.Invoke(__instance); } if (!GameNetworkManager.Instance.isHostingGame || flag) { return; } bool flag2 = false; if (TimeOfDay.Instance.daysUntilDeadline == 0 && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)) { List<GrabbableObject> list = new List<GrabbableObject>(Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0)); list.RemoveAll((GrabbableObject scrapObj) => scrapObj.isHeld || !scrapObj.itemProperties.isScrap || ((Object)scrapObj.itemProperties).name == "GiftBox" || HQoL.modConfig.storageException.Contains(((Object)scrapObj.itemProperties).name.ToLower()) || HQoL.modConfig.storageException.Contains(((Component)scrapObj).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText.ToLower())); HQoLNetwork.Instance.AddItems(list.ToArray()); list.ForEach(delegate(GrabbableObject scrapObj) { ((NetworkBehaviour)scrapObj).NetworkObject.Despawn(true); }); flag2 = true; } if (!flag2 && !HQoLNetwork.Instance.storageHasBeenModified) { return; } try { List<ItemReference> list2 = new List<ItemReference>(); foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { list2.Add(item); } ES3.Save<List<ItemReference>>("HQoL.ScrapList", list2, GameNetworkManager.Instance.currentSaveFileName); HQoLNetwork.Instance.storageHasBeenModified = false; } catch (Exception arg) { HQoL.Logger.LogError((object)$"Error while trying to save game values when disconnecting as host: {arg}"); } } [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileLoadShipGrabbableItems(IEnumerable<CodeInstruction> codes) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[8] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Ldloc_S, (object)9), new CodeInstruction(OpCodes.Ldelem_I4, (object)null), new CodeInstruction(OpCodes.Ldloc_2, (object)null), new CodeInstruction(OpCodes.Ldloc_S, (object)9), new CodeInstruction(OpCodes.Ldelema, (object)typeof(Vector3)), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StartOfRoundHelper), "MoveItemsToSpecialStartPosition", (Type[])null, (Type[])null)) }; CodeMatcher val = new CodeMatcher(codes, (ILGenerator)null); val.End().MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null) }).Advance(-9); int pos = val.Pos; val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StartOfRound), "shipBounds"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Collider), "bounds"), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }); int pos2 = val.Pos; return val.RemoveInstructionsInRange(pos2, pos).Insert(array).InstructionEnumeration(); } } public static class StartOfRoundHelper { public const int jetpackID = 4; public const int keyID = 5; public const int shovelID = 10; public const int shotgunID = 59; public const int knifeID = 68; public static void MoveItemsToSpecialStartPosition(StartOfRound instance, int currItemID, ref Vector3 currItemPosition) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) switch (currItemID) { case 4: currItemPosition.x = 5f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -16.5f; return; case 5: currItemPosition.x = -4f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -13f; return; case 10: currItemPosition.x = 3.5f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -14.5f; return; case 59: currItemPosition.x = 0f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -13f; return; case 68: currItemPosition.x = -1f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -13f; return; } if (instance.allItemsList.itemsList[currItemID].isScrap) { currItemPosition.x = -4.5f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -15f; } else { currItemPosition = instance.playerSpawnPositions[1].position; currItemPosition.x += (float)currItemID / 15f; currItemPosition.z += 2f; currItemPosition.y += 0.5f; } } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatches { [HarmonyPatch("ParsePlayerSentence")] [HarmonyPrefix] private static void ParsePlayerSentencePrePatch(Terminal __instance) { TerminalHelper.terminalInput = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower(); } [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(Terminal __instance) { TerminalHelper.terminal = Object.FindAnyObjectByType<Terminal>(); ((TMP_Text)__instance.topRightText).enableAutoSizing = true; if (!TerminalHelper.internalStateInitialized) { TerminalHelper.TerminalNodes.InitializeNodes(); TerminalHelper.TerminalKeywords.InitializeKeywords(); TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[0].result = TerminalHelper.TerminalNodes.sellCommand; TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[1].result = TerminalHelper.TerminalNodes.depositCommand; TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[2].result = TerminalHelper.TerminalNodes.checkScrap; TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[3].result = TerminalHelper.TerminalNodes.confirmOvertime; TerminalHelper.internalStateInitialized = true; } if (!TerminalHelper.addedCustomKeywords) { TerminalHelper.TerminalKeywords.sellWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; TerminalHelper.TerminalKeywords.depositWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; TerminalHelper.TerminalKeywords.checkScrapWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; TerminalHelper.TerminalKeywords.overtimeWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; int num = __instance.terminalNodes.allKeywords.Count(); List<TerminalKeyword> list = new List<TerminalKeyword>(__instance.terminalNodes.allKeywords); list.Add(TerminalHelper.TerminalKeywords.sellWord); list.Add(TerminalHelper.TerminalKeywords.depositWord); list.Add(TerminalHelper.TerminalKeywords.checkScrapWord); list.Add(TerminalHelper.TerminalKeywords.overtimeWord); list.Add(TerminalHelper.TerminalKeywords.defaultVerb); __instance.terminalNodes.allKeywords = list.ToArray(); TerminalHelper.addedCustomKeywords = true; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void PostUpdate(Terminal __instance) { if (__instance.terminalInUse) { TextMeshProUGUI topRightText = __instance.topRightText; ((TMP_Text)topRightText).text = ((TMP_Text)topRightText).text + $"\n<color=#09DBB5>${HQoLNetwork.Instance.totalStorageValue.Value}"; } } [HarmonyPatch("LoadNewNode")] [HarmonyPostfix] private static void PostLoadNewNode(Terminal __instance) { if (!TerminalHelper.isSellValid && (Object)(object)__instance.currentNode == (Object)(object)TerminalHelper.TerminalNodes.sellCommand) { __instance.currentNode = TerminalHelper.TerminalNodes.sellDeny; } else if (!TerminalHelper.isDepositValid && (Object)(object)__instance.currentNode == (Object)(object)TerminalHelper.TerminalNodes.depositCommand) { __instance.currentNode = TerminalHelper.TerminalNodes.depositDeny; } } [HarmonyPatch("TextPostProcess")] [HarmonyPrefix] private static void PreTextPostProcess(Terminal __instance, ref string modifiedDisplayText) { if (modifiedDisplayText.Contains("[sellConfirm]")) { modifiedDisplayText = modifiedDisplayText.Replace("[sellConfirm]", TerminalHelper.SellItems()); } else if (modifiedDisplayText.Contains("[sell]")) { modifiedDisplayText = modifiedDisplayText.Replace("[sell]", TerminalHelper.FindItemsToSell()); } else if (modifiedDisplayText.Contains("[depositConfirm]")) { modifiedDisplayText = modifiedDisplayText.Replace("[depositConfirm]", TerminalHelper.DepositItems()); } else if (modifiedDisplayText.Contains("[deposit]")) { modifiedDisplayText = modifiedDisplayText.Replace("[deposit]", TerminalHelper.FindItemsToDeposit()); } else if (modifiedDisplayText.Contains("[confirmOvertime]")) { modifiedDisplayText = modifiedDisplayText.Replace("[confirmOvertime]", TerminalHelper.ConfirmOvertime()); } else if (modifiedDisplayText.Contains("[checkScrap]")) { modifiedDisplayText = modifiedDisplayText.Replace("[checkScrap]", TerminalHelper.CheckItems()); } } } internal static class TerminalHelper { public class TerminalNodes { public static TerminalNode sellDeny; public static TerminalNode sellConfirm; public static TerminalNode sellCommand; public static TerminalNode confirmOvertime; public static TerminalNode depositDeny; public static TerminalNode depositConfirm; public static TerminalNode depositCommand; public static TerminalNode checkScrap; public static void InitializeNodes() { sellDeny = ScriptableObject.CreateInstance<TerminalNode>(); sellDeny.acceptAnything = false; sellDeny.buyItemIndex = -1; sellDeny.buyRerouteToMoon = -1; sellDeny.buyUnlockable = false; sellDeny.clearPreviousText = false; sellDeny.creatureFileID = -1; sellDeny.creatureName = ""; sellDeny.displayPlanetInfo = -1; sellDeny.displayText = "\nSell canceled.\n\n"; sellDeny.displayTexture = null; sellDeny.displayVideo = null; ((Object)sellDeny).hideFlags = (HideFlags)0; sellDeny.isConfirmationNode = false; sellDeny.itemCost = 0; sellDeny.loadImageSlowly = false; sellDeny.maxCharactersToType = 35; ((Object)sellDeny).name = "sellDeny"; sellDeny.overrideOptions = false; sellDeny.persistentImage = false; sellDeny.playClip = null; sellDeny.playSyncedClip = -1; sellDeny.returnFromStorage = false; sellDeny.shipUnlockableID = -1; sellDeny.storyLogFileID = -1; sellDeny.terminalEvent = ""; sellDeny.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; sellConfirm = ScriptableObject.CreateInstance<TerminalNode>(); sellConfirm.acceptAnything = false; sellConfirm.buyItemIndex = -1; sellConfirm.buyRerouteToMoon = -1; sellConfirm.buyUnlockable = false; sellConfirm.clearPreviousText = false; sellConfirm.creatureFileID = -1; sellConfirm.creatureName = ""; sellConfirm.displayPlanetInfo = -1; sellConfirm.displayText = "[sellConfirm]"; sellConfirm.displayTexture = null; sellConfirm.displayVideo = null; ((Object)sellConfirm).hideFlags = (HideFlags)0; sellConfirm.isConfirmationNode = false; sellConfirm.itemCost = 0; sellConfirm.loadImageSlowly = false; sellConfirm.maxCharactersToType = 35; ((Object)sellConfirm).name = "sellConfirm"; sellConfirm.overrideOptions = false; sellConfirm.persistentImage = false; sellConfirm.playClip = null; sellConfirm.playSyncedClip = 0; sellConfirm.returnFromStorage = false; sellConfirm.shipUnlockableID = -1; sellConfirm.storyLogFileID = -1; sellConfirm.terminalEvent = ""; sellConfirm.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; sellCommand = ScriptableObject.CreateInstance<TerminalNode>(); sellCommand.acceptAnything = false; sellCommand.buyItemIndex = -1; sellCommand.buyRerouteToMoon = -1; sellCommand.buyUnlockable = false; sellCommand.clearPreviousText = true; sellCommand.creatureFileID = -1; sellCommand.creatureName = ""; sellCommand.displayPlanetInfo = -1; sellCommand.displayText = "[sell]"; sellCommand.displayTexture = null; sellCommand.displayVideo = null; ((Object)sellCommand).hideFlags = (HideFlags)0; sellCommand.isConfirmationNode = true; sellCommand.itemCost = 0; sellCommand.loadImageSlowly = false; sellCommand.maxCharactersToType = 35; ((Object)sellCommand).name = "sellCommand"; sellCommand.overrideOptions = true; sellCommand.persistentImage = false; sellCommand.playClip = null; sellCommand.playSyncedClip = -1; sellCommand.returnFromStorage = false; sellCommand.shipUnlockableID = -1; sellCommand.storyLogFileID = -1; sellCommand.terminalEvent = ""; sellCommand.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[3], sellConfirm), CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[4], sellDeny) }; confirmOvertime = ScriptableObject.CreateInstance<TerminalNode>(); confirmOvertime.acceptAnything = false; confirmOvertime.buyItemIndex = -1; confirmOvertime.buyRerouteToMoon = -1; confirmOvertime.buyUnlockable = false; confirmOvertime.clearPreviousText = true; confirmOvertime.creatureFileID = -1; confirmOvertime.creatureName = ""; confirmOvertime.displayPlanetInfo = -1; confirmOvertime.displayText = "[confirmOvertime]"; confirmOvertime.displayTexture = null; confirmOvertime.displayVideo = null; ((Object)confirmOvertime).hideFlags = (HideFlags)0; confirmOvertime.isConfirmationNode = false; confirmOvertime.itemCost = 0; confirmOvertime.loadImageSlowly = false; confirmOvertime.maxCharactersToType = 35; ((Object)confirmOvertime).name = "confirmOvertime"; confirmOvertime.overrideOptions = false; confirmOvertime.persistentImage = false; confirmOvertime.playClip = null; confirmOvertime.playSyncedClip = -1; confirmOvertime.returnFromStorage = false; confirmOvertime.shipUnlockableID = -1; confirmOvertime.storyLogFileID = -1; confirmOvertime.terminalEvent = ""; confirmOvertime.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositDeny = ScriptableObject.CreateInstance<TerminalNode>(); depositDeny.acceptAnything = false; depositDeny.buyItemIndex = -1; depositDeny.buyRerouteToMoon = -1; depositDeny.buyUnlockable = false; depositDeny.clearPreviousText = false; depositDeny.creatureFileID = -1; depositDeny.creatureName = ""; depositDeny.displayPlanetInfo = -1; depositDeny.displayText = "\nItem storing canceled.\n\n"; depositDeny.displayTexture = null; depositDeny.displayVideo = null; ((Object)depositDeny).hideFlags = (HideFlags)0; depositDeny.isConfirmationNode = false; depositDeny.itemCost = 0; depositDeny.loadImageSlowly = false; depositDeny.maxCharactersToType = 35; ((Object)depositDeny).name = "depositDeny"; depositDeny.overrideOptions = false; depositDeny.persistentImage = false; depositDeny.playClip = null; depositDeny.playSyncedClip = -1; depositDeny.returnFromStorage = false; depositDeny.shipUnlockableID = -1; depositDeny.storyLogFileID = -1; depositDeny.terminalEvent = ""; depositDeny.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositConfirm = ScriptableObject.CreateInstance<TerminalNode>(); depositConfirm.acceptAnything = false; depositConfirm.buyItemIndex = -1; depositConfirm.buyRerouteToMoon = -1; depositConfirm.buyUnlockable = false; depositConfirm.clearPreviousText = false; depositConfirm.creatureFileID = -1; depositConfirm.creatureName = ""; depositConfirm.displayPlanetInfo = -1; depositConfirm.displayText = "[depositConfirm]"; depositConfirm.displayTexture = null; depositConfirm.displayVideo = null; ((Object)depositConfirm).hideFlags = (HideFlags)0; depositConfirm.isConfirmationNode = false; depositConfirm.itemCost = 0; depositConfirm.loadImageSlowly = false; depositConfirm.maxCharactersToType = 35; ((Object)depositConfirm).name = "depositConfirm"; depositConfirm.overrideOptions = false; depositConfirm.persistentImage = false; depositConfirm.playClip = null; depositConfirm.playSyncedClip = -1; depositConfirm.returnFromStorage = false; depositConfirm.shipUnlockableID = -1; depositConfirm.storyLogFileID = -1; depositConfirm.terminalEvent = ""; depositConfirm.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositCommand = ScriptableObject.CreateInstance<TerminalNode>(); depositCommand.acceptAnything = false; depositCommand.buyItemIndex = -1; depositCommand.buyRerouteToMoon = -1; depositCommand.buyUnlockable = false; depositCommand.clearPreviousText = true; depositCommand.creatureFileID = -1; depositCommand.creatureName = ""; depositCommand.displayPlanetInfo = -1; depositCommand.displayText = "[deposit]"; depositCommand.displayTexture = null; depositCommand.displayVideo = null; ((Object)depositCommand).hideFlags = (HideFlags)0; depositCommand.isConfirmationNode = true; depositCommand.itemCost = 0; depositCommand.loadImageSlowly = false; depositCommand.maxCharactersToType = 35; ((Object)depositCommand).name = "depositCommand"; depositCommand.overrideOptions = true; depositCommand.persistentImage = false; depositCommand.playClip = null; depositCommand.playSyncedClip = -1; depositCommand.returnFromStorage = false; depositCommand.shipUnlockableID = -1; depositCommand.storyLogFileID = -1; depositCommand.terminalEvent = ""; depositCommand.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[3], depositConfirm), CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[4], depositDeny) }; checkScrap = ScriptableObject.CreateInstance<TerminalNode>(); checkScrap.acceptAnything = false; checkScrap.buyItemIndex = -1; checkScrap.buyRerouteToMoon = -1; checkScrap.buyUnlockable = false; checkScrap.clearPreviousText = true; checkScrap.creatureFileID = -1; checkScrap.creatureName = ""; checkScrap.displayPlanetInfo = -1; checkScrap.displayText = "[checkScrap]"; checkScrap.displayTexture = null; checkScrap.displayVideo = null; ((Object)checkScrap).hideFlags = (HideFlags)0; checkScrap.isConfirmationNode = false; checkScrap.itemCost = 0; checkScrap.loadImageSlowly = false; checkScrap.maxCharactersToType = 35; ((Object)checkScrap).name = "checkScrap"; checkScrap.overrideOptions = false; checkScrap.persistentImage = false; checkScrap.playClip = null; checkScrap.playSyncedClip = -1; checkScrap.returnFromStorage = false; checkScrap.shipUnlockableID = -1; checkScrap.storyLogFileID = -1; checkScrap.terminalEvent = ""; checkScrap.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; } } public class TerminalKeywords { public static TerminalKeyword sellWord; public static TerminalKeyword depositWord; public static TerminalKeyword overtimeWord; public static TerminalKeyword checkScrapWord; public static TerminalKeyword defaultVerb; public static void InitializeKeywords() { sellWord = ScriptableObject.CreateInstance<TerminalKeyword>(); sellWord.accessTerminalObjects = false; sellWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; sellWord.defaultVerb = null; ((Object)sellWord).hideFlags = (HideFlags)0; sellWord.isVerb = false; ((Object)sellWord).name = "SellWord"; sellWord.specialKeywordResult = null; sellWord.word = "sell"; depositWord = ScriptableObject.CreateInstance<TerminalKeyword>(); depositWord.accessTerminalObjects = false; depositWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositWord.defaultVerb = null; ((Object)depositWord).hideFlags = (HideFlags)0; depositWord.isVerb = false; ((Object)depositWord).name = "DepositWord"; depositWord.specialKeywordResult = null; depositWord.word = "deposit"; overtimeWord = ScriptableObject.CreateInstance<TerminalKeyword>(); overtimeWord.accessTerminalObjects = false; overtimeWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; overtimeWord.defaultVerb = null; ((Object)overtimeWord).hideFlags = (HideFlags)0; overtimeWord.isVerb = false; ((Object)overtimeWord).name = "OvertimeWord"; overtimeWord.specialKeywordResult = null; overtimeWord.word = "overtime"; checkScrapWord = ScriptableObject.CreateInstance<TerminalKeyword>(); checkScrapWord.accessTerminalObjects = false; checkScrapWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; checkScrapWord.defaultVerb = null; ((Object)checkScrapWord).hideFlags = (HideFlags)0; checkScrapWord.isVerb = false; ((Object)checkScrapWord).name = "CheckScrapWord"; checkScrapWord.specialKeywordResult = null; checkScrapWord.word = "check"; defaultVerb = ScriptableObject.CreateInstance<TerminalKeyword>(); defaultVerb.accessTerminalObjects = false; defaultVerb.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[4] { CompatibleNounMixedCtor(sellWord, TerminalNodes.sellCommand), CompatibleNounMixedCtor(depositWord, TerminalNodes.depositCommand), CompatibleNounMixedCtor(checkScrapWord, TerminalNodes.checkScrap), CompatibleNounMixedCtor(overtimeWord, TerminalNodes.confirmOvertime) }; defaultVerb.defaultVerb = null; ((Object)defaultVerb).hideFlags = (HideFlags)0; defaultVerb.isVerb = true; ((Object)defaultVerb).name = "DefaultVerb"; defaultVerb.specialKeywordResult = null; defaultVerb.word = "_"; } } public const string sellConfirmString = "[sellConfirm]"; public const string sellCommandString = "[sell]"; public const string confirmOvertimeString = "[confirmOvertime]"; public const string depositConfirmString = "[depositConfirm]"; public const string depositCommandString = "[deposit]"; public const string checkScrapString = "[checkScrap]"; public static Terminal terminal = null; public static string terminalInput = null; public static bool addedCustomKeywords = false; public static bool internalStateInitialized = false; public static bool isSellValid = false; public static bool isDepositValid = false; private static string itemNameToDeposit = ""; private static CompatibleNoun CompatibleNounMixedCtor(TerminalKeyword newNoun, TerminalNode newResult) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown Type typeFromHandle = typeof(CompatibleNoun); ConstructorInfo constructor = typeFromHandle.GetConstructor(new Type[2] { typeof(TerminalKeyword), typeof(TerminalNode) }); if (constructor != null) { return (CompatibleNoun)constructor.Invoke(new object[2] { newNoun, newResult }); } ConstructorInfo constructor2 = typeFromHandle.GetConstructor(Type.EmptyTypes); if (constructor2 != null) { CompatibleNoun val = (CompatibleNoun)constructor2.Invoke(null); val.noun = newNoun; val.result = newResult; return val; } throw new MissingMethodException("The compiler complains if this exception isn't here :3"); } public static string FindItemsToSell() { if (StartOfRound.Instance.inShipPhase) { isSellValid = false; return "Cannot sell while in orbit.\n\n"; } if ((Object)(object)Object.FindAnyObjectByType<DepositItemsDesk>() == (Object)null) { isSellValid = false; return "Current moon does not have a sell counter.\n\n"; } string[] array = terminalInput.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); bool useOvertime = terminalInput.Contains("-o"); if (array.Count() < 2 || (!int.TryParse(array[1], out var result) && !array[1].Equals("all", StringComparison.OrdinalIgnoreCase) && !array[1].Equals("quota", StringComparison.OrdinalIgnoreCase))) { isSellValid = false; terminal.currentNode = TerminalNodes.sellDeny; return "Invalid sell command.\n\n"; } if (array[1] == "all") { HQoL.sellModule.FindAllItems(); } else if (array[1] == "quota") { HQoL.sellModule.FindItemsWithTotalValue(TimeOfDay.Instance.profitQuota, useOvertime: false); } else { HQoL.sellModule.FindItemsWithTotalValue(result, useOvertime); } result = HQoL.sellModule.sellValue; string text = $"Found value to sell: ${result}\n"; int num = ((TimeOfDay.Instance.daysUntilDeadline == 0) ? (-1) : TimeOfDay.Instance.daysUntilDeadline); int num2 = Math.Max(((int)((float)result * StartOfRound.Instance.companyBuyingRate) - TimeOfDay.Instance.profitQuota) / 5 + 15 * num, 0); text += $"Overtime: ${num2} (Total: ${(int)((float)result * StartOfRound.Instance.companyBuyingRate) + num2})\n\n"; foreach (KeyValuePair<string, int> item in HQoL.sellModule.itemTypesToSell) { text += $"{item.Key} (x{item.Value})\n"; } text += "\nConfirm sell?\n\n"; isSellValid = true; return text; } public static string SellItems() { if (!isSellValid) { return "Items could not be sold.\n\n"; } int creditsEarned = (int)((float)HQoL.sellModule.sellValue * StartOfRound.Instance.companyBuyingRate); HQoLNetwork.Instance.SellItemsServerRpc(creditsEarned, HQoL.sellModule.itemReferenceIndexToSell.ToArray()); HQoL.sellModule.ClearSellModule(); isSellValid = false; return "Selling...\n\n"; } public static string FindItemsToDeposit() { if (!StartOfRound.Instance.inShipPhase && StartOfRound.Instance.currentLevelID != 3) { isDepositValid = false; return "Can only deposit items while the ship is in orbit or at company.\n\n"; } string text = terminalInput.Replace("deposit ", string.Empty); if (text.Length < 1) { isDepositValid = false; return "Deposit command needs an item name.\n\n"; } GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); if (text == "all") { Dictionary<string, int> dictionary = new Dictionary<string, int>(); GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { if (val.itemProperties.isScrap) { if (dictionary.ContainsKey(((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText)) { dictionary[((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText]++; } else { dictionary[((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText] = 1; } } } string text2 = ""; int num = 0; foreach (KeyValuePair<string, int> item2 in dictionary) { num += item2.Value; text2 += $"{item2.Key} (x{item2.Value})\n"; } if (num == 0) { isDepositValid = false; return "No items to deposit.\n\n"; } itemNameToDeposit = "all"; isDepositValid = true; return $"Found {num} items to deposit.\n\n" + text2 + "\nConfirm?\n\n"; } HashSet<string> hashSet = new HashSet<string>(); GrabbableObject[] array3 = array; foreach (GrabbableObject val2 in array3) { if (val2.itemProperties.isScrap && !(((Object)val2.itemProperties).name == "GiftBox")) { string item = ((Object)val2.itemProperties).name + "#" + ((Component)val2).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText; hashSet.Add(item); } } bool flag = false; foreach (string item3 in hashSet) { if (!flag && item3.ToLower().Contains(text)) { itemNameToDeposit = item3.Split(new char[1] { '#' }, StringSplitOptions.RemoveEmptyEntries)[1]; flag = true; } } if (!flag) { isDepositValid = false; return "Could not find " + text + " to deposit.\n\n"; } int num2 = 0; GrabbableObject[] array4 = array; foreach (GrabbableObject val3 in array4) { if (val3.itemProperties.isScrap && !(((Object)val3.itemProperties).name == "GiftBox") && itemNameToDeposit == ((Component)val3).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText && !val3.isHeld) { num2++; } } isDepositValid = true; return $"Found {itemNameToDeposit} (x{num2}).\n\nConfirm?\n\n"; } public static string DepositItems() { if (!isDepositValid) { return "Items could not be deposited.\n\n"; } HQoLNetwork.Instance.DepositItemsServerRpc(itemNameToDeposit); return "Depositing...\n\n"; } public static string ConfirmOvertime() { int num = ((TimeOfDay.Instance.daysUntilDeadline == 0) ? (-1) : TimeOfDay.Instance.daysUntilDeadline); int num2 = Math.Max((TimeOfDay.Instance.quotaFulfilled - TimeOfDay.Instance.profitQuota) / 5 + 15 * num, 0); string text = $"Value sold: ${TimeOfDay.Instance.quotaFulfilled}\n"; text += $"Overtime: ${num2}\n"; text += $"Quota: ${TimeOfDay.Instance.profitQuota}\n"; return text + $"Total: ${terminal.groupCredits + num2}\n\n"; } public static string CheckItems() { //IL_0030: 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_00b3: 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_00d0: 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_004e: 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_007e: 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) int num = 0; Dictionary<string, int> dictionary = new Dictionary<string, int>(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { FixedString32Bytes itemName = item.itemName; if (dictionary.ContainsKey(((object)(FixedString32Bytes)(ref itemName)).ToString())) { itemName = item.itemName; dictionary[((object)(FixedString32Bytes)(ref itemName)).ToString()]++; Dictionary<string, int> dictionary3 = dictionary2; itemName = item.itemName; dictionary3[((object)(FixedString32Bytes)(ref itemName)).ToString()] += item.value; } else { itemName = item.itemName; dictionary[((object)(FixedString32Bytes)(ref itemName)).ToString()] = 1; itemName = item.itemName; dictionary2[((object)(FixedString32Bytes)(ref itemName)).ToString()] = item.value; } num++; } string text = $"{num} scrap in storage.\n\n"; foreach (string key in dictionary.Keys) { text += $"{key} (x{dictionary[key]}: ${dictionary2[key]})\n"; } return text + "\n"; } } } namespace HQoL.Network { internal class HQoLNetwork : NetworkBehaviour { private static GameObject prefab; public NetworkList<ItemReference> netStorage = new NetworkList<ItemReference>(); public NetworkVariable<int> totalStorageValue = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public bool storageHasBeenModified; public static HQoLNetwork Instance { get; private set; } public static void CreateAndRegisterPrefab() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab != (Object)null)) { prefab = new GameObject("OreoM.HQoL.72 Prefab"); GameObject obj = prefab; ((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D); NetworkObject val = prefab.AddComponent<NetworkObject>(); val.GlobalObjectIdHash = XXHash.Hash32(((Object)prefab).name); prefab.AddComponent<HQoLNetwork>(); NetworkManager.Singleton.AddNetworkPrefab(prefab); HQoL.Logger.LogInfo((object)"Network prefab created and registered"); } } public static void SpawnNetworkHandler() { if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(false); HQoL.Logger.LogInfo((object)"Network handler spawned"); } } public static void DespawnNetworkHandler() { if ((Object)(object)Instance != (Object)null && ((Component)Instance).gameObject.GetComponent<NetworkObject>().IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)) { ((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true); HQoL.Logger.LogInfo((object)"Network handler despawned"); } } private void Awake() { Instance = this; } public void AddItem(GrabbableObject item) { //IL_0020: 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) netStorage.Add(new ItemReference { itemName = FixedString32Bytes.op_Implicit(((Component)item).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText), value = item.scrapValue }); NetworkVariable<int> obj = totalStorageValue; obj.Value += item.scrapValue; storageHasBeenModified = true; } public void AddItems(GrabbableObject[] items) { foreach (GrabbableObject item in items) { AddItem(item); } } public void AddItems(List<ItemReference> itemRefs) { int num = 0; foreach (ItemReference itemRef in itemRefs) { netStorage.Add(itemRef); num += itemRef.value; } NetworkVariable<int> obj = totalStorageValue; obj.Value += num; storageHasBeenModified = true; } public void ClearItems() { netStorage.Clear(); totalStorageValue.Value = 0; storageHasBeenModified = true; } [ServerRpc(RequireOwnership = false)] public void SellItemsServerRpc(int creditsEarned, int[] indicesToSell) { //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00bf: 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)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3634342093u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, creditsEarned); bool flag = indicesToSell != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(indicesToSell, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3634342093u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } List<int> list = (from i in new List<int>(indicesToSell).Distinct() orderby i descending select i).ToList(); foreach (int item in list) { NetworkVariable<int> obj = totalStorageValue; obj.Value -= netStorage[item].value; netStorage.RemoveAt(item); } storageHasBeenModified = true; UpdateQuotaAndDisplayCreditsEarningClientRpc(creditsEarned); } [ClientRpc] public void UpdateQuotaAndDisplayCreditsEarningClientRpc(int creditsEarned) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1270434226u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, creditsEarned); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1270434226u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { EndOfGameStats gameStats = StartOfRound.Instance.gameStats; gameStats.scrapValueCollected += creditsEarned; Terminal terminal = TerminalHelper.terminal; terminal.groupCredits += creditsEarned; TimeOfDay instance = TimeOfDay.Instance; instance.quotaFulfilled += creditsEarned; TimeOfDay.Instance.UpdateProfitQuotaCurrentTime(); ((TMP_Text)HUDManager.Instance.moneyRewardsListText).text = ""; ((TMP_Text)HUDManager.Instance.moneyRewardsTotalText).text = $"TOTAL: ${creditsEarned}"; HUDManager.Instance.moneyRewardsAnimator.SetTrigger("showRewards"); HUDManager.Instance.rewardsScrollbar.value = 1f; } } } [ServerRpc(RequireOwnership = false)] public void DepositItemsServerRpc(string itemName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00ba: 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)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3786121119u, val, (RpcDelivery)0); bool flag = itemName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(itemName, false); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3786121119u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } string itemName2 = itemName; List<GrabbableObject> list = new List<GrabbableObject>(Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0)); if (itemName2 == "all") { list.RemoveAll(delegate(GrabbableObject scrapObj) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) if (!scrapObj.isHeld && scrapObj.itemProperties.isScrap && !(((Object)scrapObj.itemProperties).name == "GiftBox") && !HQoL.modConfig.storageException.Contains(((Object)scrapObj.itemProperties).name.ToLower()) && !HQoL.modConfig.storageException.Contains(((Component)scrapObj).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText.ToLower())) { if (TimeOfDay.Instance.daysUntilDeadline != 0) { Bounds bounds2 = StartOfRound.Instance.shipInnerRoomBounds.bounds; return !((Bounds)(ref bounds2)).Contains(((Component)scrapObj).transform.position); } return false; } return true; }); } else { list.RemoveAll(delegate(GrabbableObject scrapObj) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) if (!scrapObj.isHeld && scrapObj.itemProperties.isScrap && !(((Object)scrapObj.itemProperties).name == "GiftBox") && !(((Component)scrapObj).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText != itemName2)) { if (TimeOfDay.Instance.daysUntilDeadline != 0) { Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds; return !((Bounds)(ref bounds)).Contains(((Component)scrapObj).transform.position); } return false; } return true; }); } AddItems(list.ToArray()); list.ForEach(delegate(GrabbableObject scrapObj) { ((NetworkBehaviour)scrapObj).NetworkObject.Despawn(true); }); storageHasBeenModified = true; } protected override void __initializeVariables() { if (netStorage == null) { throw new Exception("HQoLNetwork.netStorage cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)netStorage).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)netStorage, "netStorage"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)netStorage); if (totalStorageValue == null) { throw new Exception("HQoLNetwork.totalStorageValue cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)totalStorageValue).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)totalStorageValue, "totalStorageValue"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)totalStorageValue); ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_HQoLNetwork() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(3634342093u, new RpcReceiveHandler(__rpc_handler_3634342093)); NetworkManager.__rpc_func_table.Add(1270434226u, new RpcReceiveHandler(__rpc_handler_1270434226)); NetworkManager.__rpc_func_table.Add(3786121119u, new RpcReceiveHandler(__rpc_handler_3786121119)); } private static void __rpc_handler_3634342093(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int creditsEarned = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref creditsEarned); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); int[] indicesToSell = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref indicesToSell, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((HQoLNetwork)(object)target).SellItemsServerRpc(creditsEarned, indicesToSell); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1270434226(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int creditsEarned = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref creditsEarned); target.__rpc_exec_stage = (__RpcExecStage)2; ((HQoLNetwork)(object)target).UpdateQuotaAndDisplayCreditsEarningClientRpc(creditsEarned); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3786121119(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_0061: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string itemName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemName, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((HQoLNetwork)(object)target).DepositItemsServerRpc(itemName); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "HQoLNetwork"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace OreoM.HQoL.72.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }
OreoM.HQoL.73.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HQoL.Network; using HQoL.Patches; using HQoL.Util; using HarmonyLib; using Microsoft.CodeAnalysis; using OreoM.HQoL.73.NetcodePatcher; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("OreoM.HQoL.73")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.12.0")] [assembly: AssemblyInformationalVersion("1.0.12+8192d70c26f5eff58384fba668009dc70cc53d3d")] [assembly: AssemblyProduct("HQoL")] [assembly: AssemblyTitle("OreoM.HQoL.73")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.12.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 HQoL { [BepInPlugin("OreoM.HQoL.73", "HQoL", "1.0.12")] public class HQoL : BaseUnityPlugin { internal static SellModule sellModule; internal static HQoLConfig modConfig; private const string UnityVersion = "2022.3.62"; public static HQoL Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; if (!Application.unityVersion.StartsWith("2022.3.62", StringComparison.OrdinalIgnoreCase)) { Logger.LogInfo((object)"Skipping OreoM.HQoL.73, no patches will be loaded."); return; } sellModule = new SellModule(); modConfig = new HQoLConfig(((BaseUnityPlugin)this).Config); Patch(); NetcodePatch(); Logger.LogInfo((object)"OreoM.HQoL.73 v1.0.12 has loaded!"); } internal static void NetcodePatch() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (Exception arg) { Logger.LogWarning((object)$"Netcode patch failed, but it's likely intended: {arg}"); } } } } } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("OreoM.HQoL.73"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public class HQoLConfig { public HashSet<string> storageException; public readonly ConfigEntry<string> storageExceptionConfig; public HQoLConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; storageExceptionConfig = cfg.Bind<string>("General", "Dont store list", "Shotgun, Knife", "What items should not be stored automatically"); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; storageException = new HashSet<string>(from s in storageExceptionConfig.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) select s.Trim().ToLower()); } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "OreoM.HQoL.73"; public const string PLUGIN_NAME = "HQoL"; public const string PLUGIN_VERSION = "1.0.12"; } } namespace HQoL.Util { internal class SellModule { public int sellValue; public List<int> itemReferenceIndexToSell; public Dictionary<string, int> itemTypesToSell; public SellModule() { itemTypesToSell = new Dictionary<string, int>(); itemReferenceIndexToSell = new List<int>(); } public bool FindItemsWithTotalValue(int value, bool useOvertime) { int num = value; int num2 = 0; int num3 = 10 * value; int profitQuota = TimeOfDay.Instance.profitQuota; int num4 = ((TimeOfDay.Instance.daysUntilDeadline == 0) ? (-1) : TimeOfDay.Instance.daysUntilDeadline); float companyBuyingRate = StartOfRound.Instance.companyBuyingRate; while (useOvertime) { int num5 = num; num = (num2 + num3) / 2; int num6 = Math.Max(((int)((float)num * companyBuyingRate) - profitQuota) / 5 + 15 * num4, 0); if ((int)((float)num * companyBuyingRate) + num6 >= value) { num3 = num; } else { num2 = num; } if ((int)((float)num * companyBuyingRate) + num6 == value) { break; } if (num5 == num) { num++; break; } } int num7 = num; int num8 = 0; foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { num8 += item.value; } if (num7 > num8) { return FindAllItems(); } if (num7 < 1) { return false; } bool[,] array = new bool[num8 + 1, HQoLNetwork.Instance.netStorage.Count + 1]; for (int i = 0; i < num8 + 1; i++) { for (int j = 0; j < HQoLNetwork.Instance.netStorage.Count + 1; j++) { array[i, j] = false; } } array[0, 0] = true; for (int k = 0; k < num8 + 1; k++) { for (int l = 0; l < HQoLNetwork.Instance.netStorage.Count; l++) { if (k >= HQoLNetwork.Instance.netStorage[l].value) { array[k, l + 1] = array[k, l] || array[k - HQoLNetwork.Instance.netStorage[l].value, l]; } else { array[k, l + 1] = array[k, l]; } if (k >= num7 && array[k, HQoLNetwork.Instance.netStorage.Count]) { goto end_IL_020b; } } continue; end_IL_020b: break; } itemReferenceIndexToSell.Clear(); itemTypesToSell.Clear(); int m = num7; int num9; for (num9 = HQoLNetwork.Instance.netStorage.Count; !array[m, num9]; m++) { } sellValue = m; while (m != 0) { while (array[m, num9 - 1]) { num9--; } num9--; m -= HQoLNetwork.Instance.netStorage[num9].value; itemReferenceIndexToSell.Add(num9); Dictionary<string, int> dictionary = itemTypesToSell; ItemReference itemReference = HQoLNetwork.Instance.netStorage[num9]; if (dictionary.ContainsKey(((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString())) { Dictionary<string, int> dictionary2 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[num9]; dictionary2[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()]++; } else { Dictionary<string, int> dictionary3 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[num9]; dictionary3[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()] = 1; } } return true; } public bool FindAllItems() { sellValue = HQoLNetwork.Instance.totalStorageValue.Value; itemReferenceIndexToSell.Clear(); itemTypesToSell.Clear(); for (int i = 0; i < HQoLNetwork.Instance.netStorage.Count; i++) { itemReferenceIndexToSell.Add(i); Dictionary<string, int> dictionary = itemTypesToSell; ItemReference itemReference = HQoLNetwork.Instance.netStorage[i]; if (dictionary.ContainsKey(((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString())) { Dictionary<string, int> dictionary2 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[i]; dictionary2[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()]++; } else { Dictionary<string, int> dictionary3 = itemTypesToSell; itemReference = HQoLNetwork.Instance.netStorage[i]; dictionary3[((object)(FixedString32Bytes)(ref itemReference.itemName)).ToString()] = 1; } } return true; } public void ClearSellModule() { sellValue = 0; itemTypesToSell.Clear(); itemReferenceIndexToSell.Clear(); } } public struct ItemReference : INetworkSerializable, IEquatable<ItemReference> { public FixedString32Bytes itemName; public int value; public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //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_0020: 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) ((BufferSerializer<FixedString32Bytes>*)(&serializer))->SerializeValue<FixedString32Bytes>(ref itemName, default(ForFixedStrings)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref value, default(ForPrimitives)); } public bool Equals(ItemReference other) { if ((ref itemName) == (ref other.itemName)) { return value == other.value; } return false; } } } namespace HQoL.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(GameNetworkManager __instance) { HQoLNetwork.CreateAndRegisterPrefab(); } [HarmonyPatch("Disconnect")] [HarmonyPrefix] private static void PreDisconnect(GameNetworkManager __instance) { bool flag = false; if (StartOfRoundPatches.hasChallengeFile) { flag = StartOfRoundPatches.isChallengeFileRef.Invoke(StartOfRound.Instance); } if (HQoLNetwork.Instance.storageHasBeenModified && __instance.isHostingGame && StartOfRound.Instance.inShipPhase && !flag) { try { List<ItemReference> list = new List<ItemReference>(); foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { list.Add(item); } ES3.Save<List<ItemReference>>("HQoL.ScrapList", list, GameNetworkManager.Instance.currentSaveFileName); HQoLNetwork.Instance.storageHasBeenModified = false; } catch (Exception arg) { HQoL.Logger.LogError((object)$"Error while trying to save game values when disconnecting as host: {arg}"); } } HQoLNetwork.DespawnNetworkHandler(); } private static void NewCodeFromV81() { ES3.DeleteKey("shipGrabbableItemIDs", GameNetworkManager.Instance.currentSaveFileName); ES3.DeleteKey("shipGrabbableItemPos", GameNetworkManager.Instance.currentSaveFileName); ES3.DeleteKey("shipScrapValues", GameNetworkManager.Instance.currentSaveFileName); ES3.DeleteKey("shipItemSaveData", GameNetworkManager.Instance.currentSaveFileName); } [HarmonyPatch("SaveItemsInShip")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileSaveItemsInShip(IEnumerable<CodeInstruction> codes) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(codes, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(List<int>), "Count"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Bgt, (object)null, (string)null) }); CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GameNetworkManagerPatches), "NewCodeFromV81", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Ret, (object)null) }; val.Advance(6); if (val.Opcode != OpCodes.Ret) { HQoL.Logger.LogInfo((object)"0 item save bug already fix, this is likely v80+"); return codes; } List<Label> labels = val.Labels; return val.Advance(-2).RemoveInstructions(3).Insert(array) .AddLabels((IEnumerable<Label>)labels) .InstructionEnumeration(); } } [HarmonyPatch(typeof(ItemDropship))] internal class ItemDropshipPatches { private static FieldRef<ItemDropship, int> refPreOrderedVehicle = null; private static bool hasCruiser = false; private static int preOrderedVehicle = -1; private static int preOrderedItemCount = 0; private static DepositItemsDesk? deskReference; [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(ItemDropship __instance) { FieldInfo fieldInfo = AccessTools.Field(typeof(ItemDropship), "orderedVehicleFromTerminal"); if (fieldInfo != null) { refPreOrderedVehicle = AccessTools.FieldRefAccess<ItemDropship, int>(fieldInfo); hasCruiser = true; } __instance.shipAnimator.speed = 1f; deskReference = Object.FindObjectOfType<DepositItemsDesk>(); if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { __instance.playersFirstOrder = false; } } [HarmonyPatch("LandShipClientRpc")] [HarmonyPrefix] private static void PreLandShipClientRpc(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { __instance.shipAnimator.speed = 5f; } } [HarmonyPatch("OpenShipDoorsOnServer")] [HarmonyPostfix] private static void PostOpenShipDoorsOnServer(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { __instance.ShipLeaveClientRpc(); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void PostUpdate(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)deskReference == (Object)null)) { int num = -1; if (hasCruiser) { num = refPreOrderedVehicle.Invoke(__instance); } if (!__instance.deliveringOrder && (preOrderedItemCount != __instance.terminalScript.numberOfItemsInDropship || preOrderedVehicle < num)) { __instance.shipTimer = 34f; } preOrderedItemCount = __instance.terminalScript.numberOfItemsInDropship; preOrderedVehicle = num; } } } [HarmonyPatch(typeof(ItemDropship))] internal class ItemDropshipLandVehiclePatch { private static MethodBase refDeliverVehicleClientRpc; private static bool Prepare() { refDeliverVehicleClientRpc = AccessTools.Method(typeof(ItemDropship), "DeliverVehicleClientRpc", (Type[])null, (Type[])null); if (refDeliverVehicleClientRpc == null) { HQoL.Logger.LogInfo((object)"Method DeliverVehicleClientRpc in ItemDropship not found, skipping..."); return false; } return true; } private static MethodBase TargetMethod() { return refDeliverVehicleClientRpc; } private static void Prefix(ItemDropship __instance) { if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap && !((Object)(object)Object.FindObjectOfType<DepositItemsDesk>() == (Object)null)) { __instance.shipAnimator.speed = 1f; } } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatches { [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyPostfix] private static void PostDespawnPropsAtEndOfRound(RoundManager __instance) { if (StartOfRound.Instance.allPlayersDead && ((NetworkBehaviour)__instance).IsServer) { HQoLNetwork.Instance.ClearItems(); } } } [HarmonyPatch] internal class ShotgunItemPatches { private static PropertyInfo transformInfo; private static MethodBase refLoadItemSaveData; private static bool Prepare() { Type type = AccessTools.TypeByName("ShotgunItem"); if (type == null) { HQoL.Logger.LogInfo((object)"Class ShotgunItem not found, skipping..."); return false; } transformInfo = AccessTools.Property(type, "transform"); refLoadItemSaveData = AccessTools.Method(type, "LoadItemSaveData", (Type[])null, (Type[])null); if (refLoadItemSaveData == null) { HQoL.Logger.LogInfo((object)"Method LoadItemSaveData in ShotgunItem not found, skipping..."); return false; } return true; } private static MethodBase TargetMethod() { return refLoadItemSaveData; } private static void Prefix(object __instance, int saveData) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001f: 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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (GameNetworkManager.Instance.isHostingGame) { Transform val = (Transform)transformInfo.GetValue(__instance); Vector3 position = val.position; position += new Vector3(1f - (float)saveData / 2f, 0f, 0f); val.position = position; } } } [HarmonyPatch] internal class SprayPaintItemPatches { private static PropertyInfo transformInfo; private static FieldInfo isWeedKillerSprayBottleInfo; private static MethodBase refLoadItemSaveData; private static bool Prepare() { Type type = AccessTools.TypeByName("SprayPaintItem"); if (type == null) { HQoL.Logger.LogInfo((object)"Class SprayPaintItem not found, skipping..."); return false; } transformInfo = AccessTools.Property(type, "transform"); isWeedKillerSprayBottleInfo = AccessTools.Field(type, "isWeedKillerSprayBottle"); if (isWeedKillerSprayBottleInfo == null) { HQoL.Logger.LogInfo((object)"Property isWeedKillerSprayBottleInfo in SprayPaintItem not found, skipping..."); return false; } refLoadItemSaveData = AccessTools.Method(type, "LoadItemSaveData", (Type[])null, (Type[])null); if (refLoadItemSaveData == null) { HQoL.Logger.LogInfo((object)"Method LoadItemSaveData in SprayPaintItem not found, skipping..."); return false; } return true; } private static MethodBase TargetMethod() { return refLoadItemSaveData; } private static void Prefix(object __instance, int saveData) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_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_005c: 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) if (GameNetworkManager.Instance.isHostingGame) { bool flag = (bool)isWeedKillerSprayBottleInfo.GetValue(__instance); Transform val = (Transform)transformInfo.GetValue(__instance); if (flag) { Vector3 position = val.position; position += new Vector3(-3f - (float)saveData / 50f, 0f, -2f); val.position = position; } } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatches { public static FieldRef<StartOfRound, bool> isChallengeFileRef; public static bool hasChallengeFile; [HarmonyPatch("Awake")] [HarmonyPrefix] private static void PreAwake(StartOfRound __instance) { HQoLNetwork.SpawnNetworkHandler(); } [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(StartOfRound __instance) { FieldInfo fieldInfo = AccessTools.Field(typeof(StartOfRound), "isChallengeFile"); if (fieldInfo != null) { isChallengeFileRef = AccessTools.FieldRefAccess<StartOfRound, bool>(fieldInfo); hasChallengeFile = true; } else { hasChallengeFile = false; HQoL.Logger.LogInfo((object)"Variable isChallengeFile not found, skipping..."); } } [HarmonyPatch("SetTimeAndPlanetToSavedSettings")] [HarmonyPostfix] private static void PostSetTimeAndPlanetToSavedSettings(StartOfRound __instance) { List<ItemReference> itemRefs = ES3.Load<List<ItemReference>>("HQoL.ScrapList", GameNetworkManager.Instance.currentSaveFileName, new List<ItemReference>()); HQoLNetwork.Instance.AddItems(itemRefs); } [HarmonyPatch("PlayFirstDayShipAnimation")] [HarmonyPrefix] private static void PrePlayFirstDayShipAnimation(StartOfRound __instance) { __instance.shipIntroSpeechSFX = __instance.disableSpeakerSFX; } [HarmonyPatch("PassTimeToNextDay")] [HarmonyPostfix] private static void PostPassTimeToNextDay(StartOfRound __instance) { bool flag = false; if (hasChallengeFile) { _ = ref isChallengeFileRef.Invoke(__instance); } if (!GameNetworkManager.Instance.isHostingGame || flag) { return; } bool flag2 = false; if (TimeOfDay.Instance.daysUntilDeadline == 0 && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)) { List<GrabbableObject> list = new List<GrabbableObject>(Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0)); list.RemoveAll((GrabbableObject scrapObj) => scrapObj.isHeld || !scrapObj.itemProperties.isScrap || ((Object)scrapObj.itemProperties).name == "GiftBox" || HQoL.modConfig.storageException.Contains(((Object)scrapObj.itemProperties).name.ToLower()) || HQoL.modConfig.storageException.Contains(((Component)scrapObj).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText.ToLower())); HQoLNetwork.Instance.AddItems(list.ToArray()); list.ForEach(delegate(GrabbableObject scrapObj) { ((NetworkBehaviour)scrapObj).NetworkObject.Despawn(true); }); flag2 = true; } if (!flag2 && !HQoLNetwork.Instance.storageHasBeenModified) { return; } try { List<ItemReference> list2 = new List<ItemReference>(); foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { list2.Add(item); } ES3.Save<List<ItemReference>>("HQoL.ScrapList", list2, GameNetworkManager.Instance.currentSaveFileName); HQoLNetwork.Instance.storageHasBeenModified = false; } catch (Exception arg) { HQoL.Logger.LogError((object)$"Error while trying to save game values when disconnecting as host: {arg}"); } } [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileLoadShipGrabbableItems(IEnumerable<CodeInstruction> codes) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[8] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Ldloc_S, (object)9), new CodeInstruction(OpCodes.Ldelem_I4, (object)null), new CodeInstruction(OpCodes.Ldloc_2, (object)null), new CodeInstruction(OpCodes.Ldloc_S, (object)9), new CodeInstruction(OpCodes.Ldelema, (object)typeof(Vector3)), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StartOfRoundHelper), "MoveItemsToSpecialStartPosition", (Type[])null, (Type[])null)) }; CodeMatcher val = new CodeMatcher(codes, (ILGenerator)null); val.End().MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null) }).Advance(-9); int pos = val.Pos; val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StartOfRound), "shipBounds"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Collider), "bounds"), (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }); int pos2 = val.Pos; return val.RemoveInstructionsInRange(pos2, pos).Insert(array).InstructionEnumeration(); } } public static class StartOfRoundHelper { public const int jetpackID = 4; public const int keyID = 5; public const int shovelID = 10; public const int shotgunID = 59; public const int knifeID = 68; public static void MoveItemsToSpecialStartPosition(StartOfRound instance, int currItemID, ref Vector3 currItemPosition) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) switch (currItemID) { case 4: currItemPosition.x = 5f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -16.5f; return; case 5: currItemPosition.x = -4f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -13f; return; case 10: currItemPosition.x = 3.5f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -14.5f; return; case 59: currItemPosition.x = 0f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -13f; return; case 68: currItemPosition.x = -1f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -13f; return; } if (instance.allItemsList.itemsList[currItemID].isScrap) { currItemPosition.x = -4.5f; currItemPosition.y = instance.playerSpawnPositions[1].position.y + 0.5f; currItemPosition.z = -15f; } else { currItemPosition = instance.playerSpawnPositions[1].position; currItemPosition.x += (float)currItemID / 15f; currItemPosition.z += 2f; currItemPosition.y += 0.5f; } } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatches { [HarmonyPatch("ParsePlayerSentence")] [HarmonyPrefix] private static void ParsePlayerSentencePrePatch(Terminal __instance) { TerminalHelper.terminalInput = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower(); } [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(Terminal __instance) { TerminalHelper.terminal = Object.FindAnyObjectByType<Terminal>(); ((TMP_Text)__instance.topRightText).enableAutoSizing = true; if (!TerminalHelper.internalStateInitialized) { TerminalHelper.TerminalNodes.InitializeNodes(); TerminalHelper.TerminalKeywords.InitializeKeywords(); TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[0].result = TerminalHelper.TerminalNodes.sellCommand; TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[1].result = TerminalHelper.TerminalNodes.depositCommand; TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[2].result = TerminalHelper.TerminalNodes.checkScrap; TerminalHelper.TerminalKeywords.defaultVerb.compatibleNouns[3].result = TerminalHelper.TerminalNodes.confirmOvertime; TerminalHelper.internalStateInitialized = true; } if (!TerminalHelper.addedCustomKeywords) { TerminalHelper.TerminalKeywords.sellWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; TerminalHelper.TerminalKeywords.depositWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; TerminalHelper.TerminalKeywords.checkScrapWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; TerminalHelper.TerminalKeywords.overtimeWord.defaultVerb = TerminalHelper.TerminalKeywords.defaultVerb; int num = __instance.terminalNodes.allKeywords.Count(); List<TerminalKeyword> list = new List<TerminalKeyword>(__instance.terminalNodes.allKeywords); list.Add(TerminalHelper.TerminalKeywords.sellWord); list.Add(TerminalHelper.TerminalKeywords.depositWord); list.Add(TerminalHelper.TerminalKeywords.checkScrapWord); list.Add(TerminalHelper.TerminalKeywords.overtimeWord); list.Add(TerminalHelper.TerminalKeywords.defaultVerb); __instance.terminalNodes.allKeywords = list.ToArray(); TerminalHelper.addedCustomKeywords = true; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void PostUpdate(Terminal __instance) { if (__instance.terminalInUse) { TextMeshProUGUI topRightText = __instance.topRightText; ((TMP_Text)topRightText).text = ((TMP_Text)topRightText).text + $"\n<color=#09DBB5>${HQoLNetwork.Instance.totalStorageValue.Value}"; } } [HarmonyPatch("LoadNewNode")] [HarmonyPostfix] private static void PostLoadNewNode(Terminal __instance) { if (!TerminalHelper.isSellValid && (Object)(object)__instance.currentNode == (Object)(object)TerminalHelper.TerminalNodes.sellCommand) { __instance.currentNode = TerminalHelper.TerminalNodes.sellDeny; } else if (!TerminalHelper.isDepositValid && (Object)(object)__instance.currentNode == (Object)(object)TerminalHelper.TerminalNodes.depositCommand) { __instance.currentNode = TerminalHelper.TerminalNodes.depositDeny; } } [HarmonyPatch("TextPostProcess")] [HarmonyPrefix] private static void PreTextPostProcess(Terminal __instance, ref string modifiedDisplayText) { if (modifiedDisplayText.Contains("[sellConfirm]")) { modifiedDisplayText = modifiedDisplayText.Replace("[sellConfirm]", TerminalHelper.SellItems()); } else if (modifiedDisplayText.Contains("[sell]")) { modifiedDisplayText = modifiedDisplayText.Replace("[sell]", TerminalHelper.FindItemsToSell()); } else if (modifiedDisplayText.Contains("[depositConfirm]")) { modifiedDisplayText = modifiedDisplayText.Replace("[depositConfirm]", TerminalHelper.DepositItems()); } else if (modifiedDisplayText.Contains("[deposit]")) { modifiedDisplayText = modifiedDisplayText.Replace("[deposit]", TerminalHelper.FindItemsToDeposit()); } else if (modifiedDisplayText.Contains("[confirmOvertime]")) { modifiedDisplayText = modifiedDisplayText.Replace("[confirmOvertime]", TerminalHelper.ConfirmOvertime()); } else if (modifiedDisplayText.Contains("[checkScrap]")) { modifiedDisplayText = modifiedDisplayText.Replace("[checkScrap]", TerminalHelper.CheckItems()); } } } internal static class TerminalHelper { public class TerminalNodes { public static TerminalNode sellDeny; public static TerminalNode sellConfirm; public static TerminalNode sellCommand; public static TerminalNode confirmOvertime; public static TerminalNode depositDeny; public static TerminalNode depositConfirm; public static TerminalNode depositCommand; public static TerminalNode checkScrap; public static void InitializeNodes() { sellDeny = ScriptableObject.CreateInstance<TerminalNode>(); sellDeny.acceptAnything = false; sellDeny.buyItemIndex = -1; sellDeny.buyRerouteToMoon = -1; sellDeny.buyUnlockable = false; sellDeny.clearPreviousText = false; sellDeny.creatureFileID = -1; sellDeny.creatureName = ""; sellDeny.displayPlanetInfo = -1; sellDeny.displayText = "\nSell canceled.\n\n"; sellDeny.displayTexture = null; sellDeny.displayVideo = null; ((Object)sellDeny).hideFlags = (HideFlags)0; sellDeny.isConfirmationNode = false; sellDeny.itemCost = 0; sellDeny.loadImageSlowly = false; sellDeny.maxCharactersToType = 35; ((Object)sellDeny).name = "sellDeny"; sellDeny.overrideOptions = false; sellDeny.persistentImage = false; sellDeny.playClip = null; sellDeny.playSyncedClip = -1; sellDeny.returnFromStorage = false; sellDeny.shipUnlockableID = -1; sellDeny.storyLogFileID = -1; sellDeny.terminalEvent = ""; sellDeny.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; sellConfirm = ScriptableObject.CreateInstance<TerminalNode>(); sellConfirm.acceptAnything = false; sellConfirm.buyItemIndex = -1; sellConfirm.buyRerouteToMoon = -1; sellConfirm.buyUnlockable = false; sellConfirm.clearPreviousText = false; sellConfirm.creatureFileID = -1; sellConfirm.creatureName = ""; sellConfirm.displayPlanetInfo = -1; sellConfirm.displayText = "[sellConfirm]"; sellConfirm.displayTexture = null; sellConfirm.displayVideo = null; ((Object)sellConfirm).hideFlags = (HideFlags)0; sellConfirm.isConfirmationNode = false; sellConfirm.itemCost = 0; sellConfirm.loadImageSlowly = false; sellConfirm.maxCharactersToType = 35; ((Object)sellConfirm).name = "sellConfirm"; sellConfirm.overrideOptions = false; sellConfirm.persistentImage = false; sellConfirm.playClip = null; sellConfirm.playSyncedClip = 0; sellConfirm.returnFromStorage = false; sellConfirm.shipUnlockableID = -1; sellConfirm.storyLogFileID = -1; sellConfirm.terminalEvent = ""; sellConfirm.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; sellCommand = ScriptableObject.CreateInstance<TerminalNode>(); sellCommand.acceptAnything = false; sellCommand.buyItemIndex = -1; sellCommand.buyRerouteToMoon = -1; sellCommand.buyUnlockable = false; sellCommand.clearPreviousText = true; sellCommand.creatureFileID = -1; sellCommand.creatureName = ""; sellCommand.displayPlanetInfo = -1; sellCommand.displayText = "[sell]"; sellCommand.displayTexture = null; sellCommand.displayVideo = null; ((Object)sellCommand).hideFlags = (HideFlags)0; sellCommand.isConfirmationNode = true; sellCommand.itemCost = 0; sellCommand.loadImageSlowly = false; sellCommand.maxCharactersToType = 35; ((Object)sellCommand).name = "sellCommand"; sellCommand.overrideOptions = true; sellCommand.persistentImage = false; sellCommand.playClip = null; sellCommand.playSyncedClip = -1; sellCommand.returnFromStorage = false; sellCommand.shipUnlockableID = -1; sellCommand.storyLogFileID = -1; sellCommand.terminalEvent = ""; sellCommand.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[3], sellConfirm), CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[4], sellDeny) }; confirmOvertime = ScriptableObject.CreateInstance<TerminalNode>(); confirmOvertime.acceptAnything = false; confirmOvertime.buyItemIndex = -1; confirmOvertime.buyRerouteToMoon = -1; confirmOvertime.buyUnlockable = false; confirmOvertime.clearPreviousText = true; confirmOvertime.creatureFileID = -1; confirmOvertime.creatureName = ""; confirmOvertime.displayPlanetInfo = -1; confirmOvertime.displayText = "[confirmOvertime]"; confirmOvertime.displayTexture = null; confirmOvertime.displayVideo = null; ((Object)confirmOvertime).hideFlags = (HideFlags)0; confirmOvertime.isConfirmationNode = false; confirmOvertime.itemCost = 0; confirmOvertime.loadImageSlowly = false; confirmOvertime.maxCharactersToType = 35; ((Object)confirmOvertime).name = "confirmOvertime"; confirmOvertime.overrideOptions = false; confirmOvertime.persistentImage = false; confirmOvertime.playClip = null; confirmOvertime.playSyncedClip = -1; confirmOvertime.returnFromStorage = false; confirmOvertime.shipUnlockableID = -1; confirmOvertime.storyLogFileID = -1; confirmOvertime.terminalEvent = ""; confirmOvertime.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositDeny = ScriptableObject.CreateInstance<TerminalNode>(); depositDeny.acceptAnything = false; depositDeny.buyItemIndex = -1; depositDeny.buyRerouteToMoon = -1; depositDeny.buyUnlockable = false; depositDeny.clearPreviousText = false; depositDeny.creatureFileID = -1; depositDeny.creatureName = ""; depositDeny.displayPlanetInfo = -1; depositDeny.displayText = "\nItem storing canceled.\n\n"; depositDeny.displayTexture = null; depositDeny.displayVideo = null; ((Object)depositDeny).hideFlags = (HideFlags)0; depositDeny.isConfirmationNode = false; depositDeny.itemCost = 0; depositDeny.loadImageSlowly = false; depositDeny.maxCharactersToType = 35; ((Object)depositDeny).name = "depositDeny"; depositDeny.overrideOptions = false; depositDeny.persistentImage = false; depositDeny.playClip = null; depositDeny.playSyncedClip = -1; depositDeny.returnFromStorage = false; depositDeny.shipUnlockableID = -1; depositDeny.storyLogFileID = -1; depositDeny.terminalEvent = ""; depositDeny.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositConfirm = ScriptableObject.CreateInstance<TerminalNode>(); depositConfirm.acceptAnything = false; depositConfirm.buyItemIndex = -1; depositConfirm.buyRerouteToMoon = -1; depositConfirm.buyUnlockable = false; depositConfirm.clearPreviousText = false; depositConfirm.creatureFileID = -1; depositConfirm.creatureName = ""; depositConfirm.displayPlanetInfo = -1; depositConfirm.displayText = "[depositConfirm]"; depositConfirm.displayTexture = null; depositConfirm.displayVideo = null; ((Object)depositConfirm).hideFlags = (HideFlags)0; depositConfirm.isConfirmationNode = false; depositConfirm.itemCost = 0; depositConfirm.loadImageSlowly = false; depositConfirm.maxCharactersToType = 35; ((Object)depositConfirm).name = "depositConfirm"; depositConfirm.overrideOptions = false; depositConfirm.persistentImage = false; depositConfirm.playClip = null; depositConfirm.playSyncedClip = -1; depositConfirm.returnFromStorage = false; depositConfirm.shipUnlockableID = -1; depositConfirm.storyLogFileID = -1; depositConfirm.terminalEvent = ""; depositConfirm.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositCommand = ScriptableObject.CreateInstance<TerminalNode>(); depositCommand.acceptAnything = false; depositCommand.buyItemIndex = -1; depositCommand.buyRerouteToMoon = -1; depositCommand.buyUnlockable = false; depositCommand.clearPreviousText = true; depositCommand.creatureFileID = -1; depositCommand.creatureName = ""; depositCommand.displayPlanetInfo = -1; depositCommand.displayText = "[deposit]"; depositCommand.displayTexture = null; depositCommand.displayVideo = null; ((Object)depositCommand).hideFlags = (HideFlags)0; depositCommand.isConfirmationNode = true; depositCommand.itemCost = 0; depositCommand.loadImageSlowly = false; depositCommand.maxCharactersToType = 35; ((Object)depositCommand).name = "depositCommand"; depositCommand.overrideOptions = true; depositCommand.persistentImage = false; depositCommand.playClip = null; depositCommand.playSyncedClip = -1; depositCommand.returnFromStorage = false; depositCommand.shipUnlockableID = -1; depositCommand.storyLogFileID = -1; depositCommand.terminalEvent = ""; depositCommand.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[3], depositConfirm), CompatibleNounMixedCtor(terminal.terminalNodes.allKeywords[4], depositDeny) }; checkScrap = ScriptableObject.CreateInstance<TerminalNode>(); checkScrap.acceptAnything = false; checkScrap.buyItemIndex = -1; checkScrap.buyRerouteToMoon = -1; checkScrap.buyUnlockable = false; checkScrap.clearPreviousText = true; checkScrap.creatureFileID = -1; checkScrap.creatureName = ""; checkScrap.displayPlanetInfo = -1; checkScrap.displayText = "[checkScrap]"; checkScrap.displayTexture = null; checkScrap.displayVideo = null; ((Object)checkScrap).hideFlags = (HideFlags)0; checkScrap.isConfirmationNode = false; checkScrap.itemCost = 0; checkScrap.loadImageSlowly = false; checkScrap.maxCharactersToType = 35; ((Object)checkScrap).name = "checkScrap"; checkScrap.overrideOptions = false; checkScrap.persistentImage = false; checkScrap.playClip = null; checkScrap.playSyncedClip = -1; checkScrap.returnFromStorage = false; checkScrap.shipUnlockableID = -1; checkScrap.storyLogFileID = -1; checkScrap.terminalEvent = ""; checkScrap.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[0]; } } public class TerminalKeywords { public static TerminalKeyword sellWord; public static TerminalKeyword depositWord; public static TerminalKeyword overtimeWord; public static TerminalKeyword checkScrapWord; public static TerminalKeyword defaultVerb; public static void InitializeKeywords() { sellWord = ScriptableObject.CreateInstance<TerminalKeyword>(); sellWord.accessTerminalObjects = false; sellWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; sellWord.defaultVerb = null; ((Object)sellWord).hideFlags = (HideFlags)0; sellWord.isVerb = false; ((Object)sellWord).name = "SellWord"; sellWord.specialKeywordResult = null; sellWord.word = "sell"; depositWord = ScriptableObject.CreateInstance<TerminalKeyword>(); depositWord.accessTerminalObjects = false; depositWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; depositWord.defaultVerb = null; ((Object)depositWord).hideFlags = (HideFlags)0; depositWord.isVerb = false; ((Object)depositWord).name = "DepositWord"; depositWord.specialKeywordResult = null; depositWord.word = "deposit"; overtimeWord = ScriptableObject.CreateInstance<TerminalKeyword>(); overtimeWord.accessTerminalObjects = false; overtimeWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; overtimeWord.defaultVerb = null; ((Object)overtimeWord).hideFlags = (HideFlags)0; overtimeWord.isVerb = false; ((Object)overtimeWord).name = "OvertimeWord"; overtimeWord.specialKeywordResult = null; overtimeWord.word = "overtime"; checkScrapWord = ScriptableObject.CreateInstance<TerminalKeyword>(); checkScrapWord.accessTerminalObjects = false; checkScrapWord.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[0]; checkScrapWord.defaultVerb = null; ((Object)checkScrapWord).hideFlags = (HideFlags)0; checkScrapWord.isVerb = false; ((Object)checkScrapWord).name = "CheckScrapWord"; checkScrapWord.specialKeywordResult = null; checkScrapWord.word = "check"; defaultVerb = ScriptableObject.CreateInstance<TerminalKeyword>(); defaultVerb.accessTerminalObjects = false; defaultVerb.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[4] { CompatibleNounMixedCtor(sellWord, TerminalNodes.sellCommand), CompatibleNounMixedCtor(depositWord, TerminalNodes.depositCommand), CompatibleNounMixedCtor(checkScrapWord, TerminalNodes.checkScrap), CompatibleNounMixedCtor(overtimeWord, TerminalNodes.confirmOvertime) }; defaultVerb.defaultVerb = null; ((Object)defaultVerb).hideFlags = (HideFlags)0; defaultVerb.isVerb = true; ((Object)defaultVerb).name = "DefaultVerb"; defaultVerb.specialKeywordResult = null; defaultVerb.word = "_"; } } public const string sellConfirmString = "[sellConfirm]"; public const string sellCommandString = "[sell]"; public const string confirmOvertimeString = "[confirmOvertime]"; public const string depositConfirmString = "[depositConfirm]"; public const string depositCommandString = "[deposit]"; public const string checkScrapString = "[checkScrap]"; public static Terminal terminal = null; public static string terminalInput = null; public static bool addedCustomKeywords = false; public static bool internalStateInitialized = false; public static bool isSellValid = false; public static bool isDepositValid = false; private static string itemNameToDeposit = ""; private static CompatibleNoun CompatibleNounMixedCtor(TerminalKeyword newNoun, TerminalNode newResult) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown Type typeFromHandle = typeof(CompatibleNoun); ConstructorInfo constructor = typeFromHandle.GetConstructor(new Type[2] { typeof(TerminalKeyword), typeof(TerminalNode) }); if (constructor != null) { return (CompatibleNoun)constructor.Invoke(new object[2] { newNoun, newResult }); } ConstructorInfo constructor2 = typeFromHandle.GetConstructor(Type.EmptyTypes); if (constructor2 != null) { CompatibleNoun val = (CompatibleNoun)constructor2.Invoke(null); val.noun = newNoun; val.result = newResult; return val; } throw new MissingMethodException("The compiler complains if this exception isn't here :3"); } public static string FindItemsToSell() { if (StartOfRound.Instance.inShipPhase) { isSellValid = false; return "Cannot sell while in orbit.\n\n"; } if ((Object)(object)Object.FindAnyObjectByType<DepositItemsDesk>() == (Object)null) { isSellValid = false; return "Current moon does not have a sell counter.\n\n"; } string[] array = terminalInput.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); bool useOvertime = terminalInput.Contains("-o"); if (array.Count() < 2 || (!int.TryParse(array[1], out var result) && !array[1].Equals("all", StringComparison.OrdinalIgnoreCase) && !array[1].Equals("quota", StringComparison.OrdinalIgnoreCase))) { isSellValid = false; terminal.currentNode = TerminalNodes.sellDeny; return "Invalid sell command.\n\n"; } if (array[1] == "all") { HQoL.sellModule.FindAllItems(); } else if (array[1] == "quota") { HQoL.sellModule.FindItemsWithTotalValue(TimeOfDay.Instance.profitQuota, useOvertime: false); } else { HQoL.sellModule.FindItemsWithTotalValue(result, useOvertime); } result = HQoL.sellModule.sellValue; string text = $"Found value to sell: ${result}\n"; int num = ((TimeOfDay.Instance.daysUntilDeadline == 0) ? (-1) : TimeOfDay.Instance.daysUntilDeadline); int num2 = Math.Max(((int)((float)result * StartOfRound.Instance.companyBuyingRate) - TimeOfDay.Instance.profitQuota) / 5 + 15 * num, 0); text += $"Overtime: ${num2} (Total: ${(int)((float)result * StartOfRound.Instance.companyBuyingRate) + num2})\n\n"; foreach (KeyValuePair<string, int> item in HQoL.sellModule.itemTypesToSell) { text += $"{item.Key} (x{item.Value})\n"; } text += "\nConfirm sell?\n\n"; isSellValid = true; return text; } public static string SellItems() { if (!isSellValid) { return "Items could not be sold.\n\n"; } int creditsEarned = (int)((float)HQoL.sellModule.sellValue * StartOfRound.Instance.companyBuyingRate); HQoLNetwork.Instance.SellItemsServerRpc(creditsEarned, HQoL.sellModule.itemReferenceIndexToSell.ToArray()); HQoL.sellModule.ClearSellModule(); isSellValid = false; return "Selling...\n\n"; } public static string FindItemsToDeposit() { if (!StartOfRound.Instance.inShipPhase && StartOfRound.Instance.currentLevelID != 3) { isDepositValid = false; return "Can only deposit items while the ship is in orbit or at company.\n\n"; } string text = terminalInput.Replace("deposit ", string.Empty); if (text.Length < 1) { isDepositValid = false; return "Deposit command needs an item name.\n\n"; } GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); if (text == "all") { Dictionary<string, int> dictionary = new Dictionary<string, int>(); GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { if (val.itemProperties.isScrap) { if (dictionary.ContainsKey(((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText)) { dictionary[((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText]++; } else { dictionary[((Component)val).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText] = 1; } } } string text2 = ""; int num = 0; foreach (KeyValuePair<string, int> item2 in dictionary) { num += item2.Value; text2 += $"{item2.Key} (x{item2.Value})\n"; } if (num == 0) { isDepositValid = false; return "No items to deposit.\n\n"; } itemNameToDeposit = "all"; isDepositValid = true; return $"Found {num} items to deposit.\n\n" + text2 + "\nConfirm?\n\n"; } HashSet<string> hashSet = new HashSet<string>(); GrabbableObject[] array3 = array; foreach (GrabbableObject val2 in array3) { if (val2.itemProperties.isScrap && !(((Object)val2.itemProperties).name == "GiftBox")) { string item = ((Object)val2.itemProperties).name + "#" + ((Component)val2).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText; hashSet.Add(item); } } bool flag = false; foreach (string item3 in hashSet) { if (!flag && item3.ToLower().Contains(text)) { itemNameToDeposit = item3.Split(new char[1] { '#' }, StringSplitOptions.RemoveEmptyEntries)[1]; flag = true; } } if (!flag) { isDepositValid = false; return "Could not find " + text + " to deposit.\n\n"; } int num2 = 0; GrabbableObject[] array4 = array; foreach (GrabbableObject val3 in array4) { if (val3.itemProperties.isScrap && !(((Object)val3.itemProperties).name == "GiftBox") && itemNameToDeposit == ((Component)val3).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText && !val3.isHeld) { num2++; } } isDepositValid = true; return $"Found {itemNameToDeposit} (x{num2}).\n\nConfirm?\n\n"; } public static string DepositItems() { if (!isDepositValid) { return "Items could not be deposited.\n\n"; } HQoLNetwork.Instance.DepositItemsServerRpc(itemNameToDeposit); return "Depositing...\n\n"; } public static string ConfirmOvertime() { int num = ((TimeOfDay.Instance.daysUntilDeadline == 0) ? (-1) : TimeOfDay.Instance.daysUntilDeadline); int num2 = Math.Max((TimeOfDay.Instance.quotaFulfilled - TimeOfDay.Instance.profitQuota) / 5 + 15 * num, 0); string text = $"Value sold: ${TimeOfDay.Instance.quotaFulfilled}\n"; text += $"Overtime: ${num2}\n"; text += $"Quota: ${TimeOfDay.Instance.profitQuota}\n"; return text + $"Total: ${terminal.groupCredits + num2}\n\n"; } public static string CheckItems() { //IL_0030: 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_00b3: 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_00d0: 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_004e: 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_007e: 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) int num = 0; Dictionary<string, int> dictionary = new Dictionary<string, int>(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); foreach (ItemReference item in HQoLNetwork.Instance.netStorage) { FixedString32Bytes itemName = item.itemName; if (dictionary.ContainsKey(((object)(FixedString32Bytes)(ref itemName)).ToString())) { itemName = item.itemName; dictionary[((object)(FixedString32Bytes)(ref itemName)).ToString()]++; Dictionary<string, int> dictionary3 = dictionary2; itemName = item.itemName; dictionary3[((object)(FixedString32Bytes)(ref itemName)).ToString()] += item.value; } else { itemName = item.itemName; dictionary[((object)(FixedString32Bytes)(ref itemName)).ToString()] = 1; itemName = item.itemName; dictionary2[((object)(FixedString32Bytes)(ref itemName)).ToString()] = item.value; } num++; } string text = $"{num} scrap in storage.\n\n"; foreach (string key in dictionary.Keys) { text += $"{key} (x{dictionary[key]}: ${dictionary2[key]})\n"; } return text + "\n"; } } } namespace HQoL.Network { internal class HQoLNetwork : NetworkBehaviour { private static GameObject prefab; public NetworkList<ItemReference> netStorage = new NetworkList<ItemReference>(); public NetworkVariable<int> totalStorageValue = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public bool storageHasBeenModified; public static HQoLNetwork Instance { get; private set; } public static void CreateAndRegisterPrefab() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab != (Object)null)) { prefab = new GameObject("OreoM.HQoL.73 Prefab"); GameObject obj = prefab; ((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D); NetworkObject val = prefab.AddComponent<NetworkObject>(); val.GlobalObjectIdHash = XXHash.Hash32(((Object)prefab).name); prefab.AddComponent<HQoLNetwork>(); NetworkManager.Singleton.AddNetworkPrefab(prefab); HQoL.Logger.LogInfo((object)"Network prefab created and registered"); } } public static void SpawnNetworkHandler() { if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(false); HQoL.Logger.LogInfo((object)"Network handler spawned"); } } public static void DespawnNetworkHandler() { if ((Object)(object)Instance != (Object)null && ((Component)Instance).gameObject.GetComponent<NetworkObject>().IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)) { ((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true); HQoL.Logger.LogInfo((object)"Network handler despawned"); } } private void Awake() { Instance = this; } public void AddItem(GrabbableObject item) { //IL_0020: 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) netStorage.Add(new ItemReference { itemName = FixedString32Bytes.op_Implicit(((Component)item).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText), value = item.scrapValue }); NetworkVariable<int> obj = totalStorageValue; obj.Value += item.scrapValue; storageHasBeenModified = true; } public void AddItems(GrabbableObject[] items) { foreach (GrabbableObject item in items) { AddItem(item); } } public void AddItems(List<ItemReference> itemRefs) { int num = 0; foreach (ItemReference itemRef in itemRefs) { netStorage.Add(itemRef); num += itemRef.value; } NetworkVariable<int> obj = totalStorageValue; obj.Value += num; storageHasBeenModified = true; } public void ClearItems() { netStorage.Clear(); totalStorageValue.Value = 0; storageHasBeenModified = true; } [ServerRpc(RequireOwnership = false)] public void SellItemsServerRpc(int creditsEarned, int[] indicesToSell) { //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3273020359u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, creditsEarned); bool flag = indicesToSell != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(indicesToSell, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3273020359u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; List<int> list = (from i in new List<int>(indicesToSell).Distinct() orderby i descending select i).ToList(); foreach (int item in list) { NetworkVariable<int> obj = totalStorageValue; obj.Value -= netStorage[item].value; netStorage.RemoveAt(item); } storageHasBeenModified = true; UpdateQuotaAndDisplayCreditsEarningClientRpc(creditsEarned); } [ClientRpc] public void UpdateQuotaAndDisplayCreditsEarningClientRpc(int creditsEarned) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2706010165u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, creditsEarned); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2706010165u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; EndOfGameStats gameStats = StartOfRound.Instance.gameStats; gameStats.scrapValueCollected += creditsEarned; Terminal terminal = TerminalHelper.terminal; terminal.groupCredits += creditsEarned; TimeOfDay instance = TimeOfDay.Instance; instance.quotaFulfilled += creditsEarned; TimeOfDay.Instance.UpdateProfitQuotaCurrentTime(); ((TMP_Text)HUDManager.Instance.moneyRewardsListText).text = ""; ((TMP_Text)HUDManager.Instance.moneyRewardsTotalText).text = $"TOTAL: ${creditsEarned}"; HUDManager.Instance.moneyRewardsAnimator.SetTrigger("showRewards"); HUDManager.Instance.rewardsScrollbar.value = 1f; } } } [ServerRpc(RequireOwnership = false)] public void DepositItemsServerRpc(string itemName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00ff: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1385542601u, val, (RpcDelivery)0); bool flag = itemName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(itemName, false); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1385542601u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; string itemName2 = itemName; List<GrabbableObject> list = new List<GrabbableObject>(Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0)); if (itemName2 == "all") { list.RemoveAll(delegate(GrabbableObject scrapObj) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) if (!scrapObj.isHeld && scrapObj.itemProperties.isScrap && !(((Object)scrapObj.itemProperties).name == "GiftBox") && !HQoL.modConfig.storageException.Contains(((Object)scrapObj.itemProperties).name.ToLower()) && !HQoL.modConfig.storageException.Contains(((Component)scrapObj).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText.ToLower())) { if (TimeOfDay.Instance.daysUntilDeadline != 0) { Bounds bounds2 = StartOfRound.Instance.shipInnerRoomBounds.bounds; return !((Bounds)(ref bounds2)).Contains(((Component)scrapObj).transform.position); } return false; } return true; }); } else { list.RemoveAll(delegate(GrabbableObject scrapObj) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) if (!scrapObj.isHeld && scrapObj.itemProperties.isScrap && !(((Object)scrapObj.itemProperties).name == "GiftBox") && !(((Component)scrapObj).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText != itemName2)) { if (TimeOfDay.Instance.daysUntilDeadline != 0) { Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds; return !((Bounds)(ref bounds)).Contains(((Component)scrapObj).transform.position); } return false; } return true; }); } AddItems(list.ToArray()); list.ForEach(delegate(GrabbableObject scrapObj) { ((NetworkBehaviour)scrapObj).NetworkObject.Despawn(true); }); storageHasBeenModified = true; } protected override void __initializeVariables() { if (netStorage == null) { throw new Exception("HQoLNetwork.netStorage cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)netStorage).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)netStorage, "netStorage"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)netStorage); if (totalStorageValue == null) { throw new Exception("HQoLNetwork.totalStorageValue cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)totalStorageValue).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)totalStorageValue, "totalStorageValue"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)totalStorageValue); ((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(3273020359u, new RpcReceiveHandler(__rpc_handler_3273020359), "SellItemsServerRpc"); ((NetworkBehaviour)this).__registerRpc(2706010165u, new RpcReceiveHandler(__rpc_handler_2706010165), "UpdateQuotaAndDisplayCreditsEarningClientRpc"); ((NetworkBehaviour)this).__registerRpc(1385542601u, new RpcReceiveHandler(__rpc_handler_1385542601), "DepositItemsServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3273020359(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int creditsEarned = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref creditsEarned); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); int[] indicesToSell = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref indicesToSell, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((HQoLNetwork)(object)target).SellItemsServerRpc(creditsEarned, indicesToSell); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2706010165(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int creditsEarned = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref creditsEarned); target.__rpc_exec_stage = (__RpcExecStage)1; ((HQoLNetwork)(object)target).UpdateQuotaAndDisplayCreditsEarningClientRpc(creditsEarned); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1385542601(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_0061: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string itemName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemName, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((HQoLNetwork)(object)target).DepositItemsServerRpc(itemName); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "HQoLNetwork"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<ItemReference>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<ItemReference>(); } } } namespace OreoM.HQoL.73.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }