Decompiled source of Tamed And Logs Harpoon v1.3.1

HarpoonForLogs.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HarpoonForLogs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HarpoonForLogs")]
[assembly: AssemblyTitle("HarpoonForLogs")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TamedHarpoon
{
	[BepInPlugin("com.Azura.tamedharpoon", "Tamed+Logs Harpoon", "1.3.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.Azura.tamedharpoon";

		public const string PluginName = "Tamed+Logs Harpoon";

		public const string PluginVersion = "1.3.1";

		public static ConfigEntry<bool> Actif;

		public static ConfigEntry<bool> SansDegats;

		public static ConfigEntry<bool> Rondins;

		public static ConfigEntry<float> Rembobinage;

		public static ConfigEntry<float> EndurancePulling;

		public static ConfigEntry<float> Facilite;

		public static ConfigEntry<bool> Objets;

		public static ConfigEntry<bool> Poissons;

		public static ConfigEntry<bool> Tombes;

		public static ConfigEntry<bool> Charrettes;

		public static ConfigEntry<float> RayonPrise;

		private static int hashHarpon;

		private void Awake()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			Actif = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "true = the harpoon also catches tamed animals.\ntrue = le harpon accroche aussi les animaux apprivoisés.");
			SansDegats = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoDamage", true, "true = the harpoon does no damage to tamed animals (it only pulls them).\ntrue = le harpon ne blesse pas les animaux apprivoisés (il ne fait que les tirer).");
			Rondins = ((BaseUnityPlugin)this).Config.Bind<bool>("Logs", "HookLogs", true, "true = the harpoon also hooks felled tree logs, to pull them out of the water.\ntrue = le harpon accroche aussi les rondins d'arbres abattus, pour les sortir de l'eau.");
			Rembobinage = ((BaseUnityPlugin)this).Config.Bind<float>("Logs", "ReelSpeed", 1.5f, new ConfigDescription("Meters per second the line is reeled in, until the log (or anything else the harpoon hooked) is a step away from you (0 = it only follows you).\nMètres rembobinés par seconde, jusqu'à ce que le rondin (ou tout ce que le harpon a accroché) soit à un pas de vous (0 = il ne fait que vous suivre).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 6f), Array.Empty<object>()));
			EndurancePulling = ((BaseUnityPlugin)this).Config.Bind<float>("Logs", "StaminaPerSecond", 12f, new ConfigDescription("Stamina used per second while the line is taut (logs and everything else the harpoon hooks).\nEndurance utilisée par seconde quand la corde est tendue (rondins et tout ce que le harpon accroche).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>()));
			Facilite = ((BaseUnityPlugin)this).Config.Bind<float>("Logs", "TowingEase", 17.5f, new ConfigDescription("Percent: at the end of the line, a log (or anything else the harpoon hooked) behaves as if it were this much lighter (less stamina used, stronger pull). Things themselves are unchanged. 0 = as in 1.1.1.\nPourcentage : au bout de la corde, un rondin (ou tout ce que le harpon a accroché) se comporte comme s'il était d'autant plus léger (moins d'endurance, traction plus forte). Les choses elles-mêmes ne changent pas. 0 = comme en 1.1.1.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			Objets = ((BaseUnityPlugin)this).Config.Bind<bool>("Things", "HookItems", true, "true = the harpoon also hooks dropped items (on the ground, sunk to the bottom of the water, lying in lava…) and reels them in to your inventory.\ntrue = le harpon accroche aussi les objets tombés (au sol, coulés au fond de l'eau, posés dans la lave…) et les ramène jusque dans votre inventaire.");
			Poissons = ((BaseUnityPlugin)this).Config.Bind<bool>("Things", "HookFish", true, "true = the harpoon catches fish (on its own, the game's harpoon does nothing to them): the fish is reeled in and lands in your inventory.\ntrue = le harpon attrape les poissons (celui du jeu ne leur fait rien) : le poisson est ramené et finit dans votre inventaire.");
			Tombes = ((BaseUnityPlugin)this).Config.Bind<bool>("Things", "HookTombstones", true, "true = the harpoon hooks tombstones (yours or a friend's), to pull them out of water, lava or a hole.\ntrue = le harpon accroche les tombes (la vôtre ou celle d'un ami), pour les sortir de l'eau, de la lave ou d'un trou.");
			Charrettes = ((BaseUnityPlugin)this).Config.Bind<bool>("Things", "HookCarts", true, "true = the harpoon hooks carts nobody is pulling (without damaging them), to tow them out of water or a ditch.\ntrue = le harpon accroche les charrettes que personne ne tire (sans les abîmer), pour les sortir de l'eau ou d'un fossé.");
			RayonPrise = ((BaseUnityPlugin)this).Config.Bind<float>("Things", "GrabRadius", 1f, new ConfigDescription("Meters: where the harpoon lands (ground, bottom of the water, lava), it grabs the closest of these things within this distance. 0 = only what it hits directly.\nMètres : là où le harpon se plante (sol, fond de l'eau, lave), il saisit la plus proche de ces choses à cette distance. 0 = seulement ce qu'il touche directement.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			new Harmony("com.Azura.tamedharpoon").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)Traductions.Format("journal_charge", null, new object[2] { "Tamed+Logs Harpoon", "1.3.1" }));
		}

		public static bool EstHarpon(int hashEffet)
		{
			if (hashEffet == 0 || (Object)(object)ObjectDB.instance == (Object)null)
			{
				return false;
			}
			if (hashHarpon != 0)
			{
				return hashEffet == hashHarpon;
			}
			if (ObjectDB.instance.GetStatusEffect(hashEffet) is SE_Harpooned)
			{
				hashHarpon = hashEffet;
				return true;
			}
			return false;
		}

		public static bool HarponLocal(Character proprio, int hashEffet)
		{
			if ((Object)(object)proprio != (Object)null && (Object)(object)proprio == (Object)(object)Player.m_localPlayer)
			{
				return EstHarpon(hashEffet);
			}
			return false;
		}

		public static bool ApprivoiseHarponne(Projectile p, Character proprio, int hashEffet, Character cible)
		{
			if (Actif.Value && (Object)(object)cible != (Object)null && !cible.IsPlayer() && cible.IsTamed() && (Object)(object)proprio != (Object)null && proprio.IsPlayer())
			{
				return EstHarpon(hashEffet);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Projectile), "IsValidTarget")]
	public static class Projectile_IsValidTarget_Patch
	{
		public static void Postfix(Projectile __instance, IDestructible destr, ref bool __result, Character ___m_owner, int ___m_statusEffectHash)
		{
			if (!__result && Plugin.ApprivoiseHarponne(__instance, ___m_owner, ___m_statusEffectHash, (Character)(object)((destr is Character) ? destr : null)))
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(Projectile), "OnHit")]
	public static class Projectile_OnHit_Patch
	{
		public struct Sauvegarde
		{
			public bool Change;

			public DamageTypes Degats;

			public float Force;
		}

		public static void Prefix(Projectile __instance, Collider collider, Character ___m_owner, int ___m_statusEffectHash, ref Sauvegarde __state)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			__state = default(Sauvegarde);
			if (!((Object)(object)collider == (Object)null))
			{
				GameObject val = Projectile.FindHitObject(collider);
				Character val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Character>() : null);
				if ((Plugin.SansDegats.Value && Plugin.ApprivoiseHarponne(__instance, ___m_owner, ___m_statusEffectHash, val2)) || (!((Object)(object)val2 != (Object)null) && Plugin.HarponLocal(___m_owner, ___m_statusEffectHash) && Prises.Trouver(collider, out var _) != Prise.Aucune))
				{
					__state = new Sauvegarde
					{
						Change = true,
						Degats = __instance.m_damage,
						Force = __instance.m_attackForce
					};
					__instance.m_damage = default(DamageTypes);
					__instance.m_attackForce = 0f;
				}
			}
		}

		public static void Finalizer(Projectile __instance, Sauvegarde __state)
		{
			//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)
			if (__state.Change && !((Object)(object)__instance == (Object)null))
			{
				__instance.m_damage = __state.Degats;
				__instance.m_attackForce = __state.Force;
			}
		}
	}
	[HarmonyPatch(typeof(Projectile), "OnHit")]
	public static class Projectile_OnHit_Rondin_Patch
	{
		public static void Postfix(Collider collider, Vector3 hitPoint, Character ___m_owner, int ___m_statusEffectHash, bool ___m_didHit)
		{
			//IL_0017: 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_0066: 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 (!___m_didHit || !Plugin.HarponLocal(___m_owner, ___m_statusEffectHash))
			{
				return;
			}
			GameObject chose;
			Prise prise = Prises.Trouver(collider, out chose);
			Vector3 prise2 = hitPoint;
			if (prise == Prise.Aucune)
			{
				GameObject val = (((Object)(object)collider != (Object)null) ? Projectile.FindHitObject(collider) : null);
				if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponentInParent<Character>() != (Object)null)
				{
					return;
				}
				prise = Prises.PlusProche(hitPoint, Plugin.RayonPrise.Value, out chose, out prise2);
			}
			if (prise != Prise.Aucune)
			{
				Player localPlayer = Player.m_localPlayer;
				Prise prise3 = prise;
				GameObject chose2 = chose;
				Vector3 point = prise2;
				StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(___m_statusEffectHash);
				Corde.Accrocher(localPlayer, prise3, chose2, point, (SE_Harpooned)(object)((statusEffect is SE_Harpooned) ? statusEffect : null));
			}
		}
	}
	[HarmonyPatch(typeof(Projectile), "FixedUpdate")]
	public static class Projectile_FixedUpdate_Patch
	{
		public const float Marge = 0.3f;

		private static readonly FieldInfo masqueDuJeu = AccessTools.Field(typeof(Projectile), "s_rayMaskSolids");

		private static int masqueObjets;

		public static bool Prefix(Projectile __instance, ZNetView ___m_nview, Character ___m_owner, int ___m_statusEffectHash, ref bool ___m_didHit, Vector3 ___m_vel, bool ___m_haveStartPoint, Vector3 ___m_startPoint)
		{
			//IL_0047: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0083: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00c4: 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_00dc: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: 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_0262: Unknown result type (might be due to invalid IL or missing references)
			if (___m_didHit || (!Plugin.Objets.Value && !Plugin.Tombes.Value) || !Plugin.HarponLocal(___m_owner, ___m_statusEffectHash) || (Object)(object)___m_nview == (Object)null || !___m_nview.IsValid() || !___m_nview.IsOwner())
			{
				return true;
			}
			float fixedDeltaTime = Time.fixedDeltaTime;
			Vector3 val = ___m_vel + Vector3.down * (__instance.m_gravity * fixedDeltaTime);
			val += Mathf.Pow(((Vector3)(ref val)).magnitude, 2f) * __instance.m_drag * fixedDeltaTime * -((Vector3)(ref val)).normalized;
			Vector3 val2 = (___m_haveStartPoint ? ___m_startPoint : ((Component)__instance).transform.position);
			Vector3 val3 = ((Component)__instance).transform.position + val * fixedDeltaTime - val2;
			if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
			{
				return true;
			}
			if (!___m_haveStartPoint)
			{
				val2 -= ((Vector3)(ref val3)).normalized * (((Vector3)(ref val3)).magnitude * 0.5f);
			}
			float rayRadius = __instance.m_rayRadius;
			float num = ((rayRadius != 0f) ? ((Vector3)(ref val3)).magnitude : (((Vector3)(ref val3)).magnitude * 1.5f));
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			if (masqueObjets == 0)
			{
				masqueObjets = LayerMask.GetMask(new string[1] { "item" });
			}
			RaycastHit val4 = default(RaycastHit);
			bool flag = false;
			RaycastHit[] array = Physics.SphereCastAll(val2, Mathf.Max(rayRadius, 0.3f), normalized, num, masqueObjets, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val5 = array[i];
				if ((!flag || ((RaycastHit)(ref val5)).distance < ((RaycastHit)(ref val4)).distance) && Prises.Trouver(((RaycastHit)(ref val5)).collider, out var _) != Prise.Aucune)
				{
					val4 = val5;
					flag = true;
				}
			}
			if (!flag)
			{
				return true;
			}
			int num2 = (int)masqueDuJeu.GetValue(null);
			array = ((rayRadius != 0f) ? Physics.SphereCastAll(val2, rayRadius, normalized, num, num2) : Physics.RaycastAll(val2, normalized, num, num2));
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val6 = array[i];
				if (((RaycastHit)(ref val6)).distance < ((RaycastHit)(ref val4)).distance && (Object)(object)((Component)((RaycastHit)(ref val6)).collider).GetComponentInParent<Character>() != (Object)(object)___m_owner)
				{
					return true;
				}
			}
			__instance.OnHit(((RaycastHit)(ref val4)).collider, (((RaycastHit)(ref val4)).distance == 0f) ? val2 : ((RaycastHit)(ref val4)).point, false, ((RaycastHit)(ref val4)).normal);
			return !___m_didHit;
		}
	}
	[HarmonyPatch(typeof(Fish), "CustomFixedUpdate")]
	public static class Fish_Corde_Patch
	{
		public static bool Prefix(Fish __instance)
		{
			return !Corde.Tient(((Component)__instance).gameObject);
		}
	}
	public enum Prise
	{
		Aucune,
		Rondin,
		Objet,
		Poisson,
		Tombe,
		Charrette
	}
	public static class Prises
	{
		private static readonly Collider[] autour = (Collider[])(object)new Collider[64];

		private static int masqueAutour;

		public static Prise Trouver(Collider forme, out GameObject chose)
		{
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			chose = null;
			if ((Object)(object)forme == (Object)null)
			{
				return Prise.Aucune;
			}
			FloatingTerrainDummy componentInParent = ((Component)forme).GetComponentInParent<FloatingTerrainDummy>();
			GameObject val = ((!((Object)(object)componentInParent != (Object)null)) ? Projectile.FindHitObject(forme) : (((Object)(object)componentInParent.m_parent != (Object)null) ? ((Component)componentInParent.m_parent).gameObject : null));
			if ((Object)(object)val == (Object)null || (Object)(object)val.GetComponentInParent<Character>() != (Object)null || (Object)(object)val.GetComponentInParent<Ship>() != (Object)null)
			{
				return Prise.Aucune;
			}
			Prise prise = Prise.Aucune;
			Component componentInParent2;
			if ((Object)(object)(componentInParent2 = (Component)(object)val.GetComponentInParent<TreeLog>()) != (Object)null)
			{
				prise = (Plugin.Rondins.Value ? Prise.Rondin : Prise.Aucune);
			}
			else if ((Object)(object)(componentInParent2 = (Component)(object)val.GetComponentInParent<Fish>()) != (Object)null)
			{
				prise = (Plugin.Poissons.Value ? Prise.Poisson : Prise.Aucune);
			}
			else if ((Object)(object)(componentInParent2 = (Component)(object)val.GetComponentInParent<TombStone>()) != (Object)null)
			{
				prise = (Plugin.Tombes.Value ? Prise.Tombe : Prise.Aucune);
			}
			else if ((Object)(object)(componentInParent2 = (Component)(object)val.GetComponentInParent<Vagon>()) != (Object)null)
			{
				prise = ((Plugin.Charrettes.Value && !((Vagon)componentInParent2).InUse()) ? Prise.Charrette : Prise.Aucune);
			}
			else if ((Object)(object)(componentInParent2 = (Component)(object)val.GetComponentInParent<ItemDrop>()) != (Object)null)
			{
				prise = ((Plugin.Objets.Value && !((ItemDrop)componentInParent2).IsPiece()) ? Prise.Objet : Prise.Aucune);
			}
			if (prise != Prise.Aucune)
			{
				chose = componentInParent2.gameObject;
			}
			return prise;
		}

		public static Prise PlusProche(Vector3 point, float rayon, out GameObject chose, out Vector3 prise)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			chose = null;
			prise = point;
			if (rayon <= 0f)
			{
				return Prise.Aucune;
			}
			if (masqueAutour == 0)
			{
				masqueAutour = LayerMask.GetMask(new string[5] { "item", "character", "vehicle", "Default", "Default_small" });
			}
			Prise result = Prise.Aucune;
			float num = float.MaxValue;
			int num2 = Physics.OverlapSphereNonAlloc(point, rayon, autour, masqueAutour, (QueryTriggerInteraction)1);
			for (int i = 0; i < num2; i++)
			{
				GameObject chose2;
				Prise prise2 = Trouver(autour[i], out chose2);
				if (prise2 != Prise.Aucune)
				{
					Vector3 val = autour[i].ClosestPoint(point);
					Vector3 val2 = val - point;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = prise2;
						chose = chose2;
						prise = val;
					}
				}
			}
			return result;
		}
	}
	public class Corde : MonoBehaviour
	{
		private const float LongueurMin = 2.5f;

		private const float Ecart = 1.8f;

		private const float LongueurMinLeger = 1f;

		private const float EcartLeger = 1f;

		private const float Ramassage = 1.8f;

		private const float Arrivee = 1f;

		private const float Raideur = 1.5f;

		private const float VitesseMax = 5f;

		private const float Reactivite = 5f;

		private const float TractionMax = 12f;

		private const float FreinMax = 6f;

		private const float VerticalMax = 3f;

		private const float MonteeMax = 2f;

		private const float AmortiRotation = 2f;

		private const float RotationMax = 1.5f;

		private const float Portage = 0.9f;

		private const float LongueurMinTraine = 1.5f;

		private static Corde actuelle;

		private Prise prise;

		private string nom = "";

		private Player joueur;

		private Rigidbody corps;

		private Rigidbody[] lies;

		private RigidbodyConstraints blocages;

		private ZNetView vue;

		private Collider[] formes;

		private Vector3 ancrage;

		private float longueur;

		private float longueurMin = 2.5f;

		private float ecartArret = 1.8f;

		private float debut;

		private float rupture = 6f;

		private float porteeMax = 60f;

		private float prochainRamassage;

		private float prochaineTombe;

		private bool plein;

		private bool lache;

		private bool graviteAvant = true;

		private LineRenderer ligne;

		public float EcartMesure { get; private set; } = float.MaxValue;

		public float Tendue { get; private set; }

		public float Traction { get; private set; }

		public Prise Chose => prise;

		public static Corde Actuelle => actuelle;

		public static string DerniereRaison { get; private set; } = "";

		private bool Leger
		{
			get
			{
				if (prise != Prise.Objet)
				{
					return prise == Prise.Poisson;
				}
				return true;
			}
		}

		public static bool Tient(GameObject go)
		{
			if ((Object)(object)actuelle != (Object)null)
			{
				return (Object)(object)((Component)actuelle).gameObject == (Object)(object)go;
			}
			return false;
		}

		public static void Accrocher(Player p, TreeLog rondin, Vector3 point, SE_Harpooned reglages)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Accrocher(p, Prise.Rondin, ((Component)rondin).gameObject, point, reglages);
		}

		public static void Accrocher(Player p, Prise prise, GameObject chose, Vector3 point, SE_Harpooned reglages)
		{
			//IL_002f: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)actuelle != (Object)null)
			{
				actuelle.Lacher(null);
			}
			if ((Object)(object)p == (Object)null || (Object)(object)chose == (Object)null || prise == Prise.Aucune)
			{
				return;
			}
			float num = Vector3.Distance(Main(p), point);
			if ((Object)(object)reglages != (Object)null && num > reglages.m_maxDistance)
			{
				((Character)p).Message((MessageType)2, "$msg_harpoon_targettoofar", 0, (Sprite)null, false);
				return;
			}
			Rigidbody val = Corps(chose);
			ZNetView component = chose.GetComponent<ZNetView>();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)component == (Object)null) && component.IsValid())
			{
				Corde corde = chose.AddComponent<Corde>();
				corde.prise = prise;
				corde.nom = Nom(prise, chose);
				corde.joueur = p;
				corde.Prendre(val);
				corde.vue = component;
				corde.ancrage = chose.transform.InverseTransformPoint(point);
				corde.debut = Time.time;
				if (corde.Leger)
				{
					corde.longueurMin = 1f;
					corde.ecartArret = 1f;
				}
				else if (prise != Prise.Rondin)
				{
					corde.longueurMin = 1.5f;
				}
				if ((Object)(object)reglages != (Object)null)
				{
					corde.rupture = Mathf.Max(2f, reglages.m_breakDistance) + 2f;
					corde.porteeMax = reglages.m_maxDistance + 10f;
				}
				corde.longueur = Mathf.Max(corde.longueurMin, Vector3.Distance(Main(p), val.worldCenterOfMass));
				component.ClaimOwnership();
				corde.ligne = CreerLigne(chose.transform);
				actuelle = corde;
				((Character)p).Message((MessageType)2, (prise == Prise.Rondin) ? Traductions.Texte("rondin_accroche") : Traductions.Format("prise_accrochee", null, new object[1] { corde.nom }), 0, (Sprite)null, false);
			}
		}

		private void Prendre(Rigidbody b)
		{
			//IL_001e: 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_0089: 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)
			if ((Object)(object)corps != (Object)null && prise == Prise.Tombe)
			{
				corps.constraints = blocages;
			}
			corps = b;
			lies = (Rigidbody[])(((Object)(object)((Component)b).gameObject == (Object)(object)((Component)this).gameObject) ? ((Array)((Component)this).GetComponentsInChildren<Rigidbody>()) : ((Array)new Rigidbody[1] { b }));
			formes = Formes(b);
			blocages = b.constraints;
			graviteAvant = b.useGravity;
			if (prise == Prise.Tombe)
			{
				b.constraints = (RigidbodyConstraints)(b.constraints & -11);
			}
		}

		private static Rigidbody Corps(GameObject chose)
		{
			Rigidbody body = FloatingTerrain.GetBody(chose);
			if (!((Object)(object)body != (Object)null))
			{
				return chose.GetComponent<Rigidbody>();
			}
			return body;
		}

		private static Collider[] Formes(Rigidbody corps)
		{
			return (from f in ((Component)corps).GetComponentsInChildren<Collider>()
				where f.enabled && !f.isTrigger
				select f).ToArray();
		}

		private static string Nom(Prise prise, GameObject chose)
		{
			switch (prise)
			{
			case Prise.Objet:
				return Localization.instance.Localize(chose.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			case Prise.Poisson:
				return Localization.instance.Localize(chose.GetComponent<Fish>().m_name);
			case Prise.Charrette:
				return Localization.instance.Localize(chose.GetComponent<Vagon>().m_name);
			case Prise.Tombe:
			{
				string text = chose.GetComponent<TombStone>().GetOwnerName() ?? "";
				if (!(text == ""))
				{
					return Traductions.Format("tombe_de", null, new object[1] { text });
				}
				return Traductions.Texte("tombe");
			}
			default:
				return "";
			}
		}

		private static Vector3 Main(Player p)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)p).GetComponent<VisEquipment>()?.m_rightHand;
			if (!((Object)(object)val != (Object)null))
			{
				return ((Component)p).transform.position + Vector3.up * 1.2f;
			}
			return val.position;
		}

		private float EcartAuJoueur()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//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_0077: 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_004f: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)joueur).transform.position + Vector3.up * 0.9f;
			float num = float.MaxValue;
			Collider[] array = formes;
			foreach (Collider val2 in array)
			{
				if ((Object)(object)val2 != (Object)null && val2.enabled)
				{
					num = Mathf.Min(num, Vector3.Distance(val, val2.ClosestPoint(val)));
				}
			}
			if (num != float.MaxValue)
			{
				return num;
			}
			return Vector3.Distance(val, corps.worldCenterOfMass);
		}

		private static LineRenderer CreerLigne(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_006b: 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)
			GameObject val = new GameObject("TamedHarpoon_Line");
			val.transform.SetParent(parent, false);
			LineRenderer obj = val.AddComponent<LineRenderer>();
			obj.positionCount = 3;
			float startWidth = (obj.endWidth = 0.03f);
			obj.startWidth = startWidth;
			obj.useWorldSpace = true;
			((Renderer)obj).material = new Material(Shader.Find("Sprites/Default"));
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.32f, 0.24f, 0.15f);
			obj.endColor = val2;
			obj.startColor = val2;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			return obj;
		}

		private void FixedUpdate()
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			if (lache)
			{
				return;
			}
			if ((Object)(object)corps == (Object)null && (Object)(object)vue != (Object)null && vue.IsValid())
			{
				Rigidbody body = FloatingTerrain.GetBody(((Component)this).gameObject);
				if ((Object)(object)body != (Object)null)
				{
					Prendre(body);
				}
			}
			if ((Object)(object)joueur == (Object)null || ((Character)joueur).IsDead() || (Object)(object)corps == (Object)null || (Object)(object)vue == (Object)null || !vue.IsValid())
			{
				Lacher(null);
				return;
			}
			if (prise == Prise.Charrette && ((Component)this).GetComponent<Vagon>().InUse())
			{
				Lacher(null);
				return;
			}
			if (!vue.IsOwner())
			{
				vue.ClaimOwnership();
			}
			if (Leger)
			{
				corps.useGravity = false;
			}
			if (corps.isKinematic)
			{
				return;
			}
			float fixedDeltaTime = Time.fixedDeltaTime;
			Vector3 val = Main(joueur) - corps.worldCenterOfMass;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < 0.01f)
			{
				return;
			}
			Vector3 val2 = val / magnitude;
			float num = EcartAuJoueur();
			EcartMesure = Mathf.Min(EcartMesure, num);
			bool flag = num < ecartArret;
			if (Leger && num < 1.8f && Time.time >= prochainRamassage)
			{
				prochainRamassage = Time.time + 0.5f;
				Ramasser();
				if ((Object)(object)vue == (Object)null || !vue.IsValid())
				{
					Lacher(null);
					return;
				}
			}
			if (prise == Prise.Tombe && Time.time >= prochaineTombe)
			{
				prochaineTombe = Time.time + 0.25f;
				vue.GetZDO().Set(ZDOVars.s_spawnPoint, ((Component)this).transform.position);
			}
			longueur = Mathf.Min(longueur, magnitude + 0.5f);
			if (flag)
			{
				longueur = Mathf.Max(longueur, magnitude);
			}
			else if (magnitude - longueur < 1.5f)
			{
				longueur = Mathf.Max(longueurMin, longueur - Plugin.Rembobinage.Value * fixedDeltaTime);
			}
			float num2 = (Tendue = magnitude - longueur);
			float num4 = Mathf.Clamp(Mathf.Min(num2 * 1.5f, (num - ecartArret) * 1f), 0f, 5f);
			float num5 = Vector3.Dot(corps.linearVelocity, val2);
			float num6 = (num4 - num5) * 5f;
			if (flag || num2 <= 0f)
			{
				num6 = Mathf.Min(num6, 0f);
			}
			float num7 = 1f - Plugin.Facilite.Value / 100f;
			num6 = (Traction = Mathf.Clamp(num6, -6f, 12f / num7));
			Vector3 val3 = val2 * num6;
			val3.y = Mathf.Clamp(val3.y, -3f, 3f);
			bool flag2 = !Leger && Floating.GetLiquidLevel(corps.worldCenterOfMass, 1f, (LiquidType)10) < corps.worldCenterOfMass.y - 0.3f;
			if (flag2)
			{
				val3.y = Mathf.Min(val3.y, (0f - Physics.gravity.y) * 0.100000024f * 0.9f);
			}
			Rigidbody[] array = lies;
			foreach (Rigidbody val4 in array)
			{
				if ((Object)(object)val4 != (Object)null && !val4.isKinematic)
				{
					val4.AddForce(val3, (ForceMode)5);
					if (flag2 && val4.useGravity)
					{
						val4.AddForce(-Physics.gravity * 0.9f, (ForceMode)5);
					}
					val4.AddTorque(-val4.angularVelocity * 2f, (ForceMode)5);
				}
			}
			if (Leger)
			{
				Vector3 val5 = corps.linearVelocity - val2 * Vector3.Dot(corps.linearVelocity, val2);
				Rigidbody obj = corps;
				obj.linearVelocity -= val5 * Mathf.Min(1f, 2f * fixedDeltaTime);
			}
			Vector3 linearVelocity = corps.linearVelocity;
			Vector3 val6 = default(Vector3);
			((Vector3)(ref val6))..ctor(linearVelocity.x, 0f, linearVelocity.z);
			if (((Vector3)(ref val6)).sqrMagnitude > 36f || linearVelocity.y > 2f)
			{
				val6 = Vector3.ClampMagnitude(val6, 6f);
				corps.linearVelocity = new Vector3(val6.x, Mathf.Min(linearVelocity.y, 2f), val6.z);
			}
			Vector3 angularVelocity = corps.angularVelocity;
			if (((Vector3)(ref angularVelocity)).sqrMagnitude > 2.25f)
			{
				Rigidbody obj2 = corps;
				angularVelocity = corps.angularVelocity;
				obj2.angularVelocity = ((Vector3)(ref angularVelocity)).normalized * 1.5f;
			}
			if (num6 > 0.1f)
			{
				((Character)joueur).UseStamina(Plugin.EndurancePulling.Value * (num6 * num7 / 12f) * fixedDeltaTime);
			}
			if (num2 > rupture || magnitude > porteeMax)
			{
				Lacher("$msg_harpoon_linebroke");
			}
			else if (!((Character)joueur).HaveStamina(0f))
			{
				Lacher((prise == Prise.Rondin) ? Traductions.Texte("rondin_libere") : Traductions.Format("prise_lachee", null, new object[1] { nom }));
			}
			else if (Time.time - debut > 2f && (((Character)joueur).IsBlocking() || ((Character)joueur).InAttack()))
			{
				Lacher((prise == Prise.Rondin) ? Traductions.Texte("rondin_lache") : Traductions.Format("prise_lachee", null, new object[1] { nom }));
			}
		}

		private void Ramasser()
		{
			ItemDrop component = ((Component)this).GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			component.Load();
			if (!((Humanoid)joueur).GetInventory().CanAddItem(component.m_itemData, -1))
			{
				if (!plein)
				{
					((Character)joueur).Message((MessageType)2, "$msg_noroom", 0, (Sprite)null, false);
				}
				plein = true;
				return;
			}
			plein = false;
			Fish component2 = ((Component)this).GetComponent<Fish>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.Pickup((Humanoid)(object)joueur);
			}
			else
			{
				component.Pickup((Humanoid)(object)joueur);
			}
		}

		private void LateUpdate()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//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_006e: 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_007d: 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_0092: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!lache && !((Object)(object)ligne == (Object)null) && !((Object)(object)joueur == (Object)null))
			{
				Vector3 val = Main(joueur);
				Vector3 val2 = ((Component)this).transform.TransformPoint(ancrage);
				float num = Mathf.Clamp01(1f - (Tendue + 1f) / 2f) * 0.6f;
				ligne.SetPosition(0, val);
				ligne.SetPosition(1, (val + val2) * 0.5f + Vector3.down * num);
				ligne.SetPosition(2, val2);
			}
		}

		public void Lacher(string message)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (!lache)
			{
				lache = true;
				DerniereRaison = message ?? "(chose ou joueur disparu, ou nouvelle corde)";
				if (message != null && (Object)(object)joueur != (Object)null)
				{
					((Character)joueur).Message((MessageType)2, message, 0, (Sprite)null, false);
				}
				if (prise == Prise.Tombe && (Object)(object)corps != (Object)null)
				{
					corps.constraints = blocages;
				}
				if (Leger && (Object)(object)corps != (Object)null)
				{
					corps.useGravity = graviteAvant;
				}
				if (prise == Prise.Tombe && (Object)(object)vue != (Object)null && vue.IsValid() && vue.IsOwner())
				{
					vue.GetZDO().Set(ZDOVars.s_spawnPoint, ((Component)this).transform.position);
				}
				if ((Object)(object)ligne != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)ligne).gameObject);
				}
				if ((Object)(object)actuelle == (Object)(object)this)
				{
					actuelle = null;
				}
				Object.Destroy((Object)(object)this);
			}
		}
	}
	internal static class Traductions
	{
		internal static readonly string[] Langues = new string[36]
		{
			"English", "Swedish", "French", "Italian", "German", "Spanish", "Russian", "Romanian", "Bulgarian", "Macedonian",
			"Finnish", "Danish", "Norwegian", "Icelandic", "Turkish", "Lithuanian", "Czech", "Hungarian", "Slovak", "Polish",
			"Dutch", "Portuguese_European", "Portuguese_Brazilian", "Chinese", "Chinese_Trad", "Japanese", "Korean", "Hindi", "Thai", "Abenaki",
			"Croatian", "Georgian", "Greek", "Serbian", "Ukrainian", "Latvian"
		};

		private static readonly string[] Cultures = new string[36]
		{
			"en-US", "sv-SE", "fr-FR", "it-IT", "de-DE", "es-ES", "ru-RU", "ro-RO", "bg-BG", "mk-MK",
			"fi-FI", "da-DK", "nb-NO", "is-IS", "tr-TR", "lt-LT", "cs-CZ", "hu-HU", "sk-SK", "pl-PL",
			"nl-NL", "pt-PT", "pt-BR", "zh-CN", "zh-TW", "ja-JP", "ko-KR", "hi-IN", "th-TH", "en-US",
			"hr-HR", "ka-GE", "el-GR", "sr-Latn-RS", "uk-UA", "lv-LV"
		};

		internal static readonly Dictionary<string, string[]> Textes;

		private static readonly FieldInfo TraductionDuJeu;

		private static bool jeuPret;

		internal static string LangueDuJeu
		{
			get
			{
				try
				{
					if (!jeuPret)
					{
						if (TraductionDuJeu != null && TraductionDuJeu.GetValue(null) == null)
						{
							return PlayerPrefs.GetString("language", "English");
						}
						jeuPret = true;
					}
					return Localization.instance.GetSelectedLanguage();
				}
				catch (Exception)
				{
					return "English";
				}
			}
		}

		internal static string Texte(string cle, string langue = null)
		{
			if (!Textes.TryGetValue(cle, out var value))
			{
				return cle;
			}
			int num = Array.IndexOf(Langues, langue ?? LangueDuJeu);
			if (num <= 0 || num >= value.Length || string.IsNullOrEmpty(value[num]))
			{
				return value[0];
			}
			return value[num];
		}

		internal static string Format(string cle, string langue, object[] valeurs)
		{
			string text = Texte(cle, langue);
			if (valeurs != null && valeurs.Length != 0)
			{
				return string.Format(Culture(langue), text, valeurs);
			}
			return text;
		}

		internal static CultureInfo Culture(string langue = null)
		{
			int num = Array.IndexOf(Langues, langue ?? LangueDuJeu);
			try
			{
				return CultureInfo.GetCultureInfo((num >= 0) ? Cultures[num] : "en-US");
			}
			catch
			{
				return CultureInfo.InvariantCulture;
			}
		}

		static Traductions()
		{
			Dictionary<string, string[]> dictionary = new Dictionary<string, string[]>
			{
				["rondin_accroche"] = new string[36]
				{
					"Log harpooned", "Stock harpunerad", "Rondin harponné", "Tronco arpionato", "Baumstamm harpuniert", "Tronco arponeado", "Бревно загарпунено", "Buștean harponat", "Дънерът е харпуниран", "Трупецот е харпуниран",
					"Puunrunko harppuunoitu", "Træstamme harpuneret", "Tømmerstokk harpunert", "Skutull festur í drumbi", "Kütük zıpkınlandı", "Rąstas užkabintas žeberklu", "Kláda zachycena harpunou", "Farönk megszigonyozva", "Klada zachytená harpúnou", "Kłoda trafiona harpunem",
					"Stam geharpoeneerd", "Tronco arpoado", "Tronco arpoado", "原木已被叉中", "木材已被魚叉叉中", "丸太に銛を打ち込んだ", "통나무에 작살을 꽂았습니다", "लट\u094dठ\u0947 म\u0947\u0902 भ\u093eल\u093e फ\u0901स गय\u093e", "ป\u0e31กฉมวกท\u0e35\u0e48ซ\u0e38งแล\u0e49ว", null,
					"Balvan pogođen harpunom", "ხის მორი ჰარპუნით დაიჭირე", "Ο κορμός καμακώθηκε", "Balvan pogođen harpunom", "Колоду загарпунено", "Baļķis noharpūnēts"
				},
				["rondin_libere"] = new string[36]
				{
					"The log got away", "Stocken slet sig loss", "Le rondin s'est libéré", "Il tronco si è liberato", "Der Baumstamm hat sich losgerissen", "El tronco se ha soltado", "Бревно сорвалось", "Bușteanul a scăpat", "Дънерът се изплъзна", "Трупецот се ослободи",
					"Puunrunko pääsi irti", "Træstammen slap fri", "Tømmerstokken slet seg løs", "Drumburinn losnaði", "Kütük kurtuldu", "Rąstas ištrūko", "Kláda se utrhla", "A farönk elszabadult", "Klada sa vytrhla", "Kłoda się wyrwała",
					"De stam is losgeschoten", "O tronco soltou-se", "O tronco se soltou", "原木挣脱了", "木材掙脫了", "丸太が外れた", "통나무가 풀려났습니다", "लट\u094dठ\u093e छ\u0942ट गय\u093e", "ซ\u0e38งหล\u0e38ดไปแล\u0e49ว", null,
					"Balvan se otrgnuo", "ხის მორი გაგექცა", "Ο κορμός ξέφυγε", "Balvan se otrgao", "Колода зірвалася", "Baļķis izrāvās"
				},
				["rondin_lache"] = new string[36]
				{
					"Log released", "Stock släppt", "Rondin lâché", "Tronco rilasciato", "Baumstamm losgelassen", "Tronco soltado", "Бревно отпущено", "Buștean eliberat", "Дънерът е пуснат", "Трупецот е пуштен",
					"Puunrunko päästetty", "Træstamme sluppet", "Tømmerstokk sluppet", "Drumbi sleppt", "Kütük bırakıldı", "Rąstas paleistas", "Kláda puštěna", "Farönk elengedve", "Klada pustená", "Kłoda puszczona",
					"Stam losgelaten", "Tronco largado", "Tronco solto", "已松开原木", "已放開木材", "丸太を放した", "통나무를 놓았습니다", "लट\u094dठ\u093e छ\u094bड\u093c द\u093fय\u093e", "ปล\u0e48อยซ\u0e38งแล\u0e49ว", null,
					"Balvan pušten", "ხის მორი გაუშვი", "Ο κορμός αφέθηκε", "Balvan pušten", "Колоду відпущено", "Baļķis atlaists"
				}
			};
			string[] array = new string[36];
			array[0] = "{0} v{1} loaded.";
			array[2] = "{0} v{1} chargé.";
			dictionary["journal_charge"] = array;
			dictionary["prise_accrochee"] = new string[36]
			{
				"{0} on the line", "{0} på linan", "{0} au bout de la corde", "{0} sulla corda", "{0} an der Leine", "{0} en la cuerda", "{0} на верёвке", "{0} la capătul frânghiei", "{0} на въжето", "{0} на јажето",
				"{0} köyden päässä", "{0} i linen", "{0} i lina", "{0} á línunni", "{0} ipin ucunda", "{0} ant virvės", "{0} na laně", "{0} a kötélen", "{0} na lane", "{0} na linie",
				"{0} aan de lijn", "{0} na ponta da corda", "{0} na ponta da corda", "{0}已被钩住", "{0}已被鉤住", "{0}を引っかけた", "{0}을(를) 걸었습니다", "{0} रस\u094dस\u0940 म\u0947\u0902 फ\u0901स\u093e", "เก\u0e35\u0e48ยว {0} ไว\u0e49แล\u0e49ว", null,
				"{0} na užetu", "{0} თოკზეა", "{0} στο σχοινί", "{0} na užetu", "{0} на мотузці", "{0} pie virves"
			};
			dictionary["prise_lachee"] = new string[36]
			{
				"{0}: line released", "{0}: linan släppt", "{0} : corde lâchée", "{0}: corda lasciata", "{0}: Leine losgelassen", "{0}: cuerda soltada", "{0}: верёвка отпущена", "{0}: frânghie eliberată", "{0}: въжето е пуснато", "{0}: јажето е пуштено",
				"{0}: köysi irrotettu", "{0}: linen sluppet", "{0}: lina sluppet", "{0}: línu sleppt", "{0}: ip bırakıldı", "{0}: virvė paleista", "{0}: lano puštěno", "{0}: kötél elengedve", "{0}: lano pustené", "{0}: lina puszczona",
				"{0}: lijn losgelaten", "{0}: corda largada", "{0}: corda solta", "{0}:绳索已松开", "{0}:繩索已鬆開", "{0}:ロープを放した", "{0}: 밧줄을 놓았습니다", "{0}: रस\u094dस\u0940 छ\u094bड\u093c द\u0940", "{0}: ปล\u0e48อยเช\u0e37อกแล\u0e49ว", null,
				"{0}: uže pušteno", "{0}: თოკი გაშვებულია", "{0}: το σχοινί αφέθηκε", "{0}: uže pušteno", "{0}: мотузку відпущено", "{0}: virve atlaista"
			};
			dictionary["tombe"] = new string[36]
			{
				"Tombstone", "Gravsten", "Tombe", "Tomba", "Grabstein", "Tumba", "Могила", "Mormânt", "Гроб", "Гроб",
				"Hauta", "Gravsten", "Gravstein", "Legsteinn", "Mezar", "Kapas", "Hrob", "Sír", "Hrob", "Grób",
				"Graf", "Túmulo", "Túmulo", "墓碑", "墓碑", "墓", "무덤", "कब\u094dर", "หล\u0e38มศพ", null,
				"Grob", "საფლავი", "Τάφος", "Grob", "Могила", "Kaps"
			};
			dictionary["tombe_de"] = new string[36]
			{
				"{0}'s tombstone", "Gravsten: {0}", "Tombe de {0}", "Tomba di {0}", "Grabstein von {0}", "Tumba de {0}", "Могила: {0}", "Mormânt: {0}", "Гроб: {0}", "Гроб: {0}",
				"Hauta: {0}", "Gravsten: {0}", "Gravstein: {0}", "Legsteinn: {0}", "Mezar: {0}", "Kapas: {0}", "Hrob: {0}", "Sír: {0}", "Hrob: {0}", "Grób: {0}",
				"Graf van {0}", "Túmulo de {0}", "Túmulo de {0}", "{0}的墓碑", "{0}的墓碑", "{0}の墓", "{0}의 무덤", "{0} क\u0940 कब\u094dर", "หล\u0e38มศพของ {0}", null,
				"Grob: {0}", "საფლავი: {0}", "Τάφος: {0}", "Grob: {0}", "Могила: {0}", "Kaps: {0}"
			};
			Textes = dictionary;
			TraductionDuJeu = typeof(Localization).GetField("m_instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		}
	}
}