Decompiled source of SailingProgression v0.1.12

plugins/SailingProgression/SailingProgression.dll

Decompiled 2 months 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.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
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("SailingProgression")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.12.0")]
[assembly: AssemblyInformationalVersion("0.1.12")]
[assembly: AssemblyProduct("SailingProgression")]
[assembly: AssemblyTitle("SailingProgression")]
[assembly: AssemblyVersion("0.1.12.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 Balance
	{
		public static float Level(float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value))
			{
				return Math.Max(0f, Math.Min(100f, value));
			}
			return 0f;
		}

		public static float BonusPercent(float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value))
			{
				return Math.Max(0f, Math.Min(100f, value));
			}
			return 0f;
		}

		public static float SpeedTarget(float level, float maximumPercent = 40f)
		{
			float num = Level(level);
			return 1f + (0.015f * Math.Min(num, 50f) + 0.005f * Math.Max(num - 50f, 0f)) * BonusPercent(maximumPercent) / 100f;
		}

		public static float SailForce(float level, float maximumPercent = 40f)
		{
			return SpeedTarget(level, maximumPercent) * SpeedTarget(level, maximumPercent);
		}

		public static float Endurance(float level, float maximumPercent = 30f)
		{
			return 1f + BonusPercent(maximumPercent) / 100f * Level(level) / 100f;
		}

		public static bool ValidSample(float seconds, float distance)
		{
			if (seconds >= 0.75f && seconds <= 2f && distance >= 0f)
			{
				return distance <= 20f * seconds;
			}
			return false;
		}

		public static float ExperienceMultiplier(float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value))
			{
				return Math.Max(1f, Math.Min(10f, value));
			}
			return 1f;
		}

		public static bool ValidJourney(float seconds, float netDistance)
		{
			if (seconds >= 10f && netDistance >= seconds && netDistance <= 20f * seconds && !float.IsNaN(netDistance))
			{
				return !float.IsInfinity(netDistance);
			}
			return false;
		}

		public static bool ValidTravel(float seconds, float horizontalDistance, float speed)
		{
			if (seconds >= 0.75f && seconds <= 2f && horizontalDistance >= 0.75f * seconds && horizontalDistance <= 20f * seconds && Math.Abs(speed) >= 0.75f && !float.IsNaN(horizontalDistance))
			{
				return !float.IsInfinity(horizontalDistance);
			}
			return false;
		}
	}
	public static class BoatCamera
	{
		[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
		private static class PassengerZoom
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				MethodInfo original = AccessTools.Method(typeof(Player), "GetControlledShip", (Type[])null, (Type[])null);
				MethodInfo replacement = AccessTools.Method(typeof(BoatCamera), "CameraShip", (Type[])null, (Type[])null);
				int replaced = 0;
				foreach (CodeInstruction instruction in instructions)
				{
					if (CodeInstructionExtensions.Calls(instruction, original))
					{
						instruction.opcode = OpCodes.Call;
						instruction.operand = replacement;
						replaced++;
					}
					yield return instruction;
				}
				if (replaced != 1)
				{
					throw new InvalidOperationException("Unsupported camera code: expected one boat zoom selection.");
				}
			}
		}

		public static Ship? CameraShip(Player player)
		{
			Ship controlledShip = player.GetControlledShip();
			if (Object.op_Implicit((Object)(object)controlledShip))
			{
				return controlledShip;
			}
			if (((Character)player).IsAttachedToShip() && Object.op_Implicit((Object)(object)player.GetAttachPoint()))
			{
				return ((Component)player.GetAttachPoint()).GetComponentInParent<Ship>();
			}
			return ((Character)player).GetStandingOnShip();
		}
	}
	[BepInPlugin("branchofyore.sailingprogression", "Sailing Progression", "0.1.12")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Ship), "GetSailForce")]
		private static class SailPatch
		{
			private static void Postfix(Ship __instance, ref Vector3 __result)
			{
				//IL_000a: 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_002e: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.IsOwner())
				{
					__result *= Balance.SailForce(CaptainLevel(__instance), instance.MaximumSpeedBonus.Value);
				}
			}
		}

		[HarmonyPatch(typeof(WearNTear), "ApplyDamage")]
		private static class HullPatch
		{
			private static void Prefix(WearNTear __instance, ref float damage)
			{
				Ship component = ((Component)__instance).GetComponent<Ship>();
				if (Object.op_Implicit((Object)(object)component) && component.IsOwner() && damage > 0f)
				{
					damage /= Balance.Endurance(CaptainLevel(component), instance.MaximumEnduranceBonus.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Ship), "CustomFixedUpdate")]
		private static class RowingPatch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				FieldInfo field = AccessTools.Field(typeof(Ship), "m_backwardForce");
				MethodInfo replacement = AccessTools.Method(typeof(Plugin), "RowingForce", (Type[])null, (Type[])null);
				int replaced = 0;
				foreach (CodeInstruction instruction in instructions)
				{
					CodeInstruction val = new CodeInstruction(instruction);
					if (CodeInstructionExtensions.LoadsField(val, field, false))
					{
						val.opcode = OpCodes.Call;
						val.operand = replacement;
						replaced++;
					}
					yield return val;
				}
				if (replaced != 2)
				{
					throw new InvalidOperationException("Unsupported Ship rowing code: expected two propulsion reads.");
				}
			}
		}

		public const string Id = "branchofyore.sailingprogression";

		public const string LevelKey = "branchofyore.sailingprogression.level";

		private static Plugin instance = null;

		private Harmony harmony;

		private Player? sampledPlayer;

		private Ship? sampledShip;

		private Vector3 previousPosition;

		private Vector3 journeyStart;

		private float nextSample;

		private float previousTime;

		private float qualifyingSeconds;

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

		public static SkillType Sailing { get; private set; }

		public ConfigEntry<float> ExperienceMultiplier { get; private set; }

		public ConfigEntry<float> MaximumSpeedBonus { get; private set; }

		public ConfigEntry<float> MaximumEnduranceBonus { get; private set; }

		private void Awake()
		{
			//IL_003d: 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_004a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//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_0098: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00e6: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0160: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01bc: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			instance = this;
			TailwindItems.Initialize();
			MaximumSpeedBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Bonuses", "Maximum Speed Bonus", 40f, new ConfigDescription("Maximum speed bonus in percent at Sailing level 100, for sails and rowing (including reverse). Level 50 receives 75% of this bonus. Default 40 means +30% at level 50 and approximately +40% at level 100. Server synchronized.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			MaximumEnduranceBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Bonuses", "Maximum Endurance Bonus", 30f, new ConfigDescription("Extra damage the hull can endure, in percent at Sailing level 100. Scales evenly with skill level. Default 30 means +15% at level 50 and +30% at level 100. Does not repair the boat. Server synchronized.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ExperienceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Progression", "Sailing XP Multiplier", 1f, new ConfigDescription("Sailing experience for everyone aboard. 1 = normal, 10 = ten times the experience. The server value applies to all players. Does not change speed or endurance per level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			Texture2D val = new Texture2D(2, 2);
			using (Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("SailingProgression.Icon.png"))
			{
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				AssetUtils.LoadImage(val, memoryStream.ToArray());
			}
			Sprite icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			Sailing = SkillManager.Instance.AddSkill(new SkillConfig
			{
				Identifier = "branchofyore.sailingprogression.sailing",
				Name = "Sailing",
				Description = "Sailing speed and endurance",
				IncreaseStep = 1f,
				Icon = icon
			});
			harmony = new Harmony("branchofyore.sailingprogression");
			harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Sailing Progression 0.1.12 loaded.");
		}

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

		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;
			}
			foreach (Player item in Players.Invoke(ship))
			{
				if (Object.op_Implicit((Object)(object)item) && !((Character)item).IsDead() && item.GetPlayerID() == user)
				{
					return item;
				}
			}
			return null;
		}

		public static float CaptainLevel(Ship ship)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Player val = Captain(ship);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return 0f;
			}
			if ((Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				return Balance.Level(((Character)val).GetSkills().GetSkillLevel(Sailing));
			}
			ZNetView component = ((Component)val).GetComponent<ZNetView>();
			if (!Object.op_Implicit((Object)(object)component) || !component.IsValid())
			{
				return 0f;
			}
			return Balance.Level(component.GetZDO().GetFloat("branchofyore.sailingprogression.level", 0f));
		}

		private void Update()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			TailwindItems.Update();
			float time = Time.time;
			if (time < nextSample)
			{
				return;
			}
			nextSample = time + 1f;
			Player localPlayer = Player.m_localPlayer;
			Ship localShip = Ship.GetLocalShip();
			if (!Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || !Object.op_Implicit((Object)(object)localShip) || !localShip.IsPlayerInBoat(localPlayer) || !Riding(localPlayer, localShip))
			{
				ResetSample();
				return;
			}
			ZNetView component = ((Component)localPlayer).GetComponent<ZNetView>();
			if (!Object.op_Implicit((Object)(object)component) || !component.IsValid() || !component.IsOwner())
			{
				ResetSample();
				return;
			}
			component.GetZDO().Set("branchofyore.sailingprogression.level", Balance.Level(((Character)localPlayer).GetSkills().GetSkillLevel(Sailing)));
			Vector3 position = ((Component)localShip).transform.position;
			if ((Object)(object)sampledPlayer != (Object)(object)localPlayer || (Object)(object)sampledShip != (Object)(object)localShip)
			{
				sampledPlayer = localPlayer;
				sampledShip = localShip;
				previousPosition = position;
				previousTime = time;
				journeyStart = position;
				qualifyingSeconds = 0f;
				return;
			}
			float num = time - previousTime;
			Vector3 val = position - previousPosition;
			val.y = 0f;
			previousPosition = position;
			previousTime = time;
			if ((int)localShip.GetSpeedSetting() == 0 || !Balance.ValidSample(num, ((Vector3)(ref val)).magnitude))
			{
				qualifyingSeconds = 0f;
				journeyStart = position;
				return;
			}
			qualifyingSeconds += num;
			if (!(qualifyingSeconds < 10f))
			{
				Vector3 val2 = position - journeyStart;
				val2.y = 0f;
				bool num2 = Balance.ValidJourney(qualifyingSeconds, ((Vector3)(ref val2)).magnitude);
				qualifyingSeconds = 0f;
				journeyStart = position;
				if (num2)
				{
					((Character)localPlayer).RaiseSkill(Sailing, 3f * Balance.ExperienceMultiplier(ExperienceMultiplier.Value));
					component.GetZDO().Set("branchofyore.sailingprogression.level", Balance.Level(((Character)localPlayer).GetSkills().GetSkillLevel(Sailing)));
				}
			}
		}

		private void ResetSample()
		{
			sampledPlayer = null;
			sampledShip = null;
			qualifyingSeconds = 0f;
		}

		public static bool Riding(Player player, Ship ship)
		{
			//IL_0054: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if ((object)player.GetDoodadController() == ship.m_shipControlls || (Object)(object)((Character)player).GetStandingOnShip() == (Object)(object)ship || (((Character)player).IsAttachedToShip() && Object.op_Implicit((Object)(object)player.GetAttachPoint()) && (Object)(object)((Component)player.GetAttachPoint()).GetComponentInParent<Ship>() == (Object)(object)ship))
			{
				return true;
			}
			RaycastHit? val = null;
			RaycastHit[] array = Physics.RaycastAll(((Component)player).transform.position + Vector3.up * 0.3f, Vector3.down, 1.5f, -5, (QueryTriggerInteraction)1);
			RaycastHit value2;
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit value = array[i];
				if ((Object)(object)((Component)((RaycastHit)(ref value)).collider).GetComponentInParent<Player>() == (Object)(object)player)
				{
					continue;
				}
				if (val.HasValue)
				{
					float distance = ((RaycastHit)(ref value)).distance;
					value2 = val.Value;
					if (!(distance < ((RaycastHit)(ref value2)).distance))
					{
						continue;
					}
				}
				val = value;
			}
			if (val.HasValue)
			{
				value2 = val.Value;
				return (Object)(object)((Component)((RaycastHit)(ref value2)).collider).GetComponentInParent<Ship>() == (Object)(object)ship;
			}
			return false;
		}

		public static float ObservedSpeed(Ship ship)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (ship.IsOwner())
			{
				return ship.GetSpeed();
			}
			ZNetView component = ((Component)ship).GetComponent<ZNetView>();
			if (!Object.op_Implicit((Object)(object)component) || !component.IsValid())
			{
				return 0f;
			}
			return Vector3.Dot(component.GetZDO().GetVec3(ZDOVars.s_velHash, Vector3.zero), ((Component)ship).transform.forward);
		}

		public static float RowingForce(Ship ship)
		{
			return ship.m_backwardForce * (ship.IsOwner() ? Balance.SailForce(CaptainLevel(ship), instance.MaximumSpeedBonus.Value) : 1f);
		}
	}
	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);
			}
		}
	}
}