Decompiled source of TidehaulNets v0.2.3

BepInEx/plugins/TidehaulNets/TidehaulNets.Core.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TidehaulNets.Core")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TidehaulNets.Core")]
[assembly: AssemblyTitle("TidehaulNets.Core")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TidehaulNets.Core
{
	public readonly struct NetBuoyPose
	{
		public Vector3 Center { get; }

		public Vector3 Attachment { get; }

		internal NetBuoyPose(Vector3 center, Vector3 attachment)
		{
			Center = center;
			Attachment = attachment;
		}
	}
	public static class NetBuoyTether
	{
		public const float MaximumLength = 0.8f;

		public static NetBuoyPose Resolve(Vector3 netAttachment, Vector3 buoyAttachmentOffset, Vector3 lateral, float waterHeight, float bob)
		{
			if (!NetMotionPlanner.IsFinite(netAttachment) || !NetMotionPlanner.IsFinite(buoyAttachmentOffset) || !NetMotionPlanner.IsFinite(lateral) || float.IsNaN(waterHeight) || float.IsInfinity(waterHeight) || float.IsNaN(bob) || float.IsInfinity(bob) || Math.Abs(bob) > 0.1f)
			{
				throw new ArgumentOutOfRangeException("netAttachment");
			}
			Vector3 vector = new Vector3(netAttachment.X + lateral.X, waterHeight + 0.16f + bob, netAttachment.Z + lateral.Z) + buoyAttachmentOffset - netAttachment;
			if (vector.LengthSquared() > 0.64000005f)
			{
				vector = Vector3.Normalize(vector) * 0.8f;
			}
			Vector3 vector2 = netAttachment + vector;
			return new NetBuoyPose(vector2 - buoyAttachmentOffset, vector2);
		}
	}
	public enum NetPhase
	{
		Stowed,
		Lowering,
		Soaking,
		Hauling,
		Ready
	}
	public enum NetActionError
	{
		StaleRevision,
		RevisionOverflow,
		AlreadyInstalled,
		NotInstalled,
		WrongPhase,
		InvalidArgument,
		PendingCatch,
		CatchNotDue,
		WrongCatchOpportunity,
		CapacityReached,
		AlreadyPaused,
		NotPaused
	}
	public sealed class NetActionException : InvalidOperationException
	{
		public NetActionError Error { get; }

		public NetActionException(NetActionError error, string message)
			: base(message)
		{
			Error = error;
		}
	}
	public sealed class NetCycleConfig
	{
		public const int MaximumCapacity = 64;

		public const double MaximumDurationSeconds = 86400.0;

		public int Capacity { get; }

		public double LoweringSeconds { get; }

		public double CatchIntervalSeconds { get; }

		public double HaulingSeconds { get; }

		public NetCycleConfig(int capacity = 3, double loweringSeconds = 8.0, double catchIntervalSeconds = 14.0, double haulingSeconds = 24.0)
		{
			if (capacity < 1 || capacity > 64)
			{
				throw new ArgumentOutOfRangeException("capacity");
			}
			Capacity = capacity;
			LoweringSeconds = ValidateDuration(loweringSeconds, "loweringSeconds");
			CatchIntervalSeconds = ValidateDuration(catchIntervalSeconds, "catchIntervalSeconds");
			HaulingSeconds = ValidateDuration(haulingSeconds, "haulingSeconds");
		}

		private static double ValidateDuration(double value, string name)
		{
			if (!NetCycle.IsFinite(value) || value <= 0.0 || value > 86400.0)
			{
				throw new ArgumentOutOfRangeException(name);
			}
			return value;
		}
	}
	public sealed class NetCatchTicket
	{
		public const double MaximumWeightFactor = 1000.0;

		public byte ItemId { get; }

		public double WeightFactor { get; }

		public bool IsShiny { get; }

		public NetCatchTicket(byte itemId, double weightFactor, bool isShiny = false)
		{
			if (!NetCycle.IsFinite(weightFactor) || weightFactor <= 0.0 || weightFactor > 1000.0)
			{
				throw new ArgumentOutOfRangeException("weightFactor");
			}
			ItemId = itemId;
			WeightFactor = weightFactor;
			IsShiny = isShiny;
		}
	}
	public sealed class NetAdvanceResult
	{
		public double ConsumedSeconds { get; }

		public double UnconsumedSeconds { get; }

		public bool CatchDue { get; }

		internal NetAdvanceResult(double consumedSeconds, double unconsumedSeconds, bool catchDue)
		{
			ConsumedSeconds = consumedSeconds;
			UnconsumedSeconds = unconsumedSeconds;
			CatchDue = catchDue;
		}
	}
	public sealed class NetCycle
	{
		public const int CurrentSchemaVersion = 1;

		public const int MaximumIdLength = 128;

		private readonly List<NetCatchTicket> _tickets = new List<NetCatchTicket>();

		private string? _activeOperatorId;

		private bool _haulPaused = true;

		private double _loweringElapsed;

		private double _soakElapsed;

		private double _haulElapsed;

		private ulong _opportunitySequence;

		public NetCycleConfig Config { get; private set; }

		public bool Installed { get; private set; }

		public NetPhase Phase { get; private set; }

		public string? DeploymentId { get; private set; }

		public ulong Revision { get; private set; }

		public bool CatchDue { get; private set; }

		public ulong CatchOpportunity
		{
			get
			{
				if (!CatchDue)
				{
					return 0uL;
				}
				return _opportunitySequence;
			}
		}

		public int TicketCount => _tickets.Count;

		public bool HaulPaused
		{
			get
			{
				if (Phase == NetPhase.Hauling)
				{
					return _haulPaused;
				}
				return false;
			}
		}

		public double DeploymentAmount => Phase switch
		{
			NetPhase.Lowering => _loweringElapsed / Config.LoweringSeconds, 
			NetPhase.Soaking => 1.0, 
			NetPhase.Hauling => 1.0 - _haulElapsed / Config.HaulingSeconds, 
			_ => 0.0, 
		};

		public NetCycle()
			: this(new NetCycleConfig())
		{
		}

		public NetCycle(NetCycleConfig config)
		{
			Config = config ?? throw new ArgumentNullException("config");
			Phase = NetPhase.Stowed;
		}

		public void Install(ulong expectedRevision)
		{
			CheckRevision(expectedRevision);
			if (Installed)
			{
				throw ActionError(NetActionError.AlreadyInstalled, "The net is already installed.");
			}
			EnsureRevisionCanAdvance();
			Installed = true;
			AdvanceRevision();
		}

		public void Pack(ulong expectedRevision)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Stowed);
			if (_tickets.Count != 0)
			{
				throw ActionError(NetActionError.WrongPhase, "A net holding tickets cannot be packed.");
			}
			EnsureRevisionCanAdvance();
			Installed = false;
			AdvanceRevision();
		}

		public void Upgrade(ulong expectedRevision, NetCycleConfig configuration)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Stowed);
			if (configuration == null)
			{
				throw new ArgumentNullException("configuration");
			}
			if (_tickets.Count != 0)
			{
				throw ActionError(NetActionError.PendingCatch, "Unload the catch before upgrading the net.");
			}
			EnsureRevisionCanAdvance();
			Config = configuration;
			AdvanceRevision();
		}

		public void BeginLowering(ulong expectedRevision, string deploymentId)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Stowed);
			ValidateId(deploymentId, "deploymentId");
			EnsureRevisionCanAdvance();
			DeploymentId = deploymentId;
			Phase = NetPhase.Lowering;
			ResetCycleValues();
			AdvanceRevision();
		}

		public NetAdvanceResult Advance(ulong expectedRevision, double elapsedSeconds, bool waterSuitable, bool boatMoving, string? activeOperatorId, bool activeOperatorNearby)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			if (Phase != NetPhase.Lowering && Phase != NetPhase.Soaking && Phase != NetPhase.Hauling)
			{
				throw ActionError(NetActionError.WrongPhase, "Only a deployed net can advance.");
			}
			if (!IsFinite(elapsedSeconds) || elapsedSeconds <= 0.0)
			{
				throw ActionError(NetActionError.InvalidArgument, "Elapsed seconds must be finite and positive.");
			}
			EnsureRevisionCanAdvance();
			double num = 0.0;
			num = ((Phase == NetPhase.Lowering) ? AdvanceLowering(elapsedSeconds, waterSuitable, boatMoving) : ((Phase != NetPhase.Soaking) ? AdvanceHauling(elapsedSeconds, activeOperatorId, activeOperatorNearby) : AdvanceSoaking(elapsedSeconds, waterSuitable, boatMoving)));
			AdvanceRevision();
			return new NetAdvanceResult(elapsedSeconds - num, num, CatchDue);
		}

		public void AcceptValidatedCatch(ulong expectedRevision, ulong catchOpportunity, NetCatchTicket ticket)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Soaking);
			RequireCatchOpportunity(catchOpportunity);
			if (ticket == null)
			{
				throw ActionError(NetActionError.InvalidArgument, "A validated ticket is required.");
			}
			if (_tickets.Count >= Config.Capacity)
			{
				throw ActionError(NetActionError.CapacityReached, "The net is full.");
			}
			EnsureRevisionCanAdvance();
			_tickets.Add(CopyTicket(ticket));
			CatchDue = false;
			_soakElapsed = 0.0;
			AdvanceRevision();
		}

		public void SkipCatch(ulong expectedRevision, ulong catchOpportunity)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Soaking);
			RequireCatchOpportunity(catchOpportunity);
			EnsureRevisionCanAdvance();
			CatchDue = false;
			_soakElapsed = 0.0;
			AdvanceRevision();
		}

		public void BeginHaul(ulong expectedRevision, string operatorId)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			if (Phase != NetPhase.Soaking && Phase != NetPhase.Lowering)
			{
				throw ActionError(NetActionError.WrongPhase, "Only a lowering or soaking net can begin retrieval.");
			}
			if (CatchDue)
			{
				throw ActionError(NetActionError.PendingCatch, "Resolve the pending catch before hauling.");
			}
			ValidateId(operatorId, "operatorId");
			EnsureRevisionCanAdvance();
			double deploymentAmount = DeploymentAmount;
			_loweringElapsed = Config.LoweringSeconds;
			_haulElapsed = (1.0 - deploymentAmount) * Config.HaulingSeconds;
			Phase = ((_haulElapsed >= Config.HaulingSeconds) ? NetPhase.Ready : NetPhase.Hauling);
			_activeOperatorId = operatorId;
			_haulPaused = false;
			if (Phase == NetPhase.Ready)
			{
				PauseHaulInternal();
			}
			AdvanceRevision();
		}

		public void PauseHaul(ulong expectedRevision, string operatorId)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Hauling);
			if (_haulPaused)
			{
				throw ActionError(NetActionError.AlreadyPaused, "The haul is already paused.");
			}
			ValidateId(operatorId, "operatorId");
			if (!string.Equals(_activeOperatorId, operatorId, StringComparison.Ordinal))
			{
				throw ActionError(NetActionError.InvalidArgument, "Only the active operator can pause this haul.");
			}
			EnsureRevisionCanAdvance();
			PauseHaulInternal();
			AdvanceRevision();
		}

		public void ResumeHaul(ulong expectedRevision, string operatorId)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Hauling);
			if (!_haulPaused)
			{
				throw ActionError(NetActionError.NotPaused, "The haul is already active.");
			}
			ValidateId(operatorId, "operatorId");
			EnsureRevisionCanAdvance();
			_activeOperatorId = operatorId;
			_haulPaused = false;
			AdvanceRevision();
		}

		public ReadOnlyCollection<NetCatchTicket> Unload(ulong expectedRevision)
		{
			CheckRevision(expectedRevision);
			RequireInstalled();
			RequirePhase(NetPhase.Ready);
			EnsureRevisionCanAdvance();
			NetCatchTicket[] array = new NetCatchTicket[_tickets.Count];
			for (int i = 0; i < _tickets.Count; i++)
			{
				array[i] = CopyTicket(_tickets[i]);
			}
			Phase = NetPhase.Stowed;
			DeploymentId = null;
			ResetCycleValues();
			AdvanceRevision();
			return Array.AsReadOnly(array);
		}

		public NetCycleSnapshot CreateSnapshot()
		{
			List<NetCatchTicketState> list = new List<NetCatchTicketState>(_tickets.Count);
			foreach (NetCatchTicket ticket in _tickets)
			{
				list.Add(new NetCatchTicketState
				{
					ItemId = ticket.ItemId,
					WeightFactor = ticket.WeightFactor,
					IsShiny = ticket.IsShiny
				});
			}
			return new NetCycleSnapshot
			{
				SchemaVersion = 1,
				Config = new NetCycleConfigState
				{
					Capacity = Config.Capacity,
					LoweringSeconds = Config.LoweringSeconds,
					CatchIntervalSeconds = Config.CatchIntervalSeconds,
					HaulingSeconds = Config.HaulingSeconds
				},
				Installed = Installed,
				Phase = Phase,
				DeploymentId = DeploymentId,
				Revision = Revision,
				LoweringElapsedSeconds = _loweringElapsed,
				SoakElapsedSeconds = _soakElapsed,
				HaulElapsedSeconds = _haulElapsed,
				CatchDue = CatchDue,
				OpportunitySequence = _opportunitySequence,
				HaulPaused = (Phase != NetPhase.Hauling || _haulPaused),
				Tickets = list
			};
		}

		public static NetCycle Restore(NetCycleSnapshot snapshot)
		{
			ValidateSnapshotShape(snapshot);
			NetCycleConfigState config = snapshot.Config;
			NetCycle netCycle = new NetCycle(new NetCycleConfig(config.Capacity.GetValueOrDefault(), config.LoweringSeconds.GetValueOrDefault(), config.CatchIntervalSeconds.GetValueOrDefault(), config.HaulingSeconds.GetValueOrDefault()))
			{
				Installed = (snapshot.Installed == true),
				Phase = snapshot.Phase.GetValueOrDefault(),
				DeploymentId = snapshot.DeploymentId,
				Revision = snapshot.Revision.GetValueOrDefault(),
				_loweringElapsed = snapshot.LoweringElapsedSeconds.GetValueOrDefault(),
				_soakElapsed = snapshot.SoakElapsedSeconds.GetValueOrDefault(),
				_haulElapsed = snapshot.HaulElapsedSeconds.GetValueOrDefault(),
				CatchDue = (snapshot.CatchDue == true),
				_opportunitySequence = snapshot.OpportunitySequence.GetValueOrDefault(),
				_haulPaused = (snapshot.HaulPaused == true),
				_activeOperatorId = null
			};
			foreach (NetCatchTicketState ticket in snapshot.Tickets)
			{
				if (ticket == null || !ticket.ItemId.HasValue || !ticket.WeightFactor.HasValue || !ticket.IsShiny.HasValue)
				{
					throw new ArgumentException("Every saved ticket must contain every field.", "snapshot");
				}
				netCycle._tickets.Add(new NetCatchTicket(ticket.ItemId.Value, ticket.WeightFactor.Value, ticket.IsShiny.Value));
			}
			netCycle.ValidateRestoredState();
			if (netCycle.Phase == NetPhase.Hauling)
			{
				netCycle._haulPaused = true;
			}
			return netCycle;
		}

		internal static bool IsFinite(double value)
		{
			if (!double.IsNaN(value))
			{
				return !double.IsInfinity(value);
			}
			return false;
		}

		private double AdvanceLowering(double seconds, bool waterSuitable, bool boatMoving)
		{
			if (!waterSuitable || boatMoving)
			{
				return 0.0;
			}
			double num = Config.LoweringSeconds - _loweringElapsed;
			if (seconds < num)
			{
				_loweringElapsed += seconds;
				return 0.0;
			}
			_loweringElapsed = Config.LoweringSeconds;
			Phase = NetPhase.Soaking;
			double num2 = seconds - num;
			if (!(num2 > 0.0))
			{
				return 0.0;
			}
			return AdvanceSoaking(num2, waterSuitable, boatMoving);
		}

		private double AdvanceSoaking(double seconds, bool waterSuitable, bool boatMoving)
		{
			if (CatchDue)
			{
				return seconds;
			}
			if (_tickets.Count >= Config.Capacity || !waterSuitable || boatMoving)
			{
				return 0.0;
			}
			double num = Config.CatchIntervalSeconds - _soakElapsed;
			if (seconds < num)
			{
				_soakElapsed += seconds;
				return 0.0;
			}
			if (_opportunitySequence == ulong.MaxValue)
			{
				throw ActionError(NetActionError.RevisionOverflow, "The catch opportunity sequence is exhausted.");
			}
			_soakElapsed = Config.CatchIntervalSeconds;
			_opportunitySequence++;
			CatchDue = true;
			return seconds - num;
		}

		private double AdvanceHauling(double seconds, string? operatorId, bool operatorNearby)
		{
			if (_haulPaused)
			{
				return 0.0;
			}
			if (!activeOperatorIsValid(operatorId, operatorNearby))
			{
				PauseHaulInternal();
				return 0.0;
			}
			double num = Config.HaulingSeconds - _haulElapsed;
			if (seconds < num)
			{
				_haulElapsed += seconds;
				return 0.0;
			}
			_haulElapsed = Config.HaulingSeconds;
			Phase = NetPhase.Ready;
			PauseHaulInternal();
			return seconds - num;
		}

		private bool activeOperatorIsValid(string? operatorId, bool nearby)
		{
			if (nearby && operatorId != null)
			{
				return string.Equals(_activeOperatorId, operatorId, StringComparison.Ordinal);
			}
			return false;
		}

		private void RequireCatchOpportunity(ulong catchOpportunity)
		{
			if (!CatchDue)
			{
				throw ActionError(NetActionError.CatchNotDue, "No catch is due.");
			}
			if (catchOpportunity != _opportunitySequence)
			{
				throw ActionError(NetActionError.WrongCatchOpportunity, "The catch opportunity is stale.");
			}
		}

		private void CheckRevision(ulong expectedRevision)
		{
			if (expectedRevision != Revision)
			{
				throw ActionError(NetActionError.StaleRevision, "The action revision is stale.");
			}
		}

		private void EnsureRevisionCanAdvance()
		{
			if (Revision == ulong.MaxValue)
			{
				throw ActionError(NetActionError.RevisionOverflow, "The action revision is exhausted.");
			}
		}

		private void AdvanceRevision()
		{
			Revision++;
		}

		private void RequireInstalled()
		{
			if (!Installed)
			{
				throw ActionError(NetActionError.NotInstalled, "The net is not installed.");
			}
		}

		private void RequirePhase(NetPhase phase)
		{
			if (Phase != phase)
			{
				throw ActionError(NetActionError.WrongPhase, $"Expected {phase}; current phase is {Phase}.");
			}
		}

		private static void ValidateId(string value, string name)
		{
			if (string.IsNullOrWhiteSpace(value) || value.Length > 128)
			{
				throw ActionError(NetActionError.InvalidArgument, $"{name} must be nonblank and at most {128} characters.");
			}
		}

		private static NetActionException ActionError(NetActionError error, string message)
		{
			return new NetActionException(error, message);
		}

		private static NetCatchTicket CopyTicket(NetCatchTicket ticket)
		{
			return new NetCatchTicket(ticket.ItemId, ticket.WeightFactor, ticket.IsShiny);
		}

		private void PauseHaulInternal()
		{
			_haulPaused = true;
			_activeOperatorId = null;
		}

		private void ResetCycleValues()
		{
			_tickets.Clear();
			_loweringElapsed = 0.0;
			_soakElapsed = 0.0;
			_haulElapsed = 0.0;
			_opportunitySequence = 0uL;
			CatchDue = false;
			PauseHaulInternal();
		}

		private static void ValidateSnapshotShape(NetCycleSnapshot snapshot)
		{
			if (snapshot == null)
			{
				throw new ArgumentNullException("snapshot");
			}
			if (!snapshot.SchemaVersion.HasValue || snapshot.SchemaVersion.Value != 1)
			{
				throw new ArgumentException("The net snapshot schema is missing or unsupported.", "snapshot");
			}
			if (snapshot.Config == null || !snapshot.Config.Capacity.HasValue || !snapshot.Config.LoweringSeconds.HasValue || !snapshot.Config.CatchIntervalSeconds.HasValue || !snapshot.Config.HaulingSeconds.HasValue)
			{
				throw new ArgumentException("The net configuration is incomplete.", "snapshot");
			}
			if (!snapshot.Installed.HasValue || !snapshot.Phase.HasValue || !snapshot.Revision.HasValue || !snapshot.LoweringElapsedSeconds.HasValue || !snapshot.SoakElapsedSeconds.HasValue || !snapshot.HaulElapsedSeconds.HasValue || !snapshot.CatchDue.HasValue || !snapshot.OpportunitySequence.HasValue || !snapshot.HaulPaused.HasValue || snapshot.Tickets == null)
			{
				throw new ArgumentException("The net snapshot is incomplete.", "snapshot");
			}
			if (!Enum.IsDefined(typeof(NetPhase), snapshot.Phase.Value))
			{
				throw new ArgumentException("The net phase is invalid.", "snapshot");
			}
		}

		private void ValidateRestoredState()
		{
			if (_tickets.Count > Config.Capacity)
			{
				throw new ArgumentException("The saved net exceeds its capacity.");
			}
			if (!ValidElapsed(_loweringElapsed, Config.LoweringSeconds) || !ValidElapsed(_soakElapsed, Config.CatchIntervalSeconds) || !ValidElapsed(_haulElapsed, Config.HaulingSeconds))
			{
				throw new ArgumentException("A saved timer is outside its valid range.");
			}
			bool flag = !string.IsNullOrWhiteSpace(DeploymentId) && DeploymentId.Length <= 128;
			if (!Installed)
			{
				if (Phase != NetPhase.Stowed)
				{
					throw new ArgumentException("An uninstalled net must be stowed.");
				}
				ValidateEmptyStowedState();
				return;
			}
			switch (Phase)
			{
			case NetPhase.Stowed:
				ValidateEmptyStowedState();
				break;
			case NetPhase.Lowering:
				if (!flag || _loweringElapsed >= Config.LoweringSeconds || _soakElapsed != 0.0 || _haulElapsed != 0.0 || CatchDue || _opportunitySequence != 0L || _tickets.Count != 0 || !_haulPaused)
				{
					throw new ArgumentException("The lowering state is inconsistent.");
				}
				break;
			case NetPhase.Soaking:
				if (!flag || _loweringElapsed != Config.LoweringSeconds || _haulElapsed != 0.0 || !_haulPaused || (CatchDue && (_soakElapsed != Config.CatchIntervalSeconds || _opportunitySequence == 0L)) || (!CatchDue && _soakElapsed >= Config.CatchIntervalSeconds) || (_tickets.Count >= Config.Capacity && CatchDue))
				{
					throw new ArgumentException("The soaking state is inconsistent.");
				}
				break;
			case NetPhase.Hauling:
				if (!flag || _loweringElapsed != Config.LoweringSeconds || _haulElapsed >= Config.HaulingSeconds || CatchDue || _soakElapsed >= Config.CatchIntervalSeconds)
				{
					throw new ArgumentException("The hauling state is inconsistent.");
				}
				break;
			case NetPhase.Ready:
				if (!flag || _loweringElapsed != Config.LoweringSeconds || _haulElapsed != Config.HaulingSeconds || CatchDue || _soakElapsed >= Config.CatchIntervalSeconds || !_haulPaused)
				{
					throw new ArgumentException("The ready state is inconsistent.");
				}
				break;
			default:
				throw new ArgumentException("The net phase is invalid.");
			}
		}

		private void ValidateEmptyStowedState()
		{
			if (DeploymentId != null || _tickets.Count != 0 || _loweringElapsed != 0.0 || _soakElapsed != 0.0 || _haulElapsed != 0.0 || CatchDue || _opportunitySequence != 0L || !_haulPaused)
			{
				throw new ArgumentException("The stowed state is inconsistent.");
			}
		}

		private static bool ValidElapsed(double value, double maximum)
		{
			if (IsFinite(value) && value >= 0.0)
			{
				return value <= maximum;
			}
			return false;
		}
	}
	public sealed class NetCycleSnapshot
	{
		public int? SchemaVersion { get; set; }

		public NetCycleConfigState? Config { get; set; }

		public bool? Installed { get; set; }

		public NetPhase? Phase { get; set; }

		public string? DeploymentId { get; set; }

		public ulong? Revision { get; set; }

		public double? LoweringElapsedSeconds { get; set; }

		public double? SoakElapsedSeconds { get; set; }

		public double? HaulElapsedSeconds { get; set; }

		public bool? CatchDue { get; set; }

		public ulong? OpportunitySequence { get; set; }

		public bool? HaulPaused { get; set; }

		public List<NetCatchTicketState>? Tickets { get; set; }
	}
	public sealed class NetCycleConfigState
	{
		public int? Capacity { get; set; }

		public double? LoweringSeconds { get; set; }

		public double? CatchIntervalSeconds { get; set; }

		public double? HaulingSeconds { get; set; }
	}
	public sealed class NetCatchTicketState
	{
		public byte? ItemId { get; set; }

		public double? WeightFactor { get; set; }

		public bool? IsShiny { get; set; }
	}
	public sealed class NetEquipmentTier
	{
		public int Level { get; }

		public string Title { get; }

		public int Cost { get; }

		public int NativeIsland { get; }

		public int Capacity { get; }

		public double HaulingSeconds { get; }

		internal NetEquipmentTier(int level, string title, int cost, int nativeIsland, int capacity, double haulingSeconds)
		{
			Level = level;
			Title = title;
			Cost = cost;
			NativeIsland = nativeIsland;
			Capacity = capacity;
			HaulingSeconds = haulingSeconds;
		}

		public NetCycleConfig Configuration()
		{
			return new NetCycleConfig(Capacity, 8.0, 14.0, HaulingSeconds);
		}
	}
	public static class NetEquipment
	{
		public const int MaximumTier = 3;

		private static readonly NetEquipmentTier[] tiers = new NetEquipmentTier[3]
		{
			new NetEquipmentTier(1, "Tidehaul Net Winch", 1200, 3, 3, 24.0),
			new NetEquipmentTier(2, "Geared Net Winch", 2000, 4, 3, 16.0),
			new NetEquipmentTier(3, "Reinforced Net", 3500, 5, 5, 16.0)
		};

		public static NetEquipmentTier Tier(int level)
		{
			if (level < 1 || level > 3)
			{
				throw new ArgumentOutOfRangeException("level");
			}
			return tiers[level - 1];
		}

		public static string? DrivingBlock(bool installed, NetPhase phase)
		{
			if (!Enum.IsDefined(typeof(NetPhase), phase))
			{
				throw new ArgumentOutOfRangeException("phase");
			}
			if (!installed || phase == NetPhase.Stowed)
			{
				return null;
			}
			return "Haul, unload and stow the net before driving the boat.";
		}

		public static string? PurchaseBlock(int ownedTier, int requestedTier, int shopMaximumTier, bool boatUnlocked, NetPhase phase, int money)
		{
			if (ownedTier < 0 || ownedTier > 3 || shopMaximumTier < 1 || shopMaximumTier > 3 || money < 0 || !Enum.IsDefined(typeof(NetPhase), phase))
			{
				throw new ArgumentOutOfRangeException("ownedTier");
			}
			if (requestedTier < 1 || requestedTier > 3)
			{
				return "That net upgrade is unavailable.";
			}
			if (!boatUnlocked)
			{
				return "Unlock the crew's boat before buying equipment.";
			}
			if (requestedTier <= ownedTier)
			{
				return "The crew already owns this net upgrade.";
			}
			if (requestedTier != ownedTier + 1)
			{
				return "Buy the preceding net upgrade first.";
			}
			if (requestedTier > shopMaximumTier)
			{
				return "This dock does not stock that net upgrade.";
			}
			if (phase != NetPhase.Stowed)
			{
				return "Haul and unload the net before upgrading it.";
			}
			if (money < Tier(requestedTier).Cost)
			{
				return "The crew cannot afford this net upgrade.";
			}
			return null;
		}

		public static int RestoreTier(int schemaVersion, int? savedTier, NetCycleSnapshot snapshot)
		{
			NetCycle netCycle = NetCycle.Restore(snapshot);
			int num;
			if (schemaVersion == 1 && !savedTier.HasValue)
			{
				num = (netCycle.Installed ? 1 : 0);
			}
			else
			{
				if (schemaVersion != 2 || !savedTier.HasValue)
				{
					throw new InvalidDataException("The saved net equipment schema is unsupported or incomplete.");
				}
				num = savedTier.Value;
			}
			if (num < 0 || num > 3 || netCycle.Installed != (num != 0))
			{
				throw new InvalidDataException("The saved net tier does not match its installation.");
			}
			NetCycleConfig netCycleConfig = Tier(Math.Max(1, num)).Configuration();
			if (netCycle.Config.Capacity != netCycleConfig.Capacity || netCycle.Config.LoweringSeconds != netCycleConfig.LoweringSeconds || netCycle.Config.CatchIntervalSeconds != netCycleConfig.CatchIntervalSeconds || netCycle.Config.HaulingSeconds != netCycleConfig.HaulingSeconds)
			{
				throw new InvalidDataException("The saved net tuning does not match its purchased tier.");
			}
			return num;
		}
	}
	public enum NetMotionStage
	{
		AboveRailTransfer,
		OutboardDescent
	}
	public readonly struct NetMotionBounds
	{
		public Vector3 Min { get; }

		public Vector3 Max { get; }

		public NetMotionBounds(Vector3 min, Vector3 max)
		{
			if (!NetMotionPlanner.IsFinite(min) || !NetMotionPlanner.IsFinite(max) || min.X >= max.X || min.Y >= max.Y || min.Z >= max.Z)
			{
				throw new ArgumentOutOfRangeException("min");
			}
			Min = min;
			Max = max;
		}
	}
	public readonly struct NetMotionPose
	{
		public Vector3 Position { get; }

		public NetMotionStage Stage { get; }

		public float SlewRadians { get; }

		internal NetMotionPose(Vector3 position, NetMotionStage stage, float slewRadians = 0f)
		{
			Position = position;
			Stage = stage;
			SlewRadians = slewRadians;
		}
	}
	public sealed class NetMotionPlanner
	{
		public const float TransferFraction = 0.22f;

		public const float VerticalClearance = 0.12f;

		public const float HorizontalClearance = 0.08f;

		public const float HoistRopeLength = 0.3f;

		public static NetMotionBounds AuthoredNetBounds { get; } = new NetMotionBounds(new Vector3(-0.727f, -0.775f, -0.624f), new Vector3(0.727f, 0.562f, 0.624f));

		public Vector3 Delivery { get; }

		public Vector3 Pivot { get; }

		public float DeliveryYaw { get; }

		public Vector3 OutboardClear { get; }

		public Vector3 Submerged { get; }

		public float RailX { get; }

		public float RailTop { get; }

		public int OutboardSign { get; }

		public NetMotionBounds Bounds { get; }

		public NetMotionPlanner(Vector3 pivot, float deliveryYaw, Vector3 outboardClear, Vector3 submerged, float railX, float railTop, int outboardSign, NetMotionBounds bounds)
		{
			if (!IsFinite(pivot) || !Finite(deliveryYaw) || Math.Abs(deliveryYaw) < 0.05f || (double)Math.Abs(deliveryYaw) > Math.PI || !IsFinite(outboardClear) || !IsFinite(submerged) || !Finite(railX) || !Finite(railTop) || (outboardSign != -1 && outboardSign != 1))
			{
				throw new ArgumentOutOfRangeException("pivot");
			}
			if (bounds.Min.X >= bounds.Max.X || bounds.Min.Y >= bounds.Max.Y || bounds.Min.Z >= bounds.Max.Z)
			{
				throw new ArgumentOutOfRangeException("bounds");
			}
			if (Math.Abs(outboardClear.X - submerged.X) > 0.001f || Math.Abs(outboardClear.Z - submerged.Z) > 0.001f || submerged.Y >= outboardClear.Y)
			{
				throw new ArgumentException("The submerged leg must descend vertically from the outboard clearance point.");
			}
			float num = ((outboardSign < 0) ? (outboardClear.X + bounds.Max.X) : (outboardClear.X + bounds.Min.X));
			float num2 = (float)outboardSign * (num - railX);
			if (num2 < 0.08f)
			{
				throw new ArgumentException("The vertical hoist leg does not keep the whole net outboard of the rail " + $"(inner edge {num:F3} m, rail {railX:F3} m, clearance {num2:F3} m, " + $"required {0.08f:F3} m).");
			}
			Vector3 vector = SwingPosition(pivot, outboardClear, deliveryYaw);
			float num3 = outboardClear.Y + bounds.Min.Y;
			float num4 = railTop + 0.12f;
			if (num3 < num4)
			{
				throw new ArgumentException("The transfer leg does not lift the whole net above the rail " + $"(lowest point {num3:F3} m, rail top {railTop:F3} m, required {num4:F3} m).");
			}
			if ((float)outboardSign * (vector.X - outboardClear.X) >= 0f)
			{
				throw new ArgumentException("The delivery point must be inboard of the vertical hoist leg.");
			}
			Delivery = vector;
			Pivot = pivot;
			DeliveryYaw = deliveryYaw;
			OutboardClear = outboardClear;
			Submerged = submerged;
			RailX = railX;
			RailTop = railTop;
			OutboardSign = outboardSign;
			Bounds = bounds;
		}

		public NetMotionPose Sample(float deploymentAmount)
		{
			if (!Finite(deploymentAmount) || deploymentAmount < 0f || deploymentAmount > 1f)
			{
				throw new ArgumentOutOfRangeException("deploymentAmount");
			}
			if (deploymentAmount <= 0.22f)
			{
				float num = DeliveryYaw * (1f - Smooth(deploymentAmount / 0.22f));
				return new NetMotionPose(SwingPosition(Pivot, OutboardClear, num), NetMotionStage.AboveRailTransfer, num);
			}
			float amount = Smooth((deploymentAmount - 0.22f) / 0.78f);
			return new NetMotionPose(Vector3.Lerp(OutboardClear, Submerged, amount), NetMotionStage.OutboardDescent);
		}

		public static Vector3 SwingPosition(Vector3 pivot, Vector3 outboardClear, float yaw)
		{
			if (!IsFinite(pivot) || !IsFinite(outboardClear) || !Finite(yaw))
			{
				throw new ArgumentOutOfRangeException("pivot");
			}
			return pivot + Vector3.Transform(outboardClear - pivot, Quaternion.CreateFromAxisAngle(Vector3.UnitY, yaw));
		}

		public Vector3 RopeEnd(float deploymentAmount, Vector3 hoistOffset)
		{
			if (!IsFinite(hoistOffset))
			{
				throw new ArgumentOutOfRangeException("hoistOffset");
			}
			return Sample(deploymentAmount).Position + hoistOffset;
		}

		public NetMotionBounds BoundsAt(float deploymentAmount)
		{
			Vector3 position = Sample(deploymentAmount).Position;
			return new NetMotionBounds(position + Bounds.Min, position + Bounds.Max);
		}

		public bool ClearsRail(float deploymentAmount)
		{
			NetMotionPose netMotionPose = Sample(deploymentAmount);
			if (netMotionPose.Stage == NetMotionStage.AboveRailTransfer)
			{
				return netMotionPose.Position.Y + Bounds.Min.Y >= RailTop + 0.12f - 0.0001f;
			}
			float num = ((OutboardSign < 0) ? (netMotionPose.Position.X + Bounds.Max.X) : (netMotionPose.Position.X + Bounds.Min.X));
			return (float)OutboardSign * (num - RailX) >= 0.0799f;
		}

		public static Vector3 Transform(Vector3 local, Vector3 origin, Quaternion rotation)
		{
			if (!IsFinite(local) || !IsFinite(origin) || !Finite(rotation.X) || !Finite(rotation.Y) || !Finite(rotation.Z) || !Finite(rotation.W) || rotation.LengthSquared() < 0.999f || rotation.LengthSquared() > 1.001f)
			{
				throw new ArgumentOutOfRangeException("rotation");
			}
			return origin + Vector3.Transform(local, rotation);
		}

		private static float Smooth(float value)
		{
			return value * value * (3f - 2f * value);
		}

		internal static bool IsFinite(Vector3 value)
		{
			if (Finite(value.X) && Finite(value.Y))
			{
				return Finite(value.Z);
			}
			return false;
		}

		private static bool Finite(float value)
		{
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}
	}
	public static class NetSaveRevision
	{
		public static bool Accept(string key, string version, string fingerprint, IReadOnlyDictionary<string, string> code)
		{
			if (key != "tidehaul_nets" || code == null || code.Count != 2 || !code.TryGetValue("TidehaulNets", out string value) || !code.TryGetValue("TidehaulNets.Core", out string value2))
			{
				return false;
			}
			return version switch
			{
				"0.1.0" => fingerprint == "f0de0fe65fd588acf8471443a7a9c06bb371dfb8125be35a660f6ea37cc970cd" && value == "39DF9CA789BF9639121A1A60A6561DA85CD772E19FD2ACCD76A1EF71880A69D3" && value2 == "1F8F4001A943D96462FAC6A617E91628C83613CA061F1A36B73133FF1F081068", 
				"0.1.1" => fingerprint == "3aa86b4683cb0bfc87a350089f958dba237732515a2e21f23c61b34cc34c6671" && value == "4BFE658F9FA056F8FF01D4735937C72023E33B63CDE6C1FB47080A5A1419FCE6" && value2 == "033D34E5896B7B9C4B32066A6E83C4309C03A00B177E8A7FB26F0A861C13C29D", 
				"0.2.0" => fingerprint == "59337ff742ba6d1973a677422696654746c57bb482b7f9347da60abf98c9a40f" && value == "3729C46B01F282BA81B8F259382EDEE411DF2522471816F882473C9F021D1B9D" && value2 == "47776D90AD676C10306EF49D8D760ABFE3D9EFFE7EE64DA4D88037AB10C7B11A", 
				"0.2.1" => fingerprint == "e4e0c2fa2cbbe1f0c6d97f7caa6bb7dc135d5d371cbeee38406b17b86d988594" && value == "19841BDB2B5E61FDFEDF439511697891D929519B5BD93C44326D095FCD22D435" && value2 == "F1C98231E13D91BB344326EA9E4DB50B9CBFFA8AC5E26278140A2FBEBC32098D", 
				"0.2.2" => fingerprint == "31b1eb65a5a499e3f93a0e359bcbaff52886dfb60d6ef93a9ea55b4ab5514a05" && value == "BCCBE61F8C70F1B75D100FC01B07877F24A22B950F35115B81FAB56BD0598B7A" && value2 == "8CC9BCD351418FABEB3C8B1B6772CD55EBFF34714F17121C1F7DE38C3BAB71BA", 
				"0.2.3" => fingerprint == "0780c25c76f291b844a7f3a9ced066b7eec55a215977ea7ad514d8a76e7c60b1" && ((value == "A6E1D77CF3D25F5AE1070457DC8C5BCACFF221F2FBBFB8BF817199061997ABA0" && value2 == "185061B08F6C4BDF2BF0E7B40247522A70BE7227A0791DF11FB2B2281D740213") || (value == "5E9EEFF81308069B5E4A4E6E42ABE58FBF1990BBFB6C0284019C9FE8D634E7CB" && value2 == "8EBF58544EDDAD9931B9718345C362165DBFEFE081CCE15E3148867D27F08A28")), 
				_ => false, 
			};
		}
	}
}

BepInEx/plugins/TidehaulNets/TidehaulNets.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using FishNet.Object;
using HowToFish.ExpansionKit.Packs;
using HowToFish.ExpansionKit.Runtime;
using HowToFish.ExpansionKit.Runtime.Content;
using HowToFish.ExpansionKit.Runtime.Networking;
using HowToFish.ExpansionKit.Runtime.Persistence;
using HowToFish.ExpansionKit.Runtime.Rendering;
using HowToFish.ExpansionKit.Runtime.Shops;
using HowToFish.ExpansionKit.Runtime.World;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TidehaulNets.Core;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TidehaulNets")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.3.0")]
[assembly: AssemblyInformationalVersion("0.2.3")]
[assembly: AssemblyProduct("TidehaulNets")]
[assembly: AssemblyTitle("TidehaulNets")]
[assembly: AssemblyVersion("0.2.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TidehaulNets
{
	internal sealed class NetAssets : IPackAssetFactory, IDisposable
	{
		internal const string BundleName = "tidehaul.models";

		private readonly AssetBundle bundle;

		private readonly NativeSceneMaterials materials = new NativeSceneMaterials();

		private readonly Dictionary<string, GameObject> prefabs = new Dictionary<string, GameObject>(StringComparer.Ordinal);

		internal string Root { get; }

		internal string Hash { get; }

		internal NetAssets()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Root = Path.GetDirectoryName(typeof(Plugin).Assembly.Location);
			string text = Path.Combine(Root, "tidehaul.models");
			Hash = PackSource.FileHash(text).ToLowerInvariant();
			bundle = AssetBundle.LoadFromFile(text);
			if (!Object.op_Implicit((Object)(object)bundle))
			{
				throw new InvalidDataException("The original Tidehaul Nets bundle could not be loaded.");
			}
			string[] array = new string[6] { "tidehaul_kit", "tidehaul_winch", "tidehaul_net", "tidehaul_net_stowed", "tidehaul_buoy", "tidehaul_tray" };
			foreach (string text2 in array)
			{
				GameObject val = bundle.LoadAsset<GameObject>(text2);
				if (!Object.op_Implicit((Object)(object)val) || val.GetComponentsInChildren<MonoBehaviour>(true).Length != 0 || val.GetComponentsInChildren<Collider>(true).Length != 0)
				{
					throw new InvalidDataException("The original net art is missing or contains unsupported runtime components: " + text2);
				}
				materials.Apply(val);
				prefabs.Add(text2, val);
			}
		}

		public GameObject Instantiate(string packKey, ArtRecipe art)
		{
			if (packKey != "tidehaul_nets" || art.Bundle != "tidehaul.models" || art.Sha256 != Hash)
			{
				throw new InvalidDataException("The net art does not match its registered pack.");
			}
			return Create(art.Prefab);
		}

		internal GameObject Create(string key)
		{
			if (!prefabs.TryGetValue(key, out GameObject value))
			{
				throw new KeyNotFoundException("Unknown net model: " + key);
			}
			GameObject obj = Object.Instantiate<GameObject>(value);
			obj.SetActive(false);
			return obj;
		}

		internal static Bounds BoundsOf(GameObject model)
		{
			//IL_0045: 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_005b: 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_00c1: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			MeshFilter[] componentsInChildren = model.GetComponentsInChildren<MeshFilter>(true);
			if (componentsInChildren.Length == 0)
			{
				throw new InvalidDataException("The original model has no measurable rendered geometry.");
			}
			Bounds? val = null;
			MeshFilter[] array = componentsInChildren;
			foreach (MeshFilter val2 in array)
			{
				if (!Object.op_Implicit((Object)(object)val2.sharedMesh))
				{
					throw new InvalidDataException("An original mesh is missing.");
				}
				Bounds val3 = NativeSceneMeshes.TransformBounds(val2.sharedMesh.bounds, model.transform.worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix);
				if (!val.HasValue)
				{
					val = val3;
					continue;
				}
				Bounds value = val.Value;
				((Bounds)(ref value)).Encapsulate(val3);
				val = value;
			}
			return val ?? throw new InvalidDataException("The original model has no mesh bounds.");
		}

		public void Dispose()
		{
			materials.Dispose();
			if (Object.op_Implicit((Object)(object)bundle))
			{
				bundle.Unload(false);
			}
		}
	}
	internal sealed class NetBoatView : IDisposable
	{
		private readonly NetRuntime runtime;

		private readonly GameObject winch;

		private readonly GameObject net;

		private readonly GameObject stowed;

		private readonly GameObject buoy;

		private readonly GameObject fastUpgrade;

		private readonly GameObject capacityUpgrade;

		private readonly Rigidbody body;

		private readonly LineRenderer rope;

		private readonly LineRenderer guideRope;

		private readonly LineRenderer buoyRope;

		private readonly Transform buoyAttachment;

		private readonly Material ropeMaterial;

		private readonly AudioSource haulingSound;

		private readonly Transform lineExit;

		private readonly Transform fairlead;

		private readonly Transform mastBlock;

		private readonly Transform mastFeed;

		private readonly Transform boomBlock;

		private readonly Transform slew;

		private readonly Vector3 slewLocal;

		private readonly float deliveryYaw;

		private readonly Vector3 baseLocal;

		private readonly Vector3 stowedLocal;

		private readonly Vector3 deliveryLocal;

		private readonly Vector3 outboardClearLocal;

		private readonly Vector3 dischargeLocal;

		private readonly Vector3 hoistLocal;

		private readonly Vector3[] catchLocals;

		private readonly Vector3 controlLocal;

		private readonly float railLocalX;

		private readonly float railTopLocal;

		private readonly Transform? crank;

		private readonly Transform? drum;

		private readonly List<GameObject> fish = new List<GameObject>();

		private string tickets = "";

		private bool wasDeployed;

		private float displayedDeployment;

		private bool disposed;

		internal BoatMount Mount { get; }

		internal PackControl Primary { get; }

		internal Vector3 ControlLocal => controlLocal;

		internal Vector3 NetPosition => net.transform.position;

		internal Quaternion NetRotation => net.transform.rotation;

		internal bool WaterSuitable
		{
			get
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: 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_007a: 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_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_00a2: 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)
				Vector3 val = Mount.PhysicsPoint(outboardClearLocal);
				Vector3 val2 = Mount.PhysicsPoint(new Vector3(baseLocal.x, railTopLocal, baseLocal.z));
				if (Vector3.Dot(((Component)Mount.Physics).transform.up, Vector3.up) < 0.65f || val2.y < WaterManager.WaterHeight - 0.3f)
				{
					return false;
				}
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(new Vector3(val.x, WaterManager.WaterHeight + 8f, val.z), Vector3.down, ref val3, 20f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1))
				{
					return ((RaycastHit)(ref val3)).point.y < WaterManager.WaterHeight - 2.7f;
				}
				return true;
			}
		}

		internal Vector3 DischargePosition
		{
			get
			{
				//IL_001c: 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_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				BoatMount mount = Mount;
				float x = dischargeLocal.x;
				float y = deliveryLocal.y;
				NetMotionBounds authoredNetBounds = NetMotionPlanner.AuthoredNetBounds;
				return mount.PhysicsPoint(new Vector3(x, y + ((NetMotionBounds)(ref authoredNetBounds)).Min.Y - 0.1f, dischargeLocal.z));
			}
		}

		internal NetBoatView(NetRuntime runtime, BoatMount mount, NetAssets assets)
		{
			//IL_006a: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Expected O, but got Unknown
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Expected O, but got Unknown
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Expected O, but got Unknown
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_072d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0732: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_088d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0903: Unknown result type (might be due to invalid IL or missing references)
			//IL_0917: Unknown result type (might be due to invalid IL or missing references)
			//IL_0943: Unknown result type (might be due to invalid IL or missing references)
			//IL_095c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0973: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09be: Expected O, but got Unknown
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Expected O, but got Unknown
			//IL_0aa1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa8: Expected O, but got Unknown
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bab: Unknown result type (might be due to invalid IL or missing references)
			NetBoatView netBoatView = this;
			this.runtime = runtime;
			Mount = mount;
			mount.Root.localRotation = Quaternion.Euler(0f, -90f, 0f);
			if (!mount.TryDeck(new Vector3(-0.85f, 0f, -2.2f), ref baseLocal))
			{
				throw new InvalidOperationException("The native boat has no supported stern equipment mount. Hull=" + ((object)mount.Boat.Mesh.bounds/*cast due to .constrained prefix*/).ToString() + "; root=" + ((object)mount.Root.position/*cast due to .constrained prefix*/).ToString() + "; rotation=" + ((object)mount.Root.eulerAngles/*cast due to .constrained prefix*/).ToString() + "; physics=" + ((object)mount.Physics.position/*cast due to .constrained prefix*/).ToString() + "; colliders=" + BoatManager.ColToBoat.Count);
			}
			baseLocal += Vector3.up * 0.015f;
			winch = Place(assets.Create("tidehaul_winch"), mount.Root, baseLocal);
			winch.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			lineExit = Find(winch, "line_exit") ?? throw new InvalidOperationException("The davit line exit is missing.");
			fairlead = Find(winch, "fairlead") ?? throw new InvalidOperationException("The winch fairlead is missing.");
			mastBlock = Find(winch, "mast_block") ?? throw new InvalidOperationException("The davit mast block is missing.");
			mastFeed = Find(winch, "mast_feed") ?? throw new InvalidOperationException("The fixed mast feed is missing.");
			boomBlock = Find(winch, "boom_block") ?? throw new InvalidOperationException("The boom pulley inlet is missing.");
			Transform? obj = Find(winch, "upgrade_fast_collar");
			fastUpgrade = ((obj != null) ? ((Component)obj).gameObject : null) ?? throw new InvalidOperationException("The geared-winch visual marker is missing.");
			Transform? obj2 = Find(winch, "upgrade_capacity_collar");
			capacityUpgrade = ((obj2 != null) ? ((Component)obj2).gameObject : null) ?? throw new InvalidOperationException("The reinforced-net visual marker is missing.");
			Transform val = Find(winch, "control") ?? throw new InvalidOperationException("The winch control marker is missing.");
			controlLocal = mount.Root.InverseTransformPoint(val.position);
			crank = Pivot(winch, "anchor_crank", "crank");
			drum = Pivot(winch, "anchor_reel", "drum");
			slew = Pivot(winch, "anchor_slew", "slew");
			slewLocal = mount.Root.InverseTransformPoint(slew.position);
			lineExit.SetParent(slew, true);
			mastBlock.SetParent(slew, true);
			boomBlock.SetParent(slew, true);
			(Find(winch, "boom_tip") ?? throw new InvalidOperationException("The boom tip is missing.")).SetParent(slew, true);
			stowed = assets.Create("tidehaul_net_stowed");
			Quaternion val2 = Quaternion.Euler(0f, 90f, 0f);
			Bounds folded = NativeSceneMeshes.TransformBounds(NetAssets.BoundsOf(stowed), Matrix4x4.Rotate(val2));
			stowedLocal = FindStowedDeck(mount, folded);
			Place(stowed, mount.Root, stowedLocal);
			stowed.transform.localRotation = val2;
			Shader val3 = Shader.Find("Universal Render Pipeline/Lit");
			if (!Object.op_Implicit((Object)(object)val3))
			{
				throw new InvalidOperationException("The native rope shader is unavailable.");
			}
			ropeMaterial = new Material(val3);
			ropeMaterial.SetColor("_BaseColor", new Color(0.62f, 0.49f, 0.27f));
			ropeMaterial.SetFloat("_Smoothness", 0f);
			GameObject[] array = (from renderer in winch.GetComponentsInChildren<Renderer>(true)
				select ((Component)renderer).gameObject).ToArray();
			Primary = PackControl.Create(mount.Root, "Operate net winch", ControlLocal, new Vector3(0.5f, 0.55f, 0.45f), array, (Func<Player, string>)((Player _) => runtime.Label()), (Action<Player>)delegate
			{
				runtime.UsePrimary();
			}, (Func<Player, bool>)null);
			AudioSource val4 = NativeAccess.Get<AudioSource>((object)(FishingRod)GameInfo.GetSpawnable((byte)61), "_slowReelSource");
			if (!Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val4.clip))
			{
				throw new InvalidOperationException("The native reel sound is unavailable.");
			}
			haulingSound = winch.AddComponent<AudioSource>();
			haulingSound.clip = val4.clip;
			haulingSound.outputAudioMixerGroup = val4.outputAudioMixerGroup;
			haulingSound.loop = true;
			haulingSound.playOnAwake = false;
			haulingSound.spatialBlend = 1f;
			haulingSound.minDistance = 1f;
			haulingSound.maxDistance = 12f;
			haulingSound.volume = 0.16f;
			haulingSound.pitch = 0.65f;
			net = new GameObject("Tidehaul environmental net");
			net.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)net);
			GameObject model = Place(assets.Create("tidehaul_net"), net.transform, Vector3.zero);
			((Object)model).name = "Net mesh";
			Transform val5 = Find(model, "hoist") ?? throw new InvalidOperationException("The authored net has no hoist marker.");
			hoistLocal = net.transform.InverseTransformPoint(val5.position);
			catchLocals = Enumerable.Range(0, 5).Select(delegate(int index)
			{
				//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)
				Transform val11 = Find(model, "catch_" + (char)(97 + index)) ?? throw new InvalidOperationException("The authored net is missing catch marker " + (index + 1) + ".");
				return netBoatView.net.transform.InverseTransformPoint(val11.position);
			}).ToArray();
			Vector3 val6 = mount.Root.InverseTransformPoint(lineExit.position);
			outboardClearLocal = val6 - hoistLocal - Vector3.up * 0.3f;
			Vector3 val7 = FindSlewDelivery(mount, out deliveryYaw);
			deliveryLocal = new Vector3(val7.x, outboardClearLocal.y, val7.z);
			MeasureGunwale(mount, out railLocalX, out railTopLocal);
			CreateMotionPlan(WaterManager.WaterHeight);
			dischargeLocal = FindDeckPosition(mount, deliveryLocal, (IEnumerable<Vector3>)(object)new Vector3[3]
			{
				new Vector3(0.3f, 0f, 0.05f),
				new Vector3(0.12f, 0f, 0.22f),
				new Vector3(0.12f, 0f, -0.22f)
			}, "catch discharge", baseLocal.y + 0.2f);
			body = net.AddComponent<Rigidbody>();
			body.mass = 4f;
			body.linearDamping = 2f;
			body.angularDamping = 6f;
			body.constraints = (RigidbodyConstraints)112;
			body.isKinematic = true;
			body.useGravity = false;
			body.collisionDetectionMode = (CollisionDetectionMode)3;
			AddRim(new Vector3(0f, 0f, -0.6f), new Vector3(1.4f, 0.055f, 0.055f));
			AddRim(new Vector3(0f, 0f, 0.6f), new Vector3(1.4f, 0.055f, 0.055f));
			AddRim(new Vector3(-0.7f, 0f, 0f), new Vector3(0.055f, 0.055f, 1.2f));
			AddRim(new Vector3(0.7f, 0f, 0f), new Vector3(0.055f, 0.055f, 1.2f));
			BoxCollider obj3 = net.AddComponent<BoxCollider>();
			((Collider)obj3).isTrigger = true;
			obj3.center = new Vector3(0f, -0.34f, 0f);
			obj3.size = new Vector3(1.3f, 0.72f, 1.1f);
			buoy = Place(assets.Create("tidehaul_buoy"), null, Vector3.zero);
			Object.DontDestroyOnLoad((Object)(object)buoy);
			buoyAttachment = Find(buoy, "line_bottom") ?? throw new InvalidOperationException("The original buoy has no lower tether eye.");
			GameObject val8 = new GameObject("Tidehaul rope");
			val8.transform.SetParent(mount.Root, false);
			rope = val8.AddComponent<LineRenderer>();
			((Renderer)rope).sharedMaterial = ropeMaterial;
			rope.positionCount = 3;
			rope.startWidth = (rope.endWidth = 0.028f);
			rope.useWorldSpace = true;
			GameObject val9 = new GameObject("Tidehaul davit line");
			val9.transform.SetParent(mount.Root, false);
			guideRope = val9.AddComponent<LineRenderer>();
			((Renderer)guideRope).sharedMaterial = ropeMaterial;
			guideRope.positionCount = 6;
			guideRope.startWidth = (guideRope.endWidth = 0.025f);
			guideRope.useWorldSpace = true;
			GameObject val10 = new GameObject("Tidehaul buoy tether");
			val10.transform.SetParent(mount.Root, false);
			buoyRope = val10.AddComponent<LineRenderer>();
			((Renderer)buoyRope).sharedMaterial = ropeMaterial;
			buoyRope.positionCount = 3;
			buoyRope.startWidth = (buoyRope.endWidth = 0.016f);
			buoyRope.useWorldSpace = true;
			winch.SetActive(false);
			stowed.SetActive(false);
			buoy.SetActive(false);
			((Renderer)rope).enabled = false;
			((Renderer)guideRope).enabled = false;
			((Renderer)buoyRope).enabled = false;
			((Component)Primary).gameObject.SetActive(false);
			Plugin.Log.LogInfo((object)($"Net mount {baseLocal}; rail x={railLocalX:F2}, top={railTopLocal:F2}; " + $"folded={stowedLocal}; discharge={dischargeLocal}; native boat {((NetworkBehaviour)mount.Boat).ObjectId}."));
		}

		internal Vector3 CatchPosition(int index)
		{
			//IL_0047: 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_007f: 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)
			if (index < 0 || index >= 5)
			{
				throw new ArgumentOutOfRangeException("index");
			}
			int num = index / 2;
			float num2 = ((index % 2 == 0) ? (-0.18f) : 0.18f);
			BoatMount mount = Mount;
			float num3 = dischargeLocal.x + num2;
			float y = deliveryLocal.y;
			NetMotionBounds authoredNetBounds = NetMotionPlanner.AuthoredNetBounds;
			return mount.PhysicsPoint(new Vector3(num3, y + ((NetMotionBounds)(ref authoredNetBounds)).Min.Y - 0.1f + (float)num * 0.035f, dischargeLocal.z + (float)(num - 1) * 0.24f));
		}

		internal Vector3 PredictedLocalPosition(float deploymentAmount)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			NetMotionPose val = CreateMotionPlan(WaterManager.WaterHeight).Sample(deploymentAmount);
			return Vector(((NetMotionPose)(ref val)).Position);
		}

		internal void Render(NetCycleSnapshot state)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Invalid comparison between Unknown and I4
			//IL_0257: 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_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Expected I4, but got Unknown
			//IL_02da: 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_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0692: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Invalid comparison between Unknown and I4
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			if (disposed)
			{
				return;
			}
			bool valueOrDefault = state.Installed == true;
			winch.SetActive(valueOrDefault);
			((Component)Primary).gameObject.SetActive(valueOrDefault);
			((Renderer)guideRope).enabled = valueOrDefault;
			fastUpgrade.SetActive(valueOrDefault && runtime.PurchasedTier >= 2);
			capacityUpgrade.SetActive(valueOrDefault && runtime.PurchasedTier >= 3);
			net.SetActive(valueOrDefault && state.Phase != (NetPhase?)0);
			stowed.SetActive(valueOrDefault && state.Phase == (NetPhase?)0);
			((Renderer)rope).enabled = valueOrDefault && state.Phase != (NetPhase?)0;
			bool flag = valueOrDefault && state.Phase != (NetPhase?)0;
			buoy.SetActive(flag);
			((Renderer)buoyRope).enabled = flag;
			if (!valueOrDefault)
			{
				wasDeployed = false;
				displayedDeployment = 0f;
				if (haulingSound.isPlaying)
				{
					haulingSound.Stop();
				}
				return;
			}
			bool flag2 = (int)state.Phase.GetValueOrDefault() == 3 && state.HaulPaused != true;
			if (flag2 && !haulingSound.isPlaying)
			{
				haulingSound.Play();
			}
			else if (!flag2 && haulingSound.isPlaying)
			{
				haulingSound.Stop();
			}
			NetCycleConfigState obj = state.Config ?? throw new InvalidOperationException("The net snapshot has no tuning.");
			double num = obj.LoweringSeconds ?? throw new InvalidOperationException("The net snapshot has no lowering duration.");
			double num2 = obj.HaulingSeconds ?? throw new InvalidOperationException("The net snapshot has no hauling duration.");
			double num3 = state.Phase switch
			{
				(NetPhase)0L => state.LoweringElapsedSeconds.Value / num, 
				(NetPhase)1L => 1.0, 
				(NetPhase)2L => 1.0 - state.HaulElapsedSeconds.Value / num2, 
				_ => 0.0, 
			};
			NetMotionPose val = CreateMotionPlan(WaterManager.WaterHeight).Sample(Mathf.Clamp01((float)num3));
			Vector3 val2 = Mount.PhysicsPoint(Vector(((NetMotionPose)(ref val)).Position));
			Quaternion physicsRotation = Mount.PhysicsRotation;
			if (Mount.IsServer)
			{
				if (!wasDeployed || !flag)
				{
					net.transform.SetPositionAndRotation(val2, physicsRotation);
					body.position = val2;
					body.rotation = physicsRotation;
					body.linearVelocity = Vector3.zero;
				}
				body.isKinematic = true;
				body.MoveRotation(physicsRotation);
				body.MovePosition(val2);
			}
			else
			{
				body.isKinematic = true;
				float num4 = ((!wasDeployed || !flag) ? 1f : (1f - Mathf.Exp((0f - Time.deltaTime) * 12f)));
				displayedDeployment = Mathf.Lerp(displayedDeployment, Mathf.Clamp01((float)num3), num4);
				NetMotionPose val3 = CreateMotionPlan(WaterManager.WaterHeight, renderedFrame: true).Sample(displayedDeployment);
				net.transform.SetPositionAndRotation(Mount.Root.TransformPoint(Vector(((NetMotionPose)(ref val3)).Position)), Mount.Root.rotation);
			}
			wasDeployed = flag;
			Collider[] componentsInChildren = net.GetComponentsInChildren<Collider>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = Mount.IsServer && flag;
			}
			Vector3 val4 = net.transform.TransformPoint(hoistLocal);
			Vector3 val5 = winch.transform.InverseTransformPoint(val4) - slew.localPosition;
			float num5 = (flag ? Mathf.Atan2(0f - val5.z, val5.x) : ((NetMotionPose)(ref val)).SlewRadians);
			slew.localRotation = Quaternion.Euler(0f, num5 * 57.29578f, 0f);
			Vector3 position = lineExit.position;
			guideRope.SetPosition(0, drum.position);
			guideRope.SetPosition(1, fairlead.position);
			guideRope.SetPosition(2, mastFeed.position);
			guideRope.SetPosition(3, mastBlock.position);
			guideRope.SetPosition(4, boomBlock.position);
			guideRope.SetPosition(5, position);
			rope.SetPosition(0, position);
			rope.SetPosition(1, (position + val4) * 0.5f);
			rope.SetPosition(2, val4);
			buoy.transform.rotation = Quaternion.identity;
			Vector3 value = buoy.transform.InverseTransformPoint(buoyAttachment.position);
			NetBuoyPose val6 = NetBuoyTether.Resolve(Motion(val4), Motion(value), Motion(Mount.PhysicsRotation * new Vector3(-0.35f, 0f, 0.1f)), WaterManager.WaterHeight, Mathf.Sin(Time.time * 2f) * 0.035f);
			buoy.transform.position = Vector(((NetBuoyPose)(ref val6)).Center);
			Vector3 position2 = buoyAttachment.position;
			buoyRope.SetPosition(0, val4);
			buoyRope.SetPosition(1, (val4 + position2) * 0.5f + Vector3.down * 0.012f);
			buoyRope.SetPosition(2, position2);
			if (flag2)
			{
				if (Object.op_Implicit((Object)(object)crank))
				{
					crank.Rotate(Vector3.forward, Time.deltaTime * 170f, (Space)1);
				}
				if (Object.op_Implicit((Object)(object)drum))
				{
					drum.Rotate(Vector3.forward, Time.deltaTime * 170f, (Space)1);
				}
			}
			else if ((int)state.Phase.GetValueOrDefault() == 1 && Mount.HorizontalSpeed <= 0.75f && WaterSuitable && Object.op_Implicit((Object)(object)drum))
			{
				drum.Rotate(Vector3.forward, Time.deltaTime * -170f, (Space)1);
			}
			UpdateFish(state);
		}

		private void UpdateFish(NetCycleSnapshot state)
		{
			//IL_0284: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			List<NetCatchTicketState> list = state.Tickets ?? throw new InvalidOperationException("The net catch snapshot is missing.");
			NetCycleConfigState config = state.Config;
			int num = ((config != null) ? config.Capacity : ((int?)null)) ?? throw new InvalidOperationException("The net snapshot has no capacity.");
			if (num < 1 || num > catchLocals.Length || list.Count > num)
			{
				throw new InvalidOperationException("The net snapshot exceeds the authored five-catch layout.");
			}
			string text = string.Join(",", list.Select((NetCatchTicketState ticket) => ticket.ItemId));
			if (text != tickets)
			{
				foreach (GameObject item in fish)
				{
					Object.Destroy((Object)(object)item);
				}
				fish.Clear();
				tickets = text;
				foreach (NetCatchTicketState item2 in list)
				{
					Item spawnable = GameInfo.GetSpawnable(item2.ItemId.Value);
					Renderer val = (Renderer)(((object)((Component)spawnable).GetComponentsInChildren<SkinnedMeshRenderer>(true).FirstOrDefault()) ?? ((object)((Component)spawnable).GetComponentsInChildren<Renderer>(true).First()));
					GameObject val2 = new GameObject("Netted " + spawnable.GetName(), new Type[2]
					{
						typeof(MeshFilter),
						typeof(MeshRenderer)
					});
					val2.transform.SetParent(net.transform, false);
					val2.GetComponent<MeshFilter>().sharedMesh = spawnable.Mesh;
					val2.GetComponent<Renderer>().sharedMaterials = val.sharedMaterials;
					float[] array = new float[3];
					Bounds bounds = spawnable.Mesh.bounds;
					array[0] = ((Bounds)(ref bounds)).size.x;
					bounds = spawnable.Mesh.bounds;
					array[1] = ((Bounds)(ref bounds)).size.y;
					bounds = spawnable.Mesh.bounds;
					array[2] = ((Bounds)(ref bounds)).size.z;
					float num2 = Mathf.Max(array);
					val2.transform.localScale = Vector3.one * (0.4f / num2);
					fish.Add(val2);
				}
			}
			for (int num3 = 0; num3 < fish.Count; num3++)
			{
				fish[num3].transform.localPosition = catchLocals[num3] + Vector3.up * (Mathf.Sin(Time.time * 2f + (float)num3) * 0.025f);
				fish[num3].transform.localRotation = Quaternion.Euler(0f, (float)(45 + num3 * 80) + Mathf.Sin(Time.time * 3f + (float)num3) * 6f, 0f);
			}
		}

		private NetMotionPlanner CreateMotionPlan(float waterHeight, bool renderedFrame = false)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00d6: Expected O, but got Unknown
			Vector3 val = (renderedFrame ? Mount.Root.TransformPoint(outboardClearLocal) : Mount.PhysicsPoint(outboardClearLocal));
			float num = Vector3.Dot(renderedFrame ? Mount.Root.up : (Mount.PhysicsRotation * Vector3.up), Vector3.up);
			if (Mathf.Abs(num) < 0.1f)
			{
				throw new InvalidOperationException("The native boat is too steep for the net hoist.");
			}
			Vector3 value = outboardClearLocal;
			value.y += (waterHeight - 0.62f - val.y) / num;
			return new NetMotionPlanner(Motion(slewLocal), deliveryYaw, Motion(outboardClearLocal), Motion(value), railLocalX, railTopLocal, -1, NetMotionPlanner.AuthoredNetBounds);
		}

		internal float PredictedSlewDegrees(float amount)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			NetMotionPose val = CreateMotionPlan(WaterManager.WaterHeight).Sample(amount);
			return ((NetMotionPose)(ref val)).SlewRadians * 57.29578f;
		}

		private Vector3 FindSlewDelivery(BoatMount mount, out float yaw)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			float[] array = new float[3] { 105f, 110f, 100f };
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < array.Length; i++)
			{
				float num = array[i] * (MathF.PI / 180f);
				Vector3 val = Vector(NetMotionPlanner.SwingPosition(Motion(slewLocal), Motion(outboardClearLocal), num));
				if (mount.TryDeck(val, ref val2) && !(val2.y > baseLocal.y + 0.2f))
				{
					yaw = num;
					return val2;
				}
			}
			throw new InvalidOperationException("The crane's fixed-radius swing has no supported inboard unloading position.");
		}

		private void MeasureGunwale(BoatMount mount, out float railX, out float railTop)
		{
			//IL_003f: 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_0090: 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_00bd: 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)
			railX = baseLocal.x - 0.4f;
			railTop = baseLocal.y;
			bool flag = false;
			float num = baseLocal.x + 0.7f;
			float x = outboardClearLocal.x;
			NetMotionBounds authoredNetBounds = NetMotionPlanner.AuthoredNetBounds;
			float num2 = x + ((NetMotionBounds)(ref authoredNetBounds)).Max.X;
			Vector3 val = default(Vector3);
			for (int i = 0; i <= 24; i++)
			{
				float num3 = Mathf.Lerp(num, num2, (float)i / 24f);
				for (int j = -2; j <= 2; j++)
				{
					if (mount.TryDeck(new Vector3(num3, 0f, baseLocal.z + (float)j * 0.28f), ref val) && !(val.y < baseLocal.y - 0.08f))
					{
						flag = true;
						railX = Mathf.Min(railX, val.x);
						railTop = Mathf.Max(railTop, val.y);
					}
				}
			}
			if (!flag)
			{
				throw new InvalidOperationException("The native gunwale could not be measured beside the net hoist.");
			}
		}

		private static Vector3 FindDeckPosition(BoatMount mount, Vector3 origin, IEnumerable<Vector3> offsets, string purpose, float maximumHeight = float.PositiveInfinity)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			foreach (Vector3 offset in offsets)
			{
				if (mount.TryDeck(origin + offset, ref val) && val.y <= maximumHeight)
				{
					return val;
				}
			}
			throw new InvalidOperationException("The native boat has no supported " + purpose + " position beside the winch.");
		}

		private Vector3 FindStowedDeck(BoatMount mount, Bounds folded)
		{
			//IL_0013: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0075: 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_0081: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00d8: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_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_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_01eb: 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)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			Bounds val = NativeSceneMeshes.TransformBounds(NetAssets.BoundsOf(winch), Matrix4x4.TRS(winch.transform.localPosition, winch.transform.localRotation, winch.transform.localScale));
			Vector3 val2 = mount.CollisionPoint(Vector3.zero);
			Quaternion collisionRotation = Quaternion.LookRotation(mount.CollisionPoint(Vector3.forward) - val2, mount.CollisionPoint(Vector3.up) - val2);
			Boat value;
			Collider[] source = (from collider in ((Component)NativeAccess.Get<Transform>((object)mount.Boat, "_dynamicObjectColsHolder")).GetComponentsInChildren<Collider>()
				where collider.enabled && !collider.isTrigger && BoatManager.ColToBoat.TryGetValue(collider, out value) && (Object)(object)value == (Object)(object)mount.Boat
				select collider).ToArray();
			GameObject val3 = new GameObject("Tidehaul folded placement probe");
			val3.transform.position = new Vector3(0f, -1000f, 0f);
			val3.layer = LayerMask.NameToLayer("Ignore Raycast");
			BoxCollider probe = val3.AddComponent<BoxCollider>();
			((Collider)probe).isTrigger = true;
			probe.size = ((Bounds)(ref folded)).size + Vector3.one * 0.02f;
			try
			{
				Vector3[] array = (Vector3[])(object)new Vector3[4]
				{
					new Vector3(0.7f, 0f, -0.8f),
					new Vector3(0.95f, 0f, -0.75f),
					new Vector3(0.55f, 0f, -0.65f),
					new Vector3(1.15f, 0f, -0.65f)
				};
				Vector3 val5 = default(Vector3);
				Vector3 val6 = default(Vector3);
				Vector3 val7 = default(Vector3);
				Vector3 val8 = default(Vector3);
				float num7 = default(float);
				foreach (Vector3 val4 in array)
				{
					if (!mount.TryDeck(baseLocal + val4, ref val5) || val5.y > baseLocal.y + 0.15f)
					{
						continue;
					}
					bool flag = true;
					float num2 = val5.y;
					float[] array2 = new float[2]
					{
						((Bounds)(ref folded)).min.x - 0.025f,
						((Bounds)(ref folded)).max.x + 0.025f
					};
					foreach (float num4 in array2)
					{
						float[] array3 = new float[3]
						{
							((Bounds)(ref folded)).min.z - 0.025f,
							0f,
							((Bounds)(ref folded)).max.z + 0.025f
						};
						foreach (float num6 in array3)
						{
							if (!mount.TryDeck(val5 + new Vector3(num4, 0f, num6), ref val6) || Math.Abs(val6.y - val5.y) > 0.05f)
							{
								flag = false;
							}
							else
							{
								num2 = Mathf.Max(num2, val6.y);
							}
						}
					}
					if (flag)
					{
						((Vector3)(ref val7))..ctor(val5.x, num2 + 0.035f - ((Bounds)(ref folded)).min.y, val5.z);
						Bounds envelope = new Bounds(val7 + ((Bounds)(ref folded)).center, probe.size);
						if (!((Bounds)(ref val)).Intersects(envelope) && !source.Any((Collider collider) => Physics.ComputePenetration((Collider)(object)probe, mount.CollisionPoint(((Bounds)(ref envelope)).center), collisionRotation, collider, ((Component)collider).transform.position, ((Component)collider).transform.rotation, ref val8, ref num7) && num7 > 0.001f))
						{
							return val7;
						}
					}
				}
			}
			finally
			{
				Object.Destroy((Object)(object)val3);
			}
			throw new InvalidOperationException("The whole folded net has no clear, level deck footprint inside the gunwales.");
		}

		private static Vector3 Motion(Vector3 value)
		{
			//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(value.x, value.y, value.z);
		}

		private static Vector3 Vector(Vector3 value)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(value.X, value.Y, value.Z);
		}

		private void AddRim(Vector3 center, Vector3 size)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			BoxCollider obj = net.AddComponent<BoxCollider>();
			obj.center = center;
			obj.size = size;
		}

		private static GameObject Place(GameObject model, Transform? parent, Vector3 local)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			model.transform.SetParent(parent, false);
			model.transform.localPosition = local;
			model.SetActive(true);
			return model;
		}

		private static Transform? Find(GameObject root, string name)
		{
			return ((IEnumerable<Transform>)root.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform value) => ((Object)value).name == name || ((Object)value).name == "marker_" + name));
		}

		private static Transform Pivot(GameObject root, string anchorName, string markerName)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = root.transform.Find(anchorName);
			Transform val = root.transform.Find("marker_" + markerName);
			if (!Object.op_Implicit((Object)(object)obj) || !Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("The authored winch is missing an animated anchor or pivot.");
			}
			Transform transform = new GameObject("Animated " + markerName).transform;
			transform.SetParent(root.transform, false);
			transform.position = val.position;
			obj.SetParent(transform, true);
			return transform;
		}

		public void Dispose()
		{
			if (!disposed)
			{
				disposed = true;
				if (Object.op_Implicit((Object)(object)net))
				{
					Object.Destroy((Object)(object)net);
				}
				if (Object.op_Implicit((Object)(object)buoy))
				{
					Object.Destroy((Object)(object)buoy);
				}
				if (Object.op_Implicit((Object)(object)ropeMaterial))
				{
					Object.Destroy((Object)(object)ropeMaterial);
				}
				runtime.Detached(this);
			}
		}
	}
	internal sealed class NetPurchaseStations : IDisposable
	{
		internal sealed class Station
		{
			internal string Key = "";

			internal int MaximumTier;

			internal MountedIsland Island;

			internal GameObject Root;

			internal PackPurchaseControl Control;
		}

		private readonly NetRuntime runtime;

		private readonly NetAssets assets;

		private readonly PackWorldRuntime world;

		private readonly Dictionary<string, Station> stations = new Dictionary<string, Station>(StringComparer.Ordinal);

		private readonly Dictionary<string, MountedIsland> pending = new Dictionary<string, MountedIsland>(StringComparer.Ordinal);

		internal IReadOnlyList<PackPurchaseControl> Controls => stations.Values.Select((Station station) => station.Control).ToArray();

		internal NetPurchaseStations(NetRuntime runtime, NetAssets assets, PackWorldRuntime world)
		{
			this.runtime = runtime;
			this.assets = assets;
			this.world = world;
			world.SceneMounted += Mounted;
			world.SceneUnmounting += Unmounting;
			foreach (MountedIsland item in world.Mounted)
			{
				Mounted(item);
			}
		}

		private void Mounted(MountedIsland island)
		{
			bool flag;
			switch (island.Reference)
			{
			case "native:3":
			case "native:4":
			case "native:5":
			case "gamblers_reach:harbor":
				flag = true;
				break;
			default:
				flag = false;
				break;
			}
			if (flag)
			{
				pending.Add(island.Reference, island);
			}
		}

		internal void Tick()
		{
			//IL_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			MountedIsland[] array = pending.Values.ToArray();
			foreach (MountedIsland val in array)
			{
				if (!Object.op_Implicit((Object)(object)val.Root))
				{
					continue;
				}
				Scene scene = val.Scene;
				if (!((Scene)(ref scene)).isLoaded)
				{
					continue;
				}
				scene = val.Scene;
				ItemPurchasable[] array2 = (from control in ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject root) => root.GetComponentsInChildren<ItemPurchasable>(true)).Where(delegate(ItemPurchasable control)
					{
						bool flag = ((Component)control).gameObject.activeInHierarchy;
						if (flag)
						{
							Item val2 = NativeAccess.Get<Item>((object)control, "_itemToPurchase");
							bool flag2 = ((val2 is FishingRod || val2 is Weapon) ? true : false);
							flag = flag2;
						}
						return flag;
					})
					orderby (!(NativeAccess.Get<Item>((object)control, "_itemToPurchase") is FishingRod)) ? 1 : 0
					select control).ToArray();
				if (array2.Length == 0)
				{
					if (runtime.Ready && !IslandManager.IsLoading)
					{
						throw new InvalidOperationException("The net equipment shop has no fishing or weapon stock: " + val.Reference);
					}
				}
				else
				{
					Create(val, array2);
					pending.Remove(val.Reference);
				}
			}
		}

		private void Create(MountedIsland island, ItemPurchasable[] stock)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0067: 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_00f2: Expected O, but got Unknown
			//IL_0134: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: 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_02b9: Unknown result type (might be due to invalid IL or missing references)
			Physics.SyncTransforms();
			Scene scene = island.Scene;
			Purchasable[] neighbors = ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject root) => root.GetComponentsInChildren<Purchasable>(true)).ToArray();
			Vector3 wall;
			Vector3 normal;
			bool num = FindShopWall(stock, neighbors, out wall, out normal);
			Vector3 position = wall + normal * 0.305f;
			Vector3[] feet = Array.Empty<Vector3>();
			if (!num && !FindShopCounter(stock, neighbors, out position, out normal, out feet))
			{
				throw new InvalidOperationException("The net display has no clear wall or supported counter position alongside " + island.Reference + "'s shops.");
			}
			Station station = new Station
			{
				Key = island.Reference.Replace(':', '_'),
				Island = island,
				MaximumTier = ((island.Reference == "gamblers_reach:harbor") ? 2 : (island.NativeEngineId - 1)),
				Root = new GameObject("Tidehaul boat equipment service")
			};
			station.Root.SetActive(false);
			station.Root.transform.SetParent(island.Additions, false);
			station.Root.transform.SetPositionAndRotation(position, Quaternion.LookRotation(normal));
			GameObject obj = assets.Create("tidehaul_kit");
			((Object)obj).name = "Tidehaul display kit";
			obj.transform.SetParent(station.Root.transform, false);
			obj.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			obj.SetActive(true);
			Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>();
			Material sharedMaterial = componentsInChildren.First((Renderer renderer) => ((Object)renderer).name == "crate slats").sharedMaterial;
			ShelfPart(station.Root.transform, "Net display shelf", new Vector3(0f, -0.04f, 0f), new Vector3(0.84f, 0.08f, 0.58f), sharedMaterial);
			if (num)
			{
				float[] array = new float[2] { -0.28f, 0.28f };
				foreach (float num3 in array)
				{
					ShelfPart(station.Root.transform, "Net shelf bracket", new Vector3(num3, -0.18f, -0.26f), new Vector3(0.06f, 0.28f, 0.12f), sharedMaterial);
				}
				GameObject val = new GameObject("Net display wall contact");
				val.transform.SetParent(station.Root.transform, false);
				val.transform.position = wall;
			}
			else
			{
				Vector3[] array2 = feet;
				foreach (Vector3 val2 in array2)
				{
					Vector3 val3 = station.Root.transform.InverseTransformPoint(val2);
					float num4 = 0f - val3.y - 0.08f;
					ShelfPart(station.Root.transform, "Net display counter leg", new Vector3(val3.x, -0.08f - num4 * 0.5f, val3.z), new Vector3(0.075f, num4, 0.075f), sharedMaterial);
					GameObject val4 = new GameObject("Net display ground contact");
					val4.transform.SetParent(station.Root.transform, false);
					val4.transform.position = val2;
				}
			}
			station.Control = PackPurchaseControl.Create(station.Root.transform, "Buy or upgrade boat net", new Vector3(0f, 0.22f, 0.02f), new Vector3(0.75f, 0.6f, 0.55f), componentsInChildren.Select((Renderer renderer) => ((Component)renderer).gameObject).ToArray(), (Func<Player, PackPurchaseOffer>)((Player player) => Offer(station, player)), (Action<Player, string>)delegate(Player _, string quote)
			{
				runtime.SendPurchase(quote);
			});
			stations.Add(station.Key, station);
			station.Root.SetActive(true);
		}

		private static bool FindShopCounter(ItemPurchasable[] stock, Purchasable[] neighbors, out Vector3 position, out Vector3 normal, out Vector3[] feet)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_0055: 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_0061: 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_0077: 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_0086: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_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_031d: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_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)
			//IL_0149: 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_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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val4 = default(RaycastHit);
			foreach (ItemPurchasable val in stock)
			{
				Quaternion val2 = Quaternion.Euler(0f, ((Component)val).transform.eulerAngles.y, 0f);
				Vector3[] array = (Vector3[])(object)new Vector3[6]
				{
					Vector3.right * 1.2f,
					Vector3.left * 1.2f,
					Vector3.forward * 1.4f,
					Vector3.back * 1.4f,
					Vector3.right * 2f,
					Vector3.left * 2f
				};
				foreach (Vector3 val3 in array)
				{
					Vector3 center = ((Component)val).transform.position + val2 * val3;
					List<Vector3> list = new List<Vector3>();
					float[] array2 = new float[2] { -0.3f, 0.3f };
					foreach (float num in array2)
					{
						float[] array3 = new float[2] { -0.2f, 0.2f };
						foreach (float num2 in array3)
						{
							if (Physics.Raycast(center + val2 * new Vector3(num, 0.2f, num2), Vector3.down, ref val4, 4f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1) && ((RaycastHit)(ref val4)).normal.y > 0.8f && ((RaycastHit)(ref val4)).point.y > WaterManager.WaterHeight + 0.1f)
							{
								list.Add(((RaycastHit)(ref val4)).point);
							}
						}
					}
					if (list.Count == 4 && !(list.Max((Vector3 point) => point.y) - list.Min((Vector3 point) => point.y) > 0.3f))
					{
						center.y = list.Max((Vector3 point) => point.y) + 0.95f;
						if (!neighbors.Any(delegate(Purchasable control)
						{
							//IL_001b: 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_0026: Unknown result type (might be due to invalid IL or missing references)
							//IL_002b: 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.op_Implicit((Object)(object)control) && ((Component)control).gameObject.activeInHierarchy)
							{
								Vector3 val5 = Vector3.ProjectOnPlane(((Component)control).transform.position - center, Vector3.up);
								return ((Vector3)(ref val5)).magnitude < 0.85f;
							}
							return false;
						}) && !Physics.CheckBox(center + Vector3.up * 0.2f, new Vector3(0.42f, 0.24f, 0.29f), val2, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1))
						{
							position = center;
							normal = val2 * Vector3.forward;
							feet = list.ToArray();
							return true;
						}
					}
				}
			}
			position = default(Vector3);
			normal = default(Vector3);
			feet = Array.Empty<Vector3>();
			return false;
		}

		private static bool FindShopWall(ItemPurchasable[] stock, Purchasable[] neighbors, out Vector3 wall, out Vector3 normal)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0037: 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_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_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_007f: 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_008b: 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_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00d2: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: 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_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val3 = default(RaycastHit);
			RaycastHit val6 = default(RaycastHit);
			RaycastHit val7 = default(RaycastHit);
			RaycastHit val8 = default(RaycastHit);
			foreach (ItemPurchasable val in stock)
			{
				Vector3[] array = (Vector3[])(object)new Vector3[8]
				{
					-((Component)val).transform.forward,
					((Component)val).transform.right,
					-((Component)val).transform.right,
					((Component)val).transform.forward,
					Vector3.left,
					Vector3.right,
					Vector3.forward,
					Vector3.back
				};
				for (int j = 0; j < array.Length; j++)
				{
					Vector3 val2 = Vector3.ProjectOnPlane(array[j], Vector3.up);
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					if (((Vector3)(ref normalized)).sqrMagnitude < 0.9f || !Physics.Raycast(((Component)val).transform.position + Vector3.up * 0.7f, normalized, ref val3, 3.5f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1) || Math.Abs(((RaycastHit)(ref val3)).normal.y) > 0.15f)
					{
						continue;
					}
					val2 = Vector3.ProjectOnPlane(((RaycastHit)(ref val3)).normal, Vector3.up);
					Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
					Vector3 val4 = Vector3.Cross(Vector3.up, normalized2);
					float[] array2 = new float[5] { -1f, 1f, -1.8f, 1.8f, 0f };
					foreach (float num in array2)
					{
						Vector3 val5 = ((RaycastHit)(ref val3)).point + val4 * num;
						if (!Physics.Raycast(val5 + normalized2 * 0.9f + Vector3.up * 0.1f, Vector3.down, ref val6, 5f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1) || ((RaycastHit)(ref val6)).normal.y < 0.8f)
						{
							continue;
						}
						val5.y = ((RaycastHit)(ref val6)).point.y + 1.15f;
						if (!Physics.Raycast(val5 + normalized2 * 0.65f, -normalized2, ref val7, 1.2f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1) || Vector3.Dot(((RaycastHit)(ref val7)).normal, normalized2) < 0.95f)
						{
							continue;
						}
						bool flag = true;
						float[] array3 = new float[2] { -0.38f, 0.38f };
						foreach (float num2 in array3)
						{
							float[] array4 = new float[2] { -0.1f, 0.45f };
							foreach (float num3 in array4)
							{
								if (!Physics.Raycast(((RaycastHit)(ref val7)).point + val4 * num2 + Vector3.up * num3 + normalized2 * 0.12f, -normalized2, ref val8, 0.18f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1) || Vector3.Dot(((RaycastHit)(ref val8)).normal, normalized2) < 0.95f)
								{
									flag = false;
								}
							}
						}
						Vector3 center = ((RaycastHit)(ref val7)).point + normalized2 * 0.305f + Vector3.up * 0.23f;
						if (flag && !neighbors.Any((Purchasable control) => Object.op_Implicit((Object)(object)control) && ((Component)control).gameObject.activeInHierarchy && Vector3.Distance(((Component)control).transform.position, center) < 0.85f) && !Physics.CheckBox(center, new Vector3(0.4f, 0.28f, 0.275f), Quaternion.LookRotation(normalized2), LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1))
						{
							wall = ((RaycastHit)(ref val7)).point;
							normal = normalized2;
							return true;
						}
					}
				}
			}
			wall = default(Vector3);
			normal = default(Vector3);
			return false;
		}

		private static void ShelfPart(Transform parent, string name, Vector3 center, Vector3 size, Material material)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = name;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = center;
			obj.transform.localScale = size;
			obj.layer = LayerMask.NameToLayer("Level");
			obj.tag = "Level";
			obj.GetComponent<Renderer>().sharedMaterial = material;
		}

		private PackPurchaseOffer Offer(Station station, Player player)
		{
			//IL_0086: 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_018b: Expected O, but got Unknown
			int purchasedTier = runtime.PurchasedTier;
			int num = Math.Min(3, purchasedTier + 1);
			NetEquipmentTier val = NetEquipment.Tier(num);
			bool flag = purchasedTier == 0 && Object.op_Implicit((Object)(object)player.Holding.HeldItem) && player.Holding.HeldItem.ID == 195;
			string text = ((purchasedTier == 3) ? "All net upgrades purchased." : (NetEquipment.PurchaseBlock(purchasedTier, num, station.MaximumTier, Object.op_Implicit((Object)(object)BoatManager.Boat) && BoatManager.Boat.BoatUnlocked, runtime.Snapshot.Phase.Value, flag ? val.Cost : Math.Max(0, MoneyManager.Money)) ?? ""));
			string text2 = val.Capacity + " live fish / " + val.HaulingSeconds.ToString("0", CultureInfo.InvariantCulture) + "s haul\n" + ((purchasedTier == 0) ? "Mounts directly on the crew's boat." : "Permanent crew upgrade.");
			if (flag)
			{
				text2 += "\nRedeem held legacy kit instead of paying.";
			}
			if (num > station.MaximumTier && purchasedTier < 3)
			{
				text = "Next upgrade is sold on native island " + val.NativeIsland + ".";
			}
			return new PackPurchaseOffer(station.Key + "|" + num.ToString(CultureInfo.InvariantCulture), val.Title, (!flag) ? val.Cost : 0, text2, text);
		}

		internal bool TryResolve(string quote, out Station? station, out int requestedTier)
		{
			//IL_005b: 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)
			station = null;
			requestedTier = 0;
			string[] array = quote.Split('|');
			if (array.Length == 2 && int.TryParse(array[1], NumberStyles.None, CultureInfo.InvariantCulture, out requestedTier) && stations.TryGetValue(array[0], out station) && Object.op_Implicit((Object)(object)station.Root) && station.Root.activeInHierarchy)
			{
				Scene scene = station.Island.Scene;
				return ((Scene)(ref scene)).isLoaded;
			}
			return false;
		}

		private void Unmounting(MountedIsland island)
		{
			pending.Remove(island.Reference);
			Station[] array = stations.Values.Where((Station station2) => station2.Island == island).ToArray();
			foreach (Station station in array)
			{
				stations.Remove(station.Key);
				if (Object.op_Implicit((Object)(object)station.Root))
				{
					Object.Destroy((Object)(object)station.Root);
				}
			}
		}

		public void Dispose()
		{
			world.SceneMounted -= Mounted;
			world.SceneUnmounting -= Unmounting;
			foreach (Station value in stations.Values)
			{
				if (Object.op_Implicit((Object)(object)value.Root))
				{
					Object.Destroy((Object)(object)value.Root);
				}
			}
			stations.Clear();
			pending.Clear();
		}
	}
	public sealed class NetSave
	{
		public int SchemaVersion { get; set; } = 2;

		public int? Tier { get; set; }

		public NetCycleSnapshot Cycle { get; set; } = new NetCycle().CreateSnapshot();

		public byte LureIndex { get; set; } = 8;
	}
	public sealed class NetViewState
	{
		public NetSave State { get; set; } = new NetSave
		{
			Tier = 0
		};

		public int Operator { get; set; } = -1;

		public string Notice { get; set; } = "";

		public float[] Position { get; set; } = new float[3];

		public float[] Rotation { get; set; } = new float[4] { 0f, 0f, 0f, 1f };
	}
	public sealed class NetRuntime : MonoBehaviour
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ItemCustomizer <0>__ConfigureKit;

			public static Func<Item, bool> <1>__IsWorldItemSaveEligible;
		}

		public const string PackKey = "tidehaul_nets";

		public const byte KitId = 195;

		public const ushort CollectionId = 48196;

		public const int KitCost = 1200;

		private static readonly HashSet<byte> SchoolFish = new HashSet<byte> { 0, 2, 4, 52 };

		private static readonly JsonSerializerSettings Json = new JsonSerializerSettings
		{
			MissingMemberHandling = (MissingMemberHandling)1,
			MaxDepth = 32,
			TypeNameHandling = (TypeNameHandling)0
		};

		private NetCycle cycle = new NetCycle();

		private NetAssets? assets;

		private PackChannel? channel;

		private IDisposable? registration;

		private NetBoatView? boatView;

		private NetPurchaseStations? shops;

		private NetViewState remote = new NetViewState();

		private byte lureIndex = 8;

		private int operatorId = -1;

		private float nextPublish;

		private string notice = "";

		private bool prepared;

		private int tier;

		public static NetRuntime? Current { get; private set; }

		public bool Ready
		{
			get
			{
				if (prepared)
				{
					return ExpansionPlatform.Current.Ready;
				}
				return false;
			}
		}

		public NetCycleSnapshot Snapshot
		{
			get
			{
				if (!IsServer)
				{
					return remote.State.Cycle;
				}
				return cycle.CreateSnapshot();
			}
		}

		public BoatMount? Mount => boatView?.Mount;

		public PackControl? PrimaryControl => boatView?.Primary;

		public IReadOnlyList<PackPurchaseControl> PurchaseStands => shops?.Controls ?? Array.Empty<PackPurchaseControl>();

		public int PurchasedTier
		{
			get
			{
				if (!IsServer)
				{
					return remote.State.Tier.GetValueOrDefault();
				}
				return tier;
			}
		}

		public Vector3 NetPosition => boatView?.NetPosition ?? Vector3.zero;

		public Vector3 DischargePosition => boatView?.DischargePosition ?? Vector3.zero;

		public bool DeploymentWaterSuitable => boatView?.WaterSuitable ?? false;

		public bool IsServer
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Server.Instance))
				{
					return ((NetworkBehaviour)Server.Instance).IsServerInitialized;
				}
				return false;
			}
		}

		public string Notice
		{
			get
			{
				if (!IsServer && notice.Length == 0)
				{
					return remote.Notice;
				}
				return notice;
			}
		}

		public int CatchesUnloaded { get; private set; }

		public Vector3 PredictedNetLocalPosition(float deploymentAmount)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return (boatView ?? throw new InvalidOperationException("The native net mount is not ready.")).PredictedLocalPosition(deploymentAmount);
		}

		public float PredictedSlewDegrees(float deploymentAmount)
		{
			return (boatView ?? throw new InvalidOperationException("The native net mount is not ready.")).PredictedSlewDegrees(deploymentAmount);
		}

		private void Awake()
		{
			//IL_003f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)Current))
			{
				throw new InvalidOperationException("Another net runtime is already active.");
			}
			Current = this;
			ExpansionPlatform.Current.RegisterExtension(new PackExtension("tidehaul_nets", (Func<PackSource>)PrepareSource, (Action<PackContentOptions>)delegate(PackContentOptions options)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Expected O, but got Unknown
				options.Assets = (IPackAssetFactory)(object)assets;
				Dictionary<string, ItemCustomizer> itemCustomizers = options.ItemCustomizers;
				object obj = <>O.<0>__ConfigureKit;
				if (obj == null)
				{
					ItemCustomizer val = ConfigureKit;
					<>O.<0>__ConfigureKit = val;
					obj = (object)val;
				}
				itemCustomizers.Add("net_kit", (ItemCustomizer)obj);
			})
			{
				PrepareGameplay = PrepareGameplay,
				GameplayReady = () => prepared,
				AcceptSavedRevision = (SavedPack saved, IReadOnlyDictionary<string, string> code) => NetSaveRevision.Accept(saved.Key, saved.Version, saved.Fingerprint, code)
			});
		}

		private static void ConfigureKit(ItemCustomization context)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_007b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//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_00db: 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_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_