Decompiled source of ValheimRAFT TemporaryPatch v1.0.2

BepInEx/patchers/L4zerShark_Team-ValheimRAFT_TemporaryPatch/ValheimRAFT_TemporaryPatch.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ValheimRAFT Temporary Patch")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ValheimRaftTemporaryPatch
{
	public static class Loader
	{
		public const string Name = "ValheimRAFT_TemporaryPatch";

		public const string Version = "1.0.0";

		public const string OriginalHash = "432b674c5cddb69fbc763372507e3e687b733480f0abee218dedde8872b91e29";

		public const string WrapperHash = "2f03ba54f5e715c3171c382974a0376052a4007103ef28a9b4ab1b4adf02213c";

		public const string RepairedHash = "6f00fa3727b62f23d81b19aba5d44bf8c2f0d30e99712e1d660ed1e14a54f903";

		private const string AssemblyIdentity = "ValheimVehicles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";

		private const string HarmonyId = "com.l4zershark.valheimraft.temporarypatch";

		private static readonly object Gate = new object();

		private static ManualLogSource log;

		private static bool prepared;

		private static Assembly repairedAssembly;

		private static string originalVehiclesPath;

		private static bool pathMapperInstalled;

		public static IEnumerable<string> TargetDLLs => new string[0];

		public static void Patch(AssemblyDefinition assembly)
		{
		}

		public static void Finish()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0106: Expected O, but got Unknown
			log = Logger.CreateLogSource("ValheimRAFT_TemporaryPatch");
			try
			{
				Type? type = Type.GetType("BepInEx.Bootstrap.Chainloader, BepInEx", throwOnError: true);
				MethodInfo methodInfo = AccessTools.Method(type, "Start", Type.EmptyTypes, (Type[])null);
				if (methodInfo == null || !methodInfo.IsStatic || methodInfo.ReturnType != typeof(void))
				{
					throw new MissingMethodException("BepInEx Chainloader.Start()");
				}
				FieldInfo fieldInfo = AccessTools.Field(type, "_loaded");
				if (fieldInfo != null && (bool)fieldInfo.GetValue(null))
				{
					throw new InvalidOperationException("Plugin loading has already started.");
				}
				Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo);
				if (patchInfo != null && patchInfo.Owners.Contains("com.l4zershark.valheimraft.temporarypatch"))
				{
					log.LogWarning((object)"A temporary patch loader is already installed; ignoring this duplicate.");
					return;
				}
				Harmony val = new Harmony("com.l4zershark.valheimraft.temporarypatch");
				val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Loader), "PrepareDependency", (Type[])null)
				{
					priority = 800
				}, (HarmonyMethod)null, new HarmonyMethod(typeof(Loader), "MapChainloaderPaths", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
				if (!pathMapperInstalled)
				{
					val.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)0, "com.l4zershark.valheimraft.temporarypatch");
					throw new InvalidOperationException("Expected one supported Assembly.LoadFile call in Chainloader.Start; no loader was installed.");
				}
				log.LogInfo((object)"1.0.0: installed dependency preparation hook for official ValheimRAFT 5.0.7.");
			}
			catch (Exception ex)
			{
				log.LogError((object)("Temporary patch is inactive; original ValheimRAFT files are unchanged. " + ex));
			}
		}

		public static IEnumerable<CodeInstruction> MapChainloaderPaths(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Invalid comparison between Unknown and I4
			pathMapperInstalled = false;
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo loadFile = typeof(Assembly).GetMethod("LoadFile", new Type[1] { typeof(string) });
			MethodInfo mapper = typeof(Loader).GetMethod("PrepareCompatiblePath");
			List<CodeInstruction> list2 = list.FindAll((CodeInstruction instruction) => instruction.opcode == OpCodes.Call && object.Equals(instruction.operand, loadFile));
			if (list2.Count != 1 || list.Any((CodeInstruction instruction) => object.Equals(instruction.operand, mapper)))
			{
				LogWarning("Unsupported or duplicate Chainloader load hook; leaving its instructions unchanged.");
				return list;
			}
			int num = list.IndexOf(list2[0]);
			CodeInstruction val = list[num];
			CodeInstruction val2 = new CodeInstruction(OpCodes.Call, (object)mapper);
			val2.labels.AddRange(val.labels);
			CodeInstruction val3 = new CodeInstruction(val.opcode, val.operand);
			foreach (ExceptionBlock block in val.blocks)
			{
				if ((int)block.blockType == 5)
				{
					val3.blocks.Add(block);
				}
				else
				{
					val2.blocks.Add(block);
				}
			}
			list[num] = val2;
			list.Insert(num + 1, val3);
			pathMapperInstalled = true;
			return list;
		}

		public static string PrepareCompatiblePath(string path)
		{
			if (repairedAssembly == null || string.IsNullOrEmpty(path))
			{
				return path;
			}
			string fullPath;
			try
			{
				fullPath = Path.GetFullPath(path);
			}
			catch (ArgumentException)
			{
				return path;
			}
			catch (NotSupportedException)
			{
				return path;
			}
			catch (PathTooLongException)
			{
				return path;
			}
			if (!string.Equals(fullPath, originalVehiclesPath, StringComparison.OrdinalIgnoreCase))
			{
				return path;
			}
			return repairedAssembly.Location;
		}

		public static void PrepareDependency()
		{
			lock (Gate)
			{
				if (prepared)
				{
					return;
				}
				prepared = true;
				try
				{
					PrepareAndLoad(Paths.PluginPath, Paths.CachePath, Path.Combine(Path.GetDirectoryName(typeof(Loader).Assembly.Location), "ValheimVehicles.payload"));
				}
				catch (Exception ex)
				{
					LogWarning("Temporary patch was not applied; original files are unchanged. " + ex.Message);
				}
			}
		}

		private static void PrepareAndLoad(string pluginRoot, string cacheRoot, string payloadPath)
		{
			string[] files = Directory.GetFiles(pluginRoot, "ValheimVehicles.dll", SearchOption.AllDirectories);
			if (files.Length != 1)
			{
				throw new InvalidOperationException("Expected exactly one enabled ValheimVehicles.dll; found " + files.Length + ".");
			}
			string fullPath = Path.GetFullPath(files[0]);
			string directoryName = Path.GetDirectoryName(fullPath);
			string path = Path.Combine(directoryName, "ValheimRAFT.dll");
			if (!Matches(fullPath, "432b674c5cddb69fbc763372507e3e687b733480f0abee218dedde8872b91e29") || !Matches(path, "2f03ba54f5e715c3171c382974a0376052a4007103ef28a9b4ab1b4adf02213c"))
			{
				throw new InvalidOperationException("This package supports only the exact official ValheimRAFT 5.0.7 files. Newer or modified builds are left unchanged.");
			}
			if (AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly2) => string.Equals(assembly2.GetName().Name, "ValheimVehicles", StringComparison.OrdinalIgnoreCase)) != null)
			{
				throw new InvalidOperationException("ValheimVehicles was already loaded before preparation. Restart after removing duplicate or conflicting loaders.");
			}
			if (!Matches(payloadPath, "6f00fa3727b62f23d81b19aba5d44bf8c2f0d30e99712e1d660ed1e14a54f903"))
			{
				throw new InvalidDataException("The compiled repair payload is missing or does not match its published SHA-256.");
			}
			if (AssemblyName.GetAssemblyName(fullPath).FullName != "ValheimVehicles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" || AssemblyName.GetAssemblyName(payloadPath).FullName != "ValheimVehicles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
			{
				throw new InvalidDataException("The original and repaired assembly identities do not match.");
			}
			string fullPath2 = Path.GetFullPath(Path.Combine(cacheRoot, "RaftTemp", "1.0.0", "6f00fa3727b62f23d81b19aba5d44bf8c2f0d30e99712e1d660ed1e14a54f903".Substring(0, 12)));
			Directory.CreateDirectory(fullPath2);
			string[] array = new string[5] { "DynamicLocations.dll", "ZdoWatcher.dll", "Zolantris.Shared.dll", "ServerSync.dll", "Newtonsoft.Json.dll" };
			foreach (string text in array)
			{
				string text2 = Path.Combine(directoryName, text);
				if (!File.Exists(text2))
				{
					throw new FileNotFoundException("Required original RAFT companion is missing.", text);
				}
				CopyVerified(text2, Path.Combine(fullPath2, text));
			}
			string text3 = Path.Combine(fullPath2, "ValheimVehicles.dll");
			CopyVerified(payloadPath, text3);
			if (!Matches(text3, "6f00fa3727b62f23d81b19aba5d44bf8c2f0d30e99712e1d660ed1e14a54f903"))
			{
				throw new InvalidDataException("Prepared repair failed final verification.");
			}
			Assembly assembly = Assembly.LoadFile(text3);
			if (assembly.FullName != "ValheimVehicles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" || !Matches(assembly.Location, "6f00fa3727b62f23d81b19aba5d44bf8c2f0d30e99712e1d660ed1e14a54f903"))
			{
				throw new InvalidDataException("The runtime loaded an unexpected ValheimVehicles assembly.");
			}
			originalVehiclesPath = fullPath;
			repairedAssembly = assembly;
			LogInfo("Loaded compiled repair for official ValheimRAFT 5.0.7; original SHA-256 432b674c5cddb69fbc763372507e3e687b733480f0abee218dedde8872b91e29, repaired SHA-256 6f00fa3727b62f23d81b19aba5d44bf8c2f0d30e99712e1d660ed1e14a54f903, cache " + assembly.Location + ". Original plugin and assets retained.");
		}

		private static void CopyVerified(string source, string destination)
		{
			string expectedHash = HashFile(source);
			if (Matches(destination, expectedHash))
			{
				return;
			}
			string text = destination + "." + Guid.NewGuid().ToString("N").Substring(0, 8) + ".tmp";
			try
			{
				File.Copy(source, text, overwrite: false);
				if (!Matches(text, expectedHash))
				{
					throw new IOException("Cache copy failed verification.");
				}
				if (File.Exists(destination))
				{
					File.Replace(text, destination, null);
				}
				else
				{
					File.Move(text, destination);
				}
				if (!Matches(destination, expectedHash))
				{
					throw new IOException("Cache installation failed verification.");
				}
			}
			finally
			{
				if (File.Exists(text))
				{
					File.Delete(text);
				}
			}
		}

		public static bool Matches(string path, string expectedHash)
		{
			if (File.Exists(path))
			{
				return string.Equals(HashFile(path), expectedHash, StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		public static string HashFile(string path)
		{
			using FileStream inputStream = File.OpenRead(path);
			using SHA256 sHA = SHA256.Create();
			return BitConverter.ToString(sHA.ComputeHash(inputStream)).Replace("-", "").ToLowerInvariant();
		}

		private static void LogInfo(string message)
		{
			if (log != null)
			{
				log.LogInfo((object)message);
			}
		}

		private static void LogWarning(string message)
		{
			if (log != null)
			{
				log.LogWarning((object)message);
			}
		}
	}
}

BepInEx/patchers/L4zerShark_Team-ValheimRAFT_TemporaryPatch/ValheimVehicles.payload

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using Advize_PlantEasily;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComfyGizmo;
using DynamicLocations.API;
using DynamicLocations.Constants;
using DynamicLocations.Controllers;
using DynamicLocations.Structs;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.GUI;
using Jotunn.Managers;
using Jotunn.Utils;
using MagicaCloth2;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using PlanBuild.Blueprints.Components;
using PlanBuild.Plans;
using Registry;
using ServerSync;
using Splatform;
using TMPro;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.TextCore;
using UnityEngine.U2D;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Valheim.UI;
using ValheimVehicles.Attributes;
using ValheimVehicles.BepInExConfig;
using ValheimVehicles.Compat;
using ValheimVehicles.Components;
using ValheimVehicles.ConsoleCommands;
using ValheimVehicles.Controllers;
using ValheimVehicles.Enums;
using ValheimVehicles.Helpers;
using ValheimVehicles.Injections;
using ValheimVehicles.Integrations;
using ValheimVehicles.Integrations.PowerSystem;
using ValheimVehicles.Integrations.PowerSystem.Interfaces;
using ValheimVehicles.Interfaces;
using ValheimVehicles.ModSupport;
using ValheimVehicles.Patches;
using ValheimVehicles.Prefabs;
using ValheimVehicles.Prefabs.Registry;
using ValheimVehicles.Prefabs.ValheimVehicles.Prefabs.Registry;
using ValheimVehicles.Propulsion.Rudder;
using ValheimVehicles.Propulsion.Sail;
using ValheimVehicles.RPC;
using ValheimVehicles.Shared.Constants;
using ValheimVehicles.SharedScripts;
using ValheimVehicles.SharedScripts.Helpers;
using ValheimVehicles.SharedScripts.Interfaces;
using ValheimVehicles.SharedScripts.Magic;
using ValheimVehicles.SharedScripts.Modules;
using ValheimVehicles.SharedScripts.PowerSystem;
using ValheimVehicles.SharedScripts.PowerSystem.Compute;
using ValheimVehicles.SharedScripts.PowerSystem.Interfaces;
using ValheimVehicles.SharedScripts.Prefabs;
using ValheimVehicles.SharedScripts.Structs;
using ValheimVehicles.SharedScripts.UI;
using ValheimVehicles.SharedScripts.ValheimVehicles.SharedScripts;
using ValheimVehicles.SharedScripts.Validation;
using ValheimVehicles.Storage.Serialization;
using ValheimVehicles.Structs;
using ValheimVehicles.UI;
using ValheimVehicles.ValheimVehicles.Components;
using ValheimVehicles.ValheimVehicles.Integrations;
using ValheimVehicles.ValheimVehicles.Patches;
using ValheimVehicles.ValheimVehicles.Prefabs.ValheimVehicles.Prefabs.Registry;
using ValheimVehicles.ValheimVehicles.Structs;
using ZdoWatcher;
using ZdoWatcher.ZdoWatcher.Utils;
using Zolantris.Shared;
using Zolantris.Shared.Debug;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyInformationalVersion("3.7.2")]
[assembly: AssemblyTitle("ValheimVehicles")]
[assembly: AssemblyProduct("ValheimVehicles")]
[assembly: ComVisible(false)]
[assembly: Guid("E9B48BE9-4D8E-44DB-961A-D7C279B2CA2B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.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;
		}
	}
}
[BepInPlugin("dev.zolantris.inventorypatchdetector", "Inventory Patch Detector", "1.0.0")]
public class PatchDetector : BaseUnityPlugin
{
	private void Start()
	{
		foreach (MethodInfo item in from m in typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
			where m.Name == "RemoveItem"
			select m)
		{
			Patches patchInfo = Harmony.GetPatchInfo((MethodBase)item);
			if (patchInfo == null)
			{
				continue;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"RemoveItem PATCHED: {item}");
			foreach (Patch prefix in patchInfo.Prefixes)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"  Prefix: {prefix.owner} {prefix.PatchMethod.DeclaringType}.{prefix.PatchMethod.Name}");
			}
			foreach (Patch postfix in patchInfo.Postfixes)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"  Postfix: {postfix.owner} {postfix.PatchMethod.DeclaringType}.{postfix.PatchMethod.Name}");
			}
			foreach (Patch transpiler in patchInfo.Transpilers)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"  Transpiler: {transpiler.owner} {transpiler.PatchMethod.DeclaringType}.{transpiler.PatchMethod.Name}");
			}
		}
	}
}
public class NearestTargetScanManager : SingletonBehaviour<NearestTargetScanManager>
{
	[SerializeField]
	public float scanRadius = 10f;

	[SerializeField]
	private string characterLayerName = "character";

	[SerializeField]
	private float scanInterval = 1f;

	private readonly Collider[] _scanBuffer = (Collider[])(object)new Collider[128];

	private readonly List<Character> _nearbyCharacters = new List<Character>();

	private float _lastScanTime;

	private int _layerMask;

	public IReadOnlyList<Character> CachedCharacters => _nearbyCharacters;

	public override void Awake()
	{
		SingletonBehaviour<NearestTargetScanManager>.Instance = this;
		_layerMask = 1 << LayerMask.NameToLayer(characterLayerName);
	}

	private void FixedUpdate()
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && !((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Game.instance == (Object)null) && Time.time - _lastScanTime >= scanInterval)
		{
			RefreshNearestTargetsToCurrentPlayer();
		}
	}

	private void RefreshNearestTargetsToCurrentPlayer()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		_nearbyCharacters.Clear();
		int num = Physics.OverlapSphereNonAlloc(((Component)Player.m_localPlayer).transform.position, scanRadius, _scanBuffer, _layerMask);
		Character item = default(Character);
		for (int i = 0; i < num; i++)
		{
			if (((Component)_scanBuffer[i]).TryGetComponent<Character>(ref item))
			{
				_nearbyCharacters.Add(item);
			}
		}
		_lastScanTime = Time.time;
	}

	private void Refresh()
	{
	}
}
public class PowerConduitPlateBridge : PowerNetworkDataEntity<PowerConduitPlateBridge, PowerConduitPlateComponent, PowerConduitData>, IPowerConduit, IPowerNode
{
	public static List<PowerConduitPlateBridge> Instances = new List<PowerConduitPlateBridge>();

	public List<Player> m_localPlayers = new List<Player>();

	public Coroutine? _triggerCoroutine;

	public float interval = 2f;

	public bool MustSync;

	public Rigidbody m_body;

	public FixedJoint m_joint;

	private Transform? _lastParent;

	public string NetworkId => base.Logic.NetworkId;

	public Vector3 Position => ((Component)this).transform.position;

	public Vector3 ConnectorPoint => Position;

	public bool IsActive => Data.IsActive;

	public bool IsDemanding => base.Logic.IsDemanding;

	public void OnEnable()
	{
		if (!Instances.Contains(this))
		{
			Instances.Add(this);
		}
	}

	public void OnDisable()
	{
		Instances.Remove(this);
		Instances.RemoveAll((PowerConduitPlateBridge x) => !Object.op_Implicit((Object)(object)x));
	}

	public float RequestPower(float deltaTime)
	{
		LoggerProvider.LogWarning("Deprecated RequestPower", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations.PowerSystem.Components\\PowerConduitPlateBridge.cs", 51);
		return 0f;
	}

	public float SupplyPower(float deltaTime)
	{
		LoggerProvider.LogWarning("Deprecated SupplyPower", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations.PowerSystem.Components\\PowerConduitPlateBridge.cs", 56);
		return 0f;
	}

	private void HandlePlayerEnterActiveZone(Player player)
	{
		if (Object.op_Implicit((Object)(object)player))
		{
			Data.AddOrUpdate(player.GetPlayerID(), player.GetEitr(), ((Character)player).GetMaxEitr());
			if (!m_localPlayers.Contains(player))
			{
				m_localPlayers.Add(player);
			}
			base.Logic.SetHasPlayerInRange(Data.HasPlayersWithEitr);
		}
	}

	private void HandlePlayerExitActiveZone(Player player)
	{
		if (Object.op_Implicit((Object)(object)player))
		{
			Data.RemovePlayer(((Character)player).GetOwner());
			if (m_localPlayers.Contains(player))
			{
				m_localPlayers.Remove(player);
			}
			base.Logic.SetHasPlayerInRange(Data.HasPlayersWithEitr);
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		Player componentInParent = ((Component)other).GetComponentInParent<Player>();
		if (!Object.op_Implicit((Object)(object)componentInParent))
		{
			Physics.IgnoreCollision(other, base.Logic.m_triggerCollider, true);
			return;
		}
		HandlePlayerEnterActiveZone(componentInParent);
		if (m_localPlayers.Count > 0 && _triggerCoroutine == null)
		{
			_triggerCoroutine = ((MonoBehaviour)this).StartCoroutine(HandleTriggerRoutine());
		}
	}

	private IEnumerator HandleTriggerRoutine()
	{
		if (!this.IsNetViewValid(out ZNetView netview))
		{
			_triggerCoroutine = null;
			yield break;
		}
		while (((Behaviour)this).isActiveAndEnabled && m_localPlayers.Count > 0 && (Object)(object)netview != (Object)null && netview.m_zdo != null)
		{
			PowerSystemRPC.Request_OfferAllPlayerEitr(netview.m_zdo, m_localPlayers);
			yield return (object)new WaitForSeconds(interval);
		}
		_triggerCoroutine = null;
	}

	private void OnTriggerExit(Collider other)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		Player componentInParent = ((Component)other).GetComponentInParent<Player>();
		if (Object.op_Implicit((Object)(object)componentInParent))
		{
			HandlePlayerExitActiveZone(componentInParent);
			if (m_localPlayers.Count <= 0 && _triggerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_triggerCoroutine);
				_triggerCoroutine = null;
			}
			if (this.IsNetViewValid(out ZNetView validNetView))
			{
				PowerSystemRPC.Request_PlayerExitedConduit(validNetView.GetZDO().m_uid, componentInParent.GetPlayerID());
			}
		}
	}

	protected override void Start()
	{
		((MonoBehaviour)(object)this).WaitForPowerSystemNodeData(delegate(PowerConduitData data)
		{
			Data = data;
			Data.Load();
			base.Logic.GetPlayerEitr = () => PowerConduitData.GetAverageEitr(Data.PlayerPeerToData.Values.ToList(), Data.PlayerPeerToData);
			base.Logic.AddPlayerEitr = delegate(float val)
			{
				Data.AddEitrToPlayers(val);
			};
			base.Logic.SubtractPlayerEitr = delegate(float val)
			{
				Data.TryRemoveEitrFromPlayers(val);
			};
			_lastParent = ((Component)this).transform.parent;
			AddRigidbodyIfParentIsRigidbody();
		});
		base.Start();
	}

	public void OnTransformParentChanged()
	{
		Transform parent = ((Component)this).transform.parent;
		if (!Object.op_Implicit((Object)(object)parent) || !((Object)(object)parent == (Object)(object)_lastParent))
		{
			_lastParent = parent;
			AddRigidbodyIfParentIsRigidbody();
		}
	}

	protected void AddRigidbodyIfParentIsRigidbody()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody componentInParent = ((Component)this).GetComponentInParent<Rigidbody>();
		if (!Object.op_Implicit((Object)(object)m_body))
		{
			m_body = ((Component)this).gameObject.AddComponent<Rigidbody>();
		}
		m_body.isKinematic = !Object.op_Implicit((Object)(object)componentInParent);
		if (!Object.op_Implicit((Object)(object)componentInParent))
		{
			if (Object.op_Implicit((Object)(object)m_joint))
			{
				Object.Destroy((Object)(object)m_joint);
			}
		}
		else
		{
			FixedJoint obj = ((Component)this).gameObject.AddComponent<FixedJoint>();
			((Joint)obj).connectedBody = componentInParent;
			((Joint)obj).axis = Vector3.one;
			((Joint)obj).enableCollision = false;
		}
	}

	protected override void OnDestroy()
	{
		base.OnDestroy();
	}

	protected override void RegisterDefaultRPCs()
	{
	}

	public void SetNetworkId(string id)
	{
		if (this.IsNetViewValid(out ZNetView validNetView))
		{
			string networkId = validNetView.GetZDO().GetString("PowerSystem_NetworkId", "");
			base.Logic.SetNetworkId(networkId);
		}
	}

	GameObject IPowerNode.get_gameObject()
	{
		return ((Component)this).gameObject;
	}
}
public class CannonHandHeldController : CannonController, Hoverable
{
	[Header("Aiming")]
	public static float minPitch = -70f;

	public static float maxPitch = 70f;

	public static float minYaw = -30f;

	public static float maxYaw = 50f;

	[SerializeField]
	public float defaultElevationDegrees = 5f;

	[SerializeField]
	public bool debugDraw;

	private float _lastPitch;

	private float _lastYaw;

	private bool _hasLastAngles;

	private Quaternion _lastRotation;

	public static float SquareMagnitudeThreshold = 1E-06f;

	public static bool ShouldUpdate = true;

	public AmmoController ammoController;

	private Player m_player;

	public Transform? playerParentTransform;

	public Player? playerParentComponent;

	public static RPCEntity FireHandHeldCannon_RPC = null;

	protected internal override void Start()
	{
		m_nview = ((Component)this).GetComponentInParent<ZNetView>();
		ammoController = ((Component)this).GetComponent<AmmoController>();
		TryInitController();
		base.Start();
	}

	protected internal override void OnEnable()
	{
		base.OnEnable();
		base.OnFired += OnCannonFire;
	}

	protected internal override void OnDisable()
	{
		base.OnDisable();
		base.OnFired -= OnCannonFire;
	}

	public void OnCannonFire()
	{
		//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)
		if (!Object.op_Implicit((Object)(object)m_player))
		{
			m_player = ((Component)this).GetComponentInParent<Player>();
		}
		if (!((Object)(object)m_player == (Object)null))
		{
			((Character)m_player).ApplyPushback(-((Component)m_player).transform.forward, 0.2f);
			((Humanoid)m_player).ResetLoadedWeapon();
		}
	}

	private bool TryInitController()
	{
		try
		{
			if ((Object)(object)ammoController == (Object)null)
			{
				ammoController = ((Component)this).GetComponent<AmmoController>();
			}
			return (Object)(object)ammoController != (Object)null;
		}
		catch (Exception ex)
		{
			LoggerProvider.LogError("[HandCannonCameraPitchAiming] Failed to init controller: \n" + ex.Message, "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations\\CannonHandHeldController.cs", 77);
			return false;
		}
	}

	public void UpdatePlayerParent()
	{
		if (!((Object)(object)playerParentTransform != (Object)null))
		{
			playerParentComponent = ((Component)((Component)this).transform).GetComponentInParent<Player>();
			if ((Object)(object)playerParentComponent == (Object)null)
			{
				playerParentTransform = null;
				playerParentComponent = null;
			}
			else
			{
				playerParentTransform = ((Component)playerParentComponent).transform;
			}
		}
	}

	protected internal override void FixedUpdate()
	{
		//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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_018e: 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_0198: 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_0177: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		if (!ShouldUpdate || !TryInitController())
		{
			return;
		}
		UpdatePlayerParent();
		bool flag = IsHeldByLocalPlayer();
		if ((Object)(object)playerParentTransform == (Object)null)
		{
			return;
		}
		Transform parent = cannonRotationalTransform.parent;
		if (!Object.op_Implicit((Object)(object)parent))
		{
			return;
		}
		Vector3 val;
		if (flag)
		{
			if ((Object)(object)GameCamera.instance == (Object)null)
			{
				return;
			}
			Camera camera = GameCamera.instance.m_camera;
			if ((Object)(object)camera == (Object)null)
			{
				return;
			}
			val = parent.InverseTransformDirection(((Component)camera).transform.forward);
		}
		else
		{
			val = parent.InverseTransformDirection(playerParentTransform.forward);
		}
		if (((Vector3)(ref val)).sqrMagnitude < SquareMagnitudeThreshold)
		{
			return;
		}
		float num = Mathf.Atan2(val.x, val.z) * 57.29578f;
		num = Mathf.Clamp(num, minYaw, maxYaw);
		float num2 = (0f - Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f))) * 57.29578f;
		num2 -= defaultElevationDegrees;
		num2 = Mathf.Clamp(num2, minPitch, maxPitch);
		if (!_hasLastAngles || !Mathf.Approximately(num2, _lastPitch) || !Mathf.Approximately(num, _lastYaw))
		{
			Quaternion val2 = Quaternion.Euler(num2, num, 0f);
			Vector3 val3 = val2 * Vector3.forward;
			if (((Vector3)(ref val3)).sqrMagnitude < 1E-05f)
			{
				val2 = Quaternion.LookRotation(Vector3.forward, Vector3.up);
			}
			if (!_hasLastAngles || Quaternion.Angle(val2, _lastRotation) > 0.01f)
			{
				cannonRotationalTransform.localRotation = val2;
				_lastRotation = val2;
				_lastPitch = num2;
				_lastYaw = num;
				_hasLastAngles = true;
			}
			if (debugDraw)
			{
				RuntimeDebugLineDrawer.DrawLine(cannonShooterTransform.position, cannonShooterTransform.position + cannonShooterTransform.forward * 5f, Color.green, 0.1f, 0.04f);
			}
			base.FixedUpdate();
		}
	}

	public void Request_FireHandHeld()
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		if (ammoController.GetAmmoAmountFromCannonballVariant(AmmoVariant) < 1)
		{
			return;
		}
		if (!Object.op_Implicit((Object)(object)m_nview))
		{
			m_nview = ((Component)this).GetComponentInParent<ZNetView>();
		}
		if (!Object.op_Implicit((Object)(object)m_nview))
		{
			LoggerProvider.LogWarning("cannonController missing znetview!", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations\\CannonHandHeldController.cs", 186);
			return;
		}
		CannonFireData? cannonFireData = CannonFireData.CreateCannonFireDataFromHandHeld(this);
		if (!cannonFireData.HasValue)
		{
			LoggerProvider.LogWarning("cannonController missing cannonfiredata!", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations\\CannonHandHeldController.cs", 192);
			return;
		}
		ZPackage pkg = CannonFireData.WriteToPackage(cannonFireData.Value);
		cannonRotationalTransform.localRotation = cannonFireData.Value.cannonLocalRotation;
		FireHandHeldCannon_RPC.Send(ZNetView.Everybody, pkg);
		if (m_nview.IsOwner())
		{
			ammoController.OnAmmoChangedFromVariant(AmmoVariant, cannonFireData.Value.allocatedAmmo);
		}
		else
		{
			LoggerProvider.LogWarning("Attempted to decrement ammo but the user is not the owner.", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations\\CannonHandHeldController.cs", 205);
		}
	}

	public static void RegisterCannonControllerRPCs()
	{
		FireHandHeldCannon_RPC = RPCManager.RegisterRPC("RPC_FireHandHeldCannon", RPC_FireHandHeldCannon);
	}

	public static IEnumerator RPC_FireHandHeldCannon(long senderId, ZPackage package)
	{
		package.SetPos(0);
		CannonFireData data = CannonFireData.ReadFromPackage(package);
		ZDOID cannonControllerZDOID = data.cannonControllerZDOID;
		GameObject val = ZNetScene.instance.FindInstance(cannonControllerZDOID);
		if (!Object.op_Implicit((Object)(object)val))
		{
			LoggerProvider.LogWarning($"cannonHandheld {cannonControllerZDOID} not found. CannonController should exist otherwise we cannot instantiate cannonball without collision issues", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations\\CannonHandHeldController.cs", 225);
			yield break;
		}
		CannonHandHeldController componentInChildren = val.GetComponentInChildren<CannonHandHeldController>();
		if (!Object.op_Implicit((Object)(object)componentInChildren))
		{
			LoggerProvider.LogWarning($"cannonHandheld {cannonControllerZDOID} not found. CannonController should exist otherwise we cannot instantiate cannonball without collision issues", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.Integrations\\CannonHandHeldController.cs", 233);
			yield break;
		}
		bool isHost = componentInChildren.m_nview.IsOwner();
		componentInChildren.FireHandHeldCannon(data, isHost);
	}

	internal bool FireHandHeldCannon(CannonFireData data, bool isHost = true)
	{
		if (Fire(data, ammoController.GetAmmoAmountFromCannonballVariant(AmmoVariant), isManualFiring: true, isHost))
		{
			return true;
		}
		return false;
	}

	private bool IsHeldByLocalPlayer()
	{
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return false;
		}
		if ((Object)(object)playerParentComponent == (Object)null)
		{
			return false;
		}
		return (Object)(object)Player.m_localPlayer == (Object)(object)playerParentComponent;
	}

	public string GetHoverText()
	{
		return Localization.instance.Localize("$valheim_vehicles_cannon_handheld_item (H)");
	}

	public string GetHoverName()
	{
		return Localization.instance.Localize("$valheim_vehicles_cannon_handheld_item");
	}

	public float GetHoverOffset()
	{
		return 0f;
	}
}
namespace Registry
{
	public class ShipKeelPrefab : RegisterPrefab<ShipKeelPrefab>
	{
		public override void OnRegister()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab(PrefabNames.ShipKeel, LoadValheimVehicleAssets.ShipKeelAsset);
			PrefabRegistryHelpers.HoistSnapPointsToPrefab(val, val.transform);
			PrefabRegistryHelpers.AddNetViewWithPersistence(val);
			PrefabRegistryHelpers.SetWearNTear(val);
			PrefabRegistryHelpers.AddPieceForPrefab(PrefabNames.ShipKeel, val);
			PrefabRegistryHelpers.PieceData valueSafe = GeneralExtensions.GetValueSafe<string, PrefabRegistryHelpers.PieceData>(PrefabRegistryHelpers.PieceDataDictionary, PrefabNames.ShipKeel);
			PieceConfig val2 = new PieceConfig();
			val2.PieceTable = PrefabRegistryController.GetPieceTableName();
			val2.Description = valueSafe.Description;
			val2.Icon = LoadValheimVehicleAssets.VehicleSprites.GetSprite("keel");
			val2.Category = PrefabRegistryController.SetCategoryName("Structure");
			val2.Enabled = true;
			val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Amount = 10,
					Item = "Wood",
					Recover = true
				}
			};
			PrefabRegistryController.AddPiece(new CustomPiece(val, false, val2));
		}
	}
	public class VehiclePiecesPrefab : RegisterPrefab<VehiclePiecesPrefab>
	{
		public static GameObject VehiclePiecesContainer;

		public override void OnRegister()
		{
			RegisterPiecesContainer();
		}

		public void RegisterPiecesContainer()
		{
			VehiclePiecesContainer = PrefabManager.Instance.CreateClonedPrefab(PrefabNames.VehiclePiecesContainer, LoadValheimVehicleAssets.VehiclePiecesAsset);
		}
	}
}
namespace ValheimVehicles
{
	public class ValheimVehiclesPlugin : MonoBehaviour
	{
		public const string Author = "zolantris";

		public const string Version = "1.0.0";

		internal const string ModName = "ValheimVehicles";

		public const string ModGuid = "zolantris.ValheimVehicles";

		public static bool HasRunSetup;

		private static bool HasCreatedConfig;

		private RetryGuard _languageRetry;

		private MapPinSync _mapPinSync;

		private SwivelUIPanelComponentIntegration _swivelUIPanel;

		private ScreenSizeWatcher _screenSizeWatcher;

		private PowerNetworkControllerIntegration _powerNetworkController;

		private Coroutine? translationRoutine;

		internal static ConfigSync ModConfigSync;

		public static ValheimVehiclesPlugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			_languageRetry = new RetryGuard((MonoBehaviour)(object)Instance);
			if (!Object.op_Implicit((Object)(object)LoadValheimVehicleAssets._bundle))
			{
				PrefabRegistryController.InitValheimVehiclesAssetBundle();
			}
			TMPProHelpers.Init();
		}

		private IEnumerator UpdateTranslationsRoutine()
		{
			Stopwatch timer = Stopwatch.StartNew();
			while (timer.ElapsedMilliseconds < 10000 && !ModTranslations.CanRunLocalization())
			{
				yield return null;
			}
			Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(OnLanguageChanged));
			OnLanguageChanged();
			ModTranslations.ForceUpdateTranslations();
			yield return (object)new WaitForFixedUpdate();
			ModTranslations.ForceUpdateTranslations();
			yield return (object)new WaitForSeconds(3f);
			ModTranslations.ForceUpdateTranslations();
			yield return (object)new WaitForSeconds(10f);
			_languageRetry.Reset();
			OnLanguageChanged();
			yield return (object)new WaitForSeconds(20f);
			_languageRetry.Reset();
			OnLanguageChanged();
			translationRoutine = null;
		}

		private void OnEnable()
		{
			Setup();
			translationRoutine = ((MonoBehaviour)this).StartCoroutine(UpdateTranslationsRoutine());
		}

		private void OnDisable()
		{
			((MonoBehaviour)this).CancelInvoke();
			if (translationRoutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(translationRoutine);
				translationRoutine = null;
			}
			HasRunSetup = false;
			if ((Object)(object)_mapPinSync != (Object)null)
			{
				Object.Destroy((Object)(object)_mapPinSync);
			}
			if (Localization.instance != null)
			{
				Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(OnLanguageChanged));
			}
		}

		public void Setup()
		{
			if (!HasRunSetup)
			{
				SetupComponents();
				HasRunSetup = true;
			}
		}

		private void SetupComponents()
		{
			_mapPinSync = ((Component)this).gameObject.AddComponent<MapPinSync>();
			_swivelUIPanel = ((Component)this).gameObject.AddComponent<SwivelUIPanelComponentIntegration>();
			_screenSizeWatcher = ((Component)this).gameObject.AddComponent<ScreenSizeWatcher>();
			_powerNetworkController = ((Component)this).gameObject.AddComponent<PowerNetworkControllerIntegration>();
		}

		private void OnLanguageChanged()
		{
			ModTranslations.ForceUpdateTranslations();
			if (!ModTranslations.IsHealthy())
			{
				_languageRetry.Retry(OnLanguageChanged, 1f);
			}
			else
			{
				_languageRetry.Reset();
			}
		}

		[UsedImplicitly]
		public static void CreateConfigFromValheimRAFTPluginConfig(ConfigSync configSync, ConfigFile config)
		{
			if (!HasCreatedConfig)
			{
				ModConfigSync = configSync;
				BepInExBaseConfig<PatchConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<PrefabConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<CannonPrefabConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<RamConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<PrefabRecipeConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<VehicleGuiMenuConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<PropulsionConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<ModSupportConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<CustomMeshConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<WaterConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<PhysicsConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<MinimapConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<HudConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<CameraConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<RenderingConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<VehicleGlobalConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<GuiConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<PowerSystemConfig>.BindConfig(config, ModConfigSync);
				BepInExBaseConfig<Mod_PieceOverlapConfig>.BindConfig(config, ModConfigSync);
				LoggerProvider.LogInfo("Plugin ValheimVehicles started on server.", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehiclesPlugin.cs", 196);
				HasCreatedConfig = true;
			}
		}
	}
}
namespace ValheimVehicles.Shared.Constants
{
	public static class VehicleZdoVars
	{
		public const string ZdoKeyBaseVehicleInitState = "ValheimVehicles_BaseVehicle_Initialized";

		public const string ModVersion = "ValheimVehicles_ModVersion";

		public const string VehicleFloatationHeight = "ValheimVehicles_VehicleFloatationHeight";

		public const string VehicleFloatationCustomModeEnabled = "ValheimVehicles_VehicleFloatationCustomModeEnabled";

		public const string ToggleSwitchAction = "ValheimVehicles_ToggleSwitchAction";

		public const string RopeConnections = "MBRopeAnchor_Ropes";

		public const string SwivelParentId = "SwivelParentId";

		public const string Mechanism_Swivel_TargetId = "Mechanism_swivelTargetId";

		public const string SwivelSyncPosition = "SwivelSync_Position";

		public const string SwivelSyncRotation = "SwivelSync_Rotation";

		public const string SwivelSyncVelocity = "SwivelSync_Velocity";

		public const string SwivelSyncAngularVelocity = "SwivelSync_AngularVelocity";

		public const string PowerSystem_IsActive = "PowerSystem_IsActive";

		public const string PowerSystem_NetworkId = "PowerSystem_NetworkId";

		public const string PowerSystem_Energy = "PowerSystem_StoredEnergy";

		public const string PowerSystem_Fuel = "PowerSystem_StoredFuel";

		public const string PowerSystem_FuelOutputRate = "PowerSystem_FuelOutputRate";

		public const string PowerSystem_FuelType = "PowerSystem_FuelType";

		public const string PowerSystem_EnergyCapacity = "PowerSystem_StoredEnergyCapacity";

		public const string PowerSystem_StoredFuelCapacity = "PowerSystem_StoredFuelCapacity";

		public const string PowerSystem_IsForceDeactivated = "PowerSystem_ForceDeactivated";

		public const string PowerSystem_IsRunning = "PowerSystem_IsRunning";

		public const string PowerSystem_IsDemanding = "PowerSystem_IsDemanding";

		public const string PowerSystem_BasePowerConsumption = "PowerSystem_BasePowerConsumption";

		public const string PowerSystem_Intensity_Level = "PowerSystem_ConsumerLevel";

		public static string CustomMeshId = "ValheimVehicles_CustomMesh";

		public static string CustomMeshScale = "ValheimVehicles_CustomMeshSize";

		public static string CustomMeshPrimitiveType = "ValheimVehicles_CustomMeshPrimitiveType";

		public static readonly int MBCultivatableParentIdHash = StringExtensionMethods.GetStableHashCode("MBCultivatableParentId");

		public static readonly int TempPieceParentId = StringExtensionMethods.GetStableHashCode("VehicleTempPieceParentId");

		public static readonly int DEPRECATED_VehicleFlags = StringExtensionMethods.GetStableHashCode("VehicleFlags");

		public static readonly string VehicleAnchorState = "VehicleAnchorState";

		public const string VehicleIsTeleporting = "VehicleIsTeleporting";

		public const string VehicleChunkBounds = "VehicleChunkBounds";

		public static readonly int VehicleTargetHeight = StringExtensionMethods.GetStableHashCode("VehicleTargetHeight");

		public static readonly int VehicleOceanSway = StringExtensionMethods.GetStableHashCode("VehicleOceanSway");

		public static readonly int MBParentId = StringExtensionMethods.GetStableHashCode("MBParentId");

		public static readonly int MBPositionHash = StringExtensionMethods.GetStableHashCode("MBPosition");

		public static readonly int MBRotationHash = StringExtensionMethods.GetStableHashCode("MBRotation");

		public static readonly int MBRotationVecHash = StringExtensionMethods.GetStableHashCode("MBRotationVec");

		public static readonly int MBPieceCount = StringExtensionMethods.GetStableHashCode("MBPieceCount");

		public static readonly KeyValuePair<int, int> MBCultivatableParentHash = ZDO.GetHashZDOID("MBCultivatableParent");

		public static readonly KeyValuePair<int, int> MBParentHash = ZDO.GetHashZDOID("MBParent");
	}
}
namespace ValheimVehicles.UI
{
	public static class DropdownHelpers
	{
		public static void SetupOptionsAndSelectFirst(TMP_Dropdown dropdown, List<OptionData> options)
		{
			if ((Object)(object)dropdown == (Object)null || options == null || options.Count == 0)
			{
				LoggerProvider.LogWarning("[DropdownHelpers] Dropdown or options list is null/empty. Cannot setup options.", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.UI\\DropdownHelpers.cs", 16);
				return;
			}
			dropdown.ClearOptions();
			dropdown.AddOptions(options);
			dropdown.RefreshShownValue();
			dropdown.value = 0;
			dropdown.captionText.text = options[0].text;
		}
	}
	public class DropdownRefreshOnHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler
	{
		private TMP_Dropdown dropdown;

		public Action<TMP_Dropdown>? OnPointerEnterAction;

		private void Awake()
		{
			dropdown = ((Component)this).GetComponent<TMP_Dropdown>();
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			OnPointerEnterAction?.Invoke(dropdown);
		}
	}
	public class EditRampComponent
	{
		private BoardingRampComponent m_ramp;

		private GameObject m_editPanel;

		private InputField m_segmentsInput;

		private int m_segmentCount;

		public void ShowPanel(BoardingRampComponent boardingRamp)
		{
			m_ramp = boardingRamp;
			if (!Object.op_Implicit((Object)(object)m_editPanel))
			{
				InitPanel();
			}
			m_segmentCount = boardingRamp.m_segments;
			m_segmentsInput.SetTextWithoutNotify(boardingRamp.m_segments.ToString());
			GUIManager.BlockInput(true);
			m_editPanel.SetActive(true);
		}

		private void InitPanel()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			Transform transform = GUIManager.CustomGUIFront.transform;
			m_editPanel = Object.Instantiate<GameObject>(PrefabRegistryController.vehicleAssetBundle.LoadAsset<GameObject>("edit_ramp_panel"), transform, false);
			PanelUtil.ApplyPanelStyle(m_editPanel);
			m_segmentsInput = ((Component)m_editPanel.transform.Find("SegmentsInput")).GetComponent<InputField>();
			Button component = ((Component)m_editPanel.transform.Find("SaveButton")).GetComponent<Button>();
			Button component2 = ((Component)m_editPanel.transform.Find("CancelButton")).GetComponent<Button>();
			((UnityEvent)component.onClick).AddListener(new UnityAction(SaveEditPanel));
			((UnityEvent)component2.onClick).AddListener(new UnityAction(CancelEditPanel));
			((UnityEvent<string>)(object)m_segmentsInput.onValueChanged).AddListener((UnityAction<string>)delegate(string val)
			{
				int.TryParse(val, out m_segmentCount);
				m_segmentCount = Mathf.Clamp(m_segmentCount, 2, 32);
			});
		}

		private void ClosePanel()
		{
			GUIManager.BlockInput(false);
			m_editPanel.SetActive(false);
		}

		private void CancelEditPanel()
		{
			ClosePanel();
		}

		private void SaveEditPanel()
		{
			if ((Object)(object)m_ramp != (Object)null)
			{
				m_ramp.SetSegmentCount(m_segmentCount);
			}
			ClosePanel();
		}
	}
	public class EditSailComponentPanel
	{
		private GameObject m_editPanel;

		private GameObject m_editSailPanel;

		private GameObject m_editPatternPanel;

		private GameObject m_editLogoPanel;

		private SailComponent m_editSail;

		private Toggle[] m_editLockedSailSides;

		private Toggle[] m_editLockedSailCorners;

		private Toggle m_sailShrinkingToggle;

		private GameObject m_locksTri;

		private GameObject m_locksQuad;

		private Toggle m_disableClothToggle;

		private TMP_Dropdown m_sailVariantDropdown;

		private Transform sailVariantTransform;

		public static string[] GetVariantNames()
		{
			return new string[4]
			{
				ModTranslations.CustomSail,
				ModTranslations.RaftSail,
				ModTranslations.KarveSail,
				ModTranslations.DrakkalSail
			};
		}

		public static string GetMaterialFromVariant(SailComponent.MaterialVariant material)
		{
			return material switch
			{
				SailComponent.MaterialVariant.Custom => ModTranslations.CustomSail, 
				SailComponent.MaterialVariant.Raft => ModTranslations.RaftSail, 
				SailComponent.MaterialVariant.Drakkal => ModTranslations.DrakkalSail, 
				SailComponent.MaterialVariant.Karve => ModTranslations.KarveSail, 
				_ => ModTranslations.CustomSail, 
			};
		}

		public static SailComponent.MaterialVariant GetVariant(string variantName)
		{
			if (variantName == ModTranslations.CustomSail)
			{
				return SailComponent.MaterialVariant.Custom;
			}
			if (variantName == ModTranslations.RaftSail)
			{
				return SailComponent.MaterialVariant.Raft;
			}
			if (variantName == ModTranslations.DrakkalSail)
			{
				return SailComponent.MaterialVariant.Drakkal;
			}
			if (variantName == ModTranslations.KarveSail)
			{
				return SailComponent.MaterialVariant.Karve;
			}
			return SailComponent.MaterialVariant.Custom;
		}

		public void ShowPanel(SailComponent sailComponent)
		{
			m_editSail = sailComponent;
			m_editSail.StartEdit();
			bool flag = m_editSail.m_sailCorners.Count == 3;
			if (!Object.op_Implicit((Object)(object)m_editPanel))
			{
				InitPanel();
			}
			GameObject val = (flag ? m_locksTri : m_locksQuad);
			m_editLockedSailCorners = (Toggle[])(object)new Toggle[flag ? 3 : 4];
			m_editLockedSailSides = (Toggle[])(object)new Toggle[flag ? 3 : 4];
			m_locksTri.SetActive(flag);
			m_locksQuad.SetActive(!flag);
			m_editLockedSailCorners[0] = ((Component)val.transform.Find("CornerA")).GetComponent<Toggle>();
			m_editLockedSailCorners[1] = ((Component)val.transform.Find("CornerB")).GetComponent<Toggle>();
			m_editLockedSailCorners[2] = ((Component)val.transform.Find("CornerC")).GetComponent<Toggle>();
			if (!flag)
			{
				m_editLockedSailCorners[3] = ((Component)val.transform.Find("CornerD")).GetComponent<Toggle>();
			}
			m_editLockedSailSides[0] = ((Component)val.transform.Find("SideA")).GetComponent<Toggle>();
			m_editLockedSailSides[1] = ((Component)val.transform.Find("SideB")).GetComponent<Toggle>();
			m_editLockedSailSides[2] = ((Component)val.transform.Find("SideC")).GetComponent<Toggle>();
			if (!flag)
			{
				m_editLockedSailSides[3] = ((Component)val.transform.Find("SideD")).GetComponent<Toggle>();
			}
			UpdateSelectedSailVariant();
			for (int i = 0; i < m_editLockedSailCorners.Length; i++)
			{
				m_editLockedSailCorners[i].SetIsOnWithoutNotify(m_editSail.m_lockedSailCorners.HasFlag((SailComponent.SailLockedSide)(1 << i)));
				m_editLockedSailSides[i].SetIsOnWithoutNotify(m_editSail.m_lockedSailSides.HasFlag((SailComponent.SailLockedSide)(1 << i)));
			}
			m_sailShrinkingToggle.SetIsOnWithoutNotify(m_editSail.m_sailFlags.HasFlag(SailComponent.SailFlags.AllowSailShrinking));
			m_disableClothToggle.SetIsOnWithoutNotify(m_editSail.m_sailFlags.HasFlag(SailComponent.SailFlags.DisableCloth));
			GUIManager.BlockInput(true);
			m_editPanel.SetActive(true);
		}

		private void UpdateSelectedSailVariant()
		{
			if (!Object.op_Implicit((Object)(object)sailVariantTransform))
			{
				return;
			}
			TMP_Dropdown componentInChildren = ((Component)sailVariantTransform).GetComponentInChildren<TMP_Dropdown>();
			string[] variantNames = GetVariantNames();
			int valueWithoutNotify = 0;
			try
			{
				valueWithoutNotify = variantNames.ToList().FindIndex((string x) => GetVariant(x) == m_editSail.m_materialVariant);
			}
			catch (Exception)
			{
			}
			componentInChildren.SetValueWithoutNotify(valueWithoutNotify);
		}

		private void InitPanel()
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Expected O, but got Unknown
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Expected O, but got Unknown
			Transform transform = GUIManager.CustomGUIFront.transform;
			m_editPanel = Object.Instantiate<GameObject>(LoadValheimRaftAssets.editPanel, transform, false);
			PanelUtil.ApplyPanelStyle(m_editPanel);
			GameObject editTexturePanel = LoadValheimRaftAssets.editTexturePanel;
			PanelUtil.ApplyPanelStyle(editTexturePanel);
			GUIManager.Instance.ApplyDropdownStyle(((Component)editTexturePanel.transform.Find("TextureName")).GetComponent<Dropdown>(), 15);
			m_editSailPanel = Object.Instantiate<GameObject>(editTexturePanel, transform, false);
			m_editPatternPanel = Object.Instantiate<GameObject>(editTexturePanel, transform, false);
			m_editLogoPanel = Object.Instantiate<GameObject>(editTexturePanel, transform, false);
			m_editSailPanel.SetActive(false);
			m_editPatternPanel.SetActive(false);
			m_editLogoPanel.SetActive(false);
			((UnityEvent)((Component)m_editSailPanel.transform.Find("Button")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				m_editSailPanel.SetActive(false);
				m_editPanel.SetActive(true);
			});
			((UnityEvent)((Component)m_editPatternPanel.transform.Find("Button")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				m_editPatternPanel.SetActive(false);
				m_editPanel.SetActive(true);
			});
			((UnityEvent)((Component)m_editLogoPanel.transform.Find("Button")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				m_editLogoPanel.SetActive(false);
				m_editPanel.SetActive(true);
			});
			GameObject gameObject = ((Component)m_editPanel.transform.Find("SaveButton")).gameObject;
			((UnityEvent)((Component)m_editPanel.transform.Find("CancelButton")).gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(CancelEditPanel));
			((UnityEvent)gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(SaveEditPanel));
			m_sailShrinkingToggle = ((Component)m_editPanel.transform.Find("SailShrinkingToggle")).GetComponent<Toggle>();
			((UnityEvent<bool>)(object)m_sailShrinkingToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool b)
			{
				m_editSail.SetSailMastSetting(SailComponent.SailFlags.AllowSailShrinking, b);
			});
			m_disableClothToggle = ((Component)m_editPanel.transform.Find("SailClothToggle")).GetComponent<Toggle>();
			((UnityEvent<bool>)(object)m_disableClothToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool b)
			{
				m_editSail.SetSailMastSetting(SailComponent.SailFlags.DisableCloth, b);
			});
			m_locksTri = ((Component)m_editPanel.transform.Find("LocksTri")).gameObject;
			m_locksQuad = ((Component)m_editPanel.transform.Find("LocksQuad")).gameObject;
			Toggle[] componentsInChildren = m_locksTri.GetComponentsInChildren<Toggle>();
			for (int num = 0; num < componentsInChildren.Length; num++)
			{
				((UnityEvent<bool>)(object)componentsInChildren[num].onValueChanged).AddListener((UnityAction<bool>)delegate
				{
					UpdateSails();
				});
			}
			componentsInChildren = m_locksQuad.GetComponentsInChildren<Toggle>();
			for (int num = 0; num < componentsInChildren.Length; num++)
			{
				((UnityEvent<bool>)(object)componentsInChildren[num].onValueChanged).AddListener((UnityAction<bool>)delegate
				{
					UpdateSails();
				});
			}
			Button component = ((Component)m_editPanel.transform.Find("EditSailButton")).GetComponent<Button>();
			Button component2 = ((Component)m_editPanel.transform.Find("EditPatternButton")).GetComponent<Button>();
			Button component3 = ((Component)m_editPanel.transform.Find("EditLogoButton")).GetComponent<Button>();
			sailVariantTransform = m_editPanel.transform.Find("SailVariant");
			if (Object.op_Implicit((Object)(object)sailVariantTransform))
			{
				SwivelUISharedStyles viewStyles = new SwivelUISharedStyles();
				string[] variantNames = GetVariantNames();
				int num2 = 0;
				try
				{
					num2 = variantNames.ToList().FindIndex((string x) => GetVariant(x) == m_editSail.m_materialVariant);
				}
				catch (Exception)
				{
				}
				SwivelUIHelpers.AddDropdownRow(sailVariantTransform, viewStyles, ModTranslations.SailVariant, variantNames, variantNames[num2], delegate(int val)
				{
					if (val <= variantNames.Length - 1)
					{
						SailComponent.MaterialVariant variant = GetVariant(variantNames[val]);
						m_editSail.SetMaterialVariant(variant);
					}
				});
			}
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				m_editSailPanel.SetActive(true);
				m_editPatternPanel.SetActive(false);
				m_editLogoPanel.SetActive(false);
				m_editPanel.SetActive(false);
				LoadTexturePanel(m_editSailPanel, m_editSail.GetSailMaterial(), "_Main", CustomTextureGroup.Get("Sails"));
			});
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				m_editSailPanel.SetActive(false);
				m_editPatternPanel.SetActive(true);
				m_editLogoPanel.SetActive(false);
				m_editPanel.SetActive(false);
				LoadTexturePanel(m_editPatternPanel, m_editSail.GetSailMaterial(), "_Pattern", CustomTextureGroup.Get("Patterns"));
			});
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				m_editSailPanel.SetActive(false);
				m_editPatternPanel.SetActive(false);
				m_editLogoPanel.SetActive(true);
				m_editPanel.SetActive(false);
				LoadTexturePanel(m_editLogoPanel, m_editSail.GetSailMaterial(), "_Logo", CustomTextureGroup.Get("Logos"));
			});
		}

		private void LoadTexturePanel(GameObject editPanel, Material mat, string parameterName, CustomTextureGroup group)
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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_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)
			Button component = ((Component)editPanel.transform.Find("TextureColor")).GetComponent<Button>();
			Dropdown component2 = ((Component)editPanel.transform.Find("TextureName")).GetComponent<Dropdown>();
			InputField component3 = ((Component)editPanel.transform.Find("OffsetX")).GetComponent<InputField>();
			InputField component4 = ((Component)editPanel.transform.Find("OffsetY")).GetComponent<InputField>();
			InputField component5 = ((Component)editPanel.transform.Find("TilingX")).GetComponent<InputField>();
			InputField component6 = ((Component)editPanel.transform.Find("TilingY")).GetComponent<InputField>();
			InputField component7 = ((Component)editPanel.transform.Find("Rotation")).GetComponent<InputField>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((UnityEventBase)component2.onValueChanged).RemoveAllListeners();
			((UnityEventBase)component3.onValueChanged).RemoveAllListeners();
			((UnityEventBase)component4.onValueChanged).RemoveAllListeners();
			((UnityEventBase)component5.onValueChanged).RemoveAllListeners();
			((UnityEventBase)component6.onValueChanged).RemoveAllListeners();
			((UnityEventBase)component7.onValueChanged).RemoveAllListeners();
			List<OptionData> list = new List<OptionData>();
			for (int i = 0; i < group.Textures.Count; i++)
			{
				list.Add(new OptionData(((Object)group.Textures[i].Texture).name));
			}
			component2.options = list;
			((UnityEvent<int>)(object)component2.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
			{
				mat.SetTexture(parameterName + "Tex", group.Textures[index].Texture);
				if (Object.op_Implicit((Object)(object)group.Textures[index].Normal))
				{
					mat.SetTexture(parameterName + "Normal", group.Textures[index].Normal);
				}
			});
			GUIManager.Instance.ApplyDropdownStyle(component2, 15);
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: 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_0059: 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_0070: Expected O, but got Unknown
				//IL_0070: Expected O, but got Unknown
				GUIManager.Instance.CreateColorPicker(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), mat.GetColor(parameterName + "Color"), "Color", (ColorEvent)delegate(Color color)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					mat.SetColor(parameterName + "Color", color);
				}, (ColorEvent)delegate(Color color)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					mat.SetColor(parameterName + "Color", color);
				}, true);
			});
			((UnityEvent<string>)(object)component3.onValueChanged).AddListener((UnityAction<string>)delegate(string str)
			{
				//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_0044: Unknown result type (might be due to invalid IL or missing references)
				if (float.TryParse(str, out var result))
				{
					Vector2 textureOffset2 = mat.GetTextureOffset(parameterName + "Tex");
					textureOffset2.x = result;
					mat.SetTextureOffset(parameterName + "Tex", textureOffset2);
				}
			});
			((UnityEvent<string>)(object)component4.onValueChanged).AddListener((UnityAction<string>)delegate(string str)
			{
				//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_0044: Unknown result type (might be due to invalid IL or missing references)
				if (float.TryParse(str, out var result))
				{
					Vector2 textureOffset2 = mat.GetTextureOffset(parameterName + "Tex");
					textureOffset2.y = result;
					mat.SetTextureOffset(parameterName + "Tex", textureOffset2);
				}
			});
			((UnityEvent<string>)(object)component5.onValueChanged).AddListener((UnityAction<string>)delegate(string str)
			{
				//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_0044: Unknown result type (might be due to invalid IL or missing references)
				if (float.TryParse(str, out var result))
				{
					Vector2 textureScale2 = mat.GetTextureScale(parameterName + "Tex");
					textureScale2.x = result;
					mat.SetTextureScale(parameterName + "Tex", textureScale2);
				}
			});
			((UnityEvent<string>)(object)component6.onValueChanged).AddListener((UnityAction<string>)delegate(string str)
			{
				//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_0044: Unknown result type (might be due to invalid IL or missing references)
				if (float.TryParse(str, out var result))
				{
					Vector2 textureScale2 = mat.GetTextureScale(parameterName + "Tex");
					textureScale2.y = result;
					mat.SetTextureScale(parameterName + "Tex", textureScale2);
				}
			});
			string text = parameterName + "Rotation";
			if (mat.HasProperty(text))
			{
				((Component)component7).gameObject.SetActive(true);
				((UnityEvent<string>)(object)component7.onValueChanged).AddListener((UnityAction<string>)delegate(string str)
				{
					if (float.TryParse(str, out var result))
					{
						mat.SetFloat(parameterName + "Rotation", result);
					}
				});
			}
			else
			{
				((Component)component7).gameObject.SetActive(false);
			}
			Texture texture = mat.GetTexture(parameterName + "Tex");
			CustomTexture textureByHash = group.GetTextureByHash(StringExtensionMethods.GetStableHashCode(((Object)texture).name));
			if (textureByHash != null)
			{
				component2.SetValueWithoutNotify(textureByHash.Index);
			}
			UpdateColorButton(component, mat.GetColor(parameterName + "Color"));
			Vector2 textureOffset = mat.GetTextureOffset(parameterName + "Tex");
			component3.SetTextWithoutNotify(textureOffset.x.ToString());
			component4.SetTextWithoutNotify(textureOffset.y.ToString());
			Vector2 textureScale = mat.GetTextureScale(parameterName + "Tex");
			component5.SetTextWithoutNotify(textureScale.x.ToString());
			component6.SetTextWithoutNotify(textureScale.y.ToString());
			if (((Component)component7).gameObject.activeSelf)
			{
				component7.SetTextWithoutNotify(mat.GetFloat(parameterName + "Rotation").ToString());
			}
		}

		private void UpdateColorButton(Button button, Color color)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_003b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			color.a = 1f;
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = color;
			((ColorBlock)(ref colors)).highlightedColor = color;
			((ColorBlock)(ref colors)).disabledColor = color;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			((ColorBlock)(ref colors)).pressedColor = color;
			((ColorBlock)(ref colors)).selectedColor = color;
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((Selectable)button).colors = colors;
		}

		private void UpdateSails()
		{
			if (Object.op_Implicit((Object)(object)m_editSail))
			{
				m_editSail.m_lockedSailCorners = SailComponent.SailLockedSide.None;
				for (int i = 0; i < m_editLockedSailCorners.Length; i++)
				{
					m_editSail.m_lockedSailCorners |= (SailComponent.SailLockedSide)(m_editLockedSailCorners[i].isOn ? (1 << i) : 0);
				}
				m_editSail.m_lockedSailSides = SailComponent.SailLockedSide.None;
				for (int j = 0; j < m_editLockedSailSides.Length; j++)
				{
					m_editSail.m_lockedSailSides |= (SailComponent.SailLockedSide)(m_editLockedSailSides[j].isOn ? (1 << j) : 0);
				}
				m_editSail.UpdateCoefficients();
			}
		}

		private void CloseEditPanel()
		{
			if (Object.op_Implicit((Object)(object)m_editPanel))
			{
				m_editPanel.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)m_editSail))
			{
				m_editSail.EndEdit();
			}
			m_editSail = null;
			GUIManager.BlockInput(false);
		}

		private void CancelEditPanel()
		{
			if (Object.op_Implicit((Object)(object)m_editSail))
			{
				m_editSail.LoadZDO();
			}
			CloseEditPanel();
		}

		private void SaveEditPanel()
		{
			if (Object.op_Implicit((Object)(object)m_editSail))
			{
				m_editSail.LoadFromMaterial();
				m_editSail.SaveZdo();
				m_editSail.LoadZDO();
				m_editSail.RequestSyncZDOData();
			}
			CloseEditPanel();
		}
	}
	public class PanelUtil
	{
		public static GameObject CreateBasicPanel(string panelName, bool hasImage)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_004e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			GameObject val = new GameObject(panelName, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			((Object)val).name = panelName;
			if (!hasImage)
			{
				((Behaviour)val.GetComponent<Image>()).enabled = false;
			}
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(600f, 0f);
			VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
			((LayoutGroup)obj).padding = new RectOffset(20, 20, 20, 20);
			ContentSizeFitter obj2 = val.AddComponent<ContentSizeFitter>();
			obj2.verticalFit = (FitMode)2;
			obj2.horizontalFit = (FitMode)2;
			LayoutElement obj3 = val.AddComponent<LayoutElement>();
			obj3.preferredHeight = Mathf.Clamp((float)Screen.height - 100f, 500f, 800f);
			obj3.flexibleWidth = 1f;
			obj3.minWidth = 300f;
			obj3.preferredWidth = 500f;
			obj3.flexibleHeight = 0f;
			return val;
		}

		public static void OnPanelPositionChange(RectTransform panelTransform, ConfigEntry<Vector2> WindowPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Vector2 anchoredPosition = panelTransform.anchoredPosition;
			WindowPosition.Value = anchoredPosition;
		}

		public static GameObject CreateDraggableHideShowPanel(string panelName, Transform panelParent, Unity2dViewStyles panelStyles, Unity2dViewStyles buttonStyles, string hideText, string showText, ConfigEntry<Vector2> WindowPosition, Action<Text>? onToggle = null, bool isActive = false)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_0168: 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_020f: Expected O, but got Unknown
			GameObject panel = CreateBasicPanel(panelName, hasImage: false);
			DragWindowControllerExtension dragWindowControllerExtension = panel.AddComponent<DragWindowControllerExtension>();
			panel.transform.SetParent(panelParent, false);
			panel.GetComponent<Image>().pixelsPerUnitMultiplier = 1f;
			RectTransform panelTransform = (RectTransform)panel.transform;
			panelTransform.anchoredPosition = WindowPosition.Value;
			panelTransform.anchorMin = panelStyles.anchorMin;
			panelTransform.anchorMax = panelStyles.anchorMax;
			if (panelStyles.width.HasValue)
			{
				panelTransform.SetSizeWithCurrentAnchors((Axis)0, panelStyles.width.GetValueOrDefault());
			}
			if (panelStyles.height.HasValue)
			{
				panelTransform.SetSizeWithCurrentAnchors((Axis)1, panelStyles.height.GetValueOrDefault());
			}
			dragWindowControllerExtension.OnDragCalled = (Action<RectTransform>)Delegate.Combine(dragWindowControllerExtension.OnDragCalled, (Action<RectTransform>)delegate(RectTransform _panelTransform)
			{
				OnPanelPositionChange(_panelTransform, WindowPosition);
			});
			ScreenSizeWatcher.OnScreenSizeChanged += delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				GuiConfig.EnsurePanelInScreenBounds(panelTransform.anchoredPosition, WindowPosition);
				panelTransform.anchoredPosition = WindowPosition.Value;
			};
			GameObject val = GUIManager.Instance.CreateButton(isActive ? hideText : showText, panel.transform, buttonStyles.anchorMin, buttonStyles.anchorMax, buttonStyles.position, buttonStyles.width ?? 150f, buttonStyles.height ?? 150f);
			LayoutElement obj = val.AddComponent<LayoutElement>();
			obj.flexibleWidth = 150f;
			obj.flexibleHeight = 0f;
			obj.preferredHeight = buttonStyles.height ?? 40f;
			obj.minHeight = 32f;
			Text text = val.GetComponentInChildren<Text>();
			Button component = val.GetComponent<Button>();
			bool hasToggle = onToggle != null;
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				if (!((Object)(object)text == (Object)null))
				{
					if (hasToggle)
					{
						onToggle?.Invoke(text);
					}
					else
					{
						bool flag = !panel.activeSelf;
						text.text = (flag ? hideText : showText);
						panel.SetActive(flag);
					}
				}
			});
			return panel;
		}

		public static void ApplyPanelStyle(GameObject editPanel)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			Array.ForEach(editPanel.GetComponentsInChildren<Button>(true), delegate(Button b)
			{
				if (((Object)b).name.EndsWith("Button"))
				{
					GUIManager.Instance.ApplyButtonStyle(b, 16);
				}
			});
			Array.ForEach(editPanel.GetComponentsInChildren<InputField>(true), delegate(InputField b)
			{
				GUIManager.Instance.ApplyInputFieldStyle(b, 16);
			});
			Array.ForEach(editPanel.GetComponentsInChildren<Text>(true), delegate(Text b)
			{
				b.text = Localization.instance.Localize(b.text);
				if (((Object)b).name.EndsWith("Label"))
				{
					GUIManager.Instance.ApplyTextStyle(b, 16);
				}
			});
			Array.ForEach(editPanel.GetComponentsInChildren<Toggle>(true), delegate(Toggle b)
			{
				if (((Object)b).name.EndsWith("Toggle"))
				{
					GUIManager.Instance.ApplyToogleStyle(b);
				}
			});
			Image component = editPanel.GetComponent<Image>();
			component.sprite = GUIManager.Instance.GetSprite("woodpanel_trophys");
			component.type = (Type)1;
			((Graphic)component).material = Cache.GetPrefab<Material>("litpanel");
			((Graphic)component).color = Color.white;
		}
	}
	public class ScreenSizeWatcher : SingletonBehaviour<ScreenSizeWatcher>
	{
		private Vector2Int _lastSize;

		private Coroutine? _updateCoroutine;

		public static event Action<Vector2Int>? OnScreenSizeChanged;

		private void Start()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			_lastSize = new Vector2Int(Screen.width, Screen.height);
		}

		private void OnEnable()
		{
			_updateCoroutine = ((MonoBehaviour)this).StartCoroutine(UpdateScreenSizeCoroutine());
		}

		private void OnDisable()
		{
			if (_updateCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_updateCoroutine);
				_updateCoroutine = null;
			}
		}

		private void SyncScreenSize()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)this).isActiveAndEnabled)
			{
				Vector2Int val = default(Vector2Int);
				((Vector2Int)(ref val))..ctor(Screen.width, Screen.height);
				if (val != _lastSize)
				{
					_lastSize = val;
					ScreenSizeWatcher.OnScreenSizeChanged?.Invoke(val);
				}
			}
		}

		private IEnumerator UpdateScreenSizeCoroutine()
		{
			while (((Behaviour)this).isActiveAndEnabled)
			{
				yield return (object)new WaitForEndOfFrame();
				SyncScreenSize();
			}
		}
	}
	public class SwivelUIPanelComponentIntegration : SwivelUIPanelComponent
	{
		public Action<Text>? OnPanelToggleAction;

		public Unity2dViewStyles buttonStyles = new Unity2dViewStyles
		{
			anchorMin = Vector2.zero,
			anchorMax = Vector2.one,
			position = Vector2.zero,
			width = 150f
		};

		public Unity2dViewStyles panelStyles = new Unity2dViewStyles
		{
			width = 500f
		};

		private const string PanelName = "ValheimVehicles_SwivelPanel";

		public override void OnAwake()
		{
			_ = ZNetView.m_forceDisableInit;
		}

		public void OnEnable()
		{
		}

		public void OnDisable()
		{
		}

		public static void Init()
		{
			if (!Object.op_Implicit((Object)(object)SingletonBehaviour<SwivelUIPanelComponent>.Instance) && Object.op_Implicit((Object)(object)Game.instance))
			{
				((Component)Game.instance).gameObject.AddComponent<SwivelUIPanelComponentIntegration>();
			}
		}

		public void TryGetCurrentSwivelIntegration()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_currentSwivel) && Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				SwivelHelpers.FindAllSwivelsWithinRange(((Component)Player.m_localPlayer).transform.position, out List<SwivelComponent> _, out _currentSwivel);
			}
		}

		public override void BindTo(SwivelComponent target, bool isToggle = false)
		{
			if (!Object.op_Implicit((Object)(object)target))
			{
				LoggerProvider.LogDebug("No swivel to open this panel", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.UI\\SwivelUIPanelComponentIntegration.cs", 64);
				Object.Destroy((Object)(object)panelRoot);
				return;
			}
			if (Object.op_Implicit((Object)(object)_currentSwivel))
			{
				SwivelComponentBridge swivelComponentBridge = _currentSwivel as SwivelComponentBridge;
				if ((Object)(object)swivelComponentBridge != (Object)null)
				{
					swivelComponentBridge.prefabConfigSync.Load();
				}
			}
			base.BindTo(target, isToggle);
		}

		public void SyncUIFromPartialConfig(SwivelCustomConfig updated)
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_currentSwivel == (Object)null || IsEditing)
			{
				return;
			}
			SwivelCustomConfig currentPanelConfig = _currentPanelConfig;
			if (updated.Mode != currentPanelConfig.Mode)
			{
				modeDropdown.value = (int)updated.Mode;
				_currentPanelConfig.Mode = updated.Mode;
				RefreshUI();
			}
			if (!Mathf.Approximately(updated.InterpolationSpeed, currentPanelConfig.InterpolationSpeed))
			{
				movementLerpRow.GetComponentInChildren<Slider>().SetValueWithoutNotify(updated.InterpolationSpeed);
				_currentPanelConfig.InterpolationSpeed = updated.InterpolationSpeed;
			}
			if (updated.HingeAxes != currentPanelConfig.HingeAxes)
			{
				Toggle[] componentsInChildren = hingeAxisRow.GetComponentsInChildren<Toggle>();
				if (componentsInChildren.Length == 3)
				{
					componentsInChildren[0].isOn = updated.HingeAxes.HasFlag(HingeAxis.X);
					componentsInChildren[1].isOn = updated.HingeAxes.HasFlag(HingeAxis.Y);
					componentsInChildren[2].isOn = updated.HingeAxes.HasFlag(HingeAxis.Z);
				}
				_currentPanelConfig.HingeAxes = updated.HingeAxes;
			}
			if (updated.MaxEuler != currentPanelConfig.MaxEuler)
			{
				maxXRow.GetComponentInChildren<Slider>().value = updated.MaxEuler.x;
				maxYRow.GetComponentInChildren<Slider>().value = updated.MaxEuler.y;
				maxZRow.GetComponentInChildren<Slider>().value = updated.MaxEuler.z;
				_currentPanelConfig.MaxEuler = updated.MaxEuler;
			}
			if (updated.MovementOffset != currentPanelConfig.MovementOffset)
			{
				targetDistanceXRow.GetComponentInChildren<Slider>().value = updated.MovementOffset.x;
				targetDistanceYRow.GetComponentInChildren<Slider>().value = updated.MovementOffset.y;
				targetDistanceZRow.GetComponentInChildren<Slider>().value = updated.MovementOffset.z;
				_currentPanelConfig.MovementOffset = updated.MovementOffset;
			}
			motionStateDropdown.value = (int)updated.MotionState;
			IsEditing = false;
		}

		protected override void OnPanelSave()
		{
			TryGetCurrentSwivelIntegration();
			SwivelComponentBridge swivelComponentBridge = _currentSwivel as SwivelComponentBridge;
			if (Object.op_Implicit((Object)(object)swivelComponentBridge) && ((INetView)swivelComponentBridge).IsNetViewValid())
			{
				SwivelCustomConfig swivelCustomConfig = new SwivelCustomConfig();
				swivelCustomConfig.ApplyFrom(_currentPanelConfig);
				swivelCustomConfig.MotionState = swivelComponentBridge.MotionState;
				if (swivelCustomConfig.Mode == SwivelMode.None && modeDropdown.value != 0)
				{
					LoggerProvider.LogWarning("Swivel is in None mode, but the UI does not match. Not saving. This is a bug.", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.UI\\SwivelUIPanelComponentIntegration.cs", 151);
				}
				else
				{
					swivelComponentBridge.prefabConfigSync.Request_CommitConfigChange(swivelCustomConfig);
				}
			}
		}

		public override GameObject CreateUIRoot()
		{
			return PanelUtil.CreateDraggableHideShowPanel("ValheimVehicles_SwivelPanel", VehicleGui.GetVehicleGui().transform, panelStyles, buttonStyles, ModTranslations.GuiShow, ModTranslations.GuiHide, GuiConfig.SwivelPanelLocation);
		}
	}
	public static class TMPDropdownFactory
	{
		public static Color BackgroundElementColor = new Color(0.2f, 0.2f, 0.2f, 1f);

		public static TMP_Dropdown CreateTMPDropDown(Transform parent, Vector2 anchoredPosition, Vector2 size, string captionText = "", string itemPrototypeText = "Option")
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Expected O, but got Unknown
			//IL_0314: 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_0340: 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_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Expected O, but got Unknown
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Expected O, but got Unknown
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Expected O, but got Unknown
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: 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)
			GameObject val = new GameObject("VehicleGUI_TMP_Dropdown", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(TMP_Dropdown)
			});
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = size;
			component.anchoredPosition = anchoredPosition;
			GameObject val2 = new GameObject("Label", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val2.transform.SetParent(val.transform, false);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = new Vector2(10f, 6f);
			component2.offsetMax = new Vector2(-25f, -7f);
			TextMeshProUGUI component3 = val2.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component3).font = TMP_Settings.defaultFontAsset;
			((TMP_Text)component3).text = captionText ?? "";
			((TMP_Text)component3).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)component3).fontSize = 24f;
			((Graphic)component3).color = GUIManager.Instance.ValheimOrange;
			GameObject val3 = new GameObject("Arrow", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val3.transform.SetParent(val.transform, false);
			RectTransform component4 = val3.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(1f, 0.5f);
			component4.anchorMax = new Vector2(1f, 0.5f);
			component4.sizeDelta = new Vector2(20f, 20f);
			component4.anchoredPosition = new Vector2(-15f, 0f);
			GameObject val4 = new GameObject("Template", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(ScrollRect)
			});
			val4.transform.SetParent(val.transform, false);
			val4.SetActive(false);
			RectTransform component5 = val4.GetComponent<RectTransform>();
			component5.pivot = new Vector2(0.5f, 1f);
			component5.anchorMin = new Vector2(0f, 0f);
			component5.anchorMax = new Vector2(1f, 0f);
			component5.sizeDelta = new Vector2(0f, 150f);
			Canvas obj = val4.AddComponent<Canvas>();
			obj.overrideSorting = true;
			obj.sortingOrder = 300;
			ScrollRect component6 = val4.GetComponent<ScrollRect>();
			GameObject val5 = new GameObject("Viewport", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Mask)
			});
			val5.transform.SetParent(val4.transform, false);
			RectTransform component7 = val5.GetComponent<RectTransform>();
			component7.pivot = new Vector2(0f, 1f);
			component7.anchorMin = new Vector2(0f, 0f);
			component7.anchorMax = new Vector2(1f, 1f);
			component7.offsetMin = Vector2.zero;
			component7.offsetMax = Vector2.zero;
			val5.GetComponent<Mask>().showMaskGraphic = false;
			component6.viewport = component7;
			GameObject val6 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val6.transform.SetParent(val5.transform, false);
			RectTransform component8 = val6.GetComponent<RectTransform>();
			component8.pivot = new Vector2(0.5f, 1f);
			component8.anchorMin = new Vector2(0f, 0f);
			component8.anchorMax = new Vector2(1f, 1f);
			component8.offsetMin = Vector2.zero;
			component8.offsetMax = Vector2.zero;
			VerticalLayoutGroup component9 = val6.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component9).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component9).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component9).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component9).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component9).spacing = 5f;
			((LayoutGroup)component9).padding = new RectOffset(5, 5, 5, 5);
			val6.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			component6.content = component8;
			GameObject val7 = new GameObject("Item", new Type[2]
			{
				typeof(RectTransform),
				typeof(Toggle)
			});
			LayoutElement obj2 = val7.AddComponent<LayoutElement>();
			obj2.preferredHeight = 30f;
			obj2.minHeight = 30f;
			obj2.flexibleHeight = 0f;
			val7.transform.SetParent(val6.transform, false);
			val7.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 30f);
			Image val8 = (Image)(object)(((Selectable)val7.GetComponent<Toggle>()).targetGraphic = (Graphic)(object)val7.AddComponent<Image>());
			GameObject val10 = new GameObject("Item Label", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val10.transform.SetParent(val7.transform, false);
			RectTransform component10 = val10.GetComponent<RectTransform>();
			component10.anchorMin = Vector2.zero;
			component10.anchorMax = Vector2.one;
			component10.offsetMin = new Vector2(10f, 0f);
			component10.offsetMax = new Vector2(-10f, 0f);
			TextMeshProUGUI component11 = val10.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component11).font = TMP_Settings.defaultFontAsset;
			((TMP_Text)component11).text = itemPrototypeText ?? "Option";
			((TMP_Text)component11).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)component11).fontSize = 22f;
			((Graphic)component11).color = GUIManager.Instance.ValheimOrange;
			TMP_Dropdown component12 = val.GetComponent<TMP_Dropdown>();
			component12.captionText = (TMP_Text)(object)component3;
			component12.template = component5;
			component12.itemText = (TMP_Text)(object)component11;
			((Selectable)component12).targetGraphic = (Graphic)(object)val.GetComponent<Image>();
			component6.content = component8;
			Image component13 = val.GetComponent<Image>();
			Image component14 = val4.GetComponent<Image>();
			((Graphic)component13).color = BackgroundElementColor;
			((Graphic)component14).color = BackgroundElementColor;
			((Graphic)val8).color = BackgroundElementColor;
			return component12;
		}
	}
	public class VehicleGui : SingletonBehaviour<VehicleGui>
	{
		private GUIStyle? myButtonStyle;

		private string ShipMovementOffsetText;

		private Vector3 _shipMovementOffset;

		public static TMP_Dropdown VehicleSelectDropdown;

		public static VehicleGui Gui;

		public static GameObject GuiObj;

		public const string vehicleConfigHide = "Vehicle Config (Hide)";

		public const string vehicleConfigShow = "Vehicle Config (Show)";

		public static bool vehicleDebugPhysicsSync = true;

		private int buttonFontSize = 16;

		private int titleFontSize = 18;

		private GUIStyle buttonStyle;

		private GUIStyle labelStyle;

		public static bool hasCommandsWindowOpened = false;

		public static bool hasConfigPanelOpened = false;

		public static bool isCommandsToggleButtonVisible = false;

		public static bool isConfigPanelToggleButtonVisible = false;

		private GameObject? configWindow;

		private GameObject? commandsWindow;

		private GameObject? commandsToggleButtonWindow;

		private GameObject? configToggleButtonWindow;

		private List<GameObject> commandsPanelToggleObjects = new List<GameObject>();

		private List<GameObject> configPanelToggleObjects = new List<GameObject>();

		private bool hasInitialized;

		private const int panelHeight = 500;

		private const float buttonHeight = 60f;

		private const float buttonWidth = 350f;

		private static float panelWidth = 385f;

		private static readonly Vector2 anchorMin = new Vector2(0f, 0.5f);

		private static readonly Vector2 anchorMax = new Vector2(0.5f, 0.5f);

		private static readonly Vector2 panelPosition = Vector2.zero;

		private static readonly Vector3 buttonHeightVector3 = Vector3.up * 60f;

		private static readonly Vector3 panelHeightVector3 = Vector3.up * 500f / 2f;

		public bool lastPanelState;

		public VehicleManager? targetInstance;

		private GenericInputAction _getCurrentVehicleGenericInputAction = new GenericInputAction
		{
			title = "Update current vehicle",
			OnButtonPress = delegate
			{
				if (!((Object)(object)SingletonBehaviour<VehicleGui>.Instance == (Object)null))
				{
					VehicleManager nearestVehicleManager = VehicleCommands.GetNearestVehicleManager();
					if ((Object)(object)nearestVehicleManager == (Object)null)
					{
						SingletonBehaviour<VehicleGui>.Instance.targetInstance = null;
					}
					else
					{
						SingletonBehaviour<VehicleGui>.Instance.targetInstance = nearestVehicleManager;
					}
				}
			}
		};

		private const string CommandsPanelWindowName = "ValheimVehicles_commandsWindow";

		private const string ConfigPanelWindowName = "ValheimVehicles_configWindow";

		public static GameObject? ConfigScrollView;

		public static Slider? LandVehicleTreadDistance_Slider;

		public static Slider? LandVehicleTreadScale_Slider;

		public static TMP_InputField? LandVehicleTreadDistance_Input;

		public static TMP_InputField? LandVehicleTreadScale_Input;

		public static TMP_InputField? VehicleName_Input;

		public static Slider? WaterFloatation_Slider;

		public static Toggle? WaterFloatation_Toggle;

		public static GameObject? WaterFloatationSliderRow;

		public static TMP_InputField? WaterFloatation_Input;

		public static VehicleManager? CurrentSelectedVehicle;

		public static bool IsEditing = false;

		private static TextMeshProUGUI _saveStatus;

		private static Button _resetButton;

		public static VehicleCustomConfig _tempVehicleConfig = new VehicleCustomConfig();

		public static string vehicleCommandsHide => ModTranslations.GuiCommandsMenuTitle + " (" + ModTranslations.GuiHide + ")";

		public static string vehicleCommandsShow => ModTranslations.GuiCommandsMenuTitle + " (" + ModTranslations.GuiShow + ")";

		public static GameObject GetVehicleGui()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if ((Object)(object)GuiObj == (Object)null)
			{
				GameObject val = new GameObject("ValheimVehicles_VehicleGui");
				val.transform.parent = GUIManager.CustomGUIFront.transform;
				val.layer = LayerHelpers.UILayer;
				GuiObj = val;
			}
			return GuiObj;
		}

		public static void AddRemoveVehicleGui()
		{
			if (!((Object)(object)ZNet.instance == (Object)null))
			{
				if (Object.op_Implicit((Object)(object)Gui))
				{
					Gui.RemoveGui();
					Gui = null;
				}
				if (Object.op_Implicit((Object)(object)GuiObj))
				{
					Object.Destroy((Object)(object)GuiObj);
					GuiObj = null;
				}
				GuiObj = GetVehicleGui();
				if ((Object)(object)Gui == (Object)null)
				{
					Gui = GuiObj.gameObject.GetOrAddComponent<VehicleGui>();
				}
				if ((Object)(object)SingletonBehaviour<VehicleGui>.Instance != (Object)null)
				{
					SingletonBehaviour<VehicleGui>.Instance.InitPanel();
					SetCommandsPanelState(VehicleGuiMenuConfig.VehicleDebugMenuEnabled.Value);
				}
			}
		}

		private Vector3 GetShipMovementOffset()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			string[] array = ShipMovementOffsetText.Split(',');
			if (array.Length != 3)
			{
				return new Vector3(0f, 0f, 0f);
			}
			float num = float.Parse(array[0]);
			float num2 = float.Parse(array[1]);
			float num3 = float.Parse(array[2]);
			return new Vector3(num, num2, num3);
		}

		private void Start()
		{
			buttonFontSize = VehicleGuiMenuConfig.ButtonFontSize.Value;
			titleFontSize = VehicleGuiMenuConfig.TitleFontSize.Value;
			hasInitialized = false;
			GUIManager.OnCustomGUIAvailable += InitPanel;
		}

		private void OnEnable()
		{
			hasInitialized = false;
			InitPanel();
		}

		private void OnDisable()
		{
			RemoveGui();
		}

		public void RemoveGui()
		{
			commandsPanelToggleObjects.Clear();
			configPanelToggleObjects.Clear();
			if (Object.op_Implicit((Object)(object)commandsToggleButtonWindow))
			{
				Object.Destroy((Object)(object)commandsToggleButtonWindow);
			}
			if (Object.op_Implicit((Object)(object)configToggleButtonWindow))
			{
				Object.Destroy((Object)(object)configToggleButtonWindow);
			}
			if (Object.op_Implicit((Object)(object)commandsWindow))
			{
				Object.Destroy((Object)(object)commandsWindow);
			}
			if (Object.op_Implicit((Object)(object)configWindow))
			{
				Object.Destroy((Object)(object)configWindow);
			}
			commandsToggleButtonWindow = null;
			configToggleButtonWindow = null;
			commandsWindow = null;
			configWindow = null;
			if (Object.op_Implicit((Object)(object)GuiObj))
			{
				Object.Destroy((Object)(object)GuiObj);
			}
		}

		public static void ToggleConfigPanelState(bool shouldHideShowButton = false)
		{
			hasConfigPanelOpened = !hasConfigPanelOpened;
			HideOrShowVehicleConfigPanel(hasConfigPanelOpened, shouldHideShowButton);
		}

		public static void SetConfigPanelState(bool val)
		{
			hasConfigPanelOpened = val;
			HideOrShowVehicleConfigPanel(val, canUpdateTogglePanel: true);
		}

		public void HideOrShowPanel(bool isVisible, bool shouldDeactivateToggleButton, ref GameObject toggleWindow, ref GameObject panelWindow, ref List<GameObject> toggleObjects)
		{
			if ((Object)(object)SingletonBehaviour<VehicleGui>.Instance == (Object)null)
			{
				return;
			}
			if ((Object)(object)toggleWindow == (Object)null || (Object)(object)panelWindow == (Object)null)
			{
				InitPanel();
			}
			if ((Object)(object)toggleWindow != (Object)null && shouldDeactivateToggleButton)
			{
				toggleWindow.SetActive(isVisible);
			}
			if (!((Object)(object)panelWindow != (Object)null))
			{
				return;
			}
			panelWindow.SetActive(isVisible);
			toggleObjects.ForEach(delegate(GameObject x)
			{
				if (!((Object)(object)x == (Object)null))
				{
					x.SetActive(isVisible);
				}
			});
		}

		public static void HideOrShowCommandPanel(bool isVisible, bool canUpdateTogglePanel)
		{
			if ((Object)(object)SingletonBehaviour<VehicleGui>.Instance == (Object)null)
			{
				AddRemoveVehicleGui();
			}
			else
			{
				SingletonBehaviour<VehicleGui>.Instance.HideOrShowPanel(isVisible, canUpdateTogglePanel, ref SingletonBehaviour<VehicleGui>.Instance.commandsToggleButtonWindow, ref SingletonBehaviour<VehicleGui>.Instance.commandsWindow, ref SingletonBehaviour<VehicleGui>.Instance.commandsPanelToggleObjects);
			}
		}

		public static void HideOrShowVehicleConfigPanel(bool isVisible, bool canUpdateTogglePanel)
		{
			if ((Object)(object)SingletonBehaviour<VehicleGui>.Instance == (Object)null)
			{
				AddRemoveVehicleGui();
			}
			else
			{
				SingletonBehaviour<VehicleGui>.Instance.HideOrShowPanel(isVisible, canUpdateTogglePanel, ref SingletonBehaviour<VehicleGui>.Instance.configToggleButtonWindow, ref SingletonBehaviour<VehicleGui>.Instance.configWindow, ref SingletonBehaviour<VehicleGui>.Instance.configPanelToggleObjects);
			}
		}

		public static void SetCommandsPanelState(bool val)
		{
			hasCommandsWindowOpened = val;
			HideOrShowVehicleConfigPanel(val, canUpdateTogglePanel: false);
		}

		public static void ToggleCommandsPanelState(bool canUpdateTogglePanel)
		{
			hasCommandsWindowOpened = !hasCommandsWindowOpened;
			HideOrShowCommandPanel(hasCommandsWindowOpened, canUpdateTogglePanel);
			if (!hasCommandsWindowOpened)
			{
				HideOrShowVehicleConfigPanel(hasCommandsWindowOpened, canUpdateTogglePanel: true);
			}
		}

		public void InitPanel()
		{
			if (GUIManager.Instance != null && !((Object)(object)GUIManager.CustomGUIFront == (Object)null))
			{
				CreateCommandsShortcutPanel();
				CreateVehicleConfigShortcutPanel();
				HideOrShowCommandPanel(hasCommandsWindowOpened, canUpdateTogglePanel: true);
				HideOrShowVehicleConfigPanel(hasConfigPanelOpened, canUpdateTogglePanel: true);
				hasInitialized = true;
			}
		}

		public static void VehicleSelectOnDropdownChanged(int index)
		{
			List<VehicleStorageController.StoredVehicleData> allVehicles = VehicleStorageController.GetAllVehicles();
			if (index == 0)
			{
				VehicleStorageController.SelectedVehicle = "";
			}
			else if (index > 0 && index <= allVehicles.Count)
			{
				VehicleStorageController.SelectedVehicle = allVehicles[index - 1].VehicleName;
				LoggerProvider.LogInfo("Selected Vehicle: " + VehicleStorageController.SelectedVehicle, "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.UI\\VehicleGui.cs", 306);
			}
			else
			{
				LoggerProvider.LogWarning("No vehicles detected cannot select any vehicle.", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.UI\\VehicleGui.cs", 310);
				VehicleStorageController.SelectedVehicle = "";
			}
		}

		public static GameObject AddDropdownWithAction(GenericInputAction genericInputAction, int index, float StartHeight, Transform parent)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			TMP_Dropdown val = TMPDropdownFactory.CreateTMPDropDown(parent, new Vector2(0f, StartHeight - (float)index * 60f), new Vector2(350f, 90f));
			if (genericInputAction.OnDropdownChanged != null)
			{
				((UnityEvent<int>)(object)val.onValueChanged).AddListener(genericInputAction.OnDropdownChanged);
			}
			else
			{
				LoggerProvider.LogError("OnDropdownChanged not provided for a AddDropdownAction. This is an error with Valheim Vehicles. Please Report", "C:\\Users\\L4zerShark\\Documents\\CODEX_LOCAL_PROJECTS\\VALHEIM_PROJECTS\\ValheimRAFT\\source-5.0.7\\src\\ValheimVehicles\\ValheimVehicles.UI\\VehicleGui.cs", 330);
			}
			DropdownRefreshOnHover dropdownRefreshOnHover = ((Component)val).gameObject.AddComponent<DropdownRefreshOnHover>();
			if (genericInputAction.OnPointerEnterAction != null)
			{
				dropdownRefreshOnHover.OnPointerEnterAction = genericInputAction.OnPointerEnterAction;
			}
			if (genericInputAction.OnCreateDropdown != null)
			{
				genericInputAction.OnCreateDropdown(val);
			}
			return ((Component)val).gameObject;
		}

		public GameObject AddInputWithAction(GenericInputAction genericInputAction, int index, float StartHeight, Transform windowTransform)
		{
			//IL_0011: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GUIManager.Instance.CreateInputField(windowTransform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, StartHeight - (float)index * 60f), (ContentType)2, "8", 16, 0f, 0f);
			obj.SetActive(true);
			((UnityEvent<string>)(object)obj.GetComponent<InputField>().onSubmit).AddListener((UnityAction<string>)delegate(string x)
			{
				if (float.TryParse(x, out var result))
				{
					Logger.LogDebug((object)$"Converted string to float {result}");
				}
				else
				{
					Logger.LogDebug((object)("Not a string " + x));
				}
			});
			return obj;
		}

		public GameObject AddButtonWithAction(GenericInputAction genericInputAction, int index, float StartHeight, Transform windowTransform)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			GameObject obj = GUIManager.Instance.CreateButton(genericInputAction.title, windowTransform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, StartHeight - (float)index * 60f), 350f, 60f);
			obj.SetActive(true);
			Button component = obj.GetComponent<Button>();
			Text component2 = obj.GetComponent<Text>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.fontSize = buttonFontSize;
			}
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				genericInputAction.OnButtonPress();
			});
			return obj;
		}

		private GameObject CreateConfigTogglePanel()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			Unity2dViewStyles panelStyles = new Unity2dViewStyles
			{
				anchorMin = anchorMin,