using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using GameNetcodeStuff; using HQoL.Network; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using StatsTracker.Patches; using StatsTracker.Util; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("OreoM.HQoL.72")] [assembly: IgnoresAccessChecksTo("OreoM.HQoL.73")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OreoM.StatsTracker")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+fe7019100f364ca762c78adf05655ed6349a5945")] [assembly: AssemblyProduct("StatsTracker")] [assembly: AssemblyTitle("OreoM.StatsTracker")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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 StatsTracker { [BepInPlugin("OreoM.StatsTracker", "StatsTracker", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class StatsTracker : BaseUnityPlugin { internal static Stats? DayStats; internal static HttpSSE LocalServer = new HttpSSE(); internal static Dictionary VanillaInteriorNames = new Dictionary { { "Level1Flow", "Facility" }, { "Level2Flow", "Mansion" }, { "Level1FlowExtraLarge", "UnusedFacility" }, { "Level1Flow3Exits", "Facility3Exit" }, { "Level3Flow", "Mineshaft" } }; public static StatsTracker Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Patch(); if (Chainloader.PluginInfos.ContainsKey("OreoM.HQoL.72") || Chainloader.PluginInfos.ContainsKey("OreoM.HQoL.73")) { Harmony? harmony = Harmony; if (harmony != null) { harmony.PatchAll(typeof(HQoLTracker)); } } LocalServer.Start(); Logger.LogInfo((object)"OreoM.StatsTracker v1.0.2 has loaded!"); } 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.StatsTracker"); } 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!"); } internal static string GetCurrentTimeString() { float normalizedTimeOfDay = TimeOfDay.Instance.normalizedTimeOfDay; float num = TimeOfDay.Instance.numberOfHours; bool flag = false; string text = ""; string text2 = ""; int num2 = (int)(normalizedTimeOfDay * (60f * num)) + 360; int num3 = (int)Mathf.Floor((float)(num2 / 60)); text = (flag ? "\n" : " "); text2 = text + "AM"; if (num3 >= 24) { return "12:00 " + text + " AM"; } text2 = ((num3 >= 12) ? (text + "PM") : (text + "AM")); if (num3 > 12) { num3 %= 12; } int num4 = num2 % 60; return $"{num3:00}:{num4:00}".TrimStart('0') + text2; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "OreoM.StatsTracker"; public const string PLUGIN_NAME = "StatsTracker"; public const string PLUGIN_VERSION = "1.0.2"; } } namespace StatsTracker.Util { public class HttpSSE { private HttpListener? listener; private string? currentJson; private Thread? serverThread; private const int PORT = 2145; private readonly ManualResetEvent dayFinishedSignaler = new ManualResetEvent(initialState: false); public void Start() { listener = new HttpListener(); listener.Prefixes.Add($"http://localhost:{2145}/"); listener.Start(); serverThread = new Thread(ListenLoop) { IsBackground = true }; serverThread.Start(); StatsTracker.Logger.LogInfo((object)$"Stat server running at http://localhost:{2145}"); } public void Stop() { listener?.Stop(); serverThread?.Join(); StatsTracker.Logger.LogInfo((object)"Stat server stopped"); } public void PublishStats(string json) { currentJson = json; dayFinishedSignaler.Set(); } public void Reset() { currentJson = null; dayFinishedSignaler.Reset(); } private void ListenLoop() { while (listener.IsListening) { try { HttpListenerContext context = listener.GetContext(); ThreadPool.QueueUserWorkItem(delegate { HandleRequest(context); }); } catch (HttpListenerException) { break; } } } private void HandleRequest(HttpListenerContext context) { HttpListenerResponse response = context.Response; response.StatusCode = 200; response.ContentType = "text/event-stream"; response.Headers.Add("Cache-Control", "no-cache"); response.Headers.Add("Access-Control-Allow-Origin", "*"); dayFinishedSignaler.WaitOne(); string s = "data: " + currentJson + "\n\n"; byte[] bytes = Encoding.UTF8.GetBytes(s); response.OutputStream.Write(bytes, 0, bytes.Length); response.OutputStream.Flush(); response.Close(); Reset(); } } internal class PlayerStats { public string Name; public bool Alive; public bool Disconnected; public string TimeOfDeath; public string CauseOfDeath; public PlayerStats(string name) { Name = name; Alive = true; Disconnected = false; TimeOfDeath = ""; CauseOfDeath = ""; } public void Kill(string TimeOfDeath, string CauseOfDeath) { Alive = false; this.TimeOfDeath = TimeOfDeath; this.CauseOfDeath = CauseOfDeath; } public void Disconnect() { Disconnected = true; } } internal class KiwiBirdInfo { public List EggValues; public KiwiBirdInfo() { EggValues = new List(); } public void AddEggValue(int[] values) { EggValues.AddRange(values); } } internal class BeeInfo { public List Values; public BeeInfo() { Values = new List(); } public void AddBeeValue(int value) { Values.Add(value); } } internal class MissingItemInfo { public int Value; public string ItemType; public double[] DespawnPosition; public bool CollectedOnPreviousDay; public MissingItemInfo(string Name, int Value, Vector3 DespawnPosition, bool CollectedOnPreviousDay) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) ItemType = Name; this.Value = Value; this.DespawnPosition = new double[3] { Math.Round(DespawnPosition.x, 1), Math.Round(DespawnPosition.y, 1), Math.Round(DespawnPosition.z, 1) }; this.CollectedOnPreviousDay = CollectedOnPreviousDay; } } internal class HazardInfo { public int TurretCount; public int LandmineCount; public int SpiketrapCount; public HazardInfo(int TurretCount, int LandmineCount, int SpiketrapCount) { this.TurretCount = TurretCount; this.LandmineCount = LandmineCount; this.SpiketrapCount = SpiketrapCount; } } internal class MoonInfo { public string Name; public string Weather; public MoonInfo(string Name, string Weather) { this.Name = Name; this.Weather = Weather; } } internal class DungeonInfo { public int ItemCount; public string Interior; public DungeonInfo(int ItemCount, string Interior) { this.ItemCount = ItemCount; this.Interior = Interior; } } internal class SpawnInfo { public string Enemy; public string SpawnTime; public SpawnInfo(EnemyType EnemyType, string Time) { Enemy = EnemyType.enemyName; SpawnTime = Time; } } internal class Stats { public MoonInfo MoonInfo; public DungeonInfo? DungeonInfo; public HazardInfo? HazardInfo; public BeeInfo BeeInfo; public KiwiBirdInfo BirdInfo; public int Seed; public int ShotgunsCollected; public int KnivesCollected; public int CollectedNoExtra; public int CollectedTotal; public int BottomLine; public int BottomLineTrue; public int ValueSold; public int NewQuota; public bool AppSpawned; public bool IndoorFog; public string TakeOffTime; public string SIDType; public string InfestationType; public string MeteorShowerTime; public Dictionary Players; public List IndoorSpawns; public List DayTimeSpawns; public List NightTimeSpawns; public List MissedItems; public Stats(int seed, string moonName, string weather, PlayerControllerB[] allPlayers) { MoonInfo = new MoonInfo(moonName, weather); BeeInfo = new BeeInfo(); BirdInfo = new KiwiBirdInfo(); MissedItems = new List(); IndoorSpawns = new List(); DayTimeSpawns = new List(); NightTimeSpawns = new List(); Players = new Dictionary(); Seed = seed; ShotgunsCollected = 0; KnivesCollected = 0; CollectedNoExtra = 0; CollectedTotal = 0; BottomLine = 0; BottomLineTrue = 0; ValueSold = 0; NewQuota = 0; TakeOffTime = ""; SIDType = ""; InfestationType = ""; MeteorShowerTime = ""; foreach (PlayerControllerB val in allPlayers) { Players[val.playerSteamId] = new PlayerStats(val.playerUsername); } } } } namespace StatsTracker.Patches { [HarmonyPatch] internal class CompanyTracker { [HarmonyPatch(typeof(DepositItemsDesk), "SellItemsOnServer")] [HarmonyPrefix] private static void CalculateAmountSold(DepositItemsDesk __instance) { for (int i = 0; i < __instance.itemsOnCounter.Count; i++) { if (__instance.itemsOnCounter[i].itemProperties.isScrap) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.ValueSold += __instance.itemsOnCounter[i].scrapValue; } } } } } internal class HQoLTracker { private static int totalSold; [HarmonyPatch(typeof(DepositItemsDesk), "Start")] [HarmonyPostfix] private static void RegisterOnChangeWhenLandingOnCompanyTypeMoon(DepositItemsDesk __instance) { if ((Object)(object)HQoLNetwork.Instance != (Object)null) { NetworkVariable totalStorageValue = HQoLNetwork.Instance.totalStorageValue; totalStorageValue.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)totalStorageValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnChangeFindSoldValue)); } else if ((Object)(object)HQoLNetwork.Instance != (Object)null) { NetworkVariable totalStorageValue2 = HQoLNetwork.Instance.totalStorageValue; totalStorageValue2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)totalStorageValue2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnChangeFindSoldValue)); } else { StatsTracker.Logger.LogWarning((object)"Failed to find HQoL instance, sold value will not be sync'd"); } } [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyPostfix] private static void DeregisterOnChangeAfterTakingOffCompanyTypeMoon(RoundManager __instance) { if (!((Object)(object)Object.FindAnyObjectByType() == (Object)null)) { if ((Object)(object)HQoLNetwork.Instance != (Object)null) { NetworkVariable totalStorageValue = HQoLNetwork.Instance.totalStorageValue; totalStorageValue.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)totalStorageValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnChangeFindSoldValue)); } else if ((Object)(object)HQoLNetwork.Instance != (Object)null) { NetworkVariable totalStorageValue2 = HQoLNetwork.Instance.totalStorageValue; totalStorageValue2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)totalStorageValue2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnChangeFindSoldValue)); } else { StatsTracker.Logger.LogWarning((object)"Failed to find HQoL instance, sold value will not be sync'd"); } Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.ValueSold = totalSold; } totalSold = 0; } } private static void OnChangeFindSoldValue(int prevValue, int currValue) { if (currValue < prevValue) { totalSold += prevValue - currValue; } } } [HarmonyPatch] internal class HazardTracker { [HarmonyPatch] private static class CountSpiketrap { private static Type? SpikeRookTrapType; private static bool Prepare() { SpikeRookTrapType = AccessTools.TypeByName("SpikeRoofTrap"); return SpikeRookTrapType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(SpikeRookTrapType, "Start", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { spiketrapCount++; } } public static int turretCount; public static int landmineCount; public static int spiketrapCount; [HarmonyPatch(typeof(Landmine), "Start")] [HarmonyPostfix] private static void CountLandmine(Landmine __instance) { landmineCount++; } [HarmonyPatch(typeof(Turret), "Start")] [HarmonyPostfix] private static void CountTurret(Turret __instance) { turretCount++; } } [HarmonyPatch] internal class ItemAndEventTracker { [HarmonyPatch] private static class TrackSpawnedItemsAndHazards { private static bool Prepare() { return true; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(RoundManager), "SyncScrapValuesClientRpc", (Type[])null, (Type[])null); } private static void Prefix(RoundManager __instance, NetworkObjectReference[] spawnedScrap, int[] allScrapValue) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2)) { objectsNaturallySpawnedThisDay = new HashSet(spawnedScrap); int num = 0; foreach (int num2 in allScrapValue) { num += num2; } string value = Traverse.Create((object)__instance).Field("dungeonGenerator").Field("Generator") .Field("DungeonFlow") .Property("name", (object[])null) .GetValue(); string value2; bool flag = StatsTracker.VanillaInteriorNames.TryGetValue(value, out value2); Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.DungeonInfo = new DungeonInfo(spawnedScrap.Length + ((appSpawnedThisDay.Count > 0) ? 1 : 0), flag ? value2 : value); } Stats? dayStats2 = StatsTracker.DayStats; if (dayStats2 != null) { dayStats2.AppSpawned = appSpawnedThisDay.Count > 0; } Stats? dayStats3 = StatsTracker.DayStats; if (dayStats3 != null) { dayStats3.BottomLine += num; } Stats? dayStats4 = StatsTracker.DayStats; if (dayStats4 != null) { dayStats4.BottomLineTrue += num; } Stats? dayStats5 = StatsTracker.DayStats; if (dayStats5 != null) { dayStats5.HazardInfo = new HazardInfo(HazardTracker.turretCount, HazardTracker.landmineCount, HazardTracker.spiketrapCount); } HazardTracker.turretCount = (HazardTracker.landmineCount = (HazardTracker.spiketrapCount = 0)); } } } [HarmonyPatch] private static class TrackSID { private static bool Prepare() { return true; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(RoundManager), "SyncScrapValuesClientRpc", (Type[])null, (Type[])null); } private static void Prefix(RoundManager __instance, NetworkObjectReference[] spawnedScrap) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((GameNetworkManager.Instance.gameVersionNum > 72 && (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 1) || (GameNetworkManager.Instance.gameVersionNum <= 72 && (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 2) || GameNetworkManager.Instance.gameVersionNum < 60) { return; } NetworkObject val = default(NetworkObject); ((NetworkObjectReference)(ref spawnedScrap[0])).TryGet(ref val, (NetworkManager)null); GrabbableObject component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { StatsTracker.Logger.LogWarning((object)"Unable to retrieve first GrabbableObject from the spawned objects"); return; } NetworkObject val3 = default(NetworkObject); for (int i = 0; i < spawnedScrap.Length; i++) { NetworkObjectReference val2 = spawnedScrap[i]; ((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null); GrabbableObject component2 = ((Component)val3).GetComponent(); if ((Object)(object)component2 == (Object)null) { StatsTracker.Logger.LogWarning((object)"Unable to retrieve some GrabbableObject from the spawned objects"); return; } if (((Object)component2.itemProperties).name != ((Object)component.itemProperties).name) { return; } } Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.SIDType = ((Component)component).gameObject.GetComponentInChildren().headerText; } } } [HarmonyPatch] private static class TrackInfes { private static FieldInfo? enemyRushIndexInfo; private static bool Prepare() { enemyRushIndexInfo = AccessTools.Field(typeof(RoundManager), "enemyRushIndex"); return enemyRushIndexInfo != null; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(RoundManager), "SyncScrapValuesClientRpc", (Type[])null, (Type[])null); } private static void Postfix(RoundManager __instance) { int num = (int)enemyRushIndexInfo.GetValue(__instance); if (num != -1) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.InfestationType = ((Object)__instance.currentLevel.Enemies[num].enemyType).name; } } } } [HarmonyPatch] private static class TrackIndoorFog { private static FieldInfo? indoorFogInfo; private static bool Prepare() { indoorFogInfo = AccessTools.Field(typeof(RoundManager), "indoorFog"); return indoorFogInfo != null; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(RoundManager), "SyncScrapValuesClientRpc", (Type[])null, (Type[])null); } private static void Postfix(RoundManager __instance) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.IndoorFog = ((Component)(LocalVolumetricFog)indoorFogInfo.GetValue(__instance)).gameObject.activeSelf; } } } [HarmonyPatch] private static class TrackMeteorShower { private static MethodInfo? SetBeginMeteorShowerClientRpcInfo; private static bool Prepare() { SetBeginMeteorShowerClientRpcInfo = AccessTools.Method(typeof(TimeOfDay), "SetBeginMeteorShowerClientRpc", (Type[])null, (Type[])null); return SetBeginMeteorShowerClientRpcInfo != null; } private static MethodBase TargetMethod() { return SetBeginMeteorShowerClientRpcInfo; } private static void Prefix(TimeOfDay __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2)) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.MeteorShowerTime = StatsTracker.GetCurrentTimeString(); } } } } [HarmonyPatch] private static class TrackEggItems { private static Type? GiantKiwiAIType; private static bool Prepare() { GiantKiwiAIType = AccessTools.TypeByName("GiantKiwiAI"); return GiantKiwiAIType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(GiantKiwiAIType, "SpawnEggsClientRpc", (Type[])null, (Type[])null); } private static void Prefix(object __instance, NetworkObjectReference[] eggNetworkReferences) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //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_0049: Unknown result type (might be due to invalid IL or missing references) GiantKiwiAI val = (GiantKiwiAI)__instance; if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)val).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)val).__rpc_exec_stage == 2)) { foreach (NetworkObjectReference item in eggNetworkReferences) { eggsSpawnedThisDay.Add(item); } } } } [HarmonyPatch] private static class TrackTrueValueFromGiftBox { private static bool Prepare() { return GiftBoxItemType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(GiftBoxItemType, "InitializeAfterPositioning", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GiftBoxItem val = (GiftBoxItem)__instance; Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.BottomLineTrue += val.objectInPresentValue - ((GrabbableObject)val).scrapValue; } } } [HarmonyPatch] private static class TrackShotgun { private static Type? NutcrackerEnemyAIType; private static bool Prepare() { NutcrackerEnemyAIType = AccessTools.TypeByName("NutcrackerEnemyAI"); return NutcrackerEnemyAIType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(NutcrackerEnemyAIType, "InitializeNutcrackerValuesClientRpc", (Type[])null, (Type[])null); } private static void Prefix(object __instance, NetworkObjectReference gunObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 NutcrackerEnemyAI val = (NutcrackerEnemyAI)__instance; if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)val).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)val).__rpc_exec_stage == 2)) { shotgunsSpawnedThisDay.Add(gunObject); } } } [HarmonyPatch] private static class TrackButlerPopPosition { private static Type? ButlerEnemyAIType; private static bool Prepare() { ButlerEnemyAIType = AccessTools.TypeByName("ButlerEnemyAI"); return ButlerEnemyAIType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(ButlerEnemyAIType, "KillEnemy", (Type[])null, (Type[])null); } private static void Prefix(object __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) ButlerEnemyAI val = (ButlerEnemyAI)__instance; butlerPopPositionsToTrack.Add(((Component)val).transform.position); } } [HarmonyPatch] private static class TrackKnife { private static Type? KnifeItemInfo; private static bool Prepare() { KnifeItemInfo = AccessTools.TypeByName("KnifeItem"); return KnifeItemInfo != null; } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(GrabbableObject), "Start", (Type[])null, (Type[])null); } private static void Prefix(GrabbableObject __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (KnifeItemInfo.IsInstanceOfType(__instance)) { KnifeItem knife = (KnifeItem)__instance; Vector3 val = ((IEnumerable)butlerPopPositionsToTrack).FirstOrDefault((Func)((Vector3 p) => Vector3.Distance(p + Vector3.up * 0.5f, ((Component)knife).transform.position) < 0.1f)); if (val != Vector3.zero) { knivesSpawnedThisDay.Add(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject)); butlerPopPositionsToTrack.Remove(val); } } } } [HarmonyPatch] private static class AddNewlySpawnedGiftItemToItemTracker { private static bool Prepare() { return GiftBoxItemType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(GiftBoxItemType, "OpenGiftBoxClientRpc", (Type[])null, (Type[])null); } private static void Prefix(object __instance, NetworkObjectReference netObjectRef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) GiftBoxItem val = (GiftBoxItem)__instance; if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)val).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)val).__rpc_exec_stage == 2) && !StartOfRound.Instance.inShipPhase) { ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitForGiftItemToFullySpawnBeforeTracking(netObjectRef, ((GrabbableObject)val).scrapValue)); } } } [CompilerGenerated] private sealed class d__28 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkObjectReference netObjRef; public int giftScrapValue; private NetworkObject 5__2; private float 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = null; 5__3 = Time.realtimeSinceStartup; goto IL_0056; case 1: <>1__state = -1; goto IL_0056; case 2: { <>1__state = -1; valueFromGiftSpawner[netObjRef] = giftScrapValue; return false; } IL_0056: if (Time.realtimeSinceStartup - 5__3 < 8f && !((NetworkObjectReference)(ref netObjRef)).TryGet(ref 5__2, (NetworkManager)null)) { <>2__current = (object)new WaitForSeconds(0.03f); <>1__state = 1; return true; } if ((Object)(object)5__2 == (Object)null) { StatsTracker.Logger.LogWarning((object)"No network object found for giftbox"); return false; } <>2__current = (object)new WaitForSeconds(0.3f); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly Type? GiftBoxItemType = AccessTools.TypeByName("GiftBoxItem"); private static readonly Type? VehicleControllerType = AccessTools.TypeByName("VehicleController"); private static HashSet knivesSpawnedThisDay = new HashSet(); private static HashSet shotgunsSpawnedThisDay = new HashSet(); private static HashSet hivesSpawnedThisDay = new HashSet(); private static HashSet eggsSpawnedThisDay = new HashSet(); private static HashSet appSpawnedThisDay = new HashSet(); private static HashSet objectsNaturallySpawnedThisDay = new HashSet(); private static Dictionary valueFromGiftSpawner = new Dictionary(); private static HashSet butlerPopPositionsToTrack = new HashSet(); private static List missedItemsParentedToDungeon = new List(); [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPrefix] private static void ResetTrackerWhenStartingNewDay(RoundManager __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2)) { appSpawnedThisDay.Clear(); knivesSpawnedThisDay.Clear(); shotgunsSpawnedThisDay.Clear(); hivesSpawnedThisDay.Clear(); eggsSpawnedThisDay.Clear(); objectsNaturallySpawnedThisDay.Clear(); valueFromGiftSpawner.Clear(); butlerPopPositionsToTrack.Clear(); missedItemsParentedToDungeon.Clear(); } } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyPostfix] private static void TrackMissedInLevelScene(StartOfRound __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Object cruiser = ((VehicleControllerType != null) ? Object.FindAnyObjectByType(VehicleControllerType) : null); Scene currLevelScene = SceneManager.GetSceneAt(1); GrabbableObject[] collection = Object.FindObjectsByType((FindObjectsSortMode)0); List list = new List(collection); list.RemoveAll((GrabbableObject obj) => ((Component)obj).gameObject.scene != currLevelScene || !obj.itemProperties.isScrap || obj.isInShipRoom || (cruiser != (Object)null && (Object)(object)((Component)obj).transform.parent != (Object)null && (Object)(object)((Component)((Component)obj).transform.parent).gameObject.GetComponent(VehicleControllerType) == cruiser && Traverse.Create((object)cruiser).Field("magnetedToShip").GetValue())); missedItemsParentedToDungeon = list.ConvertAll((GrabbableObject obj) => new MissingItemInfo(((Object)(object)((Component)obj).gameObject.GetComponentInChildren() == (Object)null) ? ((Object)obj.itemProperties).name : ((Component)obj).gameObject.GetComponentInChildren().headerText, obj.scrapValue, ((Component)obj).transform.position, obj.scrapPersistedThroughRounds)).ToList(); } [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyPrefix] private static void TrackMissedItems(RoundManager __instance) { Object cruiser = ((VehicleControllerType != null) ? Object.FindAnyObjectByType(VehicleControllerType) : null); GrabbableObject[] source = Object.FindObjectsByType((FindObjectsSortMode)0); List list = source.ToList(); list.RemoveAll((GrabbableObject obj) => !obj.itemProperties.isScrap || obj.isInShipRoom || (cruiser != (Object)null && (Object)(object)((Component)obj).transform.parent != (Object)null && (Object)(object)((Component)((Component)obj).transform.parent).gameObject.GetComponent(VehicleControllerType) == cruiser && Traverse.Create((object)cruiser).Field("magnetedToShip").GetValue())); Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.MissedItems = list.ConvertAll((GrabbableObject obj) => new MissingItemInfo(((Object)(object)((Component)obj).gameObject.GetComponentInChildren() == (Object)null) ? ((Object)obj.itemProperties).name : ((Component)obj).gameObject.GetComponentInChildren().headerText, obj.scrapValue, ((Component)obj).transform.position, obj.scrapPersistedThroughRounds)).ToList(); } StatsTracker.DayStats?.MissedItems.AddRange(missedItemsParentedToDungeon); } [HarmonyPatch(typeof(LungProp), "Start")] [HarmonyPostfix] private static void CountApp(LungProp __instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) appSpawnedThisDay.Add(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject)); Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.BottomLineTrue += ((GrabbableObject)__instance).scrapValue; } } [HarmonyPatch(typeof(RedLocustBees), "SpawnHiveClientRpc")] [HarmonyPrefix] private static void TrackHiveItem(RedLocustBees __instance, NetworkObjectReference hiveObject) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2)) { hivesSpawnedThisDay.Add(hiveObject); } } [HarmonyPatch(typeof(PlayerControllerB), "SetItemInElevator")] [HarmonyPrefix] private static void TrackItemWhenDropped(PlayerControllerB __instance, bool droppedInShipRoom, GrabbableObject gObject) { //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)gObject).IsSpawned || StartOfRound.Instance.inShipPhase || gObject.isInShipRoom == droppedInShipRoom || gObject.scrapPersistedThroughRounds) { return; } int value2; if (droppedInShipRoom) { int value; if (objectsNaturallySpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.CollectedNoExtra += gObject.scrapValue; } Stats? dayStats2 = StatsTracker.DayStats; if (dayStats2 != null) { int collectedTotal = dayStats2.CollectedTotal; Type? giftBoxItemType = GiftBoxItemType; dayStats2.CollectedTotal = collectedTotal + (((object)giftBoxItemType != null && giftBoxItemType.IsInstanceOfType(gObject)) ? Traverse.Create((object)gObject).Property("objectInPresentValue", (object[])null).GetValue() : gObject.scrapValue); } } else if (valueFromGiftSpawner.TryGetValue(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject), out value)) { Stats? dayStats3 = StatsTracker.DayStats; if (dayStats3 != null) { dayStats3.CollectedNoExtra += value; } Stats? dayStats4 = StatsTracker.DayStats; if (dayStats4 != null) { dayStats4.CollectedTotal += gObject.scrapValue; } } else if (shotgunsSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats5 = StatsTracker.DayStats; if (dayStats5 != null) { dayStats5.CollectedTotal += gObject.scrapValue; } Stats? dayStats6 = StatsTracker.DayStats; if (dayStats6 != null) { dayStats6.ShotgunsCollected++; } } else if (knivesSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats7 = StatsTracker.DayStats; if (dayStats7 != null) { dayStats7.CollectedTotal += gObject.scrapValue; } Stats? dayStats8 = StatsTracker.DayStats; if (dayStats8 != null) { dayStats8.KnivesCollected++; } } else if (hivesSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject)) || eggsSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject)) || appSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats9 = StatsTracker.DayStats; if (dayStats9 != null) { dayStats9.CollectedTotal += gObject.scrapValue; } } } else if (objectsNaturallySpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats10 = StatsTracker.DayStats; if (dayStats10 != null) { dayStats10.CollectedNoExtra -= gObject.scrapValue; } Stats? dayStats11 = StatsTracker.DayStats; if (dayStats11 != null) { int collectedTotal2 = dayStats11.CollectedTotal; Type? giftBoxItemType2 = GiftBoxItemType; dayStats11.CollectedTotal = collectedTotal2 - (((object)giftBoxItemType2 != null && giftBoxItemType2.IsInstanceOfType(gObject)) ? Traverse.Create((object)gObject).Property("objectInPresentValue", (object[])null).GetValue() : gObject.scrapValue); } } else if (valueFromGiftSpawner.TryGetValue(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject), out value2)) { Stats? dayStats12 = StatsTracker.DayStats; if (dayStats12 != null) { dayStats12.CollectedNoExtra -= value2; } Stats? dayStats13 = StatsTracker.DayStats; if (dayStats13 != null) { dayStats13.CollectedTotal -= gObject.scrapValue; } } else if (shotgunsSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats14 = StatsTracker.DayStats; if (dayStats14 != null) { dayStats14.CollectedTotal -= gObject.scrapValue; } Stats? dayStats15 = StatsTracker.DayStats; if (dayStats15 != null) { dayStats15.ShotgunsCollected--; } } else if (knivesSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats16 = StatsTracker.DayStats; if (dayStats16 != null) { dayStats16.CollectedTotal -= gObject.scrapValue; } Stats? dayStats17 = StatsTracker.DayStats; if (dayStats17 != null) { dayStats17.KnivesCollected--; } } else if (hivesSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject)) || eggsSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject)) || appSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)gObject).NetworkObject))) { Stats? dayStats18 = StatsTracker.DayStats; if (dayStats18 != null) { dayStats18.CollectedTotal -= gObject.scrapValue; } } } [IteratorStateMachine(typeof(d__28))] private static IEnumerator WaitForGiftItemToFullySpawnBeforeTracking(NetworkObjectReference netObjRef, int giftScrapValue) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__28(0) { netObjRef = netObjRef, giftScrapValue = giftScrapValue }; } } [HarmonyPatch] internal class PlayerTracker { [HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")] [HarmonyPrefix] private static void TrackDeath(PlayerControllerB __instance, int causeOfDeath) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((GameNetworkManager.Instance.gameVersionNum > 72 && (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 1) || (GameNetworkManager.Instance.gameVersionNum <= 72 && (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 2)) { return; } Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { PlayerStats playerStats = dayStats.Players[__instance.playerSteamId]; if (playerStats != null) { string currentTimeString = StatsTracker.GetCurrentTimeString(); CauseOfDeath val = (CauseOfDeath)causeOfDeath; playerStats.Kill(currentTimeString, ((object)(CauseOfDeath)(ref val)).ToString()); } } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] [HarmonyPrefix] private static void TrackDisconnect(StartOfRound __instance, int playerObjectNumber) { StatsTracker.DayStats?.Players[__instance.allPlayerScripts[playerObjectNumber].playerSteamId].Disconnect(); } } [HarmonyPatch] internal class ServerEvents { [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public int prevQuota; internal bool b__0() { return TimeOfDay.Instance.profitQuota != prevQuota; } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int prevQuota; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil((Func)new <>c__DisplayClass2_0 { prevQuota = prevQuota }.b__0); <>1__state = 1; return true; case 1: { <>1__state = -1; Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.NewQuota = TimeOfDay.Instance.profitQuota; } StatsTracker.LocalServer.PublishStats(JsonConvert.SerializeObject((object)StatsTracker.DayStats)); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch(typeof(StartOfRound), "ResetPlayersLoadedValueClientRpc")] [HarmonyPrefix] private static void StartTrackingNewday(StartOfRound __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2)) { StatsTracker.DayStats = new Stats(__instance.randomMapSeed, __instance.currentLevel.PlanetName, ((int)__instance.currentLevel.currentWeather == -1) ? "Mild" : ((object)(LevelWeatherType)(ref __instance.currentLevel.currentWeather)).ToString(), new ArraySegment(__instance.allPlayerScripts, 0, __instance.connectedPlayersAmount + 1).ToArray()); } } [HarmonyPatch(typeof(StartOfRound), "PassTimeToNextDay")] [HarmonyPostfix] private static void PublishDayStats(StartOfRound __instance) { if (TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled <= 0) { ((MonoBehaviour)__instance).StartCoroutine(PublishDayStatsAfterQuotaRoll(TimeOfDay.Instance.profitQuota)); } else { StatsTracker.LocalServer.PublishStats(JsonConvert.SerializeObject((object)StatsTracker.DayStats)); } } [IteratorStateMachine(typeof(d__2))] private static IEnumerator PublishDayStatsAfterQuotaRoll(int prevQuota) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { prevQuota = prevQuota }; } } [HarmonyPatch] internal class ShipTracker { [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] [HarmonyPostfix] private static void RegisterTakeOffTime(StartOfRound __instance) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.TakeOffTime = StatsTracker.GetCurrentTimeString(); } } } [HarmonyPatch] internal class SpawnTracker { [HarmonyPatch] private static class NutcrackerWrapper { private static Type? NutcrackerEnemyAIType; private static bool Prepare() { NutcrackerEnemyAIType = AccessTools.TypeByName("NutcrackerEnemyAI"); return NutcrackerEnemyAIType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(NutcrackerEnemyAIType, "InitializeNutcrackerValuesClientRpc", (Type[])null, (Type[])null); } private static void Prefix(object __instance, NetworkObjectReference gunObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 NutcrackerEnemyAI val = (NutcrackerEnemyAI)__instance; if ((GameNetworkManager.Instance.gameVersionNum > 72 && (int)((NetworkBehaviour)val).__rpc_exec_stage != 1) || (GameNetworkManager.Instance.gameVersionNum <= 72 && (int)((NetworkBehaviour)val).__rpc_exec_stage != 2)) { return; } NetworkObject val2 = default(NetworkObject); ((NetworkObjectReference)(ref gunObject)).TryGet(ref val2, (NetworkManager)null); ShotgunItem component = ((Component)val2).GetComponent(); if ((Object)(object)component == (Object)null) { StatsTracker.Logger.LogWarning((object)"Unable to retrieve ShotgunItem from the spawned Nutcracker"); return; } Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.BottomLineTrue += ((GrabbableObject)component).scrapValue; } } } [HarmonyPatch] private static class ButlerWrapper { private static Type? ButlerEnemyAIType; private static bool Prepare() { ButlerEnemyAIType = AccessTools.TypeByName("ButlerEnemyAI"); return ButlerEnemyAIType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(ButlerEnemyAIType, "Start", (Type[])null, (Type[])null); } private static void Prefix(object __instance) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.BottomLineTrue += 35; } } } [HarmonyPatch] private static class GiantKiwiAIWrapper { private static Type? GiantKiwiAIType; private static bool Prepare() { GiantKiwiAIType = AccessTools.TypeByName("GiantKiwiAI"); return GiantKiwiAIType != null; } private static MethodBase TargetMethod() { return AccessTools.Method(GiantKiwiAIType, "SpawnEggsClientRpc", (Type[])null, (Type[])null); } private static void Prefix(object __instance, int[] eggScrapValues) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 GiantKiwiAI val = (GiantKiwiAI)__instance; if ((GameNetworkManager.Instance.gameVersionNum > 72 && (int)((NetworkBehaviour)val).__rpc_exec_stage != 1) || (GameNetworkManager.Instance.gameVersionNum <= 72 && (int)((NetworkBehaviour)val).__rpc_exec_stage != 2)) { return; } StatsTracker.DayStats?.BirdInfo.AddEggValue(eggScrapValues); foreach (int num in eggScrapValues) { Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.BottomLineTrue += num; } } } } private const int knifeValue = 35; [HarmonyPatch(typeof(EnemyAI), "Start")] [HarmonyPostfix] private static void TrackSpawn(EnemyAI __instance) { if (__instance.enemyType.isDaytimeEnemy) { StatsTracker.DayStats?.DayTimeSpawns.Add(new SpawnInfo(__instance.enemyType, StatsTracker.GetCurrentTimeString())); } else if (__instance.enemyType.isOutsideEnemy) { StatsTracker.DayStats?.NightTimeSpawns.Add(new SpawnInfo(__instance.enemyType, StatsTracker.GetCurrentTimeString())); } else { StatsTracker.DayStats?.IndoorSpawns.Add(new SpawnInfo(__instance.enemyType, StatsTracker.GetCurrentTimeString())); } } [HarmonyPatch(typeof(RedLocustBees), "SpawnHiveClientRpc")] [HarmonyPrefix] private static void TrackHive(RedLocustBees __instance, int hiveScrapValue) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((GameNetworkManager.Instance.gameVersionNum <= 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1) && (GameNetworkManager.Instance.gameVersionNum > 72 || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2)) { StatsTracker.DayStats?.BeeInfo.AddBeeValue(hiveScrapValue); Stats? dayStats = StatsTracker.DayStats; if (dayStats != null) { dayStats.BottomLineTrue += hiveScrapValue; } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }