Decompiled source of Gone Fishing v1.0.0

Mods/WoodStudios.GoneFishing.dll

Decompiled 21 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using GoneFishing;
using HarmonyLib;
using HoldTheFort;
using Il2CppFishNet;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.AvatarFramework;
using Il2CppScheduleOne.AvatarFramework.Animation;
using Il2CppScheduleOne.Building;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Doors;
using Il2CppScheduleOne.Economy;
using Il2CppScheduleOne.Equipping;
using Il2CppScheduleOne.Instancing;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.NPCs.Relation;
using Il2CppScheduleOne.Networking;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Property;
using Il2CppScheduleOne.Storage;
using Il2CppScheduleOne.Tiles;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Shop;
using Il2CppScheduleOne.Weather;
using Il2CppSteamworks;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using S1API.Entities;
using S1API.GameTime;
using S1API.Items;
using S1API.Items.Storable;
using S1API.Lifecycle;
using S1API.Money;
using S1API.Rendering;
using S1API.Shops;
using Schedule2;
using Schedule2.Game;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using WS_GF.FybCommon;
using WS_GF.WoodKit;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(FishCore), "Gone Fishing", "1.0.0", "Wood Studios", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonOptionalDependencies(new string[] { "HoldTheFort" })]
[assembly: AssemblyTitle("WoodStudios.GoneFishing")]
[assembly: AssemblyProduct("WoodStudios.GoneFishing")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 Schedule2
{
	internal static class Res
	{
		private static readonly Assembly Asm = typeof(Res).Assembly;

		public static Stream Open(string name)
		{
			Stream manifestResourceStream = Asm.GetManifestResourceStream(name);
			if (manifestResourceStream == null)
			{
				return null;
			}
			int num = manifestResourceStream.ReadByte();
			int num2 = manifestResourceStream.ReadByte();
			manifestResourceStream.Position = 0L;
			if (num != 31 || num2 != 139)
			{
				return manifestResourceStream;
			}
			MemoryStream memoryStream = new MemoryStream();
			using (GZipStream gZipStream = new GZipStream(manifestResourceStream, CompressionMode.Decompress))
			{
				gZipStream.CopyTo(memoryStream);
			}
			memoryStream.Position = 0L;
			return memoryStream;
		}
	}
}
namespace Schedule2.Game
{
	internal static class Sfx
	{
		public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream)
		{
			return AudioClip.Create(name, lengthSamples, channels, frequency, stream);
		}

		public static bool SetData(AudioClip clip, Il2CppStructArray<float> data, int offset)
		{
			if ((Object)(object)clip != (Object)null)
			{
				return clip.SetData(data, offset);
			}
			return false;
		}
	}
}
namespace GoneFishing
{
	public static class Dev
	{
		public static string State()
		{
			return Rod.State() + " | stand " + Stand.Where;
		}

		public static string Bite()
		{
			return Rod.Bite();
		}

		public static string Reeled()
		{
			return Rod.Reeled();
		}

		public static string Hook()
		{
			return Rod.Hook();
		}
	}
	internal sealed class Catch
	{
		public string Id;

		public string Name;

		public string Model;

		public float Value;

		public float Weight;

		public float Fight;

		public float MinKg;

		public float MaxKg;

		public bool Junk;
	}
	public sealed class FishCore : MelonMod
	{
		internal const string RodId = "gf_rod";

		internal const string BaitId = "gf_bait";

		internal static MelonPreferences_Entry<float> RodPrice;

		internal static MelonPreferences_Entry<float> BaitPrice;

		internal static MelonPreferences_Entry<float> FishPay;

		private static float _warnedAt = -100f;

		internal static readonly List<Catch> Catches = new List<Catch>
		{
			new Catch
			{
				Id = "gf_mackerel",
				Name = "Mackerel",
				Model = "GF_Mackerel.glb",
				Value = 12f,
				Weight = 30f,
				Fight = 0.15f,
				MinKg = 0.3f,
				MaxKg = 1.1f
			},
			new Catch
			{
				Id = "gf_seabass",
				Name = "Sea Bass",
				Model = "GF_SeaBass.glb",
				Value = 25f,
				Weight = 22f,
				Fight = 0.3f,
				MinKg = 0.8f,
				MaxKg = 3.5f
			},
			new Catch
			{
				Id = "gf_snapper",
				Name = "Red Snapper",
				Model = "GF_Snapper.glb",
				Value = 40f,
				Weight = 15f,
				Fight = 0.4f,
				MinKg = 1f,
				MaxKg = 5f
			},
			new Catch
			{
				Id = "gf_salmon",
				Name = "Salmon",
				Model = "GF_Salmon.glb",
				Value = 60f,
				Weight = 12f,
				Fight = 0.55f,
				MinKg = 2f,
				MaxKg = 8f
			},
			new Catch
			{
				Id = "gf_halibut",
				Name = "Halibut",
				Model = "GF_Halibut.glb",
				Value = 90f,
				Weight = 8f,
				Fight = 0.6f,
				MinKg = 4f,
				MaxKg = 20f
			},
			new Catch
			{
				Id = "gf_tuna",
				Name = "Bluefin Tuna",
				Model = "GF_Tuna.glb",
				Value = 200f,
				Weight = 4f,
				Fight = 0.85f,
				MinKg = 20f,
				MaxKg = 120f
			},
			new Catch
			{
				Id = "gf_goldencarp",
				Name = "Golden Carp",
				Model = "GF_GoldenCarp.glb",
				Value = 1000f,
				Weight = 0.6f,
				Fight = 0.95f,
				MinKg = 3f,
				MaxKg = 9f
			},
			new Catch
			{
				Id = "gf_boot",
				Name = "Old Boot",
				Model = "GF_Boot.glb",
				Value = 1f,
				Weight = 6f,
				Fight = 0.05f,
				MinKg = 0.6f,
				MaxKg = 1.2f,
				Junk = true
			},
			new Catch
			{
				Id = "gf_stash",
				Name = "Lost Stash",
				Model = "GF_Stash.glb",
				Value = 0f,
				Weight = 2.4f,
				Fight = 0.3f,
				MinKg = 4f,
				MaxKg = 9f,
				Junk = true
			}
		};

		public override void OnInitializeMelon()
		{
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Host.Init((MelonMod)(object)this, "GoneFishing", "Gone Fishing", "gf_", null, Loaded, Unloaded);
				MelonPreferences_Category obj = MelonPreferences.GetCategory("GoneFishing") ?? MelonPreferences.CreateCategory("GoneFishing", "Gone Fishing");
				RodPrice = obj.CreateEntry<float>("RodPrice", 150f, "Fishing Rod price", "What Randy charges for a rod.", false, false, (ValueValidator)null, (string)null);
				BaitPrice = obj.CreateEntry<float>("BaitPrice", 20f, "Bait price", "What Randy charges for a tub of bait (10 casts).", false, false, (ValueValidator)null, (string)null);
				FishPay = obj.CreateEntry<float>("FishPay", 1f, "Fish prices", "Multiplies what Randy pays for your catch (1 = normal).", false, false, (ValueValidator)null, (string)null);
				FortifyApi.SetNotifyIcon("gf_rod");
				Catalog.Add(new ItemSpec
				{
					Id = "gf_rod",
					Name = "Fishing Rod",
					Kind = PlaceKind.Ground,
					Price = 150f,
					RotateStep = 0f,
					StackLimit = 1,
					NotSold = true,
					IconColor = new Color(0.1f, 0.2f, 0.45f),
					BuildModel = () => FishModels.Load("gf_Rod", "GF_Rod.glb", (Vector3?)new Vector3(0.06f, 0.06f, 2f)),
					IconModel = delegate
					{
						//IL_0005: Unknown result type (might be due to invalid IL or missing references)
						//IL_000b: Expected O, but got Unknown
						//IL_0024: 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_0078: Unknown result type (might be due to invalid IL or missing references)
						GameObject val = new GameObject("gf_RodIcon");
						GameObject obj2 = FishModels.Load("gf_Rod", "GF_Rod.glb", (Vector3?)new Vector3(0.06f, 0.06f, 2f));
						obj2.transform.SetParent(val.transform, false);
						obj2.transform.localRotation = Quaternion.Euler(0f, 90f, 40f);
						obj2.transform.localScale = new Vector3(7f, 7f, 0.9f);
						return val;
					},
					Description = "A spinning rod from Randy's. Hold it facing open water and click to cast (uses 1 bait). When the bobber dips, click to hook, then hold the mouse to reel - ease off when the line gets tight."
				});
				Catalog.Add(new ItemSpec
				{
					Id = "gf_bait",
					Name = "Bait",
					Kind = PlaceKind.Ground,
					Price = 2f,
					RotateStep = 0f,
					StackLimit = 50,
					NotSold = true,
					IconColor = new Color(0.1f, 0.45f, 0.15f),
					BuildModel = () => FishModels.Load("gf_Bait", "GF_Bait.glb", (Vector3?)new Vector3(0.12f, 0.09f, 0.12f)),
					Description = "Nightcrawlers and cut squid. Each cast uses one."
				});
				foreach (Catch @catch in Catches)
				{
					if (!(@catch.Id == "gf_stash"))
					{
						Catch kk = @catch;
						Catalog.Add(new ItemSpec
						{
							Id = @catch.Id,
							Name = @catch.Name,
							Kind = PlaceKind.Ground,
							Price = @catch.Value,
							RotateStep = 45f,
							StackLimit = 10,
							NotSold = true,
							IconColor = new Color(0.3f, 0.45f, 0.55f),
							BuildModel = () => FishModels.Fish(kk),
							Description = (@catch.Junk ? "Somebody's old boot. Randy will take it off your hands for a dollar." : ("A fresh " + @catch.Name + " from the waters around Hyland Point. Sell it at Randy's stand, or put it on display."))
						});
					}
				}
				Kit.CustomPlace["gf_rod"] = Rod.Held;
				Host.WhereToBuyNote = "Gone Fishing: Randy has a bait & rod stand outside Randy's Bait & Tackle at the docks. Buy a rod and bait, fish off any dock or shore, and sell your catch back to him.";
				Host.Ok = true;
				((MelonBase)this).LoggerInstance.Msg("Gone Fishing loaded. Randy's stand is outside Randy's Bait & Tackle at the docks.");
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Error("Gone Fishing couldn't start: " + ex.Message + ". It needs MelonLoader 0.7 and S1API (Bars fork) 3.2.3 or newer.");
			}
		}

		private static void Loaded()
		{
			Stand.Schedule();
			Rod.Reset();
		}

		private static void Unloaded()
		{
			Rod.Reset();
			Stand.Clear();
		}

		public override void OnUpdate()
		{
			if (!Host.Update())
			{
				return;
			}
			try
			{
				Stand.Update();
				Rod.Update();
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime - _warnedAt > 30f)
				{
					_warnedAt = Time.unscaledTime;
					((MelonBase)this).LoggerInstance.Warning("Gone Fishing: " + ex.Message);
				}
			}
		}

		public override void OnGUI()
		{
			if (!Host.Ok || !FortifyApi.InGame)
			{
				return;
			}
			try
			{
				Rod.Draw();
				Stand.Draw();
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime - _warnedAt > 30f)
				{
					_warnedAt = Time.unscaledTime;
					((MelonBase)this).LoggerInstance.Warning("Gone Fishing (drawing): " + ex.Message);
				}
			}
			if (!Stand.Open)
			{
				Host.DrawHint();
				if (Stand.Hint != null)
				{
					FortifyApi.Hint(Stand.Hint);
				}
			}
		}
	}
	internal static class FishModels
	{
		private static readonly HashSet<int> Fixed = new HashSet<int>();

		public static GameObject Load(string name, string file, Vector3? box = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_00c9: 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_00d9: 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_00f9: 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_0062: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			((Object)GltfLoader.LoadEmbedded(file, val.transform)).name = "Model";
			foreach (Renderer componentsInChild in val.GetComponentsInChildren<Renderer>(true))
			{
				foreach (Material item in (Il2CppArrayBase<Material>)(object)componentsInChild.sharedMaterials)
				{
					if (!((Object)(object)item == (Object)null) && Fixed.Add(((Object)item).GetInstanceID()))
					{
						Color color = item.color;
						Color val2 = (item.color = ((Color)(ref color)).gamma);
						if (item.HasProperty("_BaseColor"))
						{
							item.SetColor("_BaseColor", val2);
						}
					}
				}
			}
			if (box.HasValue)
			{
				Bounds val3 = LocalBounds(val);
				BoxCollider obj = val.AddComponent<BoxCollider>();
				obj.center = ((Bounds)(ref val3)).center;
				obj.size = Vector3.Max(((Bounds)(ref val3)).size, new Vector3(0.05f, 0.05f, 0.05f));
			}
			return val;
		}

		public static GameObject Fish(Catch k)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Load("gf_" + k.Name.Replace(" ", ""), k.Model);
			Transform val = obj.transform.Find("Model");
			Bounds val2 = LocalBounds(obj);
			if ((Object)(object)val != (Object)null)
			{
				val.localPosition += new Vector3(0f, 0f - ((Bounds)(ref val2)).min.y, 0f);
			}
			val2 = LocalBounds(obj);
			BoxCollider obj2 = obj.AddComponent<BoxCollider>();
			obj2.center = ((Bounds)(ref val2)).center;
			obj2.size = Vector3.Max(((Bounds)(ref val2)).size, new Vector3(0.05f, 0.05f, 0.05f));
			return obj;
		}

		public static Bounds LocalBounds(GameObject go)
		{
			//IL_0004: 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_0049: 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_0050: 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_005d: 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)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds result = default(Bounds);
			Matrix4x4 worldToLocalMatrix = go.transform.worldToLocalMatrix;
			Vector3 val2 = default(Vector3);
			foreach (MeshFilter componentsInChild in go.GetComponentsInChildren<MeshFilter>(true))
			{
				if ((Object)(object)componentsInChild.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = componentsInChild.sharedMesh.bounds;
				Matrix4x4 val = worldToLocalMatrix * ((Component)componentsInChild).transform.localToWorldMatrix;
				for (int i = 0; i < 8; i++)
				{
					((Vector3)(ref val2))..ctor(((i & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((i & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((i & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z);
					Vector3 val3 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(val2);
					if (!flag)
					{
						result = new Bounds(val3, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val3);
					}
				}
			}
			return result;
		}

		public static GameObject Plain(GameObject template, string name)
		{
			GameObject val = Object.Instantiate<GameObject>(template);
			((Object)val).name = name;
			val.SetActive(true);
			foreach (Collider componentsInChild in val.GetComponentsInChildren<Collider>(true))
			{
				Object.Destroy((Object)(object)componentsInChild);
			}
			foreach (Renderer componentsInChild2 in val.GetComponentsInChildren<Renderer>(true))
			{
				componentsInChild2.shadowCastingMode = (ShadowCastingMode)0;
			}
			return val;
		}
	}
	internal static class FishSound
	{
		private static AudioClip _whoosh;

		private static AudioClip _splash;

		private static AudioClip _click;

		private static AudioClip _snap;

		public static AudioClip Whoosh => _whoosh ?? (_whoosh = Make("gf_whoosh", 0.45f, (float t, Random r) => (float)(r.NextDouble() * 2.0 - 1.0) * Mathf.Sin(t / 0.45f * (float)Math.PI) * 0.25f * (0.6f + 0.4f * Mathf.Sin(t * 40f))));

		public static AudioClip Splash => _splash ?? (_splash = Make("gf_splash", 0.5f, (float t, Random r) => (float)(r.NextDouble() * 2.0 - 1.0) * Mathf.Exp((0f - t) * 9f) * 0.6f + Mathf.Sin(t * 900f * (1f - t)) * Mathf.Exp((0f - t) * 14f) * 0.2f));

		public static AudioClip Click => _click ?? (_click = Make("gf_click", 0.03f, (float t, Random r) => (float)(r.NextDouble() * 2.0 - 1.0) * Mathf.Exp((0f - t) * 300f) * 0.5f));

		public static AudioClip Snap => _snap ?? (_snap = Make("gf_snap", 0.25f, (float t, Random r) => ((float)(r.NextDouble() * 2.0 - 1.0) * 0.5f + Mathf.Sin(t * 2400f) * 0.4f) * Mathf.Exp((0f - t) * 25f)));

		private static AudioClip Make(string name, float seconds, Func<float, Random, float> f)
		{
			try
			{
				int num = 22050;
				int num2 = Mathf.CeilToInt(seconds * (float)num);
				Random arg = new Random(name.GetHashCode());
				Il2CppStructArray<float> val = new Il2CppStructArray<float>((long)num2);
				for (int i = 0; i < num2; i++)
				{
					((Il2CppArrayBase<float>)(object)val)[i] = Mathf.Clamp(f((float)i / (float)num, arg), -1f, 1f);
				}
				AudioClip obj = Sfx.Create(name, num2, 1, num, stream: false);
				Sfx.SetData(obj, val, 0);
				((Object)obj).hideFlags = (HideFlags)32;
				return obj;
			}
			catch
			{
				return null;
			}
		}

		public static void Play(AudioClip c, Vector3 at, float volume)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null)
			{
				return;
			}
			try
			{
				AudioSource.PlayClipAtPoint(c, at, volume);
			}
			catch
			{
			}
		}
	}
	internal static class Rod
	{
		private enum S
		{
			Idle,
			Casting,
			Waiting,
			Bite,
			Reeling,
			Landed
		}

		private static S _s;

		private static float _t0;

		private static float _biteAt;

		private static float _slackSince;

		private static float _surgeAt;

		private static float _tension;

		private static float _progress;

		private static float _nibbleAt;

		private static Vector3 _target;

		private static Vector3 _from;

		private static Catch _fish;

		private static float _kg;

		private static int _heldFrame = -10;

		private static Camera _cam;

		private static GameObject _view;

		private static GameObject _bobber;

		private static GameObject _line;

		private static GameObject _show;

		private static Transform _tip;

		private static bool _aimOk;

		private static Vector3 _aim;

		private static float _aimAt;

		private static string _aimWhy;

		public static float WaterY = float.NaN;

		public static string WaterWhy = "";

		public static int Casts;

		public static int Landed;

		public static int Lost;

		public static string Best = "";

		private static readonly Random Rng = new Random();

		private static GameObject _stashTpl;

		private static bool _devHook;

		public static void Reset()
		{
			_s = S.Idle;
			WaterY = float.NaN;
			if ((Object)(object)_bobber != (Object)null)
			{
				Object.Destroy((Object)(object)_bobber);
			}
			if ((Object)(object)_line != (Object)null)
			{
				Object.Destroy((Object)(object)_line);
			}
			if ((Object)(object)_show != (Object)null)
			{
				Object.Destroy((Object)(object)_show);
			}
			if ((Object)(object)_view != (Object)null)
			{
				Object.Destroy((Object)(object)_view);
			}
			_bobber = (_line = (_show = (_view = null)));
			_tip = null;
		}

		public static float Water()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			if (!float.IsNaN(WaterY))
			{
				return WaterY;
			}
			float num = float.NaN;
			try
			{
				float num2 = -1000f;
				foreach (WaterCollider item in Resources.FindObjectsOfTypeAll<WaterCollider>())
				{
					if (!((Object)(object)item != (Object)null))
					{
						continue;
					}
					Scene scene = ((Component)item).gameObject.scene;
					if (!((Scene)(ref scene)).IsValid())
					{
						continue;
					}
					foreach (Collider componentsInChild in ((Component)item).GetComponentsInChildren<Collider>(true))
					{
						if ((Object)(object)componentsInChild != (Object)null)
						{
							float num3 = num2;
							Bounds bounds = componentsInChild.bounds;
							num2 = Mathf.Max(num3, ((Bounds)(ref bounds)).max.y + 0.65f);
						}
					}
				}
				if (num2 > -100f)
				{
					num = num2;
					WaterWhy = "water collider";
				}
			}
			catch
			{
			}
			if (float.IsNaN(num))
			{
				try
				{
					foreach (MeshRenderer item2 in Object.FindObjectsOfType<MeshRenderer>())
					{
						if ((Object)(object)item2 == (Object)null || (Object)(object)((Renderer)item2).sharedMaterial == (Object)null)
						{
							continue;
						}
						string text = ((Object)((Renderer)item2).sharedMaterial).name + "/" + ((Object)item2).name;
						if (text.IndexOf("water", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("ocean", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							Bounds bounds2 = ((Renderer)item2).bounds;
							if (!(((Bounds)(ref bounds2)).size.x < 150f) && !(((Bounds)(ref bounds2)).size.z < 150f) && !(((Bounds)(ref bounds2)).size.y > 3f) && (float.IsNaN(num) || ((Bounds)(ref bounds2)).center.y > num))
							{
								num = ((Bounds)(ref bounds2)).center.y;
								WaterWhy = "surface " + ((Object)item2).name + " (" + ((Object)((Renderer)item2).sharedMaterial).name + ")";
							}
						}
					}
				}
				catch
				{
				}
			}
			if (float.IsNaN(num))
			{
				num = -4.6f;
				WaterWhy = "default";
			}
			WaterY = num;
			Instance log = Kit.Log;
			if (log != null)
			{
				log.Msg($"Gone Fishing: water level {WaterY:0.00} ({WaterWhy}).");
			}
			return WaterY;
		}

		private static bool AimWater(Camera cam, out Vector3 p, out string why)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0030: 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_0075: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			p = Vector3.zero;
			why = "Aim at open water to cast";
			float num = Water();
			Vector3 position = ((Component)cam).transform.position;
			Vector3 val = ((Component)cam).transform.forward;
			if (position.y < num + 0.3f)
			{
				why = "You're too low to cast here";
				return false;
			}
			if (val.y > -0.02f)
			{
				Vector3 val2 = val + Vector3.down * 0.25f;
				val = ((Vector3)(ref val2)).normalized;
			}
			float num2 = (num - position.y) / val.y;
			p = position + val * num2;
			Vector3 val3 = p - position;
			val3.y = 0f;
			float num3 = ((Vector3)(ref val3)).magnitude;
			if (num3 > 26f)
			{
				p = position + ((Vector3)(ref val3)).normalized * 26f;
				p.y = num;
				num3 = 26f;
			}
			if (num3 < 2.5f)
			{
				why = "Too close - aim a bit further out";
				return false;
			}
			RaycastHit val4 = default(RaycastHit);
			if (Physics.Raycast(p + Vector3.up * 40f, Vector3.down, ref val4, 40.4f, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val4)).point.y > num - 0.3f)
			{
				why = "That's not open water";
				return false;
			}
			RaycastHit val5 = default(RaycastHit);
			if (Physics.Linecast(position + val * 0.6f, p + Vector3.up * 0.4f, ref val5, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val5)).distance > 0.5f)
			{
				why = "Something's in the way";
				return false;
			}
			return true;
		}

		public static bool Held(ItemSpec s, Camera cam, Player pl, out string hint)
		{
			_heldFrame = Time.frameCount;
			_cam = cam;
			hint = null;
			switch (_s)
			{
			case S.Idle:
			{
				if (Time.unscaledTime >= _aimAt)
				{
					_aimAt = Time.unscaledTime + 0.1f;
					_aimOk = AimWater(cam, out _aim, out _aimWhy);
				}
				uint num = BaitCount();
				hint = ((!_aimOk) ? _aimWhy : ((num == 0) ? "No bait - Randy's stand at the docks sells it" : $"[Click] Cast    ({num} bait)"));
				break;
			}
			case S.Casting:
				hint = null;
				break;
			case S.Waiting:
				hint = "Waiting for a bite...    [Click] Reel in";
				break;
			case S.Bite:
				hint = "BITE! [Click] Hook it!";
				break;
			case S.Reeling:
				hint = null;
				break;
			case S.Landed:
				hint = null;
				break;
			}
			return true;
		}

		private static uint BaitCount()
		{
			try
			{
				PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
				return (instance != null) ? instance.GetAmountOfItem("gf_bait") : 0u;
			}
			catch
			{
				return 0u;
			}
		}

		public static void Update()
		{
			//IL_010c: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: 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_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			if (_heldFrame < Time.frameCount - 1 || !((Object)(object)_cam != (Object)null))
			{
				if (_s != S.Idle && _s != S.Landed)
				{
					End((_s == S.Reeling) ? "You put the rod away and the fish swam off." : null);
				}
				if ((Object)(object)_view != (Object)null && _view.activeSelf)
				{
					_view.SetActive(false);
				}
				if (_s == S.Landed)
				{
					UpdateLanded();
				}
				return;
			}
			ShowView();
			bool flag = false;
			bool hold = false;
			try
			{
				flag = GameInput.GetButtonDown((ButtonCode)0);
				hold = GameInput.GetButton((ButtonCode)0);
			}
			catch
			{
			}
			float time = Time.time;
			switch (_s)
			{
			case S.Idle:
				if (!flag || !_aimOk)
				{
					break;
				}
				if (BaitCount() == 0)
				{
					FortifyApi.Notify("Gone Fishing", "You're out of bait. Randy's stand at the docks sells it.");
					break;
				}
				try
				{
					PlayerSingleton<PlayerInventory>.Instance.RemoveAmountOfItem("gf_bait", 1u);
				}
				catch
				{
				}
				Casts++;
				_target = _aim + new Vector3((float)(Rng.NextDouble() - 0.5) * 0.8f, 0f, (float)(Rng.NextDouble() - 0.5) * 0.8f);
				_from = TipPos();
				_s = S.Casting;
				_t0 = time;
				EnsureBobber();
				FishSound.Play(FishSound.Whoosh, ((Component)_cam).transform.position, 0.5f);
				break;
			case S.Casting:
			{
				float num = Mathf.Clamp01((time - _t0) / 0.75f);
				Vector3 position2 = Vector3.Lerp(_from, _target, num);
				position2.y += Mathf.Sin(num * (float)Math.PI) * (1.5f + Vector3.Distance(_from, _target) * 0.15f);
				_bobber.transform.position = position2;
				if (num >= 1f)
				{
					_s = S.Waiting;
					_t0 = time;
					float num2 = 4f + (float)Rng.NextDouble() * 10f;
					_biteAt = time + num2;
					_nibbleAt = time + num2 * 0.5f;
					FishSound.Play(FishSound.Splash, _target, 0.6f);
				}
				break;
			}
			case S.Waiting:
			{
				Vector3 position = _target + Vector3.up * (0.02f + Mathf.Sin(time * 2.1f) * 0.025f);
				if (_nibbleAt > 0f && time >= _nibbleAt && time < _nibbleAt + 0.25f)
				{
					position.y -= 0.06f;
				}
				_bobber.transform.position = position;
				if (flag)
				{
					End("You reeled in. The bait's gone.");
				}
				else if (time >= _biteAt)
				{
					_fish = Pick();
					_kg = Mathf.Lerp(_fish.MinKg, _fish.MaxKg, Mathf.Pow((float)Rng.NextDouble(), 1.8f));
					_s = S.Bite;
					_t0 = time;
					FishSound.Play(FishSound.Splash, _target, 0.9f);
				}
				break;
			}
			case S.Bite:
				_bobber.transform.position = _target + Vector3.down * (0.12f + Mathf.Abs(Mathf.Sin(time * 14f)) * 0.06f);
				if (flag || _devHook)
				{
					_devHook = false;
					_s = S.Reeling;
					_t0 = time;
					_tension = 0.35f;
					_progress = 0f;
					_slackSince = -1f;
					_surgeAt = time + 0.8f;
				}
				else if (time - _t0 > 1.4f)
				{
					Lost++;
					End("Too slow - it stole the bait.");
				}
				break;
			case S.Reeling:
				Reel(hold, time);
				break;
			case S.Landed:
				UpdateLanded();
				break;
			}
			UpdateLine();
		}

		private static void Reel(bool hold, float now)
		{
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: 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_027e: 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_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: 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_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: 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_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: 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_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Min(Time.deltaTime, 0.1f);
			float num2 = _fish.Fight * Mathf.Lerp(0.8f, 1.15f, Mathf.InverseLerp(_fish.MinKg, _fish.MaxKg, _kg));
			if (hold)
			{
				_tension += num * (0.26f + num2 * 0.36f);
				bool flag = _tension > 0.25f && _tension < 0.82f;
				_progress += num * (flag ? 0.22f : 0.08f) * Mathf.Lerp(1.2f, 0.55f, num2);
				if (Time.frameCount % 9 == 0)
				{
					FishSound.Play(FishSound.Click, ((Component)_cam).transform.position, 0.25f);
				}
			}
			else
			{
				_tension -= num * 0.6f;
			}
			if (now >= _surgeAt)
			{
				_surgeAt = now + Mathf.Lerp(1.6f, 0.6f, num2) * (0.7f + (float)Rng.NextDouble() * 0.6f);
				_tension += 0.08f + num2 * 0.22f * (float)Rng.NextDouble();
				_progress = Mathf.Max(0f, _progress - num2 * 0.05f);
				FishSound.Play(FishSound.Splash, _bobber.transform.position, 0.35f);
			}
			_tension = Mathf.Clamp01(_tension);
			if (_tension >= 1f)
			{
				Lost++;
				FishSound.Play(FishSound.Snap, ((Component)_cam).transform.position, 0.8f);
				End("SNAP! The line broke and the " + (_fish.Junk ? "catch" : _fish.Name) + " got away.");
				return;
			}
			if (_tension <= 0.04f)
			{
				if (_slackSince < 0f)
				{
					_slackSince = now;
				}
				else if (now - _slackSince > 1.8f)
				{
					Lost++;
					End("The line went slack and it slipped off the hook.");
					return;
				}
			}
			else
			{
				_slackSince = -1f;
			}
			Vector3 position = ((Component)_cam).transform.position;
			Vector3 val = new Vector3(position.x, Water(), position.z);
			Vector3 val2 = new Vector3(_target.x - position.x, 0f, _target.z - position.z);
			Vector3 val3 = val + ((Vector3)(ref val2)).normalized * 2f;
			Vector3 val4 = Vector3.Lerp(_target, val3, _progress) + Vector3.down * 0.08f;
			val4 += new Vector3(Mathf.Sin(now * 5f), 0f, Mathf.Cos(now * 4f)) * 0.15f * num2;
			_bobber.transform.position = val4;
			if (_progress >= 1f)
			{
				Land();
			}
		}

		private static Catch Pick()
		{
			float num = 0f;
			bool night = false;
			try
			{
				int currentTime = TimeManager.CurrentTime;
				night = currentTime >= 2000 || currentTime < 500;
			}
			catch
			{
			}
			foreach (Catch @catch in FishCore.Catches)
			{
				num += Weight(@catch, night);
			}
			float num2 = (float)Rng.NextDouble() * num;
			foreach (Catch catch2 in FishCore.Catches)
			{
				num2 -= Weight(catch2, night);
				if (num2 <= 0f)
				{
					return catch2;
				}
			}
			return FishCore.Catches[0];
		}

		private static float Weight(Catch c, bool night)
		{
			return c.Weight * ((night && c.Value >= 90f && !c.Junk) ? 1.8f : 1f);
		}

		private static void Land()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			Landed++;
			_s = S.Landed;
			_t0 = Time.time;
			if ((Object)(object)_bobber != (Object)null)
			{
				_bobber.SetActive(false);
			}
			FishSound.Play(FishSound.Splash, ((Component)_cam).transform.position + ((Component)_cam).transform.forward, 0.7f);
			if (_fish.Id == "gf_stash")
			{
				int num = 250 + Rng.Next(66) * 10;
				try
				{
					Money.ChangeCashBalance((float)num, true, true);
				}
				catch
				{
				}
				FortifyApi.Notify("Gone Fishing", $"You hauled up a Lost Stash! ${num} in soggy bills inside.");
			}
			else
			{
				bool flag = Give(_fish.Id);
				string text = (_fish.Junk ? "an Old Boot. Better luck next cast." : $"a {_kg:0.0} kg {_fish.Name}! (Randy pays ${_fish.Value * (FishCore.FishPay?.Value ?? 1f):0})");
				FortifyApi.Notify("Gone Fishing", "You caught " + text + (flag ? "" : " No room in your pockets, so you let it go."));
				if (!_fish.Junk && (Best == "" || _fish.Value >= 200f))
				{
					Best = $"{_kg:0.0} kg {_fish.Name}";
				}
			}
			ShowCatch();
		}

		private static bool Give(string id)
		{
			try
			{
				PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
				ItemDefinition item = Registry.GetItem<ItemDefinition>(id);
				if ((Object)(object)instance == (Object)null || (Object)(object)item == (Object)null)
				{
					return false;
				}
				ItemInstance defaultInstance = item.GetDefaultInstance(1);
				if (defaultInstance == null || !instance.CanItemFitInInventory(defaultInstance, 1))
				{
					return false;
				}
				instance.AddItemToInventory(defaultInstance);
				return true;
			}
			catch (Exception ex)
			{
				Instance log = Kit.Log;
				if (log != null)
				{
					log.Warning("Gone Fishing: giving the catch (" + ex.Message + ").");
				}
				return false;
			}
		}

		private static void ShowCatch()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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)
			if ((Object)(object)_show != (Object)null)
			{
				Object.Destroy((Object)(object)_show);
			}
			GameObject val = ((_fish.Id == "gf_stash") ? Stash() : Catalog.Get(_fish.Id)?.Template);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)_cam == (Object)null))
			{
				_show = FishModels.Plain(val, "GF_Catch");
				_show.transform.SetParent(((Component)_cam).transform, false);
				Bounds val2 = FishModels.LocalBounds(_show);
				float num = Mathf.Max(((Bounds)(ref val2)).size.x, Mathf.Max(((Bounds)(ref val2)).size.y, ((Bounds)(ref val2)).size.z));
				float num2 = Mathf.Clamp(0.55f / Mathf.Max(0.05f, num), 0.3f, 1.6f);
				_show.transform.localScale = Vector3.one * num2;
				_show.transform.localPosition = new Vector3(0f, -0.08f, 0.7f) - _show.transform.localRotation * (((Bounds)(ref val2)).center * num2);
				_show.transform.localRotation = Quaternion.Euler(0f, 90f, 10f);
			}
		}

		private static GameObject Stash()
		{
			if ((Object)(object)_stashTpl == (Object)null)
			{
				_stashTpl = FishModels.Load("gf_StashTpl", "GF_Stash.glb");
				_stashTpl.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)_stashTpl);
			}
			return _stashTpl;
		}

		private static void UpdateLanded()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_show != (Object)null)
			{
				_show.transform.localRotation = Quaternion.Euler(0f, 90f + Mathf.Sin(Time.time * 3f) * 12f, 10f + Mathf.Sin(Time.time * 9f) * 4f);
			}
			if (Time.time - _t0 > 2.6f)
			{
				if ((Object)(object)_show != (Object)null)
				{
					Object.Destroy((Object)(object)_show);
				}
				_show = null;
				_s = S.Idle;
			}
		}

		private static void End(string msg)
		{
			_s = S.Idle;
			if ((Object)(object)_bobber != (Object)null)
			{
				_bobber.SetActive(false);
			}
			if ((Object)(object)_line != (Object)null)
			{
				_line.SetActive(false);
			}
			if (!string.IsNullOrEmpty(msg))
			{
				FortifyApi.Notify("Gone Fishing", msg);
			}
		}

		private static void ShowView()
		{
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_0082: 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)
			//IL_0091: 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_00c5: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_view == (Object)null || (Object)(object)_view.transform.parent != (Object)(object)((Component)_cam).transform)
			{
				if ((Object)(object)_view != (Object)null)
				{
					Object.Destroy((Object)(object)_view);
				}
				GameObject val = Catalog.Get("gf_rod")?.Template;
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				_view = FishModels.Plain(val, "GF_RodView");
				Bounds val2 = FishModels.LocalBounds(_view);
				Vector3 val3 = ((((Bounds)(ref val2)).size.x >= ((Bounds)(ref val2)).size.y && ((Bounds)(ref val2)).size.x >= ((Bounds)(ref val2)).size.z) ? Vector3.right : ((((Bounds)(ref val2)).size.y >= ((Bounds)(ref val2)).size.z) ? Vector3.up : Vector3.forward));
				float num = Vector3.Dot(((Bounds)(ref val2)).max, val3);
				float num2 = Vector3.Dot(((Bounds)(ref val2)).min, val3);
				Vector3 val4 = ((Mathf.Abs(num) >= Mathf.Abs(num2)) ? val3 : (-val3));
				Vector3 localPosition = Vector3.Scale(((Bounds)(ref val2)).center, Vector3.one - val3) + val4 * Mathf.Max(Mathf.Abs(num), Mathf.Abs(num2));
				GameObject val5 = new GameObject("GF_Tip");
				val5.transform.SetParent(_view.transform, false);
				val5.transform.localPosition = localPosition;
				_tip = val5.transform;
				_view.transform.SetParent(((Component)_cam).transform, false);
				Transform transform = _view.transform;
				Vector3 val6 = new Vector3(0.08f, 0.55f, 1f);
				transform.localRotation = Quaternion.FromToRotation(val4, ((Vector3)(ref val6)).normalized);
				_view.transform.localPosition = new Vector3(0.28f, -0.32f, 0.35f);
			}
			if (!_view.activeSelf)
			{
				_view.SetActive(true);
			}
			if (_s == S.Reeling)
			{
				_view.transform.localPosition = new Vector3(0.28f, -0.32f, 0.35f) + new Vector3(Mathf.Sin(Time.time * 17f), Mathf.Sin(Time.time * 13f), 0f) * 0.006f * (1f + _tension * 2f);
			}
		}

		private static Vector3 TipPos()
		{
			//IL_0040: 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_0026: 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)
			if (!((Object)(object)_tip != (Object)null))
			{
				return ((Component)_cam).transform.position + ((Component)_cam).transform.forward * 1.5f;
			}
			return _tip.position;
		}

		private static void EnsureBobber()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_bobber == (Object)null)
			{
				_bobber = FishModels.Load("GF_BobberLive", "GF_Bobber.glb");
				foreach (Renderer componentsInChild in _bobber.GetComponentsInChildren<Renderer>(true))
				{
					componentsInChild.shadowCastingMode = (ShadowCastingMode)0;
				}
				_bobber.transform.localScale = Vector3.one * 1.6f;
			}
			_bobber.SetActive(true);
			if ((Object)(object)_line == (Object)null)
			{
				_line = FortifyApi.Part(null, (PrimitiveType)2, Vector3.zero, Vector3.one, FortifyApi.Mat("gf_line", new Color(0.85f, 0.88f, 0.9f), 0f, 0.6f), null, collider: false, "GF_Line");
				((Renderer)_line.GetComponent<MeshRenderer>()).shadowCastingMode = (ShadowCastingMode)0;
			}
			_line.SetActive(true);
		}

		private static void UpdateLine()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_0096: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_line == (Object)null || (Object)(object)_bobber == (Object)null)
			{
				return;
			}
			bool flag = (_s == S.Casting || _s == S.Waiting || _s == S.Bite || _s == S.Reeling) && _bobber.activeSelf;
			if (_line.activeSelf != flag)
			{
				_line.SetActive(flag);
			}
			if (flag)
			{
				Vector3 val = TipPos();
				Vector3 val2 = _bobber.transform.position + Vector3.up * 0.06f;
				Vector3 val3 = val2 - val;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (!(magnitude < 0.01f))
				{
					_line.transform.position = (val + val2) * 0.5f;
					_line.transform.rotation = Quaternion.FromToRotation(Vector3.up, val3 / magnitude);
					float num = ((_s == S.Reeling) ? 0.005f : 0.0035f);
					_line.transform.localScale = new Vector3(num, magnitude * 0.5f, num);
				}
			}
		}

		public static void Draw()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00e2: 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_0112: 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_016c: 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_01b7: 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_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			if (_s == S.Reeling)
			{
				float num = Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 2f);
				float num2 = 520f * num;
				float num3 = 26f * num;
				float num4 = ((float)Screen.width - num2) * 0.5f;
				float num5 = (float)Screen.height * 0.6f;
				WS_GF.FybCommon.Ui.Fill(new Rect(num4 - 12f * num, num5 - 52f * num, num2 + 24f * num, 120f * num), new Color(0f, 0f, 0f, 0.6f));
				WS_GF.FybCommon.Ui.Text(new Rect(num4, num5 - 50f * num, num2, 36f * num), "Hold the mouse to reel - keep the line in the green", Mathf.RoundToInt(18f * num), Color.white, (TextAnchor)4);
				WS_GF.FybCommon.Ui.Fill(new Rect(num4, num5, num2, num3), new Color(0.6f, 0.12f, 0.1f));
				WS_GF.FybCommon.Ui.Fill(new Rect(num4 + num2 * 0.25f, num5, num2 * 0.57f, num3), new Color(0.15f, 0.55f, 0.2f));
				WS_GF.FybCommon.Ui.Fill(new Rect(num4 + num2 * Mathf.Clamp01(_tension) - 3f * num, num5 - 6f * num, 6f * num, num3 + 12f * num), Color.white);
				WS_GF.FybCommon.Ui.Text(new Rect(num4 - 70f * num, num5, 66f * num, num3), "slack", Mathf.RoundToInt(14f * num), new Color(1f, 1f, 1f, 0.7f), (TextAnchor)5);
				WS_GF.FybCommon.Ui.Text(new Rect(num4 + num2 + 6f * num, num5, 70f * num, num3), "snap!", Mathf.RoundToInt(14f * num), new Color(1f, 0.6f, 0.6f), (TextAnchor)3);
				float num6 = num5 + num3 + 14f * num;
				WS_GF.FybCommon.Ui.Fill(new Rect(num4, num6, num2, 12f * num), new Color(0.2f, 0.2f, 0.22f));
				WS_GF.FybCommon.Ui.Fill(new Rect(num4, num6, num2 * Mathf.Clamp01(_progress), 12f * num), new Color(0.35f, 0.65f, 1f));
			}
		}

		public static string State()
		{
			return $"{_s}, water {Water():0.00} ({WaterWhy}), casts {Casts}, landed {Landed}, lost {Lost}, aim {_aimOk} {_aimWhy}, best {Best}";
		}

		public static string Reeled()
		{
			if (_s == S.Reeling)
			{
				_progress = 1f;
				_tension = 0.5f;
				return "reeled in";
			}
			return "not reeling (" + _s.ToString() + ")";
		}

		public static string Hook()
		{
			if (_s == S.Waiting)
			{
				_biteAt = Time.time;
				_devHook = true;
				return "hooking";
			}
			return "not waiting (" + _s.ToString() + ")";
		}

		public static string Bite()
		{
			if (_s == S.Waiting)
			{
				_biteAt = Time.time;
				return "biting";
			}
			return "not waiting (" + _s.ToString() + ")";
		}
	}
	internal static class Stand
	{
		public static bool Open;

		public static string Hint;

		public static string Where = "not placed";

		private static GameObject _go;

		private static float _at = -1f;

		private static string _msg;

		private static float _msgAt;

		public static void Schedule()
		{
			Clear();
			_at = Time.unscaledTime + 6f;
		}

		public static void Clear()
		{
			if (Open)
			{
				Close();
			}
			if ((Object)(object)_go != (Object)null)
			{
				Object.Destroy((Object)(object)_go);
			}
			_go = null;
			_at = -1f;
		}

		public static void Update()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			Hint = null;
			if ((Object)(object)_go == (Object)null && _at > 0f && Time.unscaledTime >= _at)
			{
				_at = -1f;
				try
				{
					Place();
				}
				catch (Exception ex)
				{
					Where = "failed: " + ex.Message;
					Instance log = Kit.Log;
					if (log != null)
					{
						log.Warning("Gone Fishing: the stand (" + ex.Message + ").");
					}
				}
			}
			if ((Object)(object)_go == (Object)null)
			{
				return;
			}
			if (Open)
			{
				if (Keys.RawDown((KeyCode)27))
				{
					Close();
				}
				return;
			}
			Player local = Player.Local;
			if ((Object)(object)local == (Object)null)
			{
				return;
			}
			_ = _go.transform.position + Vector3.up;
			if (Vector3.Distance(((Component)local).transform.position, _go.transform.position) < 3f)
			{
				Hint = "[E] Randy's Bait & Rods";
				if (FortifyApi.KeyDown((KeyCode)101))
				{
					Open = true;
					_msg = null;
					FortifyApi.OpenMenu("gf_stand");
				}
			}
		}

		private static void Close()
		{
			Open = false;
			FortifyApi.CloseMenu("gf_stand");
		}

		private static void Place()
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_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_01d4: 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_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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_00ee: 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_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			NPCEnterableBuilding val = null;
			foreach (NPCEnterableBuilding item in Object.FindObjectsOfType<NPCEnterableBuilding>(true))
			{
				string text = null;
				try
				{
					text = item.BuildingName;
				}
				catch
				{
				}
				if (text != null && text.IndexOf("Randy", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					val = item;
					break;
				}
			}
			Vector3 position = default(Vector3);
			((Vector3)(ref position))..ctor(-92f, 0f, -34f);
			Vector3 val2 = Vector3.forward;
			if ((Object)(object)val != (Object)null)
			{
				position = ((Component)val).transform.position;
				Il2CppReferenceArray<StaticDoor> doors = val.Doors;
				StaticDoor val3 = ((doors != null && ((Il2CppArrayBase<StaticDoor>)(object)doors).Length > 0) ? ((Il2CppArrayBase<StaticDoor>)(object)doors)[0] : null);
				if ((Object)(object)val3 != (Object)null)
				{
					position = ((Component)val3).transform.position;
					Vector3 val4 = Vector3.zero;
					try
					{
						if ((Object)(object)val3.AccessPoint != (Object)null)
						{
							val4 = val3.AccessPoint.position - position;
						}
					}
					catch
					{
					}
					val4.y = 0f;
					if (((Vector3)(ref val4)).sqrMagnitude < 0.04f)
					{
						val4 = position - ((Component)val).transform.position;
						val4.y = 0f;
					}
					if (((Vector3)(ref val4)).sqrMagnitude > 0.01f)
					{
						val2 = ((Vector3)(ref val4)).normalized;
					}
				}
			}
			Vector3 val5 = Vector3.Cross(Vector3.up, val2);
			Vector3 val6 = Vector3.zero;
			bool flag = false;
			float[] array = new float[2] { 1f, -1f };
			RaycastHit val7 = default(RaycastHit);
			foreach (float num in array)
			{
				float[] array2 = new float[3] { 2.6f, 3.4f, 4.2f };
				foreach (float num2 in array2)
				{
					if (Physics.Raycast(position + val2 * 2.2f + val5 * (num2 * num) + Vector3.up * 6f, Vector3.down, ref val7, 12f, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val7)).normal.y > 0.85f && !Physics.CheckBox(((RaycastHit)(ref val7)).point + Vector3.up * 1.2f, new Vector3(0.9f, 1f, 0.45f), Quaternion.LookRotation(val2), -1, (QueryTriggerInteraction)1))
					{
						val6 = ((RaycastHit)(ref val7)).point;
						flag = true;
						break;
					}
				}
				if (flag)
				{
					break;
				}
			}
			if (!flag)
			{
				val6 = position + val2 * 2.2f + val5 * 2.6f;
				RaycastHit val8 = default(RaycastHit);
				if (Physics.Raycast(val6 + Vector3.up * 6f, Vector3.down, ref val8, 12f, -1, (QueryTriggerInteraction)1))
				{
					val6 = ((RaycastHit)(ref val8)).point;
				}
			}
			_go = FishModels.Load("GF_RandysStand", "GF_Stand.glb");
			_go.transform.position = val6;
			_go.transform.rotation = Quaternion.LookRotation(val2);
			BoxCollider obj3 = _go.AddComponent<BoxCollider>();
			obj3.center = new Vector3(0f, 0.5f, 0f);
			obj3.size = new Vector3(1.6f, 1f, 0.6f);
			Where = $"{val6:0.0} facing {val2:0.00}" + (((Object)(object)val == (Object)null) ? " (Randy's not found, fallback)" : "");
			Instance log = Kit.Log;
			if (log != null)
			{
				log.Msg("Gone Fishing: Randy's stand at " + Where + ".");
			}
		}

		private static void Say(string s)
		{
			_msg = s;
			_msgAt = Time.unscaledTime;
		}

		private static bool Buy(string id, int qty, float price, string what)
		{
			float num = 0f;
			try
			{
				num = Money.GetCashBalance();
			}
			catch
			{
			}
			if (num < price)
			{
				Say($"You need ${price:0} in cash for {what}.");
				return false;
			}
			try
			{
				PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
				ItemDefinition item = Registry.GetItem<ItemDefinition>(id);
				ItemInstance val = ((item != null) ? item.GetDefaultInstance(qty) : null);
				if ((Object)(object)instance == (Object)null || val == null || !instance.CanItemFitInInventory(val, qty))
				{
					Say("Your pockets are full.");
					return false;
				}
				instance.AddItemToInventory(val);
				Money.ChangeCashBalance(0f - price, true, true);
				Say("Thanks! Tight lines.");
				return true;
			}
			catch (Exception ex)
			{
				Say("Couldn't sell you that (" + ex.Message + ").");
				return false;
			}
		}

		private static (int count, float total) CatchValue()
		{
			int num = 0;
			float num2 = 0f;
			try
			{
				PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
				foreach (Catch @catch in FishCore.Catches)
				{
					if (!(@catch.Id == "gf_stash"))
					{
						uint amountOfItem = instance.GetAmountOfItem(@catch.Id);
						num += (int)amountOfItem;
						num2 += (float)amountOfItem * @catch.Value * (FishCore.FishPay?.Value ?? 1f);
					}
				}
			}
			catch
			{
			}
			return (count: num, total: num2);
		}

		private static void SellAll()
		{
			var (num, num2) = CatchValue();
			if (num == 0)
			{
				Say("You haven't got any fish on you.");
				return;
			}
			try
			{
				PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
				foreach (Catch @catch in FishCore.Catches)
				{
					uint amountOfItem = instance.GetAmountOfItem(@catch.Id);
					if (amountOfItem != 0)
					{
						instance.RemoveAmountOfItem(@catch.Id, amountOfItem);
					}
				}
				Money.ChangeCashBalance(num2, true, true);
				Say($"Randy paid ${num2:0} for {num} catch{((num == 1) ? "" : "es")}.");
			}
			catch (Exception ex)
			{
				Say("Couldn't sell (" + ex.Message + ").");
			}
		}

		public static void Draw()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			if (Open)
			{
				float num = Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 2f);
				float num2 = 560f * num;
				float num3 = 470f * num;
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((float)Screen.width - num2) * 0.5f, ((float)Screen.height - num3) * 0.5f, num2, num3);
				WS_GF.FybCommon.Ui.Fill(r, new Color(0.06f, 0.16f, 0.24f, 0.96f));
				WS_GF.FybCommon.Ui.Frame(r, new Color(0.98f, 0.85f, 0.5f), 3f * num);
				WS_GF.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 14f * num, num2, 46f * num), "RANDY'S BAIT & RODS", Mathf.RoundToInt(30f * num), new Color(0.98f, 0.85f, 0.5f), (TextAnchor)4);
				WS_GF.FybCommon.Ui.Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 58f * num, num2, 30f * num), "\"Fish off any dock. Big ones bite after dark.\"", Mathf.RoundToInt(16f * num), new Color(1f, 1f, 1f, 0.8f), (TextAnchor)4, bold: false);
				float num4 = FishCore.RodPrice?.Value ?? 150f;
				float num5 = FishCore.BaitPrice?.Value ?? 20f;
				float num6 = ((Rect)(ref r)).y + 104f * num;
				float num7 = num2 - 80f * num;
				float num8 = 52f * num;
				float num9 = ((Rect)(ref r)).x + 40f * num;
				if (WS_GF.FybCommon.Ui.Button(new Rect(num9, num6, num7, num8), $"Fishing Rod  -  ${num4:0}", enabled: true, selected: false, Mathf.RoundToInt(19f * num)))
				{
					Buy("gf_rod", 1, num4, "a rod");
				}
				num6 += num8 + 12f * num;
				if (WS_GF.FybCommon.Ui.Button(new Rect(num9, num6, num7, num8), $"Bait x10  -  ${num5:0}", enabled: true, selected: false, Mathf.RoundToInt(19f * num)))
				{
					Buy("gf_bait", 10, num5, "bait");
				}
				num6 += num8 + 12f * num;
				var (num10, value) = CatchValue();
				if (WS_GF.FybCommon.Ui.Button(new Rect(num9, num6, num7, num8), (num10 > 0) ? $"Sell your catch ({num10})  -  ${value:0}" : "Sell your catch", num10 > 0, selected: false, Mathf.RoundToInt(19f * num)))
				{
					SellAll();
				}
				num6 += num8 + 18f * num;
				WS_GF.FybCommon.Ui.Text(new Rect(num9, num6, num7, 40f * num), "Mackerel $12   Sea Bass $25   Red Snapper $40   Salmon $60\nHalibut $90   Bluefin Tuna $200   Golden Carp $1,000", Mathf.RoundToInt(14f * num), new Color(1f, 1f, 1f, 0.75f), (TextAnchor)4);
				num6 += 52f * num;
				if (_msg != null && Time.unscaledTime - _msgAt < 6f)
				{
					WS_GF.FybCommon.Ui.Text(new Rect(num9, num6, num7, 30f * num), _msg, Mathf.RoundToInt(17f * num), new Color(0.6f, 1f, 0.6f), (TextAnchor)4);
				}
				if (WS_GF.FybCommon.Ui.Button(new Rect(((Rect)(ref r)).x + num2 * 0.5f - 80f * num, ((Rect)(ref r)).yMax - 58f * num, 160f * num, 42f * num), "Close", enabled: true, selected: false, Mathf.RoundToInt(18f * num)))
				{
					Close();
				}
			}
		}
	}
}
namespace WS_GF.WoodKit
{
	internal static class Catalog
	{
		public static readonly List<ItemSpec> Items = new List<ItemSpec>();

		private static readonly Dictionary<string, ItemSpec> ById = new Dictionary<string, ItemSpec>(StringComparer.OrdinalIgnoreCase);

		public static void Add(ItemSpec s)
		{
			Items.Add(s);
			ById[s.Id] = s;
		}

		public static ItemSpec Get(string id)
		{
			if (string.IsNullOrEmpty(id) || !ById.TryGetValue(id, out var value))
			{
				return null;
			}
			return value;
		}

		public static void BuildTemplates()
		{
			foreach (ItemSpec item in Items)
			{
				if ((Object)(object)item.Template != (Object)null || item.BuildModel == null)
				{
					continue;
				}
				try
				{
					item.Template = item.BuildModel();
					if ((Object)(object)item.Template != (Object)null && (Object)(object)item.Template.transform.parent == (Object)null)
					{
						item.Template.transform.SetParent(Models.Root, false);
					}
				}
				catch (Exception ex)
				{
					Instance log = Kit.Log;
					if (log != null)
					{
						log.Error("Couldn't build the " + item.Name + " model: " + ex.Message);
					}
				}
			}
		}
	}
	internal static class CoopMirror
	{
		private sealed class Shown
		{
			public string Payload;

			public readonly List<GameObject> Gos = new List<GameObject>();
		}

		private const int Chunk = 3500;

		private const int MaxChunks = 24;

		private static readonly Dictionary<ulong, Shown> Views = new Dictionary<ulong, Shown>();

		private static string _published;

		private static int _publishedChunks;

		private static float _nextBuild;

		private static float _nextView;

		private static string Key => "wk_" + (Kit.Prefix ?? "x");

		private static bool InLobby(out CSteamID lobby, out int members)
		{
			//IL_0001: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			lobby = default(CSteamID);
			members = 0;
			try
			{
				Lobby instance = Singleton<Lobby>.Instance;
				if ((Object)(object)instance == (Object)null || !instance.IsInLobby || instance.LobbyID == 0L)
				{
					return false;
				}
				lobby = new CSteamID
				{
					m_SteamID = instance.LobbyID
				};
				members = SteamMatchmaking.GetNumLobbyMembers(lobby);
				return members > 1;
			}
			catch
			{
				return false;
			}
		}

		public static void Update()
		{
			//IL_006c: 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)
			if (!InLobby(out var lobby, out var members))
			{
				if (Views.Count > 0)
				{
					Clear();
				}
				_published = null;
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime >= _nextBuild)
			{
				_nextBuild = unscaledTime + 1.5f;
				string text = Build();
				if (text != _published)
				{
					Publish(lobby, text);
				}
			}
			if (unscaledTime >= _nextView)
			{
				_nextView = unscaledTime + 1f;
				Refresh(lobby, members);
			}
		}

		public static void Reset()
		{
			Clear();
			_published = null;
			_publishedChunks = 0;
			_nextBuild = (_nextView = 0f);
		}

		private static string Build()
		{
			//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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_013d: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Placement.Placed item in Placement.All)
			{
				try
				{
					if (item != null && !((Object)(object)item.Go == (Object)null) && item.Spec != null && !item.OnShip && !((Object)(object)item.Spec.Template == (Object)null) && item.Go.activeInHierarchy)
					{
						Transform transform = item.Go.transform;
						Vector3 position = transform.position;
						Quaternion rotation = transform.rotation;
						Vector3 lossyScale = transform.lossyScale;
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append('~');
						}
						stringBuilder.Append(item.Spec.Id).Append(';');
						Num(stringBuilder, position.x);
						stringBuilder.Append(',');
						Num(stringBuilder, position.y);
						stringBuilder.Append(',');
						Num(stringBuilder, position.z);
						stringBuilder.Append(';');
						Num(stringBuilder, rotation.x, 4);
						stringBuilder.Append(',');
						Num(stringBuilder, rotation.y, 4);
						stringBuilder.Append(',');
						Num(stringBuilder, rotation.z, 4);
						stringBuilder.Append(',');
						Num(stringBuilder, rotation.w, 4);
						stringBuilder.Append(';');
						Num(stringBuilder, lossyScale.x, 3);
						stringBuilder.Append(',');
						Num(stringBuilder, lossyScale.y, 3);
						stringBuilder.Append(',');
						Num(stringBuilder, lossyScale.z, 3);
					}
				}
				catch
				{
				}
			}
			return stringBuilder.ToString();
		}

		private static void Publish(CSteamID lobby, string payload)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = ((payload.Length != 0) ? Math.Min(24, (payload.Length + 3500 - 1) / 3500) : 0);
				for (int i = 0; i < num; i++)
				{
					SteamMatchmaking.SetLobbyMemberData(lobby, Key + "_" + i, payload.Substring(i * 3500, Math.Min(3500, payload.Length - i * 3500)));
				}
				for (int j = num; j < _publishedChunks; j++)
				{
					SteamMatchmaking.SetLobbyMemberData(lobby, Key + "_" + j, "");
				}
				SteamMatchmaking.SetLobbyMemberData(lobby, Key + "_n", num.ToString(CultureInfo.InvariantCulture) + "|" + payload.Length.ToString(CultureInfo.InvariantCulture));
				_publishedChunks = num;
				_published = payload;
			}
			catch
			{
			}
		}

		private static void Refresh(CSteamID lobby, int members)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_004c: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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)
			ulong num = 0uL;
			try
			{
				num = SteamUser.GetSteamID().m_SteamID;
			}
			catch
			{
			}
			HashSet<ulong> hashSet = new HashSet<ulong>();
			for (int i = 0; i < members; i++)
			{
				CSteamID lobbyMemberByIndex;
				try
				{
					lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(lobby, i);
				}
				catch
				{
					continue;
				}
				if (lobbyMemberByIndex.m_SteamID == num || lobbyMemberByIndex.m_SteamID == 0L)
				{
					continue;
				}
				hashSet.Add(lobbyMemberByIndex.m_SteamID);
				string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, Key + "_n");
				if (string.IsNullOrEmpty(lobbyMemberData))
				{
					continue;
				}
				string[] array = lobbyMemberData.Split('|');
				if (array.Length < 2 || !int.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || !int.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) || result < 0 || result > 24)
				{
					continue;
				}
				StringBuilder stringBuilder = new StringBuilder();
				for (int j = 0; j < result; j++)
				{
					stringBuilder.Append(SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, Key + "_" + j) ?? "");
				}
				string text = stringBuilder.ToString();
				if (text.Length == result2 && (!Views.TryGetValue(lobbyMemberByIndex.m_SteamID, out var value) || !(value.Payload == text)))
				{
					if (value != null)
					{
						Destroy(value);
					}
					value = new Shown
					{
						Payload = text
					};
					Views[lobbyMemberByIndex.m_SteamID] = value;
					Spawn(value, text);
				}
			}
			List<ulong> list = new List<ulong>();
			foreach (KeyValuePair<ulong, Shown> view in Views)
			{
				if (!hashSet.Contains(view.Key))
				{
					list.Add(view.Key);
				}
			}
			foreach (ulong item in list)
			{
				Destroy(Views[item]);
				Views.Remove(item);
			}
		}

		private static void Spawn(Shown shown, string payload)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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)
			if (string.IsNullOrEmpty(payload))
			{
				return;
			}
			string[] array = payload.Split('~');
			foreach (string text in array)
			{
				try
				{
					string[] array2 = text.Split(';');
					if (array2.Length < 4)
					{
						continue;
					}
					ItemSpec itemSpec = Catalog.Get(array2[0]);
					if (itemSpec != null && !((Object)(object)itemSpec.Template == (Object)null))
					{
						GameObject val = Object.Instantiate<GameObject>(itemSpec.Template);
						((Object)val).name = Kit.Prefix + "Mirror_" + itemSpec.Id;
						val.transform.SetParent((Transform)null, false);
						val.transform.SetPositionAndRotation(Vec(array2[1]), Rot(array2[2]));
						Vector3 val2 = Vec(array2[3]);
						if (val2.x > 0.001f && val2.y > 0.001f && val2.z > 0.001f)
						{
							val.transform.localScale = val2;
						}
						val.SetActive(true);
						shown.Gos.Add(val);
					}
				}
				catch
				{
				}
			}
		}

		internal static bool IsMirror(GameObject go)
		{
			Transform val = (((Object)(object)go != (Object)null) ? go.transform : null);
			while ((Object)(object)val != (Object)null)
			{
				if ((((Object)val).name ?? "").Contains("Mirror_"))
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static void Num(StringBuilder sb, float v, int dp = 2)
		{
			sb.Append(Math.Round(v, dp).ToString(CultureInfo.InvariantCulture));
		}

		private static Vector3 Vec(string s)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			string[] a = s.Split(',');
			return new Vector3(P(a, 0), P(a, 1), P(a, 2));
		}

		private static Quaternion Rot(string s)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			string[] a = s.Split(',');
			Quaternion val = default(Quaternion);
			((Quaternion)(ref val))..ctor(P(a, 0), P(a, 1), P(a, 2), P(a, 3));
			float num = Mathf.Sqrt(val.x * val.x + val.y * val.y + val.z * val.z + val.w * val.w);
			if (!(num > 0.0001f))
			{
				return Quaternion.identity;
			}
			return new Quaternion(val.x / num, val.y / num, val.z / num, val.w / num);
		}

		private static float P(string[] a, int i)
		{
			if (i >= a.Length || !float.TryParse(a[i], NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 0f;
			}
			return result;
		}

		private static void Destroy(Shown s)
		{
			foreach (GameObject go in s.Gos)
			{
				try
				{
					if ((Object)(object)go != (Object)null)
					{
						Object.Destroy((Object)(object)go);
					}
				}
				catch
				{
				}
			}
			s.Gos.Clear();
		}

		private static void Clear()
		{
			foreach (KeyValuePair<ulong, Shown> view in Views)
			{
				Destroy(view.Value);
			}
			Views.Clear();
		}
	}
	internal static class Core
	{
		internal const string PickupLabel = "Hold Right Click";

		public static Instance Log => Kit.Log;

		public static KeyCode ViewKey => FortifyApi.UseKey;

		public static KeyCode RotateKey => Kit.RotateKey;
	}
	internal static class GltfLoader
	{
		public static GameObject LoadEmbedded(string fileName, Transform parent)
		{
			using Stream stream = Res.Open(Kit.ModelResourcePrefix + fileName);
			if (stream == null)
			{
				throw new FileNotFoundException("Embedded model missing: " + fileName);
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return Load(memoryStream.ToArray(), Path.GetFileNameWithoutExtension(fileName), parent);
		}

		public static GameObject Load(byte[] glb, string name, Transform parent)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			if (glb.Length < 20 || BitConverter.ToUInt32(glb, 0) != 1179937895)
			{
				throw new InvalidDataException("Not a GLB file");
			}
			int num = (int)BitConverter.ToUInt32(glb, 12);
			string json = Encoding.UTF8.GetString(glb, 20, num);
			int bin = 20 + num + 8;
			using JsonDocument jsonDocument = JsonDocument.Parse(json);
			JsonElement rootElement = jsonDocument.RootElement;
			Material[] materials = BuildMaterials(rootElement);
			Dictionary<int, (Mesh, Material[])> meshCache = new Dictionary<int, (Mesh, Material[])>();
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			JsonElement property = rootElement.GetProperty("nodes");
			HashSet<int> hashSet = new HashSet<int>();
			for (int i = 0; i < property.GetArrayLength(); i++)
			{
				if (!property[i].TryGetProperty("children", out var value))
				{
					continue;
				}
				foreach (JsonElement item in value.EnumerateArray())
				{
					hashSet.Add(item.GetInt32());
				}
			}
			for (int j = 0; j < property.GetArrayLength(); j++)
			{
				if (!hashSet.Contains(j))
				{
					BuildNode(rootElement, property, j, val.transform, glb, bin, materials, meshCache);
				}
			}
			return val;
		}

		private static void BuildNode(JsonElement root, JsonElement nodes, int index, Transform parent, byte[] glb, int bin, Material[] materials, Dictionary<int, (Mesh, Material[])> meshCache)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			JsonElement jsonElement = nodes[index];
			JsonElement value;
			GameObject val = new GameObject(jsonElement.TryGetProperty("name", out value) ? value.GetString() : ("node" + index));
			Transform transform = val.transform;
			transform.SetParent(parent, false);
			if (jsonElement.TryGetProperty("translation", out var value2))
			{
				transform.localPosition = new Vector3(value2[0].GetSingle(), value2[1].GetSingle(), 0f - value2[2].GetSingle());
			}
			if (jsonElement.TryGetProperty("rotation", out var value3))
			{
				transform.localRotation = new Quaternion(0f - value3[0].GetSingle(), 0f - value3[1].GetSingle(), value3[2].GetSingle(), value3[3].GetSingle());
			}
			if (jsonElement.TryGetProperty("scale", out var value4))
			{
				transform.localScale = new Vector3(value4[0].GetSingle(), value4[1].GetSingle(), value4[2].GetSingle());
			}
			if (jsonElement.TryGetProperty("mesh", out var value5))
			{
				int @int = value5.GetInt32();
				if (!meshCache.TryGetValue(@int, out var value6))
				{
					(Mesh, Material[]) tuple = (meshCache[@int] = BuildMesh(root, @int, glb, bin, materials));
					value6 = tuple;
				}
				val.AddComponent<MeshFilter>().sharedMesh = value6.Item1;
				MeshRenderer val2 = val.AddComponent<MeshRenderer>();
				Il2CppReferenceArray<Material> val3 = new Il2CppReferenceArray<Material>((long)value6.Item2.Length);
				for (int i = 0; i < value6.Item2.Length; i++)
				{
					((Il2CppArrayBase<Material>)(object)val3)[i] = value6.Item2[i];
				}
				((Renderer)val2).sharedMaterials = val3;
			}
			if (!jsonElement.TryGetProperty("children", out var value7))
			{
				return;
			}
			foreach (JsonElement item in value7.EnumerateArray())
			{
				BuildNode(root, nodes, item.GetInt32(), transform, glb, bin, materials, meshCache);
			}
		}

		private static (Mesh, Material[]) BuildMesh(JsonElement root, int meshIndex, byte[] glb, int bin, Material[] materials)
		{
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_00c1: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			JsonElement property = root.GetProperty("meshes")[meshIndex].GetProperty("primitives");
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<int[]> list4 = new List<int[]>();
			List<Material> list5 = new List<Material>();
			foreach (JsonElement item in property.EnumerateArray())
			{
				JsonElement property2 = item.GetProperty("attributes");
				int count = list.Count;
				int count2;
				float[] array = ReadFloats(root, property2.GetProperty("POSITION").GetInt32(), glb, bin, out count2);
				for (int i = 0; i < count2; i++)
				{
					list.Add(new Vector3(array[i * 3], array[i * 3 + 1], 0f - array[i * 3 + 2]));
				}
				int count3;
				if (property2.TryGetProperty("NORMAL", out var value))
				{
					float[] array2 = ReadFloats(root, value.GetInt32(), glb, bin, out count3);
					for (int j = 0; j < count2; j++)
					{
						list2.Add(new Vector3(array2[j * 3], array2[j * 3 + 1], 0f - array2[j * 3 + 2]));
					}
				}
				else
				{
					for (int k = 0; k < count2; k++)
					{
						list2.Add(Vector3.up);
					}
				}
				if (property2.TryGetProperty("TEXCOORD_0", out var value2))
				{
					float[] array3 = ReadFloats(root, value2.GetInt32(), glb, bin, out count3);
					for (int l = 0; l < count2; l++)
					{
						list3.Add(new Vector2(array3[l * 2], 1f - array3[l * 2 + 1]));
					}
				}
				else
				{
					for (int m = 0; m < count2; m++)
					{
						list3.Add(Vector2.zero);
					}
				}
				int[] array4;
				if (item.TryGetProperty("indices", out var value3))
				{
					array4 = ReadIndices(root, value3.GetInt32(), glb, bin);
				}
				else
				{
					array4 = new int[count2];
					for (int n = 0; n < count2; n++)
					{
						array4[n] = n;
					}
				}
				for (int num = 0; num + 2 < array4.Length; num += 3)
				{
					int num2 = arr