Decompiled source of TowableBoats v0.1.7

TowableBoats.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using SailwindModdingHelper;
using UnityEngine;
using cakeslice;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
internal sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace TowableBoats;

internal class BoatPerformancePatches
{
	[HarmonyPatch(typeof(BoatHorizon))]
	private static class BoatHorizonPatch
	{
		[HarmonyPatch("UpdateKinematic")]
		[HarmonyPostfix]
		public static void BoatKinematicPatch(BoatHorizon __instance, ref Rigidbody ___rigidbody)
		{
			if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<TowingSet>()) || !___rigidbody.isKinematic || !GameState.sleeping)
			{
				return;
			}
			if (((Component)__instance).GetComponentInParent<TowingSet>().towed)
			{
				Rigidbody towedBy = ((Component)__instance).GetComponentInParent<TowingSet>().GetTowedBy();
				for (int i = 0; i < 5; i++)
				{
					if ((Object)(object)((Component)towedBy).transform == (Object)(object)GameState.currentBoat || (Object)(object)((Component)towedBy).transform == (Object)(object)GameState.lastBoat)
					{
						___rigidbody.isKinematic = false;
						break;
					}
					if (!((Component)towedBy).gameObject.GetComponent<TowingSet>().towed)
					{
						break;
					}
					towedBy = ((Component)towedBy).gameObject.GetComponent<TowingSet>().GetTowedBy();
				}
			}
			if (!((Component)__instance).GetComponentInParent<TowingSet>().towing)
			{
				return;
			}
			List<Rigidbody> towedBoats = ((Component)__instance).GetComponentInParent<TowingSet>().GetTowedBoats();
			for (int j = 0; j < 5; j++)
			{
				foreach (Rigidbody item in towedBoats)
				{
					if ((Object)(object)((Component)item).transform == (Object)(object)GameState.currentBoat || (Object)(object)((Component)item).transform == (Object)(object)GameState.lastBoat)
					{
						___rigidbody.isKinematic = false;
						return;
					}
					if (((Component)item).gameObject.GetComponent<TowingSet>().towing)
					{
						towedBoats = ((Component)item).gameObject.GetComponent<TowingSet>().GetTowedBoats();
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(BoatPerformanceSwitcher))]
	private static class BoatPerformanceSwitcherPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static bool BoatPerformaceSwitcherPatch(BoatPerformanceSwitcher __instance, ref Rigidbody ___body, BoatDamage ___damage)
		{
			bool flag = true;
			if ((Object)(object)GameState.lastBoat == (Object)(object)((Component)__instance).transform || ___damage.sunk)
			{
				return true;
			}
			if ((Object)(object)((Component)__instance).GetComponentInParent<TowingSet>() == (Object)null)
			{
				return true;
			}
			if (((Component)__instance).GetComponentInParent<TowingSet>().towed && Plugin.performanceMode.Value > 0)
			{
				Rigidbody towedBy = ((Component)__instance).GetComponentInParent<TowingSet>().GetTowedBy();
				for (int i = 0; i < Plugin.performanceMode.Value; i++)
				{
					if ((Object)(object)((Component)towedBy).transform == (Object)(object)GameState.currentBoat || (Object)(object)((Component)towedBy).transform == (Object)(object)GameState.lastBoat)
					{
						flag = false;
						break;
					}
					if (!((Component)towedBy).gameObject.GetComponent<TowingSet>().towed)
					{
						break;
					}
					towedBy = ((Component)towedBy).gameObject.GetComponent<TowingSet>().GetTowedBy();
				}
			}
			if (((Component)__instance).GetComponentInParent<TowingSet>().towing)
			{
				List<Rigidbody> towedBoats = ((Component)___body).gameObject.GetComponent<TowingSet>().GetTowedBoats();
				for (int j = 0; j < 5; j++)
				{
					foreach (Rigidbody item in towedBoats)
					{
						if ((Object)(object)((Component)item).transform == (Object)(object)GameState.currentBoat || (Object)(object)((Component)item).transform == (Object)(object)GameState.lastBoat)
						{
							flag = false;
							j = 6;
							break;
						}
						if (((Component)item).gameObject.GetComponent<TowingSet>().towing)
						{
							towedBoats = ((Component)item).gameObject.GetComponent<TowingSet>().GetTowedBoats();
						}
					}
				}
			}
			if (__instance.performanceModeIsOn() != flag)
			{
				Extensions.InvokePrivateMethod((object)__instance, "SetPerformanceMode", new object[1] { flag });
			}
			return false;
		}
	}
}
[StructLayout(LayoutKind.Sequential, Size = 1)]
public readonly struct CleatDefs
{
	public static readonly Array[] brig = new Array[6]
	{
		new object[4]
		{
			"cleat_stern_left",
			(object)new Vector3(-14.9f, 4.36f, 2.23f),
			(object)new Quaternion(0.7071068f, 0f, 0f, 0.7071068f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_stern_right",
			(object)new Vector3(-14.9f, 4.36f, -2.23f),
			(object)new Quaternion(0.7071068f, 0f, 0f, 0.7071068f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_aft_left",
			(object)new Vector3(-2.3f, 3.53f, 3.27f),
			(object)new Quaternion(-0.7058f, 0.0252f, -0.0246f, 0.7075f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_aft_right",
			(object)new Vector3(-2.3f, 3.53f, -3.27f),
			(object)new Quaternion(-0.7058f, 0.0252f, -0.0246f, 0.7075f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_fore_left",
			(object)new Vector3(4.85f, 3.57f, 3.02f),
			(object)new Quaternion(-0.7041f, 0.0292f, 0.0692f, 0.7061f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_fore_right",
			(object)new Vector3(4.85f, 3.57f, -3.02f),
			(object)new Quaternion(-0.7036f, -0.0384f, 0.0012f, 0.7095f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		}
	};

	public static readonly Array[] sanbuq = new Array[6]
	{
		new object[4]
		{
			"cleat_stern_left",
			(object)new Vector3(-12.08f, 2.12f, 1.48f),
			(object)new Quaternion(0.4912f, -0.5087f, -0.5087f, -0.4912f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_stern_right",
			(object)new Vector3(-12.08f, 2.12f, -1.48f),
			(object)new Quaternion(0.5087f, -0.4912f, -0.4912f, -0.5087f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_aft_left",
			(object)new Vector3(-1.4f, 2.12f, 2.46f),
			(object)new Quaternion(0.7071068f, 0f, 0f, -0.7071068f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_aft_right",
			(object)new Vector3(-1.4f, 2.12f, -2.46f),
			(object)new Quaternion(0.7071068f, 0f, 0f, -0.7071068f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_fore_left",
			(object)new Vector3(4.2f, 2.32f, 2.25f),
			(object)new Quaternion(-0.7071f, 0f, 0.0371f, 0.7061f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_fore_right",
			(object)new Vector3(4.2f, 2.32f, -2.25f),
			(object)new Quaternion(-0.7058f, -0.0432f, 0.0062f, 0.7071f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		}
	};

	public static readonly Array[] junk = new Array[6]
	{
		new object[4]
		{
			"cleat_stern_left",
			(object)new Vector3(-9.7f, 2.27f, 0.8f),
			(object)new Quaternion(0.4731f, -0.5255f, -0.5255f, -0.4731f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_stern_right",
			(object)new Vector3(-9.7f, 2.27f, -0.8f),
			(object)new Quaternion(0.5255f, -0.4731f, -0.4731f, -0.5255f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_aft_left",
			(object)new Vector3(1.24f, 1.01f, 2.52f),
			(object)new Quaternion(0.7071068f, 0f, 0f, -0.7071068f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_aft_right",
			(object)new Vector3(1.24f, 1.01f, -2.52f),
			(object)new Quaternion(0.7071068f, 0f, 0f, -0.7071068f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_fore_left",
			(object)new Vector3(7.68f, 1.1f, 2.02f),
			(object)new Quaternion(-0.7071f, 0.0062f, 0.0309f, 0.7064f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		},
		new object[4]
		{
			"cleat_mid_fore_right",
			(object)new Vector3(7.68f, 1.1f, -2.02f),
			(object)new Quaternion(-0.7064f, -0.0309f, -0.0061f, 0.7071f),
			(object)new Vector3(0.6f, 0.6f, 0.6f)
		}
	};

	public static readonly Array[] cog = new Array[2]
	{
		new object[4]
		{
			"cleat_stern_left",
			(object)new Vector3(6.66f, 2.41f, 1.25f),
			(object)new Quaternion(0.5f, -0.5f, -0.5f, -0.5f),
			(object)new Vector3(0.5f, 0.5f, 0.5f)
		},
		new object[4]
		{
			"cleat_stern_right",
			(object)new Vector3(6.66f, 2.41f, -1.25f),
			(object)new Quaternion(0.5f, -0.5f, -0.5f, -0.5f),
			(object)new Vector3(0.5f, 0.5f, 0.5f)
		}
	};

	public static readonly Array[] dhow = new Array[2]
	{
		new object[4]
		{
			"cleat_stern_left",
			(object)new Vector3(-6.4f, 1.815f, 1.53f),
			(object)new Quaternion(-0.0616f, -0.7044f, -0.7044f, -0.0616f),
			(object)new Vector3(0.5f, 0.5f, 0.5f)
		},
		new object[4]
		{
			"cleat_stern_right",
			(object)new Vector3(-6.4f, 1.815f, -1.53f),
			(object)new Quaternion(-0.0616f, -0.7044f, -0.7044f, -0.0616f),
			(object)new Vector3(0.5f, 0.5f, 0.5f)
		}
	};

	public static readonly Array[] kakam = new Array[2]
	{
		new object[4]
		{
			"cleat_stern_left",
			(object)new Vector3(-6.3f, 2.86f, 0.64f),
			(object)new Quaternion(0.6744f, 0.2126f, 0.2126f, -0.6744f),
			(object)new Vector3(0.5f, 0.5f, 0.5f)
		},
		new object[4]
		{
			"cleat_stern_right",
			(object)new Vector3(-6.3f, 2.86f, -0.64f),
			(object)new Quaternion(0.6744f, -0.2126f, -0.2126f, -0.6744f),
			(object)new Vector3(0.5f, 0.5f, 0.5f)
		}
	};
}
internal class MooringPatches
{
	[HarmonyPatch(typeof(GPButtonDockMooring))]
	private static class GPButtonDockMooringPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		public static void MooringComponentPatch(GPButtonDockMooring __instance)
		{
			if (!Object.op_Implicit((Object)(object)cleat))
			{
				cleat = ((Component)__instance).gameObject;
			}
		}
	}

	[HarmonyPatch(typeof(MooringSet))]
	private static class MooringSetPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void MooringComponentPatch(MooringSet __instance)
		{
			TowingSet towingManager = ((Component)((Component)__instance).transform.parent).gameObject.AddComponent<TowingSet>();
			((MonoBehaviour)__instance).StartCoroutine(AddCleats(towingManager));
		}

		private static IEnumerator AddCleats(TowingSet towingManager)
		{
			Debug.Log((object)"waiting for cleat");
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)cleat != (Object)null));
			towingManager.AddCleats(cleat);
			Debug.Log((object)"got cleat");
		}
	}

	[HarmonyPatch(typeof(PickupableBoatMooringRope))]
	private static class BoatMooringRopePatches
	{
		[HarmonyPatch("ThrowRopeTo")]
		[HarmonyPrefix]
		public static bool ThrowRopeToPatch(PickupableBoatMooringRope __instance, GPButtonDockMooring mooring, Rigidbody ___boatRigidbody)
		{
			if (((Component)mooring).gameObject.CompareTag("Boat"))
			{
				if ((Object)(object)((Component)___boatRigidbody).transform != (Object)(object)((Component)mooring).GetComponentInParent<TowingSet>().GetBoatTransform() && (!((Component)__instance).GetComponentInParent<TowingSet>().towed || (Object)(object)((Component)mooring).gameObject.GetComponentInParent<TowingSet>().GetBoatTransform() == (Object)(object)((Component)((Component)___boatRigidbody).gameObject.GetComponentInParent<TowingSet>().GetTowedBy()).transform))
				{
					__instance.MoorTo(mooring);
					((Component)___boatRigidbody).GetComponentInParent<TowingSet>().UpdateTowedBy();
					((Component)mooring).GetComponentInParent<TowingSet>().UpdateTowedBoats();
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch("Unmoor")]
		[HarmonyPrefix]
		public static void UnmoorPatch(SpringJoint ___mooredToSpring, ref TowingSet __state)
		{
			if ((Object)(object)___mooredToSpring != (Object)null && Object.op_Implicit((Object)(object)((Component)___mooredToSpring).GetComponentInParent<TowingSet>()))
			{
				__state = ((Component)___mooredToSpring).GetComponentInParent<TowingSet>();
			}
		}

		[HarmonyPatch("Unmoor")]
		[HarmonyPostfix]
		public static void UnmoorPostPatch(TowingSet __state, Rigidbody ___boatRigidbody)
		{
			if (Object.op_Implicit((Object)(object)__state))
			{
				__state.UpdateTowedBoats();
			}
			((Component)___boatRigidbody).GetComponent<TowingSet>().UpdateTowedBy();
		}
	}

	[HarmonyPatch(typeof(BoatMooringRopes))]
	private static class BoatMooringRopesPatches
	{
		[HarmonyPatch("UnmoorAllRopes")]
		[HarmonyPostfix]
		public static void UnmoorAllRopesPatch(BoatMooringRopes __instance)
		{
			if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<TowingSet>()) || ((Component)__instance).GetComponentInParent<TowingSet>().GetCleats() == null)
			{
				return;
			}
			GPButtonDockMooring[] cleats = ((Component)__instance).GetComponentInParent<TowingSet>().GetCleats();
			foreach (GPButtonDockMooring val in cleats)
			{
				if (Object.op_Implicit((Object)(object)((Component)val).GetComponentInChildren<PickupableBoatMooringRope>()))
				{
					PickupableBoatMooringRope componentInChildren = ((Component)val).GetComponentInChildren<PickupableBoatMooringRope>();
					Debug.Log((object)"found a thing");
					componentInChildren.Unmoor();
					componentInChildren.ResetRopePos();
				}
			}
		}
	}

	private static GameObject cleat;
}
[BepInPlugin("com.nandbrew.towableboats", "Towable Boats", "0.1.7")]
[BepInDependency("com.app24.sailwindmoddinghelper", "2.0.3")]
public class Plugin : BaseUnityPlugin
{
	public const string PLUGIN_ID = "com.nandbrew.towableboats";

	public const string PLUGIN_NAME = "Towable Boats";

	public const string PLUGIN_VERSION = "0.1.7";

	internal static ConfigEntry<int> performanceMode;

	internal static ConfigEntry<bool> drag;

	internal static ConfigEntry<bool> smallBoats;

	internal static Plugin instance;

	private void Awake()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		instance = this;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.nandbrew.towableboats");
		performanceMode = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Performance mode", 1, new ConfigDescription("How many boats in the chain behind the current boat get full physics", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), new object[1]
		{
			new ConfigurationManagerAttributes
			{
				Order = 2
			}
		}));
		drag = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Drag", false, new ConfigDescription("Allow boats to pull on the boat towing them (buggy)", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				IsAdvanced = true
			}
		}));
		smallBoats = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Small boats can tow", true, new ConfigDescription("Add anchor points to small boats", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				IsAdvanced = false,
				Order = 1
			}
		}));
	}
}
internal class SleepPatches
{
	[HarmonyPatch(typeof(Sleep), "CurrentBoatIsMoored")]
	private static class IsMooredPatch
	{
		[HarmonyPostfix]
		public static void Postfix(ref bool __result)
		{
			if (Object.op_Implicit((Object)(object)GameState.currentBoat) && __result && ((Component)GameState.currentBoat).GetComponentInParent<TowingSet>().towed)
			{
				__result = false;
			}
		}
	}
}
internal class TowingSet : MonoBehaviour
{
	private Transform mooringSetTransform;

	private Transform boatTransform;

	private Rigidbody towedBy;

	private List<Rigidbody> towedBoats;

	public bool towing;

	public bool towed;

	private GPButtonDockMooring[] cleats;

	public bool smallBoat;

	public Transform GetBoatTransform()
	{
		return boatTransform;
	}

	public List<Rigidbody> GetTowedBoats()
	{
		return towedBoats;
	}

	public Rigidbody GetTowedBy()
	{
		return towedBy;
	}

	public GPButtonDockMooring[] GetCleats()
	{
		return cleats;
	}

	private void Awake()
	{
		mooringSetTransform = ((Component)((Component)this).gameObject.GetComponentInChildren<MooringSet>()).transform.GetChild(0);
		boatTransform = ((Component)this).transform;
	}

	private void FixedUpdate()
	{
		//IL_004c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		if (cleats != null && Plugin.drag.Value)
		{
			for (int i = 0; i < cleats.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)((Component)((Component)cleats[i]).transform).GetComponentInChildren<PickupableBoatMooringRope>()))
				{
					Vector3 val = ((Joint)((Component)((Component)cleats[i]).transform).GetComponentInChildren<SpringJoint>()).currentForce;
					if (((Component)((Joint)((Component)((Component)cleats[i]).transform).GetComponentInChildren<SpringJoint>()).connectedBody).gameObject.GetComponent<BoatPerformanceSwitcher>().performanceModeIsOn())
					{
						val /= 10f;
					}
					((Component)this).gameObject.GetComponent<Rigidbody>().AddForceAtPosition(val / 3f, ((Component)cleats[i]).transform.position, (ForceMode)0);
				}
			}
		}
		if (GameState.justStarted)
		{
			UpdateTowedBoats();
			UpdateTowedBy();
		}
		if (!smallBoat)
		{
			return;
		}
		GPButtonDockMooring[] array = cleats;
		foreach (GPButtonDockMooring val2 in array)
		{
			if (!Plugin.smallBoats.Value)
			{
				PickupableBoatMooringRope componentInChildren = ((Component)val2).GetComponentInChildren<PickupableBoatMooringRope>();
				if (componentInChildren != null)
				{
					componentInChildren.Unmoor();
					componentInChildren.ResetRopePos();
				}
			}
			((Component)val2).gameObject.SetActive(Plugin.smallBoats.Value);
		}
	}

	public void UpdateTowedBoats()
	{
		towedBoats = new List<Rigidbody>();
		bool flag = false;
		if (cleats != null)
		{
			for (int i = 0; i < cleats.Length; i++)
			{
				if ((Object)(object)((Component)((Component)cleats[i]).transform).GetComponentInChildren<PickupableBoatMooringRope>() != (Object)null)
				{
					towedBoats.Add(((Component)((Component)cleats[i]).transform).GetComponentInChildren<PickupableBoatMooringRope>().GetBoatRigidbody());
					flag = true;
				}
			}
		}
		towing = flag;
	}

	public void UpdateTowedBy()
	{
		bool flag = false;
		towedBy = null;
		PickupableBoatMooringRope[] ropes = ((Component)this).gameObject.GetComponent<BoatMooringRopes>().ropes;
		for (int i = 0; i < ropes.Length; i++)
		{
			if (ropes[i].IsMoored() && ((Component)Extensions.GetPrivateField<SpringJoint>((object)ropes[i], "mooredToSpring")).gameObject.CompareTag("Boat"))
			{
				towedBy = ((Component)((Component)((Component)Extensions.GetPrivateField<SpringJoint>((object)ropes[i], "mooredToSpring")).transform).GetComponentInParent<TowingSet>().GetBoatTransform()).GetComponent<Rigidbody>();
				flag = true;
			}
		}
		towed = flag;
	}

	public void AddCleats(GameObject refCleat)
	{
		//IL_00d6: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Expected O, but got Unknown
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		Array[] array;
		if (((Object)boatTransform).name.Contains("medi medium"))
		{
			array = CleatDefs.brig;
		}
		else if (((Object)boatTransform).name.Contains("dhow medium"))
		{
			array = CleatDefs.sanbuq;
		}
		else if (((Object)boatTransform).name.Contains("junk medium"))
		{
			array = CleatDefs.junk;
		}
		else if (((Object)boatTransform).name.Contains("medi small"))
		{
			array = CleatDefs.cog;
			smallBoat = true;
		}
		else if (((Object)boatTransform).name.Contains("dhow small"))
		{
			array = CleatDefs.dhow;
			smallBoat = true;
		}
		else
		{
			if (!((Object)boatTransform).name.Contains("junk small"))
			{
				return;
			}
			array = CleatDefs.kakam;
			smallBoat = true;
		}
		GameObject val = Object.Instantiate<GameObject>(new GameObject(), mooringSetTransform.position, mooringSetTransform.rotation, mooringSetTransform.parent);
		((Object)val).name = "towing set";
		for (int i = 0; i < array.Length; i++)
		{
			object[] array2 = array[i] as object[];
			GameObject val2 = Object.Instantiate<GameObject>(refCleat, (Vector3)array2[1], (Quaternion)array2[2]);
			val2.transform.SetParent(val.transform, false);
			((Object)val2).name = (string)array2[0];
			val2.transform.localScale = (Vector3)array2[3];
			val2.tag = "Boat";
			Outline[] components = val2.GetComponents<Outline>();
			foreach (Outline val3 in components)
			{
				if (val3 != Extensions.GetPrivateField((object)val2, "outline"))
				{
					Object.Destroy((Object)(object)val3);
				}
			}
		}
		cleats = val.GetComponentsInChildren<GPButtonDockMooring>();
	}
}