Decompiled source of Cooler Mod v0.1.18

BepInEx/plugins/CoolerMod/CoolerMod.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using FishNet;
using FishNet.Broadcast;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Object;
using FishNet.Serializing;
using FishNet.Transporting;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CoolerMod
{
	public static class Rules
	{
		public const byte ItemId = 249;

		public const ushort PrefabCollection = 42421;

		public const int Price = 1000;

		public const int ResalePrice = 500;

		public const int Capacity = 20;

		public const float UseRange = 5f;

		public const float DeployRange = 8f;

		public const float HoldSeconds = 1f;

		public const float VendorRange = 5f;

		public const float VendorLookDot = 0.72f;

		public static bool Finite(float value)
		{
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}

		public static bool SurfaceAllowed(float normalY)
		{
			if (Finite(normalY))
			{
				return normalY >= 0.02f;
			}
			return false;
		}

		public static bool CanPickUp(bool freeSlot, bool emptyHands)
		{
			return freeSlot || emptyHands;
		}

		public static bool CanUseVendor(float distance, float lookDot)
		{
			if (Finite(distance) && Finite(lookDot) && distance <= 5.35f)
			{
				return lookDot >= 0.72f;
			}
			return false;
		}

		public static float SizeMultiplier(float savedWeight)
		{
			if (Finite(savedWeight) && !(savedWeight <= 0f))
			{
				return savedWeight;
			}
			return 1f;
		}

		public static int ApplySaleBonus(int value, int percent)
		{
			long val = (long)Math.Round((double)Math.Max(0, value) * (1.0 + (double)Math.Max(0, percent) / 100.0), MidpointRounding.AwayFromZero);
			return (int)Math.Min(2147483647L, val);
		}

		public static int ScaleProtectedValue(int value, float multiplier)
		{
			if (!Finite(multiplier) || multiplier < 0f)
			{
				multiplier = 0f;
			}
			long val = (long)Math.Round((double)Math.Max(0, value) * (double)multiplier, MidpointRounding.AwayFromZero);
			return (int)Math.Min(2147483647L, val);
		}

		public static float ColorChannel(float value)
		{
			if (Finite(value))
			{
				return Math.Max(0f, Math.Min(1f, value));
			}
			return 0f;
		}
	}
	[Serializable]
	public sealed class CoolerData
	{
		public int serial;

		public string name;

		public ulong owner;

		public string ownerName;

		public bool deployed;

		public bool available = true;

		public Vector3 bodyColor = new Vector3(0.03f, 0.48f, 0.58f);

		public Vector3 position;

		public Vector3 surfaceNormal = Vector3.up;

		public float yaw;

		public List<SavedItem> fish = new List<SavedItem>();

		public List<StoredFishInfo> fishInfo = new List<StoredFishInfo>();

		public Quaternion Rotation => Quaternion.FromToRotation(Vector3.up, (((Vector3)(ref surfaceNormal)).sqrMagnitude > 0.01f) ? surfaceNormal : Vector3.up) * Quaternion.Euler(0f, yaw, 0f);
	}
	[Serializable]
	public sealed class StoredFishInfo
	{
		public string name;

		public int value;

		public float cookMultiplier;
	}
	[Serializable]
	public sealed class WorldData
	{
		public string name;

		public List<CoolerData> coolers = new List<CoolerData>();
	}
	[Serializable]
	public sealed class SaveData
	{
		public int version = 1;

		public int nextSerial = 1;

		public List<WorldData> worlds = new List<WorldData>();
	}
	[Serializable]
	public sealed class Command
	{
		public int protocol = 1;

		public int sequence;

		public int serial;

		public int index;

		public string action;

		public string text;

		public Vector3 position;

		public Vector3 normal;
	}
	[Serializable]
	public sealed class Snapshot
	{
		public int protocol = 1;

		public string world;

		public List<CoolerData> coolers = new List<CoolerData>();
	}
	[Serializable]
	public sealed class Reply
	{
		public int sequence;

		public int serial;

		public string message;

		public bool saleSound;
	}
	public struct RequestMessage : IBroadcast
	{
		public string json;
	}
	public struct StateMessage : IBroadcast
	{
		public string json;
	}
	public struct ReplyMessage : IBroadcast
	{
		public string json;
	}
	public sealed class CoolerPriceGuarantee : MonoBehaviour
	{
		public int guaranteedValue;

		public float cookMultiplier = 1f;
	}
	public static class Codec
	{
		private sealed class Fields : DefaultContractResolver
		{
			protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization mode)
			{
				return (from f in type.GetFields(BindingFlags.Instance | BindingFlags.Public)
					where !f.IsNotSerialized
					select ((DefaultContractResolver)this).CreateProperty((MemberInfo)f, (MemberSerialization)2)).ToList();
			}
		}

		private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
		{
			ContractResolver = (IContractResolver)(object)new Fields(),
			TypeNameHandling = (TypeNameHandling)0,
			ObjectCreationHandling = (ObjectCreationHandling)2,
			MaxDepth = 32
		};

		public static string ToJson(object value, bool pretty = false)
		{
			return JsonConvert.SerializeObject(value, (Formatting)(pretty ? 1 : 0), Settings);
		}

		public static T FromJson<T>(string json)
		{
			return JsonConvert.DeserializeObject<T>(json, Settings);
		}
	}
	public static class CoolerItem
	{
		public static Item Prefab;

		private static GameObject storage;

		public static bool Is(Item item)
		{
			if ((Object)(object)item != (Object)null && item.ID == 249)
			{
				return (Object)(object)((Component)item).GetComponent<CoolerVisual>() != (Object)null;
			}
			return false;
		}

		public static int Serial(Item item)
		{
			if (!Is(item))
			{
				return 0;
			}
			return Mathf.RoundToInt(item.BettingMultiplier);
		}

		public static void Register()
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Prefab != (Object)null || (Object)(object)InstanceFinder.NetworkManager == (Object)null)
			{
				return;
			}
			Dictionary<byte, Item> dictionary = (Dictionary<byte, Item>)AccessTools.Field(typeof(GameInfo), "_idToSpawnable").GetValue(null);
			if (dictionary.Count == 0)
			{
				return;
			}
			if (dictionary.ContainsKey(249))
			{
				throw new Exception("Cooler Mod item ID 249 is already in use.");
			}
			Item? obj = (from i in dictionary.Values
				where (Object)(object)i != (Object)null && ((object)i).GetType() == typeof(Item) && (Object)(object)((Component)i).GetComponent<NetworkObject>() != (Object)null
				orderby i.ID
				select i).FirstOrDefault();
			if ((Object)(object)obj == (Object)null)
			{
				throw new Exception("No compatible base item prefab was found.");
			}
			storage = new GameObject("Cooler Mod prefab storage");
			storage.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)storage);
			Item val = Object.Instantiate<Item>(obj, storage.transform);
			((Object)val).name = "Reusable Fishing Cooler";
			AccessTools.Field(typeof(Item), "_id").SetValue(val, (byte)249);
			AccessTools.Field(typeof(Item), "_cost").SetValue(val, 1000);
			AccessTools.Field(typeof(Item), "_worth").SetValue(val, 500);
			AccessTools.Field(typeof(Item), "_ignoredBySeagulls").SetValue(val, true);
			AccessTools.Field(typeof(Item), "_ignoredByMoneyNPC").SetValue(val, false);
			AccessTools.Field(typeof(Item), "_ignoredByCloseDots").SetValue(val, false);
			AccessTools.Field(typeof(Item), "_heldPos").SetValue(val, (object)new Vector3(0.32f, -0.5f, 0.82f));
			AccessTools.Field(typeof(Item), "_heldRot").SetValue(val, (object)new Vector3(2f, 88f, 2f));
			Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true);
			for (int num = 0; num < componentsInChildren.Length; num++)
			{
				componentsInChildren[num].enabled = false;
			}
			Collider[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Collider>(true);
			foreach (Collider val2 in componentsInChildren2)
			{
				if (!val2.isTrigger)
				{
					val2.enabled = false;
				}
			}
			GameObject val3 = new GameObject("CoolerBodyCollider");
			val3.transform.SetParent(((Component)val).transform, false);
			BoxCollider val4 = val3.AddComponent<BoxCollider>();
			val4.center = new Vector3(0f, 0.43f, 0f);
			val4.size = new Vector3(1.2f, 0.86f, 0.78f);
			AccessTools.Field(typeof(Item), "_worldColliders").SetValue(val, new Collider[1] { (Collider)val4 });
			Collider val5 = (Collider)AccessTools.Field(typeof(Item), "_pickUpCollider").GetValue(val);
			if (val5 is SphereCollider)
			{
				SphereCollider val6 = (SphereCollider)val5;
				val6.radius = 0.85f;
				val6.center = new Vector3(0f, 0.42f, 0f);
			}
			else if (val5 is BoxCollider)
			{
				BoxCollider val7 = (BoxCollider)val5;
				val7.size = new Vector3(1.5f, 1.15f, 1.1f);
				val7.center = new Vector3(0f, 0.42f, 0f);
			}
			AccessTools.Field(typeof(Item), "_outOfHandHolder").SetValue(val, null);
			AccessTools.Field(typeof(Item), "_inHandHolder").SetValue(val, null);
			CoolerVisual coolerVisual = ((Component)val).gameObject.AddComponent<CoolerVisual>();
			coolerVisual.Build();
			AccessTools.Field(typeof(Item), "_mesh").SetValue(val, coolerVisual.InventoryMesh());
			AccessTools.Field(typeof(Item), "_inventoryMeshScale").SetValue(val, 0.52f);
			AccessTools.Field(typeof(Item), "_inventoryMeshPos").SetValue(val, (object)new Vector3(0f, -0.15f, 0f));
			AccessTools.Field(typeof(Item), "_inventoryMeshRot").SetValue(val, (object)new Vector3(18f, 35f, 0f));
			AccessTools.Field(typeof(Item), "_renderers").SetValue(val, (from r in ((Component)coolerVisual).GetComponentsInChildren<Renderer>(true)
				where r.enabled
				select r).ToList());
			NetworkObject component = ((Component)val).GetComponent<NetworkObject>();
			component.SetIsSpawnable(true);
			PrefabObjects prefabObjects = InstanceFinder.NetworkManager.GetPrefabObjects<SinglePrefabObjects>((ushort)42421, true);
			if (prefabObjects.GetObjectCount() != 0)
			{
				throw new Exception("Cooler Mod network prefab collection 42421 is occupied.");
			}
			prefabObjects.AddObject(component, false, true);
			dictionary.Add(249, val);
			((Dictionary<byte, Item>)AccessTools.Field(typeof(GameInfo), "_allItems").GetValue(null)).Add(249, val);
			((Dictionary<string, Item>)AccessTools.Field(typeof(GameInfo), "_nameToSpawnable").GetValue(null)).Add("coolermod", val);
			Prefab = val;
			Plugin.Log("Registered reusable cooler item and network prefab.");
		}
	}
	public sealed class CoolerVisual : MonoBehaviour
	{
		private static Material teal;

		private static Material white;

		private static Material dark;

		private static Material silver;

		private Mesh inventoryMesh;

		private Material bodyMaterial;

		private Renderer bodyRenderer;

		private MaterialPropertyBlock colorBlock;

		private bool materialReady;

		public Mesh InventoryMesh()
		{
			return inventoryMesh;
		}

		public void Build()
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((Component)this).transform.Find("CoolerModel") != (Object)null)
			{
				return;
			}
			Shader val = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard");
			if ((Object)(object)teal == (Object)null)
			{
				teal = new Material(val)
				{
					color = new Color(0.03f, 0.48f, 0.58f)
				};
				white = new Material(val)
				{
					color = new Color(0.88f, 0.86f, 0.78f)
				};
				dark = new Material(val)
				{
					color = new Color(0.07f, 0.1f, 0.15f)
				};
				silver = new Material(val)
				{
					color = new Color(0.58f, 0.63f, 0.65f)
				};
			}
			Transform transform = new GameObject("CoolerModel").transform;
			transform.SetParent(((Component)this).transform, false);
			Transform val2 = Part("Body", transform, (PrimitiveType)3, new Vector3(0f, 0.39f, 0f), new Vector3(1.12f, 0.66f, 0.72f), teal);
			inventoryMesh = ((Component)val2).GetComponent<MeshFilter>().sharedMesh;
			Part("LowerBand", transform, (PrimitiveType)3, new Vector3(0f, 0.12f, 0f), new Vector3(1.18f, 0.1f, 0.78f), dark);
			Part("UpperBand", transform, (PrimitiveType)3, new Vector3(0f, 0.68f, 0f), new Vector3(1.18f, 0.1f, 0.78f), dark);
			Part("Lid", transform, (PrimitiveType)3, new Vector3(0f, 0.79f, 0f), new Vector3(1.22f, 0.18f, 0.82f), white);
			Part("LidInset", transform, (PrimitiveType)3, new Vector3(0f, 0.895f, 0f), new Vector3(0.76f, 0.035f, 0.45f), silver);
			float[] array = new float[2] { -0.35f, 0.35f };
			foreach (float num in array)
			{
				Part("Latch", transform, (PrimitiveType)3, new Vector3(num, 0.66f, -0.425f), new Vector3(0.14f, 0.22f, 0.07f), dark);
				Part("LatchCap", transform, (PrimitiveType)3, new Vector3(num, 0.73f, -0.47f), new Vector3(0.17f, 0.08f, 0.06f), silver);
			}
			array = new float[2] { -0.56f, 0.56f };
			foreach (float num2 in array)
			{
				Part("HandlePost", transform, (PrimitiveType)3, new Vector3(num2, 0.91f, 0f), new Vector3(0.08f, 0.48f, 0.09f), dark);
			}
			Part("Handle", transform, (PrimitiveType)3, new Vector3(0f, 1.14f, 0f), new Vector3(1.18f, 0.09f, 0.11f), dark);
			array = new float[2] { -0.52f, 0.52f };
			foreach (float num3 in array)
			{
				float[] array2 = new float[2] { -0.32f, 0.32f };
				foreach (float num4 in array2)
				{
					Part("Foot", transform, (PrimitiveType)3, new Vector3(num3, 0.055f, num4), new Vector3(0.16f, 0.11f, 0.13f), dark);
				}
			}
		}

		public static Transform Part(string name, Transform parent, PrimitiveType primitive, Vector3 pos, Vector3 scale, Material material)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive(primitive);
			((Object)obj).name = name;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = pos;
			obj.transform.localScale = scale;
			Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
			obj.GetComponent<Renderer>().sharedMaterial = material;
			return obj.transform;
		}

		private void EnsureBodyMaterial()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			if (materialReady)
			{
				return;
			}
			Transform val = ((Component)this).transform.Find("CoolerModel/Body");
			if (!((Object)(object)val == (Object)null))
			{
				bodyRenderer = ((Component)val).GetComponent<Renderer>();
				if (!((Object)(object)bodyRenderer == (Object)null))
				{
					bodyMaterial = (((Object)(object)bodyRenderer.sharedMaterial == (Object)null) ? new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard")) : new Material(bodyRenderer.sharedMaterial));
					bodyRenderer.sharedMaterial = bodyMaterial;
					materialReady = true;
				}
			}
		}

		public void ApplyColor(Vector3 color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			EnsureBodyMaterial();
			if (materialReady)
			{
				Color val = default(Color);
				((Color)(ref val))..ctor(Rules.ColorChannel(color.x), Rules.ColorChannel(color.y), Rules.ColorChannel(color.z), 1f);
				bodyMaterial.color = val;
				if (bodyMaterial.HasProperty("_BaseColor"))
				{
					bodyMaterial.SetColor("_BaseColor", val);
				}
				if (bodyMaterial.HasProperty("_Color"))
				{
					bodyMaterial.SetColor("_Color", val);
				}
				if (colorBlock == null)
				{
					colorBlock = new MaterialPropertyBlock();
				}
				bodyRenderer.GetPropertyBlock(colorBlock);
				colorBlock.SetColor("_BaseColor", val);
				colorBlock.SetColor("_Color", val);
				bodyRenderer.SetPropertyBlock(colorBlock);
			}
		}

		private void LateUpdate()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Plugin.Instance == (Object)null)
			{
				return;
			}
			Item component = ((Component)this).GetComponent<Item>();
			CoolerData coolerData = Plugin.Instance.Find(CoolerItem.Serial(component));
			if (coolerData != null)
			{
				ApplyColor(coolerData.bodyColor);
				if (coolerData.deployed && (Object)(object)component != (Object)null && (Object)(object)component.SyncedHolder == (Object)null)
				{
					((Component)this).transform.SetPositionAndRotation(coolerData.position, coolerData.Rotation);
				}
			}
		}
	}
	[BepInPlugin("ponyfisher.howtofish.coolermod", "Cooler Mod", "0.1.18")]
	[DefaultExecutionOrder(29100)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "ponyfisher.howtofish.coolermod";

		public static Plugin Instance;

		public List<CoolerData> Current = new List<CoolerData>();

		public bool Open;

		public int Selected;

		public string Status = "Purchase a reusable cooler from an item vendor.";

		private SaveData save = new SaveData();

		private WorldData world;

		private NetworkManager manager;

		private Harmony harmony;

		private ConfigEntry<bool> autoBulkSellDrip;

		private string savePath;

		private bool persistenceReady = true;

		private bool registrationFailed;

		private bool catalogReady;

		private float nextTick;

		private float nextSave;

		private float nextState;

		private float nextHello;

		private float nextVendorScan;

		private float nextIconRefresh;

		private int sequence;

		private bool nearMoneyVendor;

		private Component hoveredInteractable;

		private readonly Dictionary<int, int> lastSequence = new Dictionary<int, int>();

		private readonly Dictionary<int, float> rateLimit = new Dictionary<int, float>();

		private readonly Dictionary<int, Item> coolers = new Dictionary<int, Item>();

		private float useStarted;

		private Item activeTarget;

		private bool holdFired;

		private GUIStyle hintStyle;

		private GUIStyle infoStyle;

		private Rect panel = new Rect(30f, 45f, 1160f, 680f);

		private CursorLockMode oldLock;

		private GUIStyle windowStyle;

		private GUIStyle titleStyle;

		private GUIStyle headerStyle;

		private GUIStyle rowStyle;

		private GUIStyle emptyStyle;

		private GUIStyle buttonStyle;

		private GUIStyle dropStyle;

		private GUIStyle statusStyle;

		private GUIStyle toggleStyle;

		private Texture2D navy;

		private Texture2D teal;

		private Texture2D tealHover;

		private Texture2D orange;

		private Texture2D orangeHover;

		private Texture2D rowBg;

		private Texture2D rowAlt;

		private string nameDraft;

		private int nameDraftSerial;

		private int activeTab;

		private int sortField = 5;

		private int sortMenu;

		private bool sortDescending = true;

		private Vector3 colorDraft;

		private static readonly string[] SortNames = new string[6] { "Cooking %", "Score", "Size", "Price", "Name", "Most recent" };

		public bool AutoBulkSellDrip
		{
			get
			{
				if (autoBulkSellDrip != null)
				{
					return autoBulkSellDrip.Value;
				}
				return false;
			}
		}

		public static void Log(string text)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)text);
			}
		}

		private void Awake()
		{
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			Instance = this;
			autoBulkSellDrip = ((BaseUnityPlugin)this).Config.Bind<bool>("Selling", "AutoBulkSellDripCreatures", false, "Include rare drip creatures when using the cooler's bulk-sell interaction.");
			savePath = Path.Combine(Paths.ConfigPath, "CoolerMod-worlds.json");
			try
			{
				if (File.Exists(savePath))
				{
					save = Codec.FromJson<SaveData>(File.ReadAllText(savePath));
					if (save == null || save.version != 1 || save.worlds == null)
					{
						throw new Exception("Unrecognized save format");
					}
				}
			}
			catch (Exception ex)
			{
				persistenceReady = false;
				Status = "Cooler save data could not be read; storage actions are paused.";
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
			GenericWriter<RequestMessage>.SetWrite((Action<Writer, RequestMessage>)delegate(Writer w, RequestMessage v)
			{
				w.WriteString(v.json);
			});
			GenericReader<RequestMessage>.SetRead((Func<Reader, RequestMessage>)((Reader r) => new RequestMessage
			{
				json = r.ReadStringAllocated()
			}));
			GenericWriter<StateMessage>.SetWrite((Action<Writer, StateMessage>)delegate(Writer w, StateMessage v)
			{
				w.WriteString(v.json);
			});
			GenericReader<StateMessage>.SetRead((Func<Reader, StateMessage>)((Reader r) => new StateMessage
			{
				json = r.ReadStringAllocated()
			}));
			GenericWriter<ReplyMessage>.SetWrite((Action<Writer, ReplyMessage>)delegate(Writer w, ReplyMessage v)
			{
				w.WriteString(v.json);
			});
			GenericReader<ReplyMessage>.SetRead((Func<Reader, ReplyMessage>)((Reader r) => new ReplyMessage
			{
				json = r.ReadStringAllocated()
			}));
			harmony = new Harmony("ponyfisher.howtofish.coolermod");
			harmony.PatchAll(typeof(Plugin).Assembly);
			((MonoBehaviour)this).StartCoroutine(CoolerSounds.Load());
			Log("Cooler Mod 0.1.18 loaded.");
		}

		private void Update()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			UpdateInteraction();
			if ((Object)(object)manager != (Object)(object)InstanceFinder.NetworkManager)
			{
				RegisterNetwork();
			}
			if (!registrationFailed && (Object)(object)CoolerItem.Prefab == (Object)null)
			{
				try
				{
					CoolerItem.Register();
				}
				catch (Exception ex)
				{
					registrationFailed = true;
					Status = "Cooler item registration failed; see the BepInEx log.";
					((BaseUnityPlugin)this).Logger.LogError((object)ex);
				}
			}
			if ((Object)(object)CoolerItem.Prefab != (Object)null && !catalogReady)
			{
				catalogReady = true;
				Log("Cooler catalog ready.");
			}
			if (catalogReady && Time.unscaledTime >= nextVendorScan)
			{
				nextVendorScan = Time.unscaledTime + 0.15f;
				nearMoneyVendor = (Object)(object)FocusedMoneyVendor(Player.LocalPlayer, 5f) != (Object)null;
			}
			Keyboard current = Keyboard.current;
			if (catalogReady && nearMoneyVendor && !Open && current != null && ((ButtonControl)current.digit8Key).wasPressedThisFrame)
			{
				Send("buy");
			}
			if (catalogReady && Time.unscaledTime >= nextIconRefresh)
			{
				nextIconRefresh = Time.unscaledTime + 0.15f;
				CoolerInventoryIcon.RefreshAll();
			}
			if (InstanceFinder.IsServerStarted && SaveManager.CurServerSave != null)
			{
				string name = SaveManager.CurServerSave.Name;
				if (world == null || world.name != name)
				{
					world = save.worlds.FirstOrDefault((WorldData w) => w.name == name);
					if (world == null)
					{
						world = new WorldData
						{
							name = name
						};
						save.worlds.Add(world);
					}
					Current = world.coolers;
					coolers.Clear();
					lastSequence.Clear();
					rateLimit.Clear();
				}
				if (Time.unscaledTime >= nextTick)
				{
					nextTick = Time.unscaledTime + 0.2f;
					AuditWorld();
				}
				if (Time.unscaledTime >= nextState)
				{
					nextState = Time.unscaledTime + 0.35f;
					Broadcast();
				}
				if (Time.unscaledTime >= nextSave)
				{
					nextSave = Time.unscaledTime + 8f;
					Persist();
				}
			}
			else if (!InstanceFinder.IsClientStarted)
			{
				world = null;
				Current = new List<CoolerData>();
				coolers.Clear();
			}
			if (Open && InstanceFinder.IsClientStarted && !InstanceFinder.IsServerStarted && Time.unscaledTime >= nextHello)
			{
				nextHello = Time.unscaledTime + 3f;
				Send("hello");
			}
		}

		private void LateUpdate()
		{
			if (Open)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}

		private void RegisterNetwork()
		{
			if ((Object)(object)manager != (Object)null)
			{
				manager.ServerManager.UnregisterBroadcast<RequestMessage>((Action<NetworkConnection, RequestMessage, Channel>)Receive);
				manager.ClientManager.UnregisterBroadcast<StateMessage>((Action<StateMessage, Channel>)ReceiveState);
				manager.ClientManager.UnregisterBroadcast<ReplyMessage>((Action<ReplyMessage, Channel>)ReceiveReply);
			}
			manager = InstanceFinder.NetworkManager;
			if (!((Object)(object)manager == (Object)null))
			{
				manager.ServerManager.RegisterBroadcast<RequestMessage>((Action<NetworkConnection, RequestMessage, Channel>)Receive, true);
				manager.ClientManager.RegisterBroadcast<StateMessage>((Action<StateMessage, Channel>)ReceiveState);
				manager.ClientManager.RegisterBroadcast<ReplyMessage>((Action<ReplyMessage, Channel>)ReceiveReply);
			}
		}

		public static string DefaultCoolerName(int serial)
		{
			return "Fishing Cooler " + serial;
		}

		private static string CleanName(string value, int serial)
		{
			if (value == null)
			{
				return DefaultCoolerName(serial);
			}
			string text = new string(value.Where((char c) => !char.IsControl(c)).ToArray()).Trim();
			if (text.Length > 28)
			{
				text = text.Substring(0, 28).Trim();
			}
			if (text.Length != 0)
			{
				return text;
			}
			return DefaultCoolerName(serial);
		}

		private void Normalize(CoolerData data)
		{
			if (data == null)
			{
				return;
			}
			data.name = CleanName(data.name, data.serial);
			if (data.fish == null)
			{
				data.fish = new List<SavedItem>();
			}
			if (data.fishInfo == null)
			{
				data.fishInfo = new List<StoredFishInfo>();
			}
			while (data.fishInfo.Count < data.fish.Count)
			{
				SavedItem fish = data.fish[data.fishInfo.Count];
				data.fishInfo.Add(new StoredFishInfo
				{
					name = FishName(fish),
					value = FishValue(fish),
					cookMultiplier = CookMultiplier(fish)
				});
			}
			if (data.fishInfo.Count > data.fish.Count)
			{
				data.fishInfo.RemoveRange(data.fish.Count, data.fishInfo.Count - data.fish.Count);
			}
			for (int i = 0; i < data.fishInfo.Count; i++)
			{
				if (data.fishInfo[i] == null)
				{
					data.fishInfo[i] = new StoredFishInfo();
				}
				if (string.IsNullOrWhiteSpace(data.fishInfo[i].name))
				{
					data.fishInfo[i].name = FishName(data.fish[i]);
				}
				if (data.fishInfo[i].value < 0)
				{
					data.fishInfo[i].value = 0;
				}
				if (data.fishInfo[i].cookMultiplier <= 0f)
				{
					data.fishInfo[i].cookMultiplier = Mathf.Max(0.0001f, CookMultiplier(data.fish[i]));
				}
				ProtectSavedValue(data.fish[i], data.fishInfo[i].value);
			}
		}

		public CoolerData Find(int serial)
		{
			CoolerData coolerData = Current.FirstOrDefault((CoolerData c) => c.serial == serial);
			Normalize(coolerData);
			return coolerData;
		}

		public string StoredName(CoolerData data, int index)
		{
			Normalize(data);
			if (data == null || index < 0 || index >= data.fishInfo.Count)
			{
				return "Unknown fish";
			}
			return data.fishInfo[index].name;
		}

		public int StoredValue(CoolerData data, int index)
		{
			Normalize(data);
			if (data == null || index < 0 || index >= data.fishInfo.Count)
			{
				return 0;
			}
			return Mathf.Max(0, data.fishInfo[index].value);
		}

		public int StoredFishTotal(CoolerData data)
		{
			Normalize(data);
			if (data == null || data.fish == null)
			{
				return 0;
			}
			long num = 0L;
			for (int i = 0; i < data.fish.Count; i++)
			{
				num += StoredValue(data, i);
			}
			return (int)Math.Min(2147483647L, num);
		}

		public void SetAutoBulkSellDrip(bool value)
		{
			if (autoBulkSellDrip != null)
			{
				autoBulkSellDrip.Value = value;
				((BaseUnityPlugin)this).Config.Save();
			}
			Status = (value ? "Bulk selling will include drip creatures." : "Drip creatures are protected from bulk selling.");
		}

		private void RemoveStored(CoolerData data, int index)
		{
			data.fish.RemoveAt(index);
			if (data.fishInfo != null && index < data.fishInfo.Count)
			{
				data.fishInfo.RemoveAt(index);
			}
			FishPreviews.Clear();
		}

		public void Persist()
		{
			if (!persistenceReady || !InstanceFinder.IsServerStarted || world == null)
			{
				return;
			}
			try
			{
				string text = savePath + ".tmp";
				File.WriteAllText(text, Codec.ToJson(save, pretty: true));
				if (File.Exists(savePath))
				{
					File.Replace(text, savePath, savePath + ".bak");
				}
				else
				{
					File.Move(text, savePath);
				}
			}
			catch (Exception ex)
			{
				persistenceReady = false;
				Status = "Cooler Mod could not save; storage actions are paused.";
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
		}

		public void Send(string action, int index = -1, Vector3 position = default(Vector3), Vector3 normal = default(Vector3), int serial = 0, string text = null)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.LocalPlayer == (Object)null)
			{
				Status = "Load into a game first.";
				return;
			}
			Command command = new Command
			{
				action = action,
				text = text,
				serial = ((serial > 0) ? serial : Selected),
				index = index,
				position = position,
				normal = normal,
				sequence = ++sequence
			};
			if (InstanceFinder.IsServerStarted)
			{
				Execute(Player.LocalPlayer, command, null);
			}
			else if ((Object)(object)manager != (Object)null && InstanceFinder.IsClientStarted)
			{
				manager.ClientManager.Broadcast<RequestMessage>(new RequestMessage
				{
					json = Codec.ToJson(command)
				}, (Channel)0);
				if (action != "hello")
				{
					Status = "Waiting for the host...";
				}
			}
		}

		private void Receive(NetworkConnection connection, RequestMessage message, Channel channel)
		{
			if (!InstanceFinder.IsServerStarted || message.json == null || message.json.Length > 2048)
			{
				return;
			}
			try
			{
				Command command = Codec.FromJson<Command>(message.json);
				if (command != null && command.protocol == 1 && command.sequence > 0 && (!lastSequence.TryGetValue(connection.ClientId, out var value) || command.sequence > value) && (!rateLimit.TryGetValue(connection.ClientId, out var value2) || !(Time.unscaledTime - value2 < 0.1f)))
				{
					lastSequence[connection.ClientId] = command.sequence;
					rateLimit[connection.ClientId] = Time.unscaledTime;
					Player val = ((IEnumerable<Player>)Object.FindObjectsByType<Player>()).FirstOrDefault((Func<Player, bool>)((Player p) => ((NetworkBehaviour)p).Owner == connection));
					if ((Object)(object)val != (Object)null)
					{
						Execute(val, command, connection);
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Rejected Cooler Mod request: " + ex.Message));
			}
		}

		private void Respond(Command cmd, NetworkConnection connection, string message, int selected = 0, bool saleSound = false)
		{
			Reply value = new Reply
			{
				sequence = cmd.sequence,
				serial = selected,
				message = message,
				saleSound = saleSound
			};
			if (connection == (NetworkConnection)null || connection.IsLocalClient)
			{
				Status = message;
				if (selected > 0)
				{
					Selected = selected;
				}
				if (saleSound)
				{
					CoolerSounds.PlaySale();
				}
			}
			else
			{
				manager.ServerManager.Broadcast<ReplyMessage>(connection, new ReplyMessage
				{
					json = Codec.ToJson(value)
				}, true, (Channel)0);
			}
		}

		private void ReceiveReply(ReplyMessage message, Channel channel)
		{
			Reply reply = Codec.FromJson<Reply>(message.json);
			if (reply != null)
			{
				Status = reply.message;
				if (reply.serial > 0)
				{
					Selected = reply.serial;
				}
				if (reply.saleSound)
				{
					CoolerSounds.PlaySale();
				}
			}
		}

		private void ReceiveState(StateMessage message, Channel channel)
		{
			if (InstanceFinder.IsServerStarted || message.json == null || message.json.Length > 500000)
			{
				return;
			}
			Snapshot snapshot = Codec.FromJson<Snapshot>(message.json);
			if (snapshot == null || snapshot.protocol != 1 || snapshot.coolers == null)
			{
				return;
			}
			Current = snapshot.coolers;
			foreach (CoolerData item in Current)
			{
				ApplyColorNow(item);
			}
		}

		private void Broadcast()
		{
			if ((Object)(object)manager != (Object)null && world != null)
			{
				manager.ServerManager.Broadcast<StateMessage>(new StateMessage
				{
					json = Codec.ToJson(new Snapshot
					{
						world = world.name,
						coolers = Current
					})
				}, true, (Channel)0);
			}
		}

		private void ScanCoolers()
		{
			coolers.Clear();
			Item[] array = Object.FindObjectsByType<Item>((FindObjectsInactive)1);
			foreach (Item val in array)
			{
				if (CoolerItem.Is(val) && ((NetworkBehaviour)val).IsSpawned && !((NetworkBehaviour)val).IsDeinitializing)
				{
					int num = CoolerItem.Serial(val);
					if (num > 0 && !coolers.ContainsKey(num))
					{
						coolers.Add(num, val);
					}
				}
			}
		}

		private Item FindCooler(int serial)
		{
			if (coolers.TryGetValue(serial, out var value) && (Object)(object)value != (Object)null && ((NetworkBehaviour)value).IsSpawned && !((NetworkBehaviour)value).IsDeinitializing)
			{
				return value;
			}
			value = ((IEnumerable<Item>)Object.FindObjectsByType<Item>((FindObjectsInactive)1)).FirstOrDefault((Func<Item, bool>)((Item i) => CoolerItem.Is(i) && ((NetworkBehaviour)i).IsSpawned && !((NetworkBehaviour)i).IsDeinitializing && CoolerItem.Serial(i) == serial));
			if ((Object)(object)value != (Object)null)
			{
				coolers[serial] = value;
			}
			return value;
		}

		private void AuditWorld()
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			ScanCoolers();
			foreach (KeyValuePair<int, Item> cooler in coolers)
			{
				Item value = cooler.Value;
				CoolerData coolerData = Find(cooler.Key);
				if (coolerData == null)
				{
					Player syncedHolder = value.SyncedHolder;
					coolerData = new CoolerData
					{
						serial = cooler.Key,
						name = DefaultCoolerName(cooler.Key),
						owner = (((Object)(object)syncedHolder == (Object)null) ? 0 : syncedHolder.SteamID),
						ownerName = (((Object)(object)syncedHolder == (Object)null) ? null : syncedHolder.SteamName)
					};
					Current.Add(coolerData);
					save.nextSerial = Math.Max(save.nextSerial, cooler.Key + 1);
				}
				Normalize(coolerData);
				coolerData.available = true;
				if ((Object)(object)value.SyncedHolder != (Object)null)
				{
					coolerData.deployed = false;
				}
				else if (coolerData.deployed)
				{
					value.RigidbodySync.SetKinematic(true);
					if (Vector3.Distance(((Component)value).transform.position, coolerData.position) > 0.05f)
					{
						value.RigidbodySync.TeleportToPosRot(coolerData.position, coolerData.Rotation, (float[])null, (Quaternion[])null);
					}
				}
			}
			foreach (CoolerData item in Current)
			{
				item.available = coolers.ContainsKey(item.serial);
			}
		}

		private int OpenSlot(Player player)
		{
			int num = (int)AccessTools.Method(typeof(PlayerInventory), "GetTotalSlots", (Type[])null, (Type[])null).Invoke(player.Inventory, null);
			Item val = default(Item);
			for (byte b = 0; b < num; b++)
			{
				if (!player.Inventory._items.TryGetValue(b, ref val) || (Object)(object)val == (Object)null)
				{
					return b;
				}
			}
			return -1;
		}

		private Item SpawnSaved(SavedItem state, Vector3 position, StoredFishInfo info, Player holder = null, int slot = -1)
		{
			//IL_004f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			ProtectSavedValue(state, info?.value ?? 0);
			Item val = ((state == null || !state.Exists) ? null : GameInfo.GetSpawnable(state.ItemID));
			if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent<Fish>() == (Object)null)
			{
				throw new Exception("Stored fish prefab is unavailable.");
			}
			Item val2 = Object.Instantiate<Item>(val, position, Quaternion.identity, Server.Instance.DynamicObjectsHolder);
			val2.LoadFromSave(state);
			if ((Object)(object)val2.Creature != (Object)null)
			{
				val2.Creature.ServerKillOnSpawn();
				if (state.IsDripCreature)
				{
					val2.Creature.SetDrip();
				}
			}
			InstanceFinder.ServerManager.Spawn(((Component)val2).gameObject, (NetworkConnection)null, default(Scene));
			val2.ServerSetSkin(state.SkinIndex);
			CoolerPriceGuarantee coolerPriceGuarantee = ((Component)val2).gameObject.AddComponent<CoolerPriceGuarantee>();
			coolerPriceGuarantee.guaranteedValue = ((info == null) ? Mathf.Max(0, val2.TotalWorth) : Mathf.Max(0, info.value));
			coolerPriceGuarantee.cookMultiplier = ((info == null) ? Mathf.Max(0.0001f, CookMultiplier(state)) : Mathf.Max(0.0001f, info.cookMultiplier));
			if ((Object)(object)holder != (Object)null && slot >= 0)
			{
				val2.SetSyncedHolder(holder, true);
				holder.Inventory.AddItem((byte)slot, val2);
				if (!holder.Inventory.HasItemInInventory(val2))
				{
					InstanceFinder.ServerManager.Despawn(((Component)val2).gameObject, (DespawnType?)null);
					throw new Exception("Inventory did not accept the fish.");
				}
			}
			else
			{
				val2.SetSyncedHolder((Player)null, true);
				val2.ReconcileLocalHolderWithSyncedHolder();
				val2.RigidbodySync.SetKinematic(false);
				val2.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner);
			}
			return val2;
		}

		private void ApplyColorNow(CoolerData data)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (data == null)
			{
				return;
			}
			CoolerVisual[] array = Object.FindObjectsByType<CoolerVisual>((FindObjectsInactive)1);
			foreach (CoolerVisual coolerVisual in array)
			{
				if (!((Object)(object)coolerVisual == (Object)null))
				{
					Item component = ((Component)coolerVisual).GetComponent<Item>();
					if ((Object)(object)component != (Object)null && CoolerItem.Serial(component) == data.serial)
					{
						coolerVisual.ApplyColor(data.bodyColor);
					}
				}
			}
		}

		private Item SpawnCooler(Player player, int slot, int serial)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			Item val = Object.Instantiate<Item>(CoolerItem.Prefab, ((Component)player).transform.position + Vector3.up, Quaternion.identity, Server.Instance.DynamicObjectsHolder);
			val.LoadFromSave(new SavedItem
			{
				Exists = true,
				ItemID = 249,
				BettingMultiplier = serial,
				Weight = 1f,
				KillScoreMultiplier = 1f
			});
			InstanceFinder.ServerManager.Spawn(((Component)val).gameObject, (NetworkConnection)null, default(Scene));
			val.SetSyncedHolder(player, true);
			player.Inventory.AddItem((byte)slot, val);
			if (!player.Inventory.HasItemInInventory(val))
			{
				InstanceFinder.ServerManager.Despawn(((Component)val).gameObject, (DespawnType?)null);
				throw new Exception("Inventory did not accept the cooler.");
			}
			return val;
		}

		private static SavedItem Capture(Item item)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0018: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			return new SavedItem
			{
				Exists = true,
				ItemID = item.ID,
				Cookness = item.Cookness,
				BettingMultiplier = item.BettingMultiplier,
				Weight = (Object.op_Implicit((Object)(object)item.Creature) ? ((Item)item.Creature).RandomizedWeight : 1f),
				KillScoreMultiplier = item.KillScoreMultiplier,
				IsDripCreature = (Object.op_Implicit((Object)(object)item.Creature) && item.Creature.IsDrip),
				SkinIndex = item.CurSkin
			};
		}

		private static void ProtectSavedValue(SavedItem state, int target)
		{
			if (state == null || target <= 0 || FishValue(state) >= target)
			{
				return;
			}
			float num = Mathf.Max(0f, state.BettingMultiplier);
			float num2 = Mathf.Max(0.0001f, num);
			int num3 = 0;
			state.BettingMultiplier = num2;
			while (FishValue(state) < target && num3++ < 32)
			{
				num = num2;
				num2 = (state.BettingMultiplier = num2 * 2f);
			}
			for (int i = 0; i < 32; i++)
			{
				float num4 = (state.BettingMultiplier = (num + num2) * 0.5f);
				if (FishValue(state) >= target)
				{
					num2 = num4;
				}
				else
				{
					num = num4;
				}
			}
			state.BettingMultiplier = num2;
		}

		private static int CapturedSaleValue(Item fish, Player player, out float capturedCook)
		{
			capturedCook = Mathf.Max(0.0001f, GameInfo.CooknessWorthCurve.Evaluate(fish.Cookness));
			CoolerPriceGuarantee component = ((Component)fish).GetComponent<CoolerPriceGuarantee>();
			if ((Object)(object)component == (Object)null)
			{
				return CompatibleSaleValue(fish, player);
			}
			float multiplier = capturedCook / Mathf.Max(0.0001f, component.cookMultiplier);
			return Mathf.Max(fish.TotalWorth, Rules.ScaleProtectedValue(component.guaranteedValue, multiplier));
		}

		private static int CompatibleSaleValue(Item fish, Player player)
		{
			int num = Mathf.Max(0, (!((Object)(object)fish == (Object)null)) ? fish.TotalWorth : 0);
			if (num == 0 || (Object)(object)player == (Object)null)
			{
				return num;
			}
			try
			{
				Type type = AccessTools.TypeByName("GiantFishMod.RodUpgradeSystem");
				MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "GetSaleBonus", new Type[1] { typeof(Player) }, (Type[])null));
				if (methodInfo != null)
				{
					object obj = methodInfo.Invoke(null, new object[1] { player });
					if (obj != null)
					{
						num = Rules.ApplySaleBonus(num, Convert.ToInt32(obj));
					}
				}
			}
			catch (Exception ex)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Could not read Better How to Fish sale bonus: " + ex.Message));
				}
			}
			return num;
		}

		private static void RemoveHeld(Player player, Item item)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			player.Inventory.RemoveItem(item);
			if ((Object)(object)player.Holding.HeldItem == (Object)(object)item)
			{
				player.Hands.DropItem(false, item);
				player.Holding.DropItem(false, item);
				player.Holding.SetHeldItem((Item)null);
			}
			if ((Object)(object)player.Holding.UninitializedHeldItem == (Object)(object)item)
			{
				player.Holding.SetUninitializedHeldItem((Item)null);
			}
			if ((Object)(object)item.Holder != (Object)null)
			{
				item.Drop(false, default(Vector3), default(Vector3));
			}
			item.SpawnFromInventory();
			item.SetSyncedHolder((Player)null, true);
			item.ReconcileLocalHolderWithSyncedHolder();
			InstanceFinder.ServerManager.Despawn(((Component)item).gameObject, (DespawnType?)null);
		}

		private bool Ground(Player player, Command cmd, Item cooler, out RaycastHit hit)
		{
			//IL_0002: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			hit = default(RaycastHit);
			if (!Rules.Finite(cmd.position.x) || !Rules.Finite(cmd.position.y) || !Rules.Finite(cmd.position.z) || !Rules.SurfaceAllowed(cmd.normal.y) || Vector3.Distance(cmd.position, player.CamObject.position) > 8.35f)
			{
				return false;
			}
			Vector3 normalized = ((Vector3)(ref cmd.normal)).normalized;
			foreach (RaycastHit item in from h in Physics.RaycastAll(cmd.position + normalized * 0.35f, -normalized, 0.8f, -1, (QueryTriggerInteraction)1)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if (((Component)((RaycastHit)(ref current)).collider).gameObject.layer != LayerMask.NameToLayer("Water") && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Player>() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Item>() != (Object)null) && Rules.SurfaceAllowed(((RaycastHit)(ref current)).normal.y) && !(Vector3.Dot(((RaycastHit)(ref current)).normal, normalized) < 0.5f))
				{
					hit = current;
					return true;
				}
			}
			return false;
		}

		private float Distance(Player player, Item item)
		{
			//IL_0006: 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_002f: 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)
			return Mathf.Min(Vector3.Distance(((Component)player).transform.position, ((Component)item).transform.position), ((Object)(object)player.CamObject == (Object)null) ? float.MaxValue : Vector3.Distance(player.CamObject.position, ((Component)item).transform.position));
		}

		private void Execute(Player player, Command cmd, NetworkConnection connection)
		{
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_078a: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0799: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b38: Unknown result type (might be due to invalid IL or missing references)
			if (cmd.action == "hello")
			{
				Broadcast();
				return;
			}
			if (!persistenceReady || world == null || (Object)(object)CoolerItem.Prefab == (Object)null || player.Dying.IsDead)
			{
				Respond(cmd, connection, "Cooler Mod is not ready on the host.");
				return;
			}
			ScanCoolers();
			try
			{
				bool saleSound = false;
				if (cmd.action == "buy")
				{
					if ((Object)(object)FocusedMoneyVendor(player, 5f) == (Object)null)
					{
						Respond(cmd, connection, "Move close to and look at a fish-selling vendor to buy a cooler.");
						return;
					}
					int num = OpenSlot(player);
					if (num < 0)
					{
						Respond(cmd, connection, "Free an inventory slot before buying a cooler.");
						return;
					}
					if (!Wallet.Charge(player, 1000))
					{
						Respond(cmd, connection, "You need $" + 1000.ToString("N0") + " to buy a cooler.");
						return;
					}
					int num2 = save.nextSerial++;
					try
					{
						SpawnCooler(player, num, num2);
					}
					catch
					{
						Wallet.Credit(player, 1000);
						throw;
					}
					Current.Add(new CoolerData
					{
						serial = num2,
						name = DefaultCoolerName(num2),
						owner = player.SteamID,
						ownerName = player.SteamName
					});
					Persist();
					Broadcast();
					Respond(cmd, connection, "Reusable cooler purchased and added to your inventory.", num2);
					return;
				}
				CoolerData coolerData = Find(cmd.serial);
				Item val = FindCooler(cmd.serial);
				if (coolerData == null || (Object)(object)val == (Object)null)
				{
					Respond(cmd, connection, "That cooler is unavailable.");
					return;
				}
				bool flag = (Object)(object)val.SyncedHolder == (Object)(object)player;
				float num3 = Distance(player, val);
				if (!flag && num3 > 5.35f)
				{
					Respond(cmd, connection, "Move within " + 5f.ToString("0") + " metres of the cooler.");
					return;
				}
				if (cmd.action == "deploy")
				{
					if (!flag || coolerData.deployed)
					{
						Respond(cmd, connection, "Hold that cooler before deploying it.");
						return;
					}
					if (!Ground(player, cmd, val, out var hit))
					{
						Respond(cmd, connection, "Look at an upward-facing surface within 8 metres.");
						return;
					}
					val.SpawnFromInventory();
					player.Inventory.RemoveItem(val);
					if ((Object)(object)val.Holder != (Object)null)
					{
						val.Drop(false, default(Vector3), default(Vector3));
					}
					val.SetSyncedHolder((Player)null, true);
					val.ReconcileLocalHolderWithSyncedHolder();
					if ((Object)(object)player.Holding.HeldItem == (Object)(object)val)
					{
						player.Hands.DropItem(false, val);
						player.Holding.DropItem(false, val);
					}
					if ((Object)(object)player.Holding.UninitializedHeldItem == (Object)(object)val)
					{
						player.Holding.SetUninitializedHeldItem((Item)null);
					}
					coolerData.position = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.015f;
					coolerData.surfaceNormal = ((RaycastHit)(ref hit)).normal;
					Quaternion curPlayerRot = player.CurPlayerRot;
					coolerData.yaw = ((Quaternion)(ref curPlayerRot)).eulerAngles.y;
					coolerData.deployed = true;
					val.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner);
					val.RigidbodySync.TeleportToPosRot(coolerData.position, coolerData.Rotation, (float[])null, (Quaternion[])null);
					val.RigidbodySync.SetKinematic(true);
					Status = "Cooler deployed.";
				}
				else if (cmd.action == "pickup")
				{
					if (flag)
					{
						Respond(cmd, connection, "The cooler is already in your inventory.");
						return;
					}
					int num4 = OpenSlot(player);
					bool emptyHands = (Object)(object)player.Holding.HeldItem == (Object)null && (Object)(object)player.Holding.UninitializedHeldItem == (Object)null && (Object)(object)player.Inventory.SyncedCurItem == (Object)null;
					if (!Rules.CanPickUp(num4 >= 0, emptyHands))
					{
						Respond(cmd, connection, "Free an inventory slot or empty your hands first.");
						return;
					}
					coolerData.deployed = false;
					val.RigidbodySync.SetKinematic(false);
					int value = player.Inventory._syncedCurSlot.Value;
					val.SetSyncedHolder(player, true);
					if (num4 >= 0)
					{
						player.Inventory.AddItem((byte)num4, val);
					}
					val.ReconcileLocalHolderWithSyncedHolder();
					if (num4 >= 0)
					{
						player.Inventory.ServerSetSyncedCurSlot(value);
					}
					Status = "Cooler picked up with " + coolerData.fish.Count + " fish inside.";
				}
				else if (cmd.action == "insert")
				{
					if (!coolerData.deployed)
					{
						Respond(cmd, connection, "Deploy the cooler before storing fish.");
						return;
					}
					if (coolerData.fish.Count >= 20)
					{
						Respond(cmd, connection, "The cooler is full (20 / 20).");
						return;
					}
					Item heldItem = player.Holding.HeldItem;
					if ((Object)(object)heldItem == (Object)null || (Object)(object)heldItem.Fish == (Object)null)
					{
						Respond(cmd, connection, "Hold a fish before using Store fish.");
						return;
					}
					string name = heldItem.GetName();
					float capturedCook;
					int num5 = CapturedSaleValue(heldItem, player, out capturedCook);
					SavedItem val2 = Capture(heldItem);
					ProtectSavedValue(val2, num5);
					coolerData.fish.Add(val2);
					coolerData.fishInfo.Add(new StoredFishInfo
					{
						name = name,
						value = num5,
						cookMultiplier = capturedCook
					});
					RemoveHeld(player, heldItem);
					FishPreviews.Clear();
					Status = name + " stored in the cooler (" + coolerData.fish.Count + " / 20) at $" + num5.ToString("N0") + ".";
				}
				else if (cmd.action == "take")
				{
					if (cmd.index < 0 || cmd.index >= coolerData.fish.Count)
					{
						Respond(cmd, connection, "That cooler slot is empty.");
						return;
					}
					int num6 = OpenSlot(player);
					if (num6 < 0)
					{
						Respond(cmd, connection, "Free an inventory slot first.");
						return;
					}
					SavedItem state = coolerData.fish[cmd.index];
					StoredFishInfo info = coolerData.fishInfo[cmd.index];
					string text = StoredName(coolerData, cmd.index);
					SpawnSaved(state, ((Component)player).transform.position + Vector3.up, info, player, num6);
					RemoveStored(coolerData, cmd.index);
					Status = text + " moved to your inventory.";
				}
				else if (cmd.action == "drop")
				{
					if (cmd.index < 0 || cmd.index >= coolerData.fish.Count)
					{
						Respond(cmd, connection, "That cooler slot is empty.");
						return;
					}
					SavedItem state2 = coolerData.fish[cmd.index];
					StoredFishInfo info2 = coolerData.fishInfo[cmd.index];
					string text2 = StoredName(coolerData, cmd.index);
					Vector3 position = ((Component)val).transform.position + ((Component)val).transform.forward * 1.25f + Vector3.up * 0.5f;
					SpawnSaved(state2, position, info2);
					RemoveStored(coolerData, cmd.index);
					Status = text2 + " dropped beside the cooler.";
				}
				else if (cmd.action == "sellall")
				{
					if (!flag || (Object)(object)player.Holding.HeldItem != (Object)(object)val)
					{
						Respond(cmd, connection, "Hold the cooler while interacting with the fish vendor.");
						return;
					}
					if (coolerData.fish.Count == 0)
					{
						Respond(cmd, connection, "The cooler is empty.");
						return;
					}
					if (!FocusedSaleVendor(player, 5f))
					{
						Respond(cmd, connection, "Move close to and look at a vendor that buys items.");
						return;
					}
					bool flag2 = cmd.index == 1;
					long num7 = 0L;
					int num8 = 0;
					int num9 = 0;
					for (int i = 0; i < coolerData.fish.Count; i++)
					{
						if (coolerData.fish[i] != null && coolerData.fish[i].IsDripCreature && !flag2)
						{
							num9++;
							continue;
						}
						num7 += StoredValue(coolerData, i);
						num8++;
					}
					int num10 = (int)Math.Min(2147483647L, num7);
					if (num8 == 0 || num10 <= 0)
					{
						Respond(cmd, connection, (num9 > 0) ? "Only protected drip creatures remain. Enable Auto bulk sell drip creatures to sell them." : "The stored fish have no sale value.");
						return;
					}
					Wallet.Credit(player, num10);
					for (int num11 = coolerData.fish.Count - 1; num11 >= 0; num11--)
					{
						if (coolerData.fish[num11] == null || !coolerData.fish[num11].IsDripCreature || flag2)
						{
							coolerData.fish.RemoveAt(num11);
							if (coolerData.fishInfo != null && num11 < coolerData.fishInfo.Count)
							{
								coolerData.fishInfo.RemoveAt(num11);
							}
						}
					}
					FishPreviews.Clear();
					saleSound = true;
					Status = "Sold " + num8 + " fish from the cooler for $" + num10.ToString("N0") + "." + ((num9 > 0) ? (" Kept " + num9 + " drip creature" + ((num9 == 1) ? "." : "s.")) : " The empty cooler is still in your hands.");
				}
				else if (cmd.action == "rename")
				{
					if (coolerData.owner != 0L && coolerData.owner != player.SteamID)
					{
						Respond(cmd, connection, "Only the cooler owner can rename it.");
						return;
					}
					coolerData.name = CleanName(cmd.text, coolerData.serial);
					Status = "Cooler renamed to " + coolerData.name + ".";
				}
				else
				{
					if (!(cmd.action == "color"))
					{
						return;
					}
					if (coolerData.owner != 0L && coolerData.owner != player.SteamID)
					{
						Respond(cmd, connection, "Only the cooler owner can change its color.");
						return;
					}
					if (!Rules.Finite(cmd.position.x) || !Rules.Finite(cmd.position.y) || !Rules.Finite(cmd.position.z))
					{
						Respond(cmd, connection, "That cooler color is invalid.");
						return;
					}
					coolerData.bodyColor = new Vector3(Rules.ColorChannel(cmd.position.x), Rules.ColorChannel(cmd.position.y), Rules.ColorChannel(cmd.position.z));
					ApplyColorNow(coolerData);
					Status = "Cooler body color saved.";
				}
				Persist();
				Broadcast();
				Respond(cmd, connection, Status, coolerData.serial, saleSound);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
				Respond(cmd, connection, "Cooler Mod could not complete that action. Check the BepInEx log.");
			}
		}

		public static bool IsMoneyVendor(NPC npc)
		{
			if ((Object)(object)npc == (Object)null)
			{
				return false;
			}
			FieldInfo fieldInfo = AccessTools.Field(typeof(NPC), "_quests");
			return ((fieldInfo == null) ? null : (fieldInfo.GetValue(npc) as IEnumerable<NPCQuest>))?.Any((NPCQuest q) => (Object)(object)q != (Object)null && (int)q.Type == 1) ?? false;
		}

		public void SetHoveredInteractable(Component value, bool active)
		{
			if (active)
			{
				hoveredInteractable = value;
			}
			else if ((Object)(object)hoveredInteractable == (Object)(object)value)
			{
				hoveredInteractable = null;
			}
		}

		private static NPC VendorFrom(Component component)
		{
			if ((Object)(object)component == (Object)null)
			{
				return null;
			}
			NPC componentInParent = component.GetComponentInParent<NPC>();
			if (!((Object)(object)componentInParent != (Object)null))
			{
				return component.GetComponentInChildren<NPC>(true);
			}
			return componentInParent;
		}

		public NPC FocusedMoneyVendor(Player player, float range)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00b9: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || (Object)(object)player.CamObject == (Object)null)
			{
				return null;
			}
			if ((Object)(object)player == (Object)(object)Player.LocalPlayer && (Object)(object)hoveredInteractable != (Object)null)
			{
				NPC val = VendorFrom(hoveredInteractable);
				if (IsMoneyVendor(val) && Vector3.Distance(((Component)player).transform.position, ((Component)val).transform.position) <= range + 0.35f)
				{
					return val;
				}
			}
			foreach (RaycastHit item in from h in Physics.RaycastAll(player.CamObject.position, player.CamObject.forward, range, -1, (QueryTriggerInteraction)2)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Player>() == (Object)(object)player))
				{
					NPC componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<NPC>();
					if (IsMoneyVendor(componentInParent))
					{
						return componentInParent;
					}
					if (!((RaycastHit)(ref current)).collider.isTrigger)
					{
						break;
					}
				}
			}
			NPC result = null;
			float num = 0.72f;
			RaycastHit val3 = default(RaycastHit);
			foreach (NPC item2 in Object.FindObjectsByType<NPC>().Where(IsMoneyVendor))
			{
				Vector3 val2 = (((Object)(object)item2.MouthPosForItems != (Object)null) ? item2.MouthPosForItems.position : (((Component)item2).transform.position + Vector3.up)) - player.CamObject.position;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (!(magnitude <= 0.01f))
				{
					float num2 = Vector3.Dot(player.CamObject.forward, val2 / magnitude);
					if (Rules.CanUseVendor(magnitude, num2) && !(num2 < num) && Physics.Raycast(player.CamObject.position, val2 / magnitude, ref val3, magnitude + 0.5f, -1, (QueryTriggerInteraction)2) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<NPC>() != (Object)(object)item2))
					{
						result = item2;
						num = num2;
					}
				}
			}
			return result;
		}

		public bool FocusedSaleVendor(Player player, float range)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)FocusedMoneyVendor(player, range) != (Object)null)
			{
				return true;
			}
			if ((Object)(object)player == (Object)null || (Object)(object)player.CamObject == (Object)null)
			{
				return false;
			}
			foreach (RaycastHit item in from h in Physics.RaycastAll(player.CamObject.position, player.CamObject.forward, range, -1, (QueryTriggerInteraction)2)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Player>() == (Object)(object)player))
				{
					if ((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<SellBox>() != (Object)null || (Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInChildren<SellBox>(true) != (Object)null)
					{
						return true;
					}
					if (!((RaycastHit)(ref current)).collider.isTrigger)
					{
						break;
					}
				}
			}
			float num = 0.72f;
			SellBox[] array = Object.FindObjectsByType<SellBox>();
			foreach (SellBox val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Vector3 val2 = ((Component)val).transform.position;
				Collider componentInChildren = ((Component)val).GetComponentInChildren<Collider>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					val2 = componentInChildren.ClosestPoint(player.CamObject.position);
				}
				Vector3 val3 = val2 - player.CamObject.position;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (!(magnitude <= 0.01f))
				{
					float num3 = Vector3.Dot(player.CamObject.forward, val3 / magnitude);
					if (Rules.CanUseVendor(magnitude, num3) && num3 >= num)
					{
						return true;
					}
				}
			}
			return false;
		}

		public static Item FishPrefab(SavedItem fish)
		{
			if (fish == null || !fish.Exists)
			{
				return null;
			}
			Item spawnable = GameInfo.GetSpawnable(fish.ItemID);
			if (!((Object)(object)spawnable != (Object)null) || !((Object)(object)((Component)spawnable).GetComponent<Fish>() != (Object)null))
			{
				return null;
			}
			return spawnable;
		}

		public static string FishName(SavedItem fish)
		{
			Item val = FishPrefab(fish);
			if (!((Object)(object)val == (Object)null))
			{
				return val.GetName();
			}
			return "Unknown fish";
		}

		public static float CookMultiplier(SavedItem fish)
		{
			if (fish != null)
			{
				return GameInfo.CooknessWorthCurve.Evaluate(fish.Cookness);
			}
			return 0f;
		}

		public static float ScoreMultiplier(SavedItem fish)
		{
			return fish?.KillScoreMultiplier ?? 0f;
		}

		public static float SizeMultiplier(SavedItem fish)
		{
			return Rules.SizeMultiplier(fish?.Weight ?? 1f);
		}

		public static int FishValue(SavedItem fish)
		{
			Item val = FishPrefab(fish);
			if ((Object)(object)val == (Object)null)
			{
				return 0;
			}
			float num = Mathf.Max(0f, fish.Weight);
			float num2 = Mathf.Max(0f, fish.BettingMultiplier);
			float num3 = Mathf.Max(0f, fish.KillScoreMultiplier);
			int num4 = (int)((float)val.DefaultWorth * num * CookMultiplier(fish) * num2);
			return Mathf.Max(0, (int)((float)num4 * num3));
		}

		public int WholeCoolerValue(Item item)
		{
			CoolerData coolerData = (((Object)(object)item == (Object)null) ? null : Find(CoolerItem.Serial(item)));
			long num = 500L;
			if (coolerData != null && coolerData.fish != null)
			{
				for (int i = 0; i < coolerData.fish.Count; i++)
				{
					num += StoredValue(coolerData, i);
				}
			}
			return (int)Math.Min(2147483647L, num);
		}

		public void CompleteWholeCoolerSale(Item item)
		{
			if (!InstanceFinder.IsServerStarted || (Object)(object)item == (Object)null)
			{
				return;
			}
			int num = CoolerItem.Serial(item);
			CoolerData coolerData = Find(num);
			if (coolerData != null)
			{
				int num2 = ((coolerData.fish != null) ? coolerData.fish.Count : 0);
				int num3 = WholeCoolerValue(item);
				Current.Remove(coolerData);
				coolers.Remove(num);
				if (Selected == num)
				{
					Selected = 0;
					Toggle(show: false);
				}
				Status = "Sold cooler and " + num2 + " stored fish for $" + num3.ToString("N0") + ".";
				Persist();
				Broadcast();
			}
		}

		private void OnDestroy()
		{
			Persist();
			Toggle(show: false);
			VendorDisplays.Clear();
			FishPreviews.Clear();
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Instance = null;
		}

		public static bool IsDeployed(Item item)
		{
			if ((Object)(object)Instance != (Object)null && CoolerItem.Is(item) && (Object)(object)item.SyncedHolder == (Object)null)
			{
				return Instance.Find(CoolerItem.Serial(item))?.deployed ?? false;
			}
			return false;
		}

		private Item RayCooler(float range)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.CamObject == (Object)null)
			{
				return null;
			}
			foreach (RaycastHit item in from h in Physics.RaycastAll(localPlayer.CamObject.position, localPlayer.CamObject.forward, range, -1, (QueryTriggerInteraction)2)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if ((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Player>() == (Object)(object)localPlayer)
				{
					continue;
				}
				Item componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Item>();
				if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.SyncedHolder == (Object)(object)localPlayer)
				{
					continue;
				}
				if (CoolerItem.Is(componentInParent) && (Object)(object)componentInParent.SyncedHolder == (Object)null)
				{
					CoolerData coolerData = Find(CoolerItem.Serial(componentInParent));
					if (coolerData != null && coolerData.deployed)
					{
						return componentInParent;
					}
				}
				if (!((RaycastHit)(ref current)).collider.isTrigger)
				{
					return null;
				}
			}
			return null;
		}

		private float DistanceToCooler(Player player, Item cooler)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || (Object)(object)cooler == (Object)null)
			{
				return float.PositiveInfinity;
			}
			float num = Vector3.Distance(((Component)player).transform.position, ((Component)cooler).transform.position);
			Collider[] componentsInChildren = ((Component)cooler).GetComponentsInChildren<Collider>(true);
			foreach (Collider val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && val.enabled)
				{
					num = Mathf.Min(num, Vector3.Distance(((Component)player).transform.position, val.ClosestPoint(((Component)player).transform.position)));
				}
			}
			return num;
		}

		private Item FocusedNearbyCooler(Player player)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || (Object)(object)player.CamObject == (Object)null)
			{
				return null;
			}
			Item result = null;
			float num = 0.7f;
			float num2 = float.PositiveInfinity;
			CoolerVisual[] array = Object.FindObjectsByType<CoolerVisual>();
			foreach (CoolerVisual coolerVisual in array)
			{
				if ((Object)(object)coolerVisual == (Object)null)
				{
					continue;
				}
				Item component = ((Component)coolerVisual).GetComponent<Item>();
				if ((Object)(object)component == (Object)null || (Object)(object)component.SyncedHolder != (Object)null || !IsDeployed(component))
				{
					continue;
				}
				float num3 = DistanceToCooler(player, component);
				if (num3 > 1f)
				{
					continue;
				}
				Vector3 val = ((Component)component).transform.position + ((Component)component).transform.up * 0.48f;
				Transform val2 = ((Component)component).transform.Find("CoolerModel/Body");
				if ((Object)(object)val2 != (Object)null)
				{
					Renderer component2 = ((Component)val2).GetComponent<Renderer>();
					if ((Object)(object)component2 != (Object)null)
					{
						Bounds bounds = component2.bounds;
						val = ((Bounds)(ref bounds)).center;
					}
				}
				Vector3 val3 = val - player.CamObject.position;
				if (!(((Vector3)(ref val3)).sqrMagnitude < 0.001f))
				{
					float num4 = Vector3.Dot(player.CamObject.forward, ((Vector3)(ref val3)).normalized);
					if (!(num4 < num) && (!(Mathf.Abs(num4 - num) < 0.001f) || !(num3 >= num2)))
					{
						result = component;
						num = num4;
						num2 = num3;
					}
				}
			}
			return result;
		}

		private Item FocusedInfoCooler()
		{
			Player localPlayer = Player.LocalPlayer;
			if (Open || (Object)(object)localPlayer == (Object)null || localPlayer.Dying.IsDead)
			{
				return null;
			}
			Item val = activeTarget ?? RayCooler(5f);
			if (!((Object)(object)val != (Object)null) || !((Object)(object)val.SyncedHolder == (Object)null) || !IsDeployed(val))
			{
				return null;
			}
			return val;
		}

		private NPC RayMoneyVendor(float range)
		{
			return FocusedMoneyVendor(Player.LocalPlayer, range);
		}

		private Item InteractionTarget()
		{
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null || Open || localPlayer.BlockInputs || localPlayer.Dying.IsDead)
			{
				return null;
			}
			Item heldItem = localPlayer.Holding.HeldItem;
			if (CoolerItem.Is(heldItem))
			{
				return heldItem;
			}
			return RayCooler(5f);
		}

		public bool CapturesInteract()
		{
			if (!((Object)(object)InteractionTarget() != (Object)null))
			{
				return (Object)(object)activeTarget != (Object)null;
			}
			return true;
		}

		private bool CrosshairSurface(Item held, out RaycastHit surface)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			surface = default(RaycastHit);
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			foreach (RaycastHit item in from h in Physics.RaycastAll(localPlayer.CamObject.position, localPlayer.CamObject.forward, 8f, -1, (QueryTriggerInteraction)1)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Player>() == (Object)(object)localPlayer) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<Item>() == (Object)(object)held))
				{
					if (((Component)((RaycastHit)(ref current)).collider).gameObject.layer == LayerMask.NameToLayer("Water") || !Rules.SurfaceAllowed(((RaycastHit)(ref current)).normal.y))
					{
						return false;
					}
					surface = current;
					return true;
				}
			}
			return false;
		}

		private void DeployHeld(Item held)
		{
			//IL_002c: 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)
			Selected = CoolerItem.Serial(held);
			if (!CrosshairSurface(held, out var surface))
			{
				Status = "Look at an upward-facing surface within 8 metres.";
			}
			else
			{
				Send("deploy", -1, ((RaycastHit)(ref surface)).point, ((RaycastHit)(ref surface)).normal);
			}
		}

		private void TapUse(Item target)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_006d: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)target == (Object)null)
			{
				return;
			}
			int serial = (Selected = CoolerItem.Serial(target));
			if ((Object)(object)target.SyncedHolder == (Object)(object)localPlayer)
			{
				CoolerData coolerData = Find(serial);
				if (FocusedSaleVendor(localPlayer, 5f) && coolerData != null && coolerData.fish.Count > 0)
				{
					Send("sellall", AutoBulkSellDrip ? 1 : 0);
				}
				else
				{
					Status = ((coolerData != null && coolerData.fish.Count == 0) ? "The cooler is empty. Hold E while looking at a surface to deploy it." : "Look at a vendor that buys items and tap E to sell the cooler contents.");
				}
			}
			else if ((Object)(object)localPlayer.Holding.HeldItem != (Object)null && (Object)(object)localPlayer.Holding.HeldItem.Fish != (Object)null)
			{
				Send("insert");
			}
			else
			{
				Toggle(show: true, serial);
			}
		}

		private void UpdateInteraction()
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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)
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return;
			}
			if (((ButtonControl)current.eKey).wasPressedThisFrame)
			{
				activeTarget = InteractionTarget();
				useStarted = Time.unscaledTime;
				holdFired = false;
			}
			if ((Object)(object)activeTarget != (Object)null && ((ButtonControl)current.eKey).isPressed && !holdFired && Time.unscaledTime - useStarted >= 1f)
			{
				holdFired = true;
				if ((Object)(object)activeTarget.SyncedHolder == (Object)(object)Player.LocalPlayer)
				{
					DeployHeld(activeTarget);
				}
				else
				{
					Selected = CoolerItem.Serial(activeTarget);
					Send("pickup");
				}
			}
			if (((ButtonControl)current.eKey).wasReleasedThisFrame)
			{
				if ((Object)(object)activeTarget != (Object)null && !holdFired)
				{
					TapUse(activeTarget);
				}
				activeTarget = null;
				holdFired = false;
			}
			if (!((ButtonControl)current.eKey).isPressed && !((ButtonControl)current.eKey).wasReleasedThisFrame && (Object)(object)activeTarget != (Object)null && Time.unscaledTime - useStarted > 2f)
			{
				activeTarget = null;
				holdFired = false;
			}
		}

		private void DrawInteractionHint()
		{
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			if (Open)
			{
				return;
			}
			Item val = activeTarget ?? InteractionTarget();
			if (!((Object)(object)val == (Object)null))
			{
				Player localPlayer = Player.LocalPlayer;
				CoolerData coolerData = Find(CoolerItem.Serial(val));
				bool num = (Object)(object)val.SyncedHolder == (Object)(object)localPlayer;
				bool flag = num && FocusedSaleVendor(localPlayer, 5f);
				string text = (num ? ((flag && coolerData != null && coolerData.fish.Count > 0) ? ("Tap E: sell all " + coolerData.fish.Count + " fish and keep cooler   |   Hold E: deploy") : "Hold E to deploy cooler") : ((!((Object)(object)localPlayer != (Object)null) || !((Object)(object)localPlayer.Holding.HeldItem != (Object)null) || !((Object)(object)localPlayer.Holding.HeldItem.Fish != (Object)null)) ? "Tap E: open cooler   |   Hold E: pick up cooler" : "Tap E: store held fish   |   Hold E: pick up cooler"));
				if ((Object)(object)activeTarget != (Object)null && (Object)(object)InputSystem.settings != (Object)null && ((ButtonControl)Keyboard.current.eKey).isPressed)
				{
					text = text + "   " + Mathf.Clamp01((Time.unscaledTime - useStarted) / 1f).ToString("P0");
				}
				if (hintStyle == null)
				{
					hintStyle = new GUIStyle(GUI.skin.box)
					{
						fontSize = 15,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)4
					};
				}
				float num2 = (flag ? ((float)Screen.height * 0.67f + 82f) : ((float)Screen.height * 0.73f));
				GUI.Box(new Rect((float)Screen.width / 2f - 300f, num2, 600f, 42f), text, hintStyle);
			}
		}

		private void DrawCoolerInfoTooltip()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			Item val = FocusedInfoCooler();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			CoolerData coolerData = Find(CoolerItem.Serial(val));
			if (coolerData != null)
			{
				int num = ((coolerData.fish != null) ? Mathf.Clamp(coolerData.fish.Count, 0, 20) : 0);
				string text = ((!string.IsNullOrWhiteSpace(coolerData.ownerName)) ? coolerData.ownerName : ((coolerData.owner == 0L) ? "Unclaimed" : coolerData.owner.ToString()));
				string text2 = coolerData.name + "   |   Owner: " + text + "\nFish: " + num + " / " + 20 + "   |   Total value: $" + StoredFishTotal(coolerData).ToString("N0");
				if (infoStyle == null)
				{
					infoStyle = new GUIStyle(GUI.skin.box)
					{
						fontSize = 15,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)4,
						wordWrap = false
					};
					infoStyle.normal.textColor = Color.white;
				}
				float num2 = (float)Screen.height * 0.73f - 62f;
				GUI.Box(new Rect((float)Screen.width / 2f - 300f, num2, 600f, 54f), text2, infoStyle);
			}
		}

		private Texture2D Solid(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0012: 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_0020: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, color);
			val.Apply();
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return val;
		}

		private GUIStyle Button(Texture2D normal, Texture2D hover)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				fontSize = 12,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val.normal.background = normal;
			val.normal.textColor = Color.white;
			val.hover.background = hover;
			val.hover.textColor = Color.white;
			val.active.background = orangeHover;
			return val;
		}

		private void InitStyles()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			//IL_00c4: 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_0103: 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)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_012d: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Expected O, but got Unknown
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			if (windowStyle == null)
			{
				navy = Solid(new Color(0.035f, 0.075f, 0.095f, 0.985f));
				teal = Solid(new Color(0.03f, 0.46f, 0.54f));
				tealHover = Solid(new Color(0.04f, 0.66f, 0.74f));
				orange = Solid(new Color(0.85f, 0.37f, 0.08f));
				orangeHover = Solid(new Color(1f, 0.52f, 0.1f));
				rowBg = Solid(new Color(0.06f, 0.12f, 0.14f, 0.98f));
				rowAlt = Solid(new Color(0.075f, 0.15f, 0.17f, 0.98f));
				GUIStyle val = new GUIStyle(GUI.skin.window);
				val.normal.background = navy;
				val.padding = new RectOffset(0, 0, 0, 0);
				windowStyle = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 25,
					fontStyle = (FontStyle)1
				};
				val2.normal.textColor = new Color(0.45f, 1f, 1f);
				titleStyle = val2;
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1,
					alignment = (Tex