Decompiled source of NjordsFavor v0.1.4

BepInEx/plugins/NjordsFavor/NjordsFavor.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.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using SailingProgression;
using UnityEngine;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SailingProgression
{
	public static class TailwindItems
	{
		[HarmonyPatch]
		private static class BoatWind
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				string[] array = new string[4] { "GetSailForce", "GetWindAngleFactor", "UpdateSail", "GetWindAngle" };
				foreach (string text in array)
				{
					yield return AccessTools.Method(typeof(Ship), text, (Type[])null, (Type[])null);
				}
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				MethodInfo direction = AccessTools.Method(typeof(EnvMan), "GetWindDir", (Type[])null, (Type[])null);
				MethodInfo intensity = AccessTools.Method(typeof(EnvMan), "GetWindIntensity", (Type[])null, (Type[])null);
				foreach (CodeInstruction instruction in instructions)
				{
					bool wind = CodeInstructionExtensions.Calls(instruction, direction);
					bool flag = CodeInstructionExtensions.Calls(instruction, intensity);
					if (wind || flag)
					{
						CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
						val.labels.AddRange(instruction.labels);
						instruction.labels.Clear();
						val.blocks.AddRange(instruction.blocks);
						instruction.blocks.Clear();
						yield return val;
						instruction.opcode = OpCodes.Call;
						instruction.operand = AccessTools.Method(typeof(TailwindItems), wind ? "Direction" : "Intensity", (Type[])null, (Type[])null);
					}
					yield return instruction;
				}
			}
		}

		public const string Id = "branchofyore.sailingprogression";

		public const string Belt = "TailwindBelt";

		public const string Charm = "TailwindCharm";

		public const string ActiveKey = "branchofyore.tailwindgear.equipped";

		public const string Favor = "NjordsFavor";

		private static StatusEffect? favor;

		private static readonly FieldRef<Ship, List<Player>> Aboard = AccessTools.FieldRefAccess<Ship, List<Player>>("m_players");

		public static void Initialize()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Register;
		}

		private static void Register()
		{
			Add("TailwindBelt", "BeltStrength", "Njord's Belt", (ItemType)18);
			Add("TailwindCharm", "Wishbone", "Njord's Charm", (ItemType)24);
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
		}

		private static void Add(string name, string source, string label, ItemType slot)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = label;
			val.Description = "Equip to gain Njord's Favor: steady tailwind while steering a boat. Belt and charm provide the same effect and do not stack.";
			val.CraftingStation = "piece_workbench";
			val.MinStationLevel = 1;
			val.Amount = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
			{
				new RequirementConfig("SerpentScale", 5, 0, true),
				new RequirementConfig("TrophySerpent", 1, 0, true),
				new RequirementConfig("Bronze", (name == "TailwindCharm") ? 10 : 5, 0, true),
				new RequirementConfig("LeatherScraps", (name == "TailwindCharm") ? 5 : 10, 0, true)
			};
			CustomItem val2 = new CustomItem(name, source, val);
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			shared.m_itemType = slot;
			shared.m_equipStatusEffect = null;
			shared.m_maxStackSize = 1;
			shared.m_maxQuality = 1;
			shared.m_useDurability = false;
			TailwindVisuals.Apply(val2.ItemPrefab, name == "TailwindCharm");
			if (!Object.op_Implicit((Object)(object)favor))
			{
				favor = ScriptableObject.CreateInstance<StatusEffect>();
				((Object)favor).name = "NjordsFavor";
				favor.m_name = "Njord's Favor";
				favor.m_tooltip = "Steady tailwind while steering a boat.";
				favor.m_icon = shared.m_icons[0];
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(favor, false));
			}
			shared.m_equipStatusEffect = favor;
			ItemManager.Instance.AddItem(val2);
		}

		public static bool Equipped(Player player)
		{
			return ((Humanoid)player).GetInventory().GetAllItems().Any((ItemData i) => i.m_equipped && Object.op_Implicit((Object)(object)i.m_dropPrefab) && (((Object)i.m_dropPrefab).name == "TailwindBelt" || ((Object)i.m_dropPrefab).name == "TailwindCharm"));
		}

		public static void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return;
			}
			ZNetView component = ((Component)localPlayer).GetComponent<ZNetView>();
			if (Object.op_Implicit((Object)(object)component) && component.IsValid() && component.IsOwner())
			{
				bool flag = Equipped(localPlayer);
				if (component.GetZDO().GetBool("branchofyore.tailwindgear.equipped", false) != flag)
				{
					component.GetZDO().Set("branchofyore.tailwindgear.equipped", flag);
				}
			}
		}

		public static Player? Captain(Ship ship)
		{
			if (!Object.op_Implicit((Object)(object)ship) || !Object.op_Implicit((Object)(object)ship.m_shipControlls))
			{
				return null;
			}
			long user = ship.m_shipControlls.GetUser();
			if (user == 0L)
			{
				return null;
			}
			return ((IEnumerable<Player>)Aboard.Invoke(ship)).FirstOrDefault((Func<Player, bool>)((Player p) => Object.op_Implicit((Object)(object)p) && !((Character)p).IsDead() && p.GetPlayerID() == user));
		}

		public static bool Active(Ship ship)
		{
			Player val = Captain(ship);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			if ((Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				return Equipped(val);
			}
			ZNetView component = ((Component)val).GetComponent<ZNetView>();
			if (Object.op_Implicit((Object)(object)component) && component.IsValid())
			{
				return component.GetZDO().GetBool("branchofyore.tailwindgear.equipped", false);
			}
			return false;
		}

		public static Vector3 Direction(EnvMan env, Ship ship)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!Active(ship))
			{
				return env.GetWindDir();
			}
			Vector3 val = Vector3.ProjectOnPlane(((Component)ship).transform.forward, Vector3.up);
			return ((Vector3)(ref val)).normalized;
		}

		public static float Intensity(EnvMan env, Ship ship)
		{
			if (!Active(ship))
			{
				return env.GetWindIntensity();
			}
			return 1f;
		}

		public static void Shutdown()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
		}
	}
	public static class TailwindVisuals
	{
		private static Material bronze;

		private static Material leather;

		private static Material dark;

		private static Material wind;

		public static void Apply(GameObject prefab, bool charm)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0092: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			SharedData shared = prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
			using (Stream stream = typeof(TailwindVisuals).Assembly.GetManifestResourceStream("TailwindGear." + (charm ? "charm" : "belt") + ".png"))
			{
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				Texture2D val = new Texture2D(2, 2);
				AssetUtils.LoadImage(val, memoryStream.ToArray());
				shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)) };
			}
			Materials(prefab);
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			LODGroup[] componentsInChildren2 = prefab.GetComponentsInChildren<LODGroup>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			Collider[] componentsInChildren3 = prefab.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			Transform val2 = prefab.transform.Find("attach");
			if (Object.op_Implicit((Object)(object)val2))
			{
				Object.DestroyImmediate((Object)(object)((Component)val2).gameObject);
			}
			Transform transform = new GameObject("attach").transform;
			transform.SetParent(prefab.transform, false);
			if (charm)
			{
				Charm(transform);
			}
			else
			{
				Belt(transform);
			}
			Bounds val3 = default(Bounds);
			((Bounds)(ref val3))..ctor(Vector3.zero, Vector3.zero);
			bool flag = true;
			MeshFilter[] componentsInChildren4 = ((Component)transform).GetComponentsInChildren<MeshFilter>();
			foreach (MeshFilter val4 in componentsInChildren4)
			{
				Vector3[] vertices = val4.sharedMesh.vertices;
				foreach (Vector3 val5 in vertices)
				{
					Vector3 val6 = prefab.transform.InverseTransformPoint(((Component)val4).transform.TransformPoint(val5));
					if (flag)
					{
						((Bounds)(ref val3))..ctor(val6, Vector3.zero);
						flag = false;
					}
					else
					{
						((Bounds)(ref val3)).Encapsulate(val6);
					}
				}
			}
			BoxCollider obj = prefab.AddComponent<BoxCollider>();
			obj.center = ((Bounds)(ref val3)).center;
			obj.size = ((Bounds)(ref val3)).size + Vector3.one * 0.008f;
			shared.m_weight = (charm ? 0.5f : 1f);
		}

		private static void Materials(GameObject prefab)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)bronze))
			{
				return;
			}
			Material val = null;
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Material[] sharedMaterials = componentsInChildren[i].sharedMaterials;
				foreach (Material val2 in sharedMaterials)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						val = val2;
						break;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				Material[] sharedMaterials = Resources.FindObjectsOfTypeAll<Material>();
				foreach (Material val3 in sharedMaterials)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						val = val3;
						break;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("No native item material available.");
			}
			bronze = Material(val, new Color(0.61f, 0.4f, 0.15f), 0.65f);
			leather = Material(val, new Color(0.22f, 0.105f, 0.045f), 0f);
			dark = Material(val, new Color(0.13f, 0.14f, 0.12f), 0.3f);
			wind = Material(val, new Color(0.12f, 0.78f, 0.8f), 0.25f);
			wind.EnableKeyword("_EMISSION");
			wind.SetColor("_EmissionColor", new Color(0.035f, 0.35f, 0.4f));
		}

		private static Material Material(Material source, Color color, float metal)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			Material val = new Material(source)
			{
				mainTexture = (Texture)(object)Texture2D.whiteTexture,
				color = color
			};
			val.SetFloat("_Metallic", metal);
			val.SetFloat("_Glossiness", 0.3f);
			return val;
		}

		private static GameObject MeshObject(Transform parent, string name, Vector3[] vertices, int[] triangles, Material material)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			Mesh val2 = new Mesh
			{
				name = name
			};
			val2.vertices = vertices;
			val2.triangles = triangles;
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			return val;
		}

		private static GameObject Ring(Transform parent, string name, float radius, float width, float depth, Material material, int segments = 32)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[segments * 4];
			List<int> list = new List<int>();
			Vector2 val = default(Vector2);
			for (int i = 0; i < segments; i++)
			{
				float num = (float)i * (float)Math.PI * 2f / (float)segments;
				((Vector2)(ref val))..ctor(Mathf.Sin(num), Mathf.Cos(num));
				array[i * 4] = new Vector3(val.x * (radius - width / 2f), val.y * (radius - width / 2f), (0f - depth) / 2f);
				array[i * 4 + 1] = new Vector3(val.x * (radius + width / 2f), val.y * (radius + width / 2f), (0f - depth) / 2f);
				array[i * 4 + 2] = new Vector3(val.x * (radius - width / 2f), val.y * (radius - width / 2f), depth / 2f);
				array[i * 4 + 3] = new Vector3(val.x * (radius + width / 2f), val.y * (radius + width / 2f), depth / 2f);
				int num2 = (i + 1) % segments * 4;
				int num3 = i * 4;
				Quad(list, num3, num3 + 1, num2 + 1, num2);
				Quad(list, num3 + 2, num2 + 2, num2 + 3, num3 + 3);
				Quad(list, num3, num2, num2 + 2, num3 + 2);
				Quad(list, num3 + 1, num3 + 3, num2 + 3, num2 + 1);
			}
			return MeshObject(parent, name, array, list.ToArray(), material);
		}

		private static void Quad(List<int> t, int a, int b, int c, int d)
		{
			t.AddRange(new int[6] { a, b, c, a, c, d });
		}

		private static void Bar(Transform p, string name, Vector3 a, Vector3 b, float width, float thickness, Material m)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			Vector3 val2 = new Vector3(0f - val.y, val.x, 0f);
			Vector3 val3 = ((Vector3)(ref val2)).normalized * width / 2f;
			Vector3[] vertices = (Vector3[])(object)new Vector3[8]
			{
				a + val3,
				a - val3,
				b - val3,
				b + val3,
				a + val3 + Vector3.forward * thickness,
				a - val3 + Vector3.forward * thickness,
				b - val3 + Vector3.forward * thickness,
				b + val3 + Vector3.forward * thickness
			};
			List<int> list = new List<int>();
			Quad(list, 0, 3, 2, 1);
			Quad(list, 4, 5, 6, 7);
			Quad(list, 0, 1, 5, 4);
			Quad(list, 1, 2, 6, 5);
			Quad(list, 2, 3, 7, 6);
			Quad(list, 3, 0, 4, 7);
			MeshObject(p, name, vertices, list.ToArray(), m);
		}

		private static void Gem(Transform p, string name, Vector3 center, float radius, Material m)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] vertices = (Vector3[])(object)new Vector3[6]
			{
				center + Vector3.forward * radius,
				center - Vector3.forward * radius,
				center + Vector3.up * radius,
				center - Vector3.up * radius,
				center + Vector3.right * radius,
				center - Vector3.right * radius
			};
			MeshObject(p, name, vertices, new int[24]
			{
				0, 4, 2, 0, 3, 4, 0, 5, 3, 0,
				2, 5, 1, 2, 4, 1, 4, 3, 1, 3,
				5, 1, 5, 2
			}, m);
		}

		private static void Ship(Transform p, float scale, float y, float z)
		{
			//IL_002a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			Bar(p, "Dragonship keel", V(-0.055f, -0.028f), V(0.055f, -0.028f), 0.01f * scale, 0.006f, bronze);
			Bar(p, "Raised prow", V(-0.055f, -0.028f), V(-0.07f, 0.005f), 0.012f * scale, 0.006f, bronze);
			Bar(p, "Raised stern", V(0.055f, -0.028f), V(0.064f, -0.003f), 0.009f * scale, 0.006f, bronze);
			Bar(p, "Mast", V(0f, -0.022f), V(0f, 0.052f), 0.009f * scale, 0.008f, bronze);
			MeshObject(p, "Curved sail", (Vector3[])(object)new Vector3[4]
			{
				V(0.006f, 0.045f),
				V(0.047f, 0.036f),
				V(0.054f, 0.001f),
				V(0.007f, 0.002f)
			}, new int[12]
			{
				0, 1, 2, 0, 2, 3, 2, 1, 0, 3,
				2, 0
			}, bronze);
			Vector3 V(float x, float yy)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(x * scale, yy * scale + y, z);
			}
		}

		private static void Wind(Transform p, float radius, float z)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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)
			for (int i = 0; i < 3; i++)
			{
				Vector3[] array = (Vector3[])(object)new Vector3[14];
				for (int j = 0; j < array.Length; j++)
				{
					float num = (float)j / (float)(array.Length - 1) * 1.7f + (float)i * 2.1f;
					float num2 = radius * (0.8f + 0.13f * Mathf.Sin((float)j * 0.8f));
					array[j] = new Vector3(Mathf.Sin(num) * num2, Mathf.Cos(num) * num2, z);
				}
				for (int k = 1; k < array.Length; k++)
				{
					Bar(p, "Turquoise wind", array[k - 1], array[k], 0.004f, 0.002f, wind);
				}
			}
		}

		private static void Charm(Transform p)
		{
			//IL_0079: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			Ring(p, "Bronze pendant", 0.095f, 0.016f, 0.013f, bronze);
			Ring(p, "Dark inner band", 0.078f, 0.006f, 0.01f, dark);
			Ring(p, "Suspension ring", 0.016f, 0.007f, 0.012f, bronze, 12).transform.localPosition = new Vector3(0f, 0.115f, 0f);
			Bar(p, "Leather cord left", new Vector3(-0.025f, 0.127f, 0f), new Vector3(-0.065f, 0.23f, 0f), 0.009f, 0.007f, leather);
			Bar(p, "Leather cord right", new Vector3(0.025f, 0.127f, 0f), new Vector3(0.065f, 0.23f, 0f), 0.009f, 0.007f, leather);
			Gem(p, "Wind stone", new Vector3(0f, 0.025f, -0.012f), 0.023f, wind);
			Ship(p, 1f, -0.039f, -0.015f);
			Wind(p, 0.069f, -0.023f);
			for (int i = 0; i < 12; i++)
			{
				float num = (float)i * (float)Math.PI / 6f;
				Gem(p, "Bronze rivet", new Vector3(Mathf.Sin(num) * 0.096f, Mathf.Cos(num) * 0.096f, -0.012f), 0.005f, bronze);
			}
		}

		private static void Belt(Transform p)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			Ring(p, "Leather belt", 0.16f, 0.012f, 0.067f, leather, 40).transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
			Transform transform = new GameObject("Ship buckle").transform;
			transform.SetParent(p, false);
			transform.localPosition = new Vector3(0f, 0f, -0.168f);
			Ring(transform, "Bronze buckle rim", 0.063f, 0.012f, 0.014f, bronze, 24);
			Ring(transform, "Buckle inner rim", 0.049f, 0.006f, 0.009f, dark, 24);
			Ship(transform, 0.75f, 0.006f, -0.011f);
			Wind(transform, 0.052f, -0.021f);
			Gem(transform, "Turquoise buckle stone", new Vector3(0f, -0.046f, -0.015f), 0.012f, wind);
			Vector3 localPosition = default(Vector3);
			for (int i = 0; i < 20; i++)
			{
				float num = (float)i * (float)Math.PI / 10f;
				((Vector3)(ref localPosition))..ctor(Mathf.Sin(num) * 0.168f, 0f, Mathf.Cos(num) * 0.168f);
				Transform transform2 = new GameObject("Bronze belt detail").transform;
				transform2.SetParent(p, false);
				transform2.localPosition = localPosition;
				transform2.localRotation = Quaternion.Euler(0f, num * 57.29578f, 0f);
				Bar(transform2, "Stamped knot", new Vector3(-0.008f, -0.024f, 0f), new Vector3(0.008f, 0.024f, 0f), 0.003f, 0.003f, bronze);
				Bar(transform2, "Stamped knot", new Vector3(0.008f, -0.024f, 0f), new Vector3(-0.008f, 0.024f, 0f), 0.003f, 0.003f, bronze);
			}
		}
	}
}
namespace TailwindGear
{
	[BepInPlugin("branchofyore.tailwindgear", "Njord's Favor", "0.1.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Id = "branchofyore.tailwindgear";

		public const string Belt = "TailwindBelt";

		public const string Charm = "TailwindCharm";

		public const string ActiveKey = "branchofyore.tailwindgear.equipped";

		private Harmony? harmony;

		private bool ownsItems;

		private void Awake()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			ownsItems = !Chainloader.PluginInfos.ContainsKey("branchofyore.sailingprogression");
			if (!ownsItems)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Using Sailing Progression's Tailwind items; no duplicate registration or wind patches.");
				return;
			}
			TailwindItems.Initialize();
			harmony = new Harmony("branchofyore.tailwindgear");
			harmony.PatchAll(typeof(Plugin).Assembly);
		}

		private void Update()
		{
			if (ownsItems)
			{
				TailwindItems.Update();
			}
		}

		private void OnDestroy()
		{
			if (ownsItems)
			{
				TailwindItems.Shutdown();
			}
			Harmony? obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		public static bool Equipped(Player p)
		{
			return TailwindItems.Equipped(p);
		}

		public static bool Active(Ship s)
		{
			return TailwindItems.Active(s);
		}

		public static Vector3 Direction(EnvMan e, Ship s)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return TailwindItems.Direction(e, s);
		}

		public static float Intensity(EnvMan e, Ship s)
		{
			return TailwindItems.Intensity(e, s);
		}
	}
}