Decompiled source of LCStatsTracker v1.3.1

OreoM.StatsTracker.dll

Decompiled 11 hours ago
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;

[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.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1+cb7f863ef234adc6d430bdc76131921d5f6655a7")]
[assembly: AssemblyProduct("StatsTracker")]
[assembly: AssemblyTitle("OreoM.StatsTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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.3.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class StatsTracker : BaseUnityPlugin
	{
		internal static bool dayHasStarted = false;

		internal static Stats? DayStats;

		internal static HttpSSE LocalServer = new HttpSSE();

		internal static Dictionary<string, string> VanillaInteriorNames = new Dictionary<string, string>
		{
			{ "Level1Flow", "Facility" },
			{ "Level2Flow", "Mansion" },
			{ "Level1FlowExtraLarge", "UnusedFacility" },
			{ "Level1Flow3Exits", "Facility" },
			{ "Level3Flow", "Mineshaft" }
		};

		public static readonly Type? EggItemType = AccessTools.TypeByName("KiwiBabyItem");

		public static readonly Type? KnifeItemType = AccessTools.TypeByName("KnifeItem");

		public static readonly Type? ShotgunItemType = AccessTools.TypeByName("ShotgunItem");

		public static readonly Type? GiftBoxItemType = AccessTools.TypeByName("GiftBoxItem");

		public static readonly Type? BuyableVehicleType = AccessTools.TypeByName("BuyableVehicle");

		public static readonly FieldInfo? DeactivatedField = AccessTools.Field(typeof(GrabbableObject), "deactivated");

		public static readonly FieldInfo? LuckValueField = AccessTools.Field(typeof(UnlockableItem), "luckValue");

		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();
			LocalServer.Start();
			Logger.LogInfo((object)"OreoM.StatsTracker v1.3.1 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...");
			CompanyTracker.ApplyCompanyTrackerPatches(Harmony);
			HazardTracker.ApplyHazardTrakcerPatches(Harmony);
			ItemAndEventTracker.ApplyItemAndEventTrackerPatches(Harmony);
			MapTracker.ApplyMapTrackerPatches(Harmony);
			PlayerTracker.ApplyPlayerTrackerPatches(Harmony);
			ServerEvents.ApplyServerEventPatches(Harmony);
			ShipTracker.ApplyShipTrackerPatches(Harmony);
			ShopTracker.ApplyShopTrackerPatches(Harmony);
			SpawnTracker.ApplySpawnTrackerPatches(Harmony);
			if (Chainloader.PluginInfos.ContainsKey("OreoM.HQoL.72") || Chainloader.PluginInfos.ContainsKey("OreoM.HQoL.73"))
			{
				HQoLTracker.ApplyHQoLTrackerPatches(Harmony);
			}
			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;
			string text = "AM";
			int num2 = (int)(normalizedTimeOfDay * (60f * num)) + 360;
			int num3 = (int)Mathf.Floor((float)(num2 / 60));
			if (num3 >= 24)
			{
				return "12:00  AM";
			}
			text = ((num3 >= 12) ? "PM" : "AM");
			if (num3 > 12)
			{
				num3 %= 12;
			}
			int num4 = num2 % 60;
			string text2 = $"{num3:00}:{num4:00}".TrimStart('0') + text;
			if (!(text2 == "6:00 AM"))
			{
				return text2;
			}
			return "7:40 AM";
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "OreoM.StatsTracker";

		public const string PLUGIN_NAME = "StatsTracker";

		public const string PLUGIN_VERSION = "1.3.1";
	}
}
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 OutsideObjectInfo
	{
		public string Name;

		public double[] Position;

		public double Yaw;

		public OutsideObjectInfo(string Name, Vector3 Position, float Yaw)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			this.Name = Name;
			this.Position = DungeonMapUtil.ToArray(Position);
			this.Yaw = Math.Round(Yaw, 1);
			base..ctor();
		}
	}
	internal class MoonInfo(string Name, string Weather)
	{
		public string Name = Name;

		public string Weather = Weather;

		public List<DungeonEntrance> Entrances = new List<DungeonEntrance>();

		public List<OutsideObjectInfo> OutsideObjects = new List<OutsideObjectInfo>();

		public List<double[]> RemovedTrees = new List<double[]>();
	}
	internal class DungeonInfo(int ItemCount, string Interior)
	{
		public int ItemCount = ItemCount;

		public string Interior = Interior;

		public DungeonMap DungeonMap = new DungeonMap();

		public List<DoorInfo> Doors = new List<DoorInfo>();

		public List<BigDoorInfo> BigDoors = new List<BigDoorInfo>();
	}
	internal class HazardInfo(int TurretCount, int LandmineCount, int SpiketrapCount)
	{
		public int TurretCount = TurretCount;

		public int LandmineCount = LandmineCount;

		public int SpiketrapCount = SpiketrapCount;

		public List<MapHazardInfo> MapHazards = new List<MapHazardInfo>();
	}
	internal class PerformanceInfo
	{
		public int CollectedNoExtra;

		public int CollectedTotal;

		public int InitialAvailableValue;

		public int TotalAvailableValue;

		public int ExtraFromOldGift;
	}
	internal class SpecialItemInfo
	{
		public List<int> Available = new List<int>();

		public List<int> Collected = new List<int>();

		public void AddToAvailable(int value)
		{
			Available.Add(value);
		}

		public void AddToCollected(int value)
		{
			Collected.Add(value);
		}
	}
	internal class QuotaInfo
	{
		public int ValueSold;

		public int NewQuota;
	}
	internal class EventInfo
	{
		public bool AppSpawned;

		public bool IndoorFog;

		public string TakeOffTime = "";

		public string SIDType = "";

		public string InfestationType = "";

		public string MeteorShowerTime = "";
	}
	internal class PlayerStats(string name)
	{
		public string Name = name;

		public bool Alive = true;

		public bool Disconnected;

		public string TimeOfDeath = "";

		public string CauseOfDeath = "";

		public void Kill(string TimeOfDeath, string CauseOfDeath)
		{
			Alive = false;
			this.TimeOfDeath = TimeOfDeath;
			this.CauseOfDeath = CauseOfDeath;
		}

		public void Disconnect()
		{
			Disconnected = true;
		}
	}
	internal class SpawnInfo
	{
		public ulong Id;

		public string Enemy;

		public string SpawnTime;

		public string TimeOfDeath;

		public double[] SpawnPosition;

		public double[]? EndPosition;

		public SpawnInfo(ulong Id, EnemyType EnemyType, string Time, Vector3 SpawnPosition)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			this.Id = Id;
			Enemy = EnemyType.enemyName;
			SpawnTime = Time;
			TimeOfDeath = "";
			this.SpawnPosition = DungeonMapUtil.ToArray(SpawnPosition);
			base..ctor();
		}
	}
	internal class FurnitureInfo
	{
		public bool InStock = Furniture.alwaysInStock || Terminal.ShipDecorSelection.Contains(Furniture.shopSelectionNode);

		public bool Owned = Furniture.alreadyUnlocked || Furniture.hasBeenUnlockedByPlayer;

		public bool Stored = Furniture.inStorage;

		public int ApparentPrice = Furniture.shopSelectionNode.itemCost;

		public int RealPrice = Furniture.shopSelectionNode.terminalOptions[0].result.itemCost;

		public float Luck = ((float?)StatsTracker.LuckValueField?.GetValue(Furniture)).GetValueOrDefault();

		public FurnitureInfo(UnlockableItem Furniture, Terminal Terminal)
		{
		}
	}
	internal class GiftBoxInfo(int newScrapValue, int GiftScrapValue, int GiftBoxAge)
	{
		public int NewScrapValue = newScrapValue;

		public int GiftScrapValue = GiftScrapValue;

		public int GiftBoxAge = GiftBoxAge;

		public bool Collected;
	}
	internal class MissingItemInfo
	{
		public ulong Id;

		public int Value;

		public string ItemType;

		public double[]? SpawnPosition;

		public double[] DespawnPosition;

		public bool CollectedOnPreviousDay;

		public int ScrapInsideGiftValue;

		public MissingItemInfo(ulong Id, string Name, int Value, Vector3? SpawnPosition, Vector3 DespawnPosition, bool CollectedOnPreviousDay, int ScrapInsideGiftValue = 0)
		{
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			this.Id = Id;
			this.Value = Value;
			ItemType = Name;
			this.SpawnPosition = ((!SpawnPosition.HasValue) ? null : new double[3]
			{
				Math.Round(SpawnPosition.Value.x, 1),
				Math.Round(SpawnPosition.Value.y, 1),
				Math.Round(SpawnPosition.Value.z, 1)
			});
			this.DespawnPosition = new double[3]
			{
				Math.Round(DespawnPosition.x, 1),
				Math.Round(DespawnPosition.y, 1),
				Math.Round(DespawnPosition.z, 1)
			};
			this.CollectedOnPreviousDay = CollectedOnPreviousDay;
			this.ScrapInsideGiftValue = ScrapInsideGiftValue;
			base..ctor();
		}
	}
	internal class SpawnedItemInfo
	{
		public ulong Id;

		public int Value;

		public string ItemType;

		public double[] SpawnPosition;

		public int ScrapInsideGiftValue;

		public SpawnedItemInfo(ulong Id, string Name, Vector3 SpawnPosition)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			this.Id = Id;
			ItemType = Name;
			this.SpawnPosition = new double[3]
			{
				Math.Round(SpawnPosition.x, 1),
				Math.Round(SpawnPosition.y, 1),
				Math.Round(SpawnPosition.z, 1)
			};
			base..ctor();
		}
	}
	internal static class DungeonMapUtil
	{
		public static double[] ToArray(Vector3 v)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return new double[3]
			{
				Math.Round(v.x, 2),
				Math.Round(v.y, 2),
				Math.Round(v.z, 2)
			};
		}

		public static double Yaw(Transform t)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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)
			Vector3 val = t.InverseTransformDirection(Vector3.up);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(Mathf.Abs(val.x), Mathf.Abs(val.y), Mathf.Abs(val.z));
			val = ((val2.x > val2.y && val2.x > val2.z) ? new Vector3(Mathf.Sign(val.x), 0f, 0f) : ((val2.z > val2.y) ? new Vector3(0f, 0f, Mathf.Sign(val.z)) : new Vector3(0f, Mathf.Sign(val.y), 0f)));
			Quaternion val3 = ((val.y != 0f) ? Quaternion.identity : (Quaternion.LookRotation(Vector3.up, Vector3.forward) * Quaternion.Inverse(Quaternion.LookRotation(val, Vector3.up))));
			Quaternion val4 = t.rotation * Quaternion.Inverse(val3);
			double num = Math.Round(((Quaternion)(ref val4)).eulerAngles.y, 1);
			if (!(num >= 360.0))
			{
				return num;
			}
			return 0.0;
		}

		public static string CleanName(string name)
		{
			return name.Replace("(Clone)", "").Trim();
		}

		public static string PathFrom(Transform root, Transform? prefabRoot, Transform t)
		{
			return Resolve(root, prefabRoot, t).path;
		}

		private static (string path, Transform? prefab) Resolve(Transform root, Transform? prefabRoot, Transform t)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			if ((Object)(object)t == (Object)(object)root)
			{
				return (path: "", prefab: prefabRoot);
			}
			(string path, Transform? prefab) tuple = Resolve(root, prefabRoot, t.parent);
			string item = tuple.path;
			Transform item2 = tuple.prefab;
			List<Transform> list = new List<Transform>();
			foreach (Transform item3 in item2 ?? t.parent)
			{
				Transform val = item3;
				if (((Object)val).name == ((Object)t).name)
				{
					list.Add(val);
				}
			}
			Transform val2 = (Transform)(((Object)(object)item2 == (Object)null) ? ((object)t) : ((object)list.OrderBy(delegate(Transform c)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//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_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: 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)
				Vector3 val3 = c.localPosition - t.localPosition;
				return ((Vector3)(ref val3)).sqrMagnitude + Quaternion.Angle(c.localRotation, t.localRotation);
			}).FirstOrDefault()));
			string text = ((list.Count > 1) ? $"{((Object)t).name}#{list.IndexOf(val2)}" : ((Object)t).name);
			return (path: (item == "") ? text : (item + "/" + text), prefab: ((Object)(object)item2 == (Object)null) ? null : val2);
		}

		public static IEnumerable<GameObject> VariableSceneObjects(Transform tileRoot)
		{
			Component[] componentsInChildren = ((Component)tileRoot).GetComponentsInChildren(DunGenAccess.Doorway, true);
			foreach (Component dw in componentsInChildren)
			{
				foreach (GameObject item in DunGenAccess.Field<List<GameObject>>(dw, "ConnectorSceneObjects"))
				{
					if ((Object)(object)item != (Object)null)
					{
						yield return item;
					}
				}
				foreach (GameObject item2 in DunGenAccess.Field<List<GameObject>>(dw, "BlockerSceneObjects"))
				{
					if ((Object)(object)item2 != (Object)null)
					{
						yield return item2;
					}
				}
			}
			componentsInChildren = ((Component)tileRoot).GetComponentsInChildren(DunGenAccess.LocalPropSet, true);
			foreach (Component val in componentsInChildren)
			{
				foreach (object item3 in Traverse.Create((object)val).Field("Props").Field("Weights")
					.GetValue<IEnumerable>())
				{
					GameObject val2 = DunGenAccess.Field<GameObject>(item3, "Value");
					if (val2 != null && (Object)(object)val2 != (Object)null)
					{
						yield return val2;
					}
				}
			}
			componentsInChildren = ((Component)tileRoot).GetComponentsInChildren(DunGenAccess.GlobalProp, true);
			foreach (Component val3 in componentsInChildren)
			{
				if (val3.gameObject.activeSelf)
				{
					yield return val3.gameObject;
				}
			}
		}

		public static GameObject? Owner(Transform root, Transform t, HashSet<GameObject> variable)
		{
			while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)root)
			{
				if (variable.Contains(((Component)t).gameObject))
				{
					return ((Component)t).gameObject;
				}
				t = t.parent;
			}
			return null;
		}
	}
	internal static class DunGenAccess
	{
		public static readonly Type Doorway = AccessTools.TypeByName("DunGen.Doorway");

		public static readonly Type LocalPropSet = AccessTools.TypeByName("DunGen.LocalPropSet");

		public static readonly Type GlobalProp = AccessTools.TypeByName("DunGen.GlobalProp");

		public static T Field<T>(object o, string name)
		{
			return Traverse.Create(o).Field(name).GetValue<T>();
		}

		public static T Property<T>(object o, string name)
		{
			return Traverse.Create(o).Property(name, (object[])null).GetValue<T>();
		}

		public static Dictionary<string, GameObject> TilePrefabs(object generator)
		{
			Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>();
			object obj = Field<object>(generator, "DungeonFlow");
			foreach (object item in Traverse.Create(obj).Method("GetUsedTileSets", Array.Empty<object>()).GetValue<IEnumerable>())
			{
				foreach (object item2 in Traverse.Create(item).Field("TileWeights").Field("Weights")
					.GetValue<IEnumerable>())
				{
					GameObject val = Field<GameObject>(item2, "Value");
					if (val != null && (Object)(object)val != (Object)null)
					{
						dictionary[((Object)val).name] = val;
					}
				}
			}
			return dictionary;
		}

		public static IEnumerable<GameObject> SpawnedBlockers(Component doorway)
		{
			GameObject door = Property<GameObject>(doorway, "UsedDoorPrefabInstance");
			foreach (Transform item in doorway.transform)
			{
				Transform val = item;
				if (((Object)val).name.EndsWith("(Clone)") && (Object)(object)((Component)val).gameObject != (Object)(object)door)
				{
					yield return ((Component)val).gameObject;
				}
			}
		}
	}
	internal class DungeonEntrance
	{
		public double[] Position = DungeonMapUtil.ToArray(Position);

		public bool Main;

		public DungeonEntrance(Vector3 Position, bool Main)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.Main = Main;
			base..ctor();
		}
	}
	internal class DungeonNode
	{
		public string Name = DungeonMapUtil.CleanName(((Object)tile).name);

		public double[] Position = DungeonMapUtil.ToArray(tile.transform.position);

		public double[] BoundsMin;

		public double[] BoundsMax;

		public double Yaw;

		public List<string> Overlays;

		public List<DungeonEntrance> Entrances;

		public DungeonNode(Component tile, Dictionary<string, GameObject> tilePrefabs)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_004c: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			Bounds val = DunGenAccess.Property<Bounds>(tile, "Bounds");
			BoundsMin = DungeonMapUtil.ToArray(((Bounds)(ref val)).min);
			val = DunGenAccess.Property<Bounds>(tile, "Bounds");
			BoundsMax = DungeonMapUtil.ToArray(((Bounds)(ref val)).max);
			Yaw = DungeonMapUtil.Yaw(tile.transform);
			Overlays = GetOverlays(tile, tilePrefabs);
			Entrances = GetEntrances(tile);
			base..ctor();
		}

		private static List<DungeonEntrance> GetEntrances(Component tile)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			List<DungeonEntrance> list = new List<DungeonEntrance>();
			SpawnSyncedObject[] componentsInChildren = tile.GetComponentsInChildren<SpawnSyncedObject>();
			foreach (SpawnSyncedObject val in componentsInChildren)
			{
				if ((Object)(object)val.spawnPrefab != (Object)null)
				{
					EntranceTeleport componentInChildren = val.spawnPrefab.GetComponentInChildren<EntranceTeleport>(true);
					if (componentInChildren != null)
					{
						list.Add(new DungeonEntrance(((Component)val).transform.position, componentInChildren.entranceId == 0));
					}
				}
			}
			return list;
		}

		private static List<string> GetOverlays(Component tile, Dictionary<string, GameObject> tilePrefabs)
		{
			List<string> list = new List<string>();
			GameObject value;
			Transform tilePrefab = (tilePrefabs.TryGetValue(DungeonMapUtil.CleanName(((Object)tile).name), out value) ? value.transform : null);
			List<Component> list2 = DunGenAccess.Field<IEnumerable>(tile, "AllDoorways").Cast<Component>().ToList();
			List<(Component, GameObject)> list3 = new List<(Component, GameObject)>();
			foreach (Component item3 in list2)
			{
				foreach (GameObject item4 in DunGenAccess.SpawnedBlockers(item3))
				{
					list3.Add((item3, item4));
				}
				GameObject val = DunGenAccess.Property<GameObject>(item3, "UsedDoorPrefabInstance");
				if ((Object)(object)val != (Object)null && (Object)(object)val.transform.parent == (Object)(object)item3.transform)
				{
					list3.Add((item3, val));
				}
			}
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			foreach (GameObject item5 in list3.Select<(Component, GameObject), GameObject>(((Component doorway, GameObject instance) s) => s.instance))
			{
				hashSet.Add(item5);
			}
			HashSet<GameObject> spawned = hashSet;
			HashSet<GameObject> hashSet2 = new HashSet<GameObject>();
			foreach (GameObject item6 in from go in DungeonMapUtil.VariableSceneObjects(tile.transform)
				where !InsideSpawned(go.transform)
				select go)
			{
				hashSet2.Add(item6);
			}
			HashSet<GameObject> hashSet3 = hashSet2;
			HashSet<GameObject> hashSet4 = new HashSet<GameObject>();
			foreach (GameObject item7 in hashSet3)
			{
				hashSet4.Add(item7);
			}
			foreach (GameObject item8 in spawned)
			{
				hashSet4.Add(item8);
			}
			HashSet<GameObject> variable = hashSet4;
			HashSet<GameObject> hashSet5 = new HashSet<GameObject>();
			int num = LayerMask.NameToLayer("MapRadar");
			Renderer[] componentsInChildren = tile.GetComponentsInChildren<Renderer>();
			foreach (Renderer val2 in componentsInChildren)
			{
				if (((Component)val2).gameObject.layer != num)
				{
					GameObject val3 = DungeonMapUtil.Owner(tile.transform, ((Component)val2).transform, variable);
					if (val3 != null)
					{
						hashSet5.Add(val3);
					}
				}
			}
			foreach (GameObject item9 in hashSet3)
			{
				if (hashSet5.Contains(item9))
				{
					list.Add(KeyOf(item9));
				}
			}
			foreach (var item10 in list3)
			{
				Component item = item10.Item1;
				GameObject item2 = item10.Item2;
				string text = KeyOf(item.gameObject, ((Object)item2).name);
				list.Add(text);
				Component[] componentsInChildren2 = item2.GetComponentsInChildren(DunGenAccess.GlobalProp);
				foreach (Component val4 in componentsInChildren2)
				{
					if ((Object)(object)val4.gameObject != (Object)(object)item2)
					{
						list.Add(text + "/" + DungeonMapUtil.PathFrom(item2.transform, null, val4.transform));
					}
				}
			}
			SpawnSyncedObject[] componentsInChildren3 = tile.GetComponentsInChildren<SpawnSyncedObject>();
			foreach (SpawnSyncedObject val5 in componentsInChildren3)
			{
				if ((Object)(object)val5.spawnPrefab != (Object)null && !InsideSpawned(((Component)val5).transform))
				{
					list.Add(KeyOf(((Component)val5).gameObject, ((Object)val5.spawnPrefab).name));
				}
			}
			return list;
			bool InsideSpawned(Transform t)
			{
				return (Object)(object)DungeonMapUtil.Owner(tile.transform, t, spawned) != (Object)null;
			}
			string KeyOf(GameObject go, string? text3 = null)
			{
				string text2 = DungeonMapUtil.PathFrom(tile.transform, tilePrefab, go.transform);
				if (text3 != null)
				{
					return text2 + "|" + DungeonMapUtil.CleanName(text3);
				}
				return text2;
			}
		}
	}
	internal class DungeonEdge
	{
		public int[] From = Side(connection, "A", tileIds);

		public int[] To = Side(connection, "B", tileIds);

		public DungeonEdge(object connection, Dictionary<Component, int> tileIds)
		{
		}

		private static int[] Side(object connection, string side, Dictionary<Component, int> tileIds)
		{
			Component val = DunGenAccess.Property<Component>(connection, side);
			Component val2 = DunGenAccess.Property<Component>(val, "Tile");
			return new int[2]
			{
				tileIds[val2],
				DunGenAccess.Field<IList>(val2, "AllDoorways").IndexOf(val)
			};
		}
	}
	internal class DungeonMap
	{
		public List<DungeonNode> Tiles = new List<DungeonNode>();

		public List<DungeonEdge> Edges = new List<DungeonEdge>();

		public DungeonMap()
		{
		}

		public DungeonMap(object generator, object dungeon)
			: this()
		{
			List<Component> list = DunGenAccess.Property<IEnumerable>(dungeon, "AllTiles").Cast<Component>().ToList();
			Dictionary<Component, int> tileIds = list.Select((Component t, int i) => (t: t, i: i)).ToDictionary(((Component t, int i) x) => x.t, ((Component t, int i) x) => x.i);
			Dictionary<string, GameObject> tilePrefabs = DunGenAccess.TilePrefabs(generator);
			foreach (Component item in list)
			{
				Tiles.Add(new DungeonNode(item, tilePrefabs));
			}
			foreach (object item2 in DunGenAccess.Property<IEnumerable>(dungeon, "Connections"))
			{
				Edges.Add(new DungeonEdge(item2, tileIds));
			}
		}
	}
	internal class DoorInfo
	{
		public double[] Position = DungeonMapUtil.ToArray(Position);

		public bool StartedLocked;

		public string UnlockTime;

		public DoorInfo(Vector3 Position, bool StartedLocked)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.StartedLocked = StartedLocked;
			UnlockTime = "";
			base..ctor();
		}
	}
	internal class BigDoorInfo
	{
		public double[] Position = DungeonMapUtil.ToArray(Position);

		public string Code;

		public bool StartedOpen;

		public BigDoorInfo(Vector3 Position, string Code, bool StartedOpen)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.Code = Code;
			this.StartedOpen = StartedOpen;
			base..ctor();
		}
	}
	internal class MapHazardInfo
	{
		public string Kind;

		public double[] Position;

		public string Code;

		public MapHazardInfo(string Kind, Vector3 Position, string Code)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			this.Kind = Kind;
			this.Position = DungeonMapUtil.ToArray(Position);
			this.Code = Code;
			base..ctor();
		}
	}
	internal class Stats
	{
		public int Seed;

		public int Version;

		public MoonInfo MoonInfo;

		public DungeonInfo? DungeonInfo;

		public HazardInfo? HazardInfo;

		public PerformanceInfo PerformanceInfo;

		public SpecialItemInfo BeeInfo;

		public SpecialItemInfo EggInfo;

		public SpecialItemInfo KnifeInfo;

		public SpecialItemInfo ShotgunInfo;

		public QuotaInfo QuotaInfo;

		public EventInfo EventInfo;

		public Dictionary<ulong, PlayerStats> Players;

		public List<SpawnInfo> IndoorSpawns;

		public List<SpawnInfo> DayTimeSpawns;

		public List<SpawnInfo> NightTimeSpawns;

		public Dictionary<string, int> ShopSales;

		public Dictionary<string, FurnitureInfo> FurnitureInfo;

		public List<GiftBoxInfo> GiftBoxesOpened;

		public List<SpawnedItemInfo> SpawnedItems;

		public List<MissingItemInfo> MissedItems;

		public Stats(int version, string moonName, string weather, PlayerControllerB[] allPlayers)
		{
			Seed = 0;
			Version = version;
			MoonInfo = new MoonInfo(moonName, weather);
			PerformanceInfo = new PerformanceInfo();
			BeeInfo = new SpecialItemInfo();
			EggInfo = new SpecialItemInfo();
			KnifeInfo = new SpecialItemInfo();
			ShotgunInfo = new SpecialItemInfo();
			QuotaInfo = new QuotaInfo();
			EventInfo = new EventInfo();
			Players = new Dictionary<ulong, PlayerStats>();
			IndoorSpawns = new List<SpawnInfo>();
			DayTimeSpawns = new List<SpawnInfo>();
			NightTimeSpawns = new List<SpawnInfo>();
			GiftBoxesOpened = new List<GiftBoxInfo>();
			SpawnedItems = new List<SpawnedItemInfo>();
			MissedItems = new List<MissingItemInfo>();
			ShopSales = new Dictionary<string, int>();
			FurnitureInfo = new Dictionary<string, FurnitureInfo>();
			foreach (PlayerControllerB val in allPlayers)
			{
				Players[val.playerSteamId] = new PlayerStats(val.playerUsername);
			}
		}
	}
}
namespace StatsTracker.Patches
{
	internal class CompanyTracker
	{
		private static int itemsOnCounterCountLastFrame;

		public static void ApplyCompanyTrackerPatches(Harmony Harmony)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(DepositItemsDesk), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CompanyTracker), "CheckForNewItemsOnCounter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "ShipHasLeft", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CompanyTracker), "ResetItemCountAfterTakingOffCompanyTypeMoon", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void CheckForNewItemsOnCounter(DepositItemsDesk __instance)
		{
			if (__instance.itemsOnCounter.Count > itemsOnCounterCountLastFrame)
			{
				for (int i = itemsOnCounterCountLastFrame; i < __instance.itemsOnCounter.Count; i++)
				{
					if (__instance.itemsOnCounter[i].itemProperties.isScrap)
					{
						StatsTracker.DayStats.QuotaInfo.ValueSold += __instance.itemsOnCounter[i].scrapValue;
					}
				}
			}
			itemsOnCounterCountLastFrame = __instance.itemsOnCounter.Count;
		}

		private static void ResetItemCountAfterTakingOffCompanyTypeMoon(RoundManager __instance)
		{
			if (!((Object)(object)Object.FindAnyObjectByType<DepositItemsDesk>() == (Object)null))
			{
				itemsOnCounterCountLastFrame = 0;
			}
		}
	}
	internal class HQoLTracker
	{
		private static int totalSold;

		public static void ApplyHQoLTrackerPatches(Harmony Harmony)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(DepositItemsDesk), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HQoLTracker), "RegisterOnChangeWhenLandingOnCompanyTypeMoon", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "ShipHasLeft", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HQoLTracker), "DeregisterOnChangeAfterTakingOffCompanyTypeMoon", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void RegisterOnChangeWhenLandingOnCompanyTypeMoon(DepositItemsDesk __instance)
		{
			if ((Object)(object)HQoLNetwork.Instance != (Object)null)
			{
				NetworkVariable<int> totalStorageValue = HQoLNetwork.Instance.totalStorageValue;
				totalStorageValue.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)totalStorageValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnChangeFindSoldValue));
			}
			else if ((Object)(object)HQoLNetwork.Instance != (Object)null)
			{
				NetworkVariable<int> totalStorageValue2 = HQoLNetwork.Instance.totalStorageValue;
				totalStorageValue2.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)totalStorageValue2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnChangeFindSoldValue));
			}
			else
			{
				StatsTracker.Logger.LogWarning((object)"Failed to find HQoL instance, sold value will not be sync'd");
			}
		}

		private static void DeregisterOnChangeAfterTakingOffCompanyTypeMoon(RoundManager __instance)
		{
			if (!((Object)(object)Object.FindAnyObjectByType<DepositItemsDesk>() == (Object)null))
			{
				if ((Object)(object)HQoLNetwork.Instance != (Object)null)
				{
					NetworkVariable<int> totalStorageValue = HQoLNetwork.Instance.totalStorageValue;
					totalStorageValue.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Remove((Delegate?)(object)totalStorageValue.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnChangeFindSoldValue));
				}
				else if ((Object)(object)HQoLNetwork.Instance != (Object)null)
				{
					NetworkVariable<int> totalStorageValue2 = HQoLNetwork.Instance.totalStorageValue;
					totalStorageValue2.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Remove((Delegate?)(object)totalStorageValue2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnChangeFindSoldValue));
				}
				else
				{
					StatsTracker.Logger.LogWarning((object)"Failed to find HQoL instance, sold value will not be sync'd");
				}
				StatsTracker.DayStats.QuotaInfo.ValueSold = totalSold;
				totalSold = 0;
			}
		}

		private static void OnChangeFindSoldValue(int prevValue, int currValue)
		{
			if (currValue < prevValue)
			{
				totalSold += prevValue - currValue;
			}
		}
	}
	internal class HazardTracker
	{
		public static int turretCount;

		public static int landmineCount;

		public static int spiketrapCount;

		public static void ApplyHazardTrakcerPatches(Harmony Harmony)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "GenerateNewLevelClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HazardTracker), "ResetHazardTrackerWhenStartingNewDay", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(Landmine), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HazardTracker), "CountLandmine", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(Turret), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HazardTracker), "CountTurret", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Type SpikeRoofTrapType = AccessTools.TypeByName("SpikeRoofTrap");
			if (SpikeRoofTrapType != null)
			{
				SpikeRoofTrapTypePath();
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void SpikeRoofTrapTypePath()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				Harmony.Patch((MethodBase)AccessTools.Method(SpikeRoofTrapType, "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HazardTracker), "CountSpiketrap", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static void ResetHazardTrackerWhenStartingNewDay(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))
			{
				turretCount = (landmineCount = (spiketrapCount = 0));
			}
		}

		private static void CountLandmine(Landmine __instance)
		{
			landmineCount++;
		}

		private static void CountTurret(Turret __instance)
		{
			turretCount++;
		}

		private static void CountSpiketrap(SpikeRoofTrap __instance)
		{
			spiketrapCount++;
		}
	}
	internal class ItemAndEventTracker
	{
		private const int knifeValue = 35;

		private static readonly List<GiftBoxInfo> giftOpenInOrbit = new List<GiftBoxInfo>();

		private static readonly HashSet<NetworkObjectReference> appSpawnedThisDay = new HashSet<NetworkObjectReference>();

		private static readonly HashSet<NetworkObjectReference> objectsNaturallySpawnedThisDay = new HashSet<NetworkObjectReference>();

		private static readonly HashSet<NetworkObjectReference> objectsExtraSpawnedThisDay = new HashSet<NetworkObjectReference>();

		private static readonly Dictionary<NetworkObjectReference, int> valueFromGiftSpawner = new Dictionary<NetworkObjectReference, int>();

		private static readonly Dictionary<NetworkObjectReference, int> indexFromGiftBox = new Dictionary<NetworkObjectReference, int>();

		private static readonly Dictionary<NetworkObjectReference, int> giftBoxAge = new Dictionary<NetworkObjectReference, int>();

		private static readonly Dictionary<NetworkObjectReference, Vector3> spawnPostionOfItem = new Dictionary<NetworkObjectReference, Vector3>();

		public static void ApplyItemAndEventTrackerPatches(Harmony Harmony)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "GenerateNewLevelClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "ResetItemAndEventTrackerWhenStartingNewDay", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "SyncScrapValuesClientRpc", (Type[])null, (Type[])null);
			Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackDungeonInfo", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackSID", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo RoundManagerRefreshEnemiesList = AccessTools.Method(typeof(RoundManager), "RefreshEnemiesList", (Type[])null, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(RoundManager), "enemyRushIndex");
			if (fieldInfo != null)
			{
				enemyRushIndexPath();
			}
			FieldInfo fieldInfo2 = AccessTools.Field(typeof(RoundManager), "indoorFog");
			if (fieldInfo2 != null)
			{
				indoorFogIntoPath();
			}
			MethodInfo TimeOfDaySetBeginMeteorShowerClientRpcInfo = AccessTools.Method(typeof(TimeOfDay), "SetBeginMeteorShowerClientRpc", (Type[])null, (Type[])null);
			if (TimeOfDaySetBeginMeteorShowerClientRpcInfo != null)
			{
				TimeOfDaySetBeginMeteorShowerClientRpcInfoPath();
			}
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(LungProp), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "CountApp", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkBehaviour), "OnNetworkSpawn", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackSpawnedItems", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkBehaviour), "OnNetworkDespawn", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "TrackMissedItems", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "PassTimeToNextDay", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "TrackCollectedItems", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			if (StatsTracker.GiftBoxItemType != null)
			{
				GiftBoxItemTypePath();
			}
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RedLocustBees), "SpawnHiveClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "TrackHive", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Type NutcrackerEnemyAIType = AccessTools.TypeByName("NutcrackerEnemyAI");
			if (NutcrackerEnemyAIType != null)
			{
				NutcrackerEnemyAITypePath();
			}
			Type ButlerEnemyAIType = AccessTools.TypeByName("ButlerEnemyAI");
			if (ButlerEnemyAIType != null)
			{
				ButlerEnemyAITypePath();
			}
			Type GiantKiwiAIType = AccessTools.TypeByName("GiantKiwiAI");
			if (GiantKiwiAIType != null)
			{
				GiantKiwiAITypePath();
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void ButlerEnemyAITypePath()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Expected O, but got Unknown
				Harmony.Patch((MethodBase)AccessTools.Method(ButlerEnemyAIType, "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackKnifeBeforePopping", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Harmony.Patch((MethodBase)AccessTools.Method(ButlerEnemyAIType, "KillEnemy", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "TrackButlerPopAndRemoveFakeValue", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void GiantKiwiAITypePath()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				Harmony.Patch((MethodBase)AccessTools.Method(GiantKiwiAIType, "SpawnEggsClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "TrackEggs", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void GiftBoxItemTypePath()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Expected O, but got Unknown
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Expected O, but got Unknown
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Expected O, but got Unknown
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Expected O, but got Unknown
				Harmony.Patch((MethodBase)AccessTools.Method(StatsTracker.GiftBoxItemType, "OpenGiftBoxClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "AddNewlySpawnedGiftItemToItemTracker", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				MethodInfo methodInfo2 = AccessTools.Method(StatsTracker.GiftBoxItemType, "InitializeAfterPositioning", (Type[])null, (Type[])null) ?? AccessTools.Method(StatsTracker.GiftBoxItemType, "Start", (Type[])null, (Type[])null);
				Harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "PopulateObjectInGiftValueForAllClients", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackGiftBoxAge", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "PassTimeToNextDay", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "IncreaseAgeOfAllGifts", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void NutcrackerEnemyAITypePath()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				Harmony.Patch((MethodBase)AccessTools.Method(NutcrackerEnemyAIType, "InitializeNutcrackerValuesClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ItemAndEventTracker), "TrackShotgun", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void TimeOfDaySetBeginMeteorShowerClientRpcInfoPath()
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				Harmony.Patch((MethodBase)TimeOfDaySetBeginMeteorShowerClientRpcInfo, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackMeteorShower", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void enemyRushIndexPath()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				Harmony.Patch((MethodBase)RoundManagerRefreshEnemiesList, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackInfestation", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void indoorFogIntoPath()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				Harmony.Patch((MethodBase)RoundManagerRefreshEnemiesList, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemAndEventTracker), "TrackIndoorFog", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static void ResetItemAndEventTrackerWhenStartingNewDay(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))
			{
				return;
			}
			foreach (GiftBoxInfo item in giftOpenInOrbit)
			{
				StatsTracker.DayStats.GiftBoxesOpened.Add(item);
			}
			giftOpenInOrbit.Clear();
			appSpawnedThisDay.Clear();
			objectsNaturallySpawnedThisDay.Clear();
			objectsExtraSpawnedThisDay.Clear();
			valueFromGiftSpawner.Clear();
			indexFromGiftBox.Clear();
			spawnPostionOfItem.Clear();
		}

		private static void TrackDungeonInfo(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.UnionWith(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>();
				string value2;
				bool flag = StatsTracker.VanillaInteriorNames.TryGetValue(value, out value2);
				StatsTracker.DayStats.DungeonInfo = new DungeonInfo(spawnedScrap.Length + appSpawnedThisDay.Count, flag ? value2 : value);
				StatsTracker.DayStats.DungeonInfo.DungeonMap = MapTracker.CurrentMap ?? new DungeonMap();
				MapTracker.CurrentMap = null;
				StatsTracker.DayStats.DungeonInfo.Doors = MapTracker.Doors;
				StatsTracker.DayStats.DungeonInfo.BigDoors = MapTracker.BigDoors;
				StatsTracker.DayStats.PerformanceInfo.InitialAvailableValue += num;
				StatsTracker.DayStats.HazardInfo = new HazardInfo(HazardTracker.turretCount, HazardTracker.landmineCount, HazardTracker.spiketrapCount);
				StatsTracker.DayStats.HazardInfo.MapHazards = MapTracker.MapHazards;
			}
		}

		private static void TrackSID(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<GrabbableObject>();
			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<GrabbableObject>();
				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;
				}
			}
			StatsTracker.DayStats.EventInfo.SIDType = ((Component)component).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText;
		}

		private static void TrackInfestation(RoundManager __instance)
		{
			if (__instance.enemyRushIndex != -1)
			{
				StatsTracker.DayStats.EventInfo.InfestationType = ((Object)__instance.currentLevel.Enemies[__instance.enemyRushIndex].enemyType).name;
			}
		}

		private static void TrackIndoorFog(RoundManager __instance)
		{
			StatsTracker.DayStats.EventInfo.IndoorFog = ((Component)__instance.indoorFog).gameObject.activeSelf;
		}

		private static void TrackMeteorShower(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))
			{
				StatsTracker.DayStats.EventInfo.MeteorShowerTime = StatsTracker.GetCurrentTimeString();
			}
		}

		private static void CountApp(LungProp __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			StatsTracker.DayStats.EventInfo.AppSpawned = true;
			appSpawnedThisDay.Add(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject));
		}

		private static void TrackSpawnedItems(NetworkBehaviour __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0038: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (__instance is GrabbableObject && StatsTracker.dayHasStarted)
			{
				GrabbableObject val = (GrabbableObject)__instance;
				if (val.itemProperties.isScrap && !(val is RagdollGrabbableObject))
				{
					objectsExtraSpawnedThisDay.Add(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject));
					spawnPostionOfItem[NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)] = new Vector3(((Component)val).transform.position.x, ((Component)val).transform.position.y, ((Component)val).transform.position.z);
					SpawnedItemInfo spawnedItemInfo = new SpawnedItemInfo(((NetworkBehaviour)val).NetworkObjectId, GetItemName(val), ((Component)val).transform.position);
					StatsTracker.DayStats.SpawnedItems.Add(spawnedItemInfo);
					((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitUntilItemValueHasBeenSetAndUpdateBottomLine(val, spawnedItemInfo));
				}
			}
		}

		private static string GetItemName(GrabbableObject item)
		{
			ScanNodeProperties componentInChildren = ((Component)item).gameObject.GetComponentInChildren<ScanNodeProperties>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				return componentInChildren.headerText;
			}
			return ((Object)item.itemProperties).name;
		}

		private static int GetValueInsideGift(GrabbableObject item)
		{
			Type? giftBoxItemType = StatsTracker.GiftBoxItemType;
			if ((object)giftBoxItemType == null || !giftBoxItemType.IsInstanceOfType(item))
			{
				return 0;
			}
			return Traverse.Create((object)item).Field("objectInPresentValue").GetValue<int>();
		}

		private static IEnumerator WaitUntilItemValueHasBeenSetAndUpdateBottomLine(GrabbableObject instance, SpawnedItemInfo spawnedItem)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => instance.scrapValue != 0));
			StatsTracker.DayStats.PerformanceInfo.TotalAvailableValue += instance.scrapValue;
			spawnedItem.Value = instance.scrapValue;
			spawnedItem.ScrapInsideGiftValue = GetValueInsideGift(instance);
		}

		private static void PopulateObjectInGiftValueForAllClients(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;
			Random random = new Random((int)((GrabbableObject)val).targetFloorPosition.x + (int)((GrabbableObject)val).targetFloorPosition.y);
			Random random2 = new Random((int)((GrabbableObject)val).targetFloorPosition.x + (int)((GrabbableObject)val).targetFloorPosition.y);
			List<int> list = new List<int>(RoundManager.Instance.currentLevel.spawnableScrap.Count);
			for (int i = 0; i < RoundManager.Instance.currentLevel.spawnableScrap.Count; i++)
			{
				if (RoundManager.Instance.currentLevel.spawnableScrap[i].spawnableItem.itemId == 152767)
				{
					list.Add(0);
				}
				else
				{
					list.Add(RoundManager.Instance.currentLevel.spawnableScrap[i].rarity);
				}
			}
			int randomWeightedIndexList = RoundManager.Instance.GetRandomWeightedIndexList(list, random);
			Item spawnableItem = RoundManager.Instance.currentLevel.spawnableScrap[randomWeightedIndexList].spawnableItem;
			val.objectInPresentValue = (int)((float)random2.Next(spawnableItem.minValue + 25, spawnableItem.maxValue + 35) * RoundManager.Instance.scrapValueMultiplier);
		}

		private static void TrackGiftBoxAge(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)
			GiftBoxItem val = (GiftBoxItem)__instance;
			giftBoxAge[NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)] = 0;
		}

		private static void IncreaseAgeOfAllGifts(RoundManager __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.currentLevel.spawnEnemiesAndScrap)
			{
				return;
			}
			foreach (NetworkObjectReference item in giftBoxAge.Keys.ToList())
			{
				giftBoxAge[item]++;
			}
		}

		private static void TrackMissedItems(NetworkBehaviour __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0022: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (__instance is GrabbableObject && StatsTracker.dayHasStarted)
			{
				GrabbableObject val = (GrabbableObject)__instance;
				giftBoxAge.Remove(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject));
				if (val.itemProperties.isScrap && !(val is RagdollGrabbableObject) && (bool?)StatsTracker.DeactivatedField?.GetValue(val) != true)
				{
					StatsTracker.DayStats.MissedItems.Add(new MissingItemInfo(((NetworkBehaviour)val).NetworkObjectId, GetItemName(val), val.scrapValue, spawnPostionOfItem.ContainsKey(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)) ? new Vector3?(spawnPostionOfItem[NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)]) : ((Vector3?)null), ((Component)val).transform.position, !objectsExtraSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)), GetValueInsideGift(val)));
				}
			}
		}

		private static void TrackCollectedItems()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val in array2)
			{
				if (!val.itemProperties.isScrap || (bool?)StatsTracker.DeactivatedField?.GetValue(val) == true || val.itemUsedUp || !val.isInShipRoom)
				{
					continue;
				}
				if (indexFromGiftBox.TryGetValue(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject), out var value))
				{
					StatsTracker.DayStats.GiftBoxesOpened[value].Collected = true;
				}
				if (!objectsExtraSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)))
				{
					continue;
				}
				StatsTracker.DayStats.PerformanceInfo.CollectedTotal += val.scrapValue;
				if (objectsNaturallySpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)))
				{
					StatsTracker.DayStats.PerformanceInfo.CollectedNoExtra += val.scrapValue;
					continue;
				}
				if (valueFromGiftSpawner.TryGetValue(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject), out var value2))
				{
					StatsTracker.DayStats.PerformanceInfo.CollectedNoExtra += value2;
					continue;
				}
				if (((Object)val.itemProperties).name == "RedLocustHive")
				{
					StatsTracker.DayStats.BeeInfo.AddToCollected(val.scrapValue);
					continue;
				}
				Type? eggItemType = StatsTracker.EggItemType;
				if ((object)eggItemType != null && eggItemType.IsInstanceOfType(val))
				{
					StatsTracker.DayStats.EggInfo.AddToCollected(val.scrapValue);
					continue;
				}
				Type? shotgunItemType = StatsTracker.ShotgunItemType;
				if ((object)shotgunItemType != null && shotgunItemType.IsInstanceOfType(val))
				{
					StatsTracker.DayStats.ShotgunInfo.AddToCollected(val.scrapValue);
					continue;
				}
				Type? knifeItemType = StatsTracker.KnifeItemType;
				if ((object)knifeItemType != null && knifeItemType.IsInstanceOfType(val))
				{
					StatsTracker.DayStats.KnifeInfo.AddToCollected(val.scrapValue);
				}
			}
		}

		private static void AddNewlySpawnedGiftItemToItemTracker(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_009f: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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))
			{
				if (!StatsTracker.dayHasStarted)
				{
					giftOpenInOrbit.Add(new GiftBoxInfo(val.objectInPresentValue, ((GrabbableObject)val).scrapValue, giftBoxAge[NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)]));
					return;
				}
				int count = StatsTracker.DayStats.GiftBoxesOpened.Count;
				StatsTracker.DayStats.GiftBoxesOpened.Add(new GiftBoxInfo(val.objectInPresentValue, ((GrabbableObject)val).scrapValue, giftBoxAge[NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject)]));
				((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitForGiftItemToFullySpawnBeforeTracking(netObjectRef, count, ((GrabbableObject)val).scrapValue, val.objectInPresentValue, objectsExtraSpawnedThisDay.Contains(NetworkObjectReference.op_Implicit(((NetworkBehaviour)val).NetworkObject))));
			}
		}

		private static IEnumerator WaitForGiftItemToFullySpawnBeforeTracking(NetworkObjectReference netObjRef, int indexForCollectedGift, int originalGiftValue, int newScrapValue, bool giftSpawnedThisDay)
		{
			//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)
			NetworkObject netObject = null;
			float startTime = Time.realtimeSinceStartup;
			yield return (object)new WaitWhile((Func<bool>)(() => Time.realtimeSinceStartup - startTime < 8f && !((NetworkObjectReference)(ref netObjRef)).TryGet(ref netObject, (NetworkManager)null)));
			if ((Object)(object)netObject == (Object)null)
			{
				StatsTracker.Logger.LogWarning((object)"No network object found for giftbox");
				yield break;
			}
			indexFromGiftBox[NetworkObjectReference.op_Implicit(netObject)] = indexForCollectedGift;
			if (giftSpawnedThisDay)
			{
				valueFromGiftSpawner[NetworkObjectReference.op_Implicit(netObject)] = originalGiftValue;
				StatsTracker.DayStats.PerformanceInfo.TotalAvailableValue -= originalGiftValue;
			}
			else
			{
				objectsExtraSpawnedThisDay.Remove(NetworkObjectReference.op_Implicit(netObject));
				StatsTracker.DayStats.PerformanceInfo.TotalAvailableValue -= newScrapValue;
				StatsTracker.DayStats.PerformanceInfo.ExtraFromOldGift += newScrapValue - originalGiftValue;
			}
		}

		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.AddToAvailable(hiveScrapValue);
			}
		}

		private static void TrackShotgun(NutcrackerEnemyAI __instance, NetworkObjectReference gunObject)
		{
			//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))
			{
				return;
			}
			NetworkObject val = null;
			((NetworkObjectReference)(ref gunObject)).TryGet(ref val, (NetworkManager)null);
			if ((Object)(object)val == (Object)null)
			{
				StatsTracker.Logger.LogWarning((object)"Gun in GrabGun function did not contain NetworkObject.");
				return;
			}
			ShotgunItem component = ((Component)val).GetComponent<ShotgunItem>();
			if ((Object)(object)component == (Object)null)
			{
				StatsTracker.Logger.LogWarning((object)"Gun in GrabGun function did not contain ShotgunItem component.");
			}
			else
			{
				((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitUntilShotgunValueHasBeenSetBeforeAddingToAvailable(component));
			}
		}

		private static IEnumerator WaitUntilShotgunValueHasBeenSetBeforeAddingToAvailable(ShotgunItem instance)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ((GrabbableObject)instance).scrapValue != 0));
			StatsTracker.DayStats.ShotgunInfo.AddToAvailable(((GrabbableObject)instance).scrapValue);
		}

		private static void TrackKnifeBeforePopping(ButlerEnemyAI __instance)
		{
			StatsTracker.DayStats.PerformanceInfo.TotalAvailableValue += 35;
			StatsTracker.DayStats.KnifeInfo.AddToAvailable(35);
		}

		private static void TrackButlerPopAndRemoveFakeValue(ButlerEnemyAI __instance)
		{
			StatsTracker.DayStats.PerformanceInfo.TotalAvailableValue -= 35;
		}

		private static void TrackEggs(GiantKiwiAI __instance, int[] eggScrapValues)
		{
			//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))
			{
				foreach (int value in eggScrapValues)
				{
					StatsTracker.DayStats.EggInfo.AddToAvailable(value);
				}
			}
		}
	}
	internal class MapTracker
	{
		internal static DungeonMap? CurrentMap;

		internal static List<DoorInfo> Doors = new List<DoorInfo>();

		internal static List<BigDoorInfo> BigDoors = new List<BigDoorInfo>();

		internal static List<MapHazardInfo> MapHazards = new List<MapHazardInfo>();

		private static readonly Dictionary<DoorLock, DoorInfo> doors = new Dictionary<DoorLock, DoorInfo>();

		private static readonly List<(GameObject tree, Vector3 position)> treesBeforeHazards = new List<(GameObject, Vector3)>();

		public static void ApplyMapTrackerPatches(Harmony Harmony)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_007f: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "FinishGeneratingLevel", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MapTracker), "BuildDungeonMapGraph", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "SpawnOutsideHazards", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MapTracker), "RememberOutsideBeforeHazards", (Type[])null), new HarmonyMethod(typeof(MapTracker), "TrackOutsideObjects", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "SetBigDoorCodes", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MapTracker), "TrackDoorsAndHazards", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(DoorLock), "UnlockDoor", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MapTracker), "TrackDoorUnlock", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void RememberOutsideBeforeHazards(RoundManager __instance, out HashSet<Transform> __state)
		{
			//IL_0086: 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_003e: Expected O, but got Unknown
			__state = new HashSet<Transform>();
			treesBeforeHazards.Clear();
			try
			{
				if ((Object)(object)__instance.mapPropsContainer != (Object)null)
				{
					foreach (Transform item2 in __instance.mapPropsContainer.transform)
					{
						Transform item = item2;
						__state.Add(item);
					}
				}
				GameObject[] array = GameObject.FindGameObjectsWithTag("Tree");
				foreach (GameObject val in array)
				{
					treesBeforeHazards.Add((val, val.transform.position));
				}
			}
			catch (Exception ex)
			{
				StatsTracker.Logger.LogDebug((object)("Not tracking removed trees: " + ex.Message));
			}
		}

		private static void TrackOutsideObjects(RoundManager __instance, HashSet<Transform> __state)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (StatsTracker.DayStats == null || (Object)(object)__instance.mapPropsContainer == (Object)null)
				{
					return;
				}
				foreach (Transform item in __instance.mapPropsContainer.transform)
				{
					Transform val = item;
					if (!__state.Contains(val))
					{
						StatsTracker.DayStats.MoonInfo.OutsideObjects.Add(new OutsideObjectInfo(DungeonMapUtil.CleanName(((Object)val).name), val.position, val.eulerAngles.y));
					}
				}
			}
			catch (Exception arg)
			{
				StatsTracker.Logger.LogError((object)$"Failed to track outside objects: {arg}");
			}
		}

		private static void TrackDoorsAndHazards()
		{
			//IL_00da: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (StatsTracker.DayStats != null)
				{
					EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
					foreach (EntranceTeleport val in array)
					{
						if (val.isEntranceToBuilding)
						{
							StatsTracker.DayStats.MoonInfo.Entrances.Add(new DungeonEntrance(((Component)val).transform.position, val.entranceId == 0));
						}
					}
					foreach (var (val2, v) in treesBeforeHazards)
					{
						if ((Object)(object)val2 == (Object)null)
						{
							StatsTracker.DayStats.MoonInfo.RemovedTrees.Add(DungeonMapUtil.ToArray(v));
						}
					}
				}
				DoorLock[] array2 = Object.FindObjectsOfType<DoorLock>();
				foreach (DoorLock val3 in array2)
				{
					doors[val3] = new DoorInfo(((Component)val3).transform.position, val3.isLocked);
					Doors.Add(doors[val3]);
				}
				Type type = AccessTools.TypeByName("SpikeRoofTrap");
				TerminalAccessibleObject[] array3 = Object.FindObjectsOfType<TerminalAccessibleObject>();
				foreach (TerminalAccessibleObject val4 in array3)
				{
					if (val4.isBigDoor)
					{
						BigDoors.Add(new BigDoorInfo(((Component)val4).transform.position, val4.objectCode, val4.isDoorOpen));
					}
					else if ((Object)(object)((Component)val4).GetComponent<Turret>() != (Object)null)
					{
						MapHazards.Add(new MapHazardInfo("Turret", ((Component)val4).transform.position, val4.objectCode));
					}
					else if ((Object)(object)((Component)val4).GetComponent<Landmine>() != (Object)null)
					{
						MapHazards.Add(new MapHazardInfo("Landmine", ((Component)val4).transform.position, val4.objectCode));
					}
					else if (type != null)
					{
						Transform parent = ((Component)val4).transform.parent;
						if ((Object)(object)((parent != null) ? ((Component)parent).GetComponentInChildren(type) : null) != (Object)null)
						{
							MapHazards.Add(new MapHazardInfo("Spike Trap", ((Component)val4).transform.position, val4.objectCode));
						}
					}
				}
			}
			catch (Exception arg)
			{
				StatsTracker.Logger.LogError((object)$"Failed to track doors and hazards: {arg}");
			}
		}

		private static void TrackDoorUnlock(DoorLock __instance)
		{
			if (__instance.isLocked && doors.TryGetValue(__instance, out DoorInfo value))
			{
				value.UnlockTime = StatsTracker.GetCurrentTimeString();
			}
		}

		private static void BuildDungeonMapGraph(RoundManager __instance)
		{
			Doors = new List<DoorInfo>();
			BigDoors = new List<BigDoorInfo>();
			MapHazards = new List<MapHazardInfo>();
			doors.Clear();
			try
			{
				object value = Traverse.Create((object)__instance).Field("dungeonGenerator").Field("Generator")
					.GetValue();
				object obj = ((value == null) ? null : DunGenAccess.Property<object>(value, "CurrentDungeon"));
				if (obj == null)
				{
					StatsTracker.Logger.LogWarning((object)"Couldn't find the generated dungeon, skipping map graph");
					return;
				}
				CurrentMap = new DungeonMap(value, obj);
				if (StatsTracker.DayStats?.DungeonInfo != null)
				{
					StatsTracker.DayStats.DungeonInfo.DungeonMap = CurrentMap;
				}
			}
			catch (Exception arg)
			{
				StatsTracker.Logger.LogError((object)$"Failed to build dungeon map graph: {arg}");
			}
		}
	}
	internal class PlayerTracker
	{
		private static readonly Dictionary<int, ulong> allConnectedPlayersIDToSteamIDs = new Dictionary<int, ulong>();

		public static void ApplyPlayerTrackerPatches(Harmony Harmony)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "ResetPlayersLoadedValueClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PlayerTracker), "RegisterAllConnectedPlayers", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerControllerB), "KillPlayerClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PlayerTracker), "TrackDeath", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "OnPlayerDC", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PlayerTracker), "TrackDisconnect", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void RegisterAllConnectedPlayers(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_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))
			{
				return;
			}
			allConnectedPlayersIDToSteamIDs.Clear();
			for (int i = 0; i < __instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = __instance.allPlayerScripts[i];
				if (!((Object)(object)val == (Object)null))
				{
					allConnectedPlayersIDToSteamIDs.Add(i, val.playerSteamId);
				}
			}
		}

		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_004a: 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))
			{
				StatsTracker.DayStats.Players[__instance.playerSteamId].Kill(StatsTracker.GetCurrentTimeString(), ((object)(CauseOfDeath)causeOfDeath/*cast due to .constrained prefix*/).ToString());
			}
		}

		private static void TrackDisconnect(StartOfRound __instance, int playerObjectNumber)
		{
			if (StatsTracker.dayHasStarted)
			{
				StatsTracker.DayStats.Players[allConnectedPlayersIDToSteamIDs[playerObjectNumber]].Disconnect();
			}
		}
	}
	internal class ServerEvents
	{
		public static void ApplyServerEventPatches(Harmony Harmony)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "ResetPlayersLoadedValueClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ServerEvents), "StartTrackingNewday", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ServerEvents), "TrackNewSeed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "PassTimeToNextDay", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ServerEvents), "PublishDayStats", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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(GameNetworkManager.Instance.gameVersionNum, __instance.currentLevel.PlanetName, ((int)__instance.currentLevel.currentWeather == -1) ? "Mild" : ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref __instance.currentLevel.currentWeather)/*cast due to .constrained prefix*/).ToString(), new ArraySegment<PlayerControllerB>(__instance.allPlayerScripts, 0, __instance.connectedPlayersAmount + 1).ToArray());
				StatsTracker.dayHasStarted = true;
				TimeOfDay.Instance.normalizedTimeOfDay = 0f;
			}
		}

		private static void TrackNewSeed(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))
			{
				StatsTracker.DayStats.Seed = StartOfRound.Instance.randomMapSeed;
			}
		}

		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));
			}
			StatsTracker.dayHasStarted = false;
		}

		private static IEnumerator PublishDayStatsAfterQuotaRoll(int prevQuota)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => TimeOfDay.Instance.profitQuota != prevQuota));
			StatsTracker.DayStats.QuotaInfo.NewQuota = TimeOfDay.Instance.profitQuota;
			StatsTracker.LocalServer.PublishStats(JsonConvert.SerializeObject((object)StatsTracker.DayStats));
		}
	}
	internal class ShipTracker
	{
		public static void ApplyShipTrackerPatches(Harmony Harmony)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(StartOfRound), "ShipLeave", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ShipTracker), "RegisterTakeOffTime", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void RegisterTakeOffTime(StartOfRound __instance)
		{
			StatsTracker.DayStats.EventInfo.TakeOffTime = StatsTracker.GetCurrentTimeString();
		}
	}
	internal class ShopTracker
	{
		public static void ApplyShopTrackerPatches(Harmony Harmony)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(Terminal), "SetItemSales", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ShopTracker), "TrackCurrentSales", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(Terminal), "SetItemSales", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ShopTracker), "TrackCurrentFurniture", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void TrackCurrentSales(Terminal __instance)
		{
			int i;
			if (StatsTracker.DayStats != null)
			{
				i = 0;
				Item[] buyableItemsList = __instance.buyableItemsList;
				foreach (Item val in buyableItemsList)
				{
					StatsTracker.DayStats.ShopSales[val.itemName] = 100 - __instance.itemSalesPercentages[i++];
				}
				if (StatsTracker.BuyableVehicleType != null)
				{
					vehicleControllerPath();
				}
			}
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			void vehicleControllerPath()
			{
				foreach (object item in Traverse.Create((object)__instance).Field("buyableVehicles").GetValue<IEnumerable>())
				{
					StatsTracker.DayStats.ShopSales[Traverse.Create(item).Field("vehicleDisplayName").GetValue<string>()] = 100 - __instance.itemSalesPercentages[i++];
				}
			}
		}

		private static void TrackCurrentFurniture(Terminal __instance)
		{
			if (StatsTracker.DayStats == null)
			{
				return;
			}
			foreach (UnlockableItem unlockable in StartOfRound.Instance.unlockablesList.unlockables)
			{
				if (!((Object)(object)unlockable.shopSelectionNode == (Object)null))
				{
					StatsTracker.DayStats.FurnitureInfo[unlockable.unlockableName] = new FurnitureInfo(unlockable, __instance);
				}
			}
		}
	}
	internal class SpawnTracker
	{
		private static readonly Dictionary<EnemyAI, SpawnInfo> EnemySpawns = new Dictionary<EnemyAI, SpawnInfo>();

		public static void ApplySpawnTrackerPatches(Harmony Harmony)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "GenerateNewLevelClientRpc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SpawnTracker), "ResetSpawnTrackerWhenStartingNewDay", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkBehaviour), "OnNetworkSpawn", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SpawnTracker), "TrackSpawn", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyAI), "KillEnemy", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SpawnTracker), "TrackDeath", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyAI), "OnDestroy", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SpawnTracker), "TrackDespawn", (Type[])nu