Decompiled source of RTFMB v1.0.1

RTFMB.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Audio;
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("RTFMB")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RTFMB")]
[assembly: AssemblyTitle("RTFMB")]
[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 RTFMB
{
	internal static class Bandeau
	{
		private const string Or = "#E8C27A";

		private const string Gris = "#D9D2C5";

		private static GUIStyle style;

		private static Texture2D fond;

		private static Font police;

		private static bool policeCherchee;

		private static float tailleFaite;

		private static string texteVerifie;

		private static bool couverte;

		internal static void Dessiner()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			if (!CameraLibre.Actif || !Plugin.Aide.Value || (int)Event.current.type != 7)
			{
				return;
			}
			if (ModePhoto.Actif)
			{
				if (Time.frameCount != ModePhoto.ImageDeCapture)
				{
					Afficher(TextePhoto());
				}
				return;
			}
			Player joueur = CameraLibre.Joueur;
			if (!((Object)(object)joueur == (Object)null) && !((Object)(object)Hud.instance == (Object)null) && !Hud.IsUserHidden() && !Menu.IsVisible() && !InventoryGui.IsVisible() && !Minimap.IsOpen() && !Hud.IsPieceSelectionVisible())
			{
				Afficher(Texte(joueur));
			}
		}

		private static void Afficher(string texte)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			float num = Mathf.Max(0.6f, (float)Screen.height / 1080f);
			Preparer(num, texte);
			GUIContent val = new GUIContent(texte);
			Vector2 val2 = style.CalcSize(val);
			GUI.Label(new Rect(((float)Screen.width - val2.x) / 2f, 14f * num, val2.x, val2.y), val, style);
		}

		internal static string TextePhoto()
		{
			//IL_0013: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			string text = Traductions.Format("photo_bandeau", null, new object[2]
			{
				Touche(NomTouche(Plugin.ToucheCapture.Value)),
				Touche(((object)Plugin.TouchePhoto.Value/*cast due to .constrained prefix*/).ToString())
			});
			if (ModePhoto.Derniere != "" && Time.unscaledTime < ModePhoto.DerniereJusqua)
			{
				text = text + "   " + Traductions.Format(ModePhoto.DerniereRatee ? "photo_ratee" : "photo_prise", null, new object[1] { ModePhoto.Derniere });
			}
			return "<color=#E8C27A><b>R.T.F.M.B</b></color>   <color=#D9D2C5>" + text + "</color>";
		}

		private unsafe static string NomTouche(KeyboardShortcut t)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			if ((int)((KeyboardShortcut)(ref t)).MainKey == 323 && ((KeyboardShortcut)(ref t)).Modifiers != null && !((KeyboardShortcut)(ref t)).Modifiers.GetEnumerator().MoveNext())
			{
				return Traductions.Texte("clic_gauche");
			}
			return ((object)(*(KeyboardShortcut*)(&t))/*cast due to .constrained prefix*/).ToString();
		}

		internal static string Texte(Player p)
		{
			//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_0033: 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_00a1: 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_00d8: 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)
			string text = Traductions.Format("aide", null, new object[5]
			{
				Touche(((object)Plugin.ToucheCamera.Value/*cast due to .constrained prefix*/).ToString()),
				Touche(((object)Plugin.ToucheLumiere.Value/*cast due to .constrained prefix*/).ToString()),
				Touche(ToucheDuJeu("Jump")),
				Touche(ToucheDuJeu("Crouch")),
				Touche(ToucheDuJeu("Run"))
			});
			text = text + " · " + Traductions.Format("aide_photo", null, new object[1] { Touche(((object)Plugin.TouchePhoto.Value/*cast due to .constrained prefix*/).ToString()) });
			if (Localization.instance != null)
			{
				text = Localization.instance.Localize(text);
			}
			float num = Vector3.Distance(CameraLibre.Position, CameraLibre.Centre(p));
			return string.Format("<color={0}><b>R.T.F.M.B</b></color>   <color={1}>{2}   {3:0} / {4:0} m</color>", "#E8C27A", "#D9D2C5", text, num, Plugin.Rayon.Value);
		}

		private static string Touche(string nom)
		{
			return "<color=#E8C27A><b>" + nom + "</b></color>";
		}

		private static string ToucheDuJeu(string bouton)
		{
			string text = ((ZInput.instance != null) ? ZInput.instance.GetBoundKeyString(bouton, true) : "");
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			return bouton;
		}

		private static Font PolicePour(string texte)
		{
			if (!policeCherchee)
			{
				policeCherchee = true;
				Font[] array = Resources.FindObjectsOfTypeAll<Font>();
				foreach (Font val in array)
				{
					if ((Object)(object)val != (Object)null && ((Object)val).name == "AveriaSerifLibre-Bold")
					{
						police = val;
						break;
					}
					if ((Object)(object)val != (Object)null && (Object)(object)police == (Object)null && ((Object)val).name.StartsWith("AveriaSerifLibre-Bold") && !((Object)val).name.Contains("Italic"))
					{
						police = val;
					}
				}
			}
			if ((Object)(object)police == (Object)null)
			{
				return null;
			}
			if (texte != texteVerifie)
			{
				texteVerifie = texte;
				couverte = true;
				bool flag = false;
				foreach (char c in texte)
				{
					switch (c)
					{
					case '<':
						flag = true;
						continue;
					case '>':
						flag = false;
						continue;
					default:
						if (flag || char.IsWhiteSpace(c) || char.IsDigit(c) || police.HasCharacter(c))
						{
							continue;
						}
						break;
					}
					couverte = false;
					break;
				}
			}
			if (!couverte)
			{
				return null;
			}
			return police;
		}

		private static void Preparer(float echelle, string texte)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0084: 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_0097: Expected O, but got Unknown
			//IL_0097: 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_00aa: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			Font val = PolicePour(texte);
			if ((Object)(object)fond == (Object)null)
			{
				fond = FondArrondi();
			}
			if (style == null || !Mathf.Approximately(tailleFaite, echelle) || !((Object)(object)style.font == (Object)(object)val))
			{
				tailleFaite = echelle;
				int num = Mathf.RoundToInt(10f * echelle);
				style = new GUIStyle
				{
					richText = true,
					alignment = (TextAnchor)4,
					fontSize = Mathf.RoundToInt(17f * echelle),
					font = val,
					border = new RectOffset(10, 10, 10, 10),
					padding = new RectOffset(num * 2, num * 2, num, num),
					wordWrap = false
				};
				style.normal.background = fond;
				style.normal.textColor = Color.white;
			}
		}

		private static Texture2D FondArrondi()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_001a: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.04f, 0.035f, 0.03f, 0.72f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.91f, 0.76f, 0.48f, 0.55f);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = Mathf.Max(new float[3]
					{
						9f - (float)j - 0.5f,
						(float)j + 0.5f - 23f,
						0f
					});
					float num2 = Mathf.Max(new float[3]
					{
						9f - (float)i - 0.5f,
						(float)i + 0.5f - 23f,
						0f
					});
					float num3 = Mathf.Sqrt(num * num + num2 * num2) - 9f;
					float num4 = Mathf.Min(new float[4]
					{
						(float)j + 0.5f,
						(float)i + 0.5f,
						(float)(32 - j) - 0.5f,
						(float)(32 - i) - 0.5f
					});
					if (num == 0f && num2 == 0f)
					{
						num3 = 0f - num4;
					}
					Color val4 = ((num3 > -1.2f) ? val3 : val2);
					val4.a *= Mathf.Clamp01(0.5f - num3);
					val.SetPixel(j, i, val4);
				}
			}
			val.Apply();
			return val;
		}
	}
	internal static class CameraLibre
	{
		private static bool actif;

		private static Player joueur;

		private static GameCamera cameraDuJeu;

		private static Camera objectif;

		private static Vector3 position;

		private static Vector3 vitesse;

		private static float lacet;

		private static float tangage;

		private static Vector2 regard;

		private static float horsConstruction;

		internal static Func<Player, bool> SaisieLibre = SaisieDuJeu;

		internal static Func<Vector3> Deplacement = DeplacementDuJeu;

		internal static Func<bool> Course = CourseDuJeu;

		private static Func<Player, bool> prendLaSaisie;

		private static bool saisieCherchee;

		internal static bool Actif => actif;

		internal static Vector3 Position => position;

		internal static Player Joueur => joueur;

		internal static Quaternion Regard => Quaternion.Euler(tangage, lacet, 0f);

		internal static string DerniereSortie { get; private set; } = "";

		internal static bool Pour(Character c)
		{
			if (!actif || !((Object)(object)c != (Object)null) || !((Object)(object)c == (Object)(object)joueur))
			{
				return Sequence.EnCours(c);
			}
			return true;
		}

		internal static bool EstLaCamera(GameCamera gc)
		{
			if (actif && (Object)(object)gc != (Object)null)
			{
				return (Object)(object)gc == (Object)(object)cameraDuJeu;
			}
			return false;
		}

		internal static void Surveiller()
		{
			if (actif && ((Object)(object)cameraDuJeu == (Object)null || (Object)(object)joueur == (Object)null || (Object)(object)GameCamera.instance != (Object)(object)cameraDuJeu || (Object)(object)joueur != (Object)(object)Player.m_localPlayer))
			{
				DerniereSortie = "caméra du jeu ou personnage disparus";
				Sortir(null);
			}
		}

		internal static void LireTouches()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_00c3: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value;
			if (actif)
			{
				if (!SaisieLibre(joueur))
				{
					return;
				}
				value = Plugin.ToucheCamera.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					Sortir(null);
					return;
				}
				value = Plugin.TouchePhoto.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					ModePhoto.Basculer();
					return;
				}
				if (ModePhoto.Actif)
				{
					value = Plugin.ToucheCapture.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						ModePhoto.Capturer();
						return;
					}
				}
				value = Plugin.ToucheLumiere.Value;
				if (((KeyboardShortcut)(ref value)).IsDown() && (Object)(object)cameraDuJeu != (Object)null)
				{
					Lanterne.Basculer(((Component)cameraDuJeu).transform);
				}
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && Sequence.Etat == Sequence.Phase.Aucune)
			{
				value = Plugin.ToucheCamera.Value;
				if (((KeyboardShortcut)(ref value)).IsDown() && SaisieLibre(localPlayer) && Kroastructeur.EnMain((Humanoid)(object)localPlayer) && ((Character)localPlayer).InPlaceMode())
				{
					Sequence.Demarrer(localPlayer);
				}
			}
		}

		internal static bool PeutEntrer(Player p)
		{
			if (actif || (Object)(object)p == (Object)null || (Object)(object)GameCamera.instance == (Object)null || GameCamera.InFreeFly() || ((Character)p).IsDead() || ((Character)p).InCutscene() || ((Character)p).IsTeleporting() || ((Character)p).InIntro() || !Kroastructeur.EnMain((Humanoid)(object)p) || !((Character)p).InPlaceMode())
			{
				return false;
			}
			if (((Character)p).IsAttached() || ((Character)p).IsSwimming() || !((Character)p).IsOnGround() || ((Character)p).InAttack() || ((Character)p).InDodge())
			{
				Plugin.Message("sol");
				return false;
			}
			return true;
		}

		internal static bool Entrer(Player p)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			if (actif)
			{
				return true;
			}
			GameCamera instance = GameCamera.instance;
			if ((Object)(object)p == (Object)null || (Object)(object)instance == (Object)null || GameCamera.InFreeFly() || ((Character)p).IsDead() || ((Character)p).InCutscene() || ((Character)p).IsTeleporting() || ((Character)p).InIntro())
			{
				return false;
			}
			joueur = p;
			cameraDuJeu = instance;
			DerniereSortie = "";
			objectif = ((Component)instance).GetComponent<Camera>();
			Transform transform = ((Component)instance).transform;
			position = transform.position;
			Quaternion rotation = transform.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			lacet = eulerAngles.y;
			tangage = Mathf.Clamp(Mathf.DeltaAngle(0f, eulerAngles.x), -89f, 89f);
			vitesse = Vector3.zero;
			regard = Vector2.zero;
			horsConstruction = 0f;
			actif = true;
			((Character)p).m_onDamaged = (Action<float, Character>)Delegate.Combine(((Character)p).m_onDamaged, new Action<float, Character>(SurDegats));
			if (Plugin.CacherPersonnage.Value)
			{
				Masque.Cacher(p);
			}
			Lanterne.Reprendre(transform);
			return true;
		}

		internal static void Sortir(string raison)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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 (actif)
			{
				if (raison != null || DerniereSortie == "")
				{
					DerniereSortie = raison ?? "touche";
				}
				ModePhoto.Sortir();
				actif = false;
				Sequence.Arreter();
				if ((Object)(object)joueur != (Object)null)
				{
					Player obj = joueur;
					((Character)obj).m_onDamaged = (Action<float, Character>)Delegate.Remove(((Character)obj).m_onDamaged, new Action<float, Character>(SurDegats));
				}
				Masque.Montrer();
				Lanterne.Eteindre();
				joueur = null;
				cameraDuJeu = null;
				objectif = null;
				vitesse = Vector3.zero;
				regard = Vector2.zero;
				if (raison != null)
				{
					Plugin.Message(raison);
				}
			}
		}

		private static void SurDegats(float degats, Character attaquant)
		{
			if (actif && Plugin.SortieSurDegats.Value)
			{
				Sortir("degats");
			}
		}

		internal static void Regarder(Vector2 v)
		{
			//IL_0000: 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_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			regard += v;
		}

		internal static bool Piloter(GameCamera gc, float dt)
		{
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: 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)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01ab: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			if (!actif)
			{
				return false;
			}
			string text = (((Object)(object)GameCamera.instance != (Object)(object)cameraDuJeu) ? "autre caméra du jeu" : Invalide(dt));
			if (text != null)
			{
				DerniereSortie = text;
				Plugin.Log.LogDebug((object)("Caméra libre rendue au jeu : " + text));
				Sortir(null);
				return false;
			}
			dt = Mathf.Clamp(dt, 0f, 0.05f);
			if (ModePhoto.Actif)
			{
				ModePhoto.Placer(((Component)gc).transform, position, regard);
				regard = Vector2.zero;
				vitesse = Vector3.zero;
				Sequence.Publier(position, Regard);
				if ((Object)(object)objectif != (Object)null)
				{
					objectif.fieldOfView = gc.m_fov;
					objectif.nearClipPlane = gc.m_nearClipPlaneMin;
				}
				if ((Object)(object)gc.m_skyCamera != (Object)null)
				{
					gc.m_skyCamera.fieldOfView = gc.m_fov;
				}
				Lanterne.MettreAJour(((Component)gc).transform, dt);
				Masque.Entretenir();
				return true;
			}
			lacet = Mathf.Repeat(lacet + regard.x, 360f);
			tangage = Mathf.Clamp(tangage - regard.y, -89f, 89f);
			regard = Vector2.zero;
			Vector3 val = Vector3.zero;
			if (SaisieLibre(joueur))
			{
				Vector3 val2 = Deplacement();
				Vector3 val3 = Quaternion.Euler(Plugin.VolSelonRegard.Value ? tangage : 0f, lacet, 0f) * new Vector3(val2.x, 0f, val2.z) + Vector3.up * val2.y;
				if (((Vector3)(ref val3)).sqrMagnitude > 1f)
				{
					((Vector3)(ref val3)).Normalize();
				}
				val = val3 * Plugin.Vitesse.Value * (Course() ? Plugin.Acceleration.Value : 1f);
			}
			vitesse = Vector3.Lerp(vitesse, val, 1f - Mathf.Exp((0f - dt) / 0.08f));
			position += vitesse * dt;
			Contraindre(gc);
			Transform transform = ((Component)gc).transform;
			transform.SetPositionAndRotation(position, Regard);
			Sequence.Publier(position, Regard);
			if ((Object)(object)objectif != (Object)null)
			{
				objectif.fieldOfView = gc.m_fov;
				float num = (Physics.CheckSphere(position, gc.m_nearClipPlaneMax, LayerMask.op_Implicit(gc.m_blockCameraMask)) ? gc.m_nearClipPlaneMin : gc.m_nearClipPlaneMax);
				if (objectif.nearClipPlane != num)
				{
					objectif.nearClipPlane = num;
				}
			}
			if ((Object)(object)gc.m_skyCamera != (Object)null)
			{
				gc.m_skyCamera.fieldOfView = gc.m_fov;
			}
			Lanterne.MettreAJour(transform, dt);
			Masque.Entretenir();
			return true;
		}

		private static string Invalide(float dt)
		{
			Player val = joueur;
			if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer)
			{
				return "personnage parti";
			}
			if (((Character)val).IsDead())
			{
				return "mort";
			}
			if (((Character)val).InCutscene())
			{
				return "cinématique";
			}
			if (((Character)val).IsTeleporting())
			{
				return "téléportation";
			}
			if (((Character)val).IsAttached())
			{
				return "assise ou à la barre";
			}
			if (GameCamera.InFreeFly())
			{
				return "vol libre du jeu";
			}
			if (Menu.IsVisible())
			{
				return "menu";
			}
			if (((Character)val).InPlaceMode() && Kroastructeur.EnMain((Humanoid)(object)val))
			{
				horsConstruction = 0f;
			}
			else if ((horsConstruction += dt) > 0.25f)
			{
				return "outil rangé";
			}
			return null;
		}

		private static void Contraindre(GameCamera gc)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0061: 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_006a: 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_00ca: 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)
			Vector3 val = Centre(joueur);
			float value = Plugin.Rayon.Value;
			Vector3 val2 = position - val;
			if (((Vector3)(ref val2)).sqrMagnitude > value * value)
			{
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				position = val + normalized * value;
				float num = Vector3.Dot(vitesse, normalized);
				if (num > 0f)
				{
					vitesse -= normalized * num;
				}
			}
			if (!Plugin.PasseMuraille.Value)
			{
				float num2 = default(float);
				if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(position, ref num2) && position.y < num2 + 0.5f)
				{
					position.y = num2 + 0.5f;
				}
				float liquidLevel = Floating.GetLiquidLevel(position, 1f, (LiquidType)10);
				if (position.y < liquidLevel + gc.m_minWaterDistance)
				{
					position.y = liquidLevel + gc.m_minWaterDistance;
				}
			}
		}

		internal static Vector3 Centre(Player p)
		{
			//IL_0034: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)((Character)p).m_eye != (Object)null))
			{
				return ((Component)p).transform.position + Vector3.up * 1.6f;
			}
			return ((Character)p).m_eye.position;
		}

		private static bool SaisieDuJeu(Player p)
		{
			if ((Object)(object)p == (Object)null || Hud.IsPieceSelectionVisible() || Hud.InRadial())
			{
				return false;
			}
			if (!saisieCherchee)
			{
				saisieCherchee = true;
				MethodInfo methodInfo = AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null);
				if (methodInfo != null && methodInfo.ReturnType == typeof(bool) && methodInfo.GetParameters().Length == 0)
				{
					prendLaSaisie = AccessTools.MethodDelegate<Func<Player, bool>>(methodInfo, (object)null, true);
				}
			}
			if (prendLaSaisie != null)
			{
				return prendLaSaisie(p);
			}
			if (((Object)(object)Chat.instance == (Object)null || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible())
			{
				return !Minimap.IsOpen();
			}
			return false;
		}

		private static Vector3 DeplacementDuJeu()
		{
			//IL_0042: 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)
			//IL_006b: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			float num = Bouton("Forward") - Bouton("Backward");
			float num2 = Bouton("Right") - Bouton("Left");
			float num3 = Bouton("Jump") - Bouton("Crouch");
			Vector2 joyLeftStick = ZInput.GetJoyLeftStick();
			if (((Vector2)(ref joyLeftStick)).sqrMagnitude > 0.04f)
			{
				num2 += joyLeftStick.x;
				num += joyLeftStick.y;
			}
			return new Vector3(num2, num3, num);
		}

		private static float Bouton(string nom)
		{
			if (!ZInput.GetButton(nom))
			{
				return 0f;
			}
			return 1f;
		}

		private static bool CourseDuJeu()
		{
			if (!ZInput.GetButton("Run"))
			{
				return ZInput.GetButton("JoyRun");
			}
			return true;
		}
	}
	internal static class Masque
	{
		private static readonly List<Renderer> caches = new List<Renderer>();

		private static readonly List<Renderer> tampon = new List<Renderer>();

		private static Player cible;

		private static float prochaineLecture;

		internal static void Cacher(Player p)
		{
			cible = p;
			prochaineLecture = 0f;
			Entretenir();
		}

		internal static void Entretenir()
		{
			if ((Object)(object)cible == (Object)null || Time.time < prochaineLecture)
			{
				return;
			}
			prochaineLecture = Time.time + 0.5f;
			GameObject visual = ((Character)cible).GetVisual();
			if ((Object)(object)visual == (Object)null)
			{
				return;
			}
			visual.GetComponentsInChildren<Renderer>(true, tampon);
			foreach (Renderer item in tampon)
			{
				if ((Object)(object)item != (Object)null && !item.forceRenderingOff)
				{
					item.forceRenderingOff = true;
					caches.Add(item);
				}
			}
			tampon.Clear();
		}

		internal static void Montrer()
		{
			foreach (Renderer cache in caches)
			{
				if ((Object)(object)cache != (Object)null)
				{
					cache.forceRenderingOff = false;
				}
			}
			caches.Clear();
			cible = null;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	internal static class CameraDuJeu_Patch
	{
		[HarmonyPriority(600)]
		private static bool Prefix(GameCamera __instance, float dt)
		{
			if (!CameraLibre.EstLaCamera(__instance))
			{
				return true;
			}
			try
			{
				return !CameraLibre.Piloter(__instance, dt);
			}
			catch (Exception e)
			{
				Plugin.Erreur("caméra", e);
				CameraLibre.Sortir(null);
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetMouseLook")]
	internal static class RegardVersLaCamera_Patch
	{
		private static bool Prefix(Player __instance, Vector2 mouseLook)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (!CameraLibre.Pour((Character)(object)__instance))
			{
				return true;
			}
			CameraLibre.Regarder(mouseLook);
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	internal static class CorpsImmobile_Patch
	{
		private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge)
		{
			//IL_000a: 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)
			if (CameraLibre.Pour((Character)(object)__instance))
			{
				movedir = Vector3.zero;
				attack = (attackHold = (secondaryAttack = (secondaryAttackHold = false)));
				block = (blockHold = (jump = (crouch = (run = (autoRun = (dodge = false))))));
			}
		}
	}
	[HarmonyPatch(typeof(Player), "StartGuardianPower")]
	internal static class PouvoirEnAttente_Patch
	{
		private static bool Prefix(Player __instance)
		{
			return !CameraLibre.Pour((Character)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(LightLod), "GetLightReferencePoint")]
	internal static class LumieresAutourDeLaCamera_Patch
	{
		private static void Postfix(ref Vector3 __result)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (CameraLibre.Actif)
			{
				__result = CameraLibre.Position;
			}
		}
	}
	internal static class Corbeau
	{
		internal sealed class Donnees
		{
			private static Donnees instance;

			internal readonly Mesh Corps;

			internal readonly Mesh Regard;

			internal readonly Mesh Serres;

			internal readonly Mesh Marteau;

			internal readonly Mesh[] Plumes;

			internal readonly Material Ombre;

			internal static Donnees Instance => instance ?? (instance = new Donnees());

			private Donnees()
			{
				Matrix4x4[] bindposes = Ressources.Matrices("corbeau.bp");
				Corps = Ressources.Maillage("corbeau", "RTFMB_Corbeau");
				Ressources.Peau(Corps, "corbeau");
				Corps.bindposes = bindposes;
				Regard = Ressources.Maillage("yeux", "RTFMB_RegardDuCorbeau");
				Ressources.Peau(Regard, "yeux");
				Regard.bindposes = bindposes;
				Serres = Ressources.Maillage("serres", "RTFMB_Serres");
				Marteau = Ressources.Maillage("marteau", "RTFMB_KroastructeurServi", "marteau.T0", "marteau.T1", "marteau.T2");
				Plumes = (Mesh[])(object)new Mesh[2]
				{
					Ressources.Maillage("plume_1", "RTFMB_plume_1"),
					Ressources.Maillage("plume_2", "RTFMB_plume_2")
				};
				Mesh[] array = (Mesh[])(object)new Mesh[6]
				{
					Corps,
					Regard,
					Serres,
					Marteau,
					Plumes[0],
					Plumes[1]
				};
				for (int i = 0; i < array.Length; i++)
				{
					Couches.Blanchir(array[i]);
				}
				Ombre = Materiaux.Ombre("RTFMB_OmbreDuCorbeau");
			}
		}

		internal sealed class Spectre : MonoBehaviour
		{
			private readonly List<Material> crees = new List<Material>();

			private Material fond;

			private Material lueur;

			private Material fondSerres;

			private Material lueurSerres;

			private Material fondMarteau;

			private Material lueurMarteau;

			private LueurParSommet bord;

			private Mesh maillageBord;

			private readonly List<LueurParSommet> spectres = new List<LueurParSommet>();

			private readonly List<Mesh> copies = new List<Mesh>();

			private Renderer regard;

			private Light lumiere;

			private Etincelles etincelles;

			private float presence = -1f;

			private float sombre;

			internal void Preparer(SkinnedMeshRenderer corps, Renderer yeux, MeshRenderer serres, MeshRenderer marteau, List<Renderer> plumes)
			{
				//IL_0148: 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_03fb: Expected O, but got Unknown
				sombre = Ressources.F("corbeau.teinte")[0];
				fond = Garder(Materiaux.Fondu("RTFMB_CorbeauFond", (Texture)(object)Ressources.Texture("corbeau_couleur.png", (FilterMode)1, lineaire: true), 3010));
				lueur = Garder(Materiaux.Additif("RTFMB_CorbeauLueur", (Texture)(object)Ressources.Texture("corbeau_lueur.png", (FilterMode)1, lineaire: true), 3011));
				fondSerres = Garder(Materiaux.Fondu("RTFMB_SerresFond", null, 3010));
				lueurSerres = Garder(Materiaux.Additif("RTFMB_SerresLueur", null, 3011));
				fondMarteau = Garder(Materiaux.Fondu("RTFMB_MarteauFond", (Texture)(object)Kroastructeur.Apparence.Instance.Couleur, 3010));
				lueurMarteau = Garder(Materiaux.Additif("RTFMB_MarteauLueur", (Texture)(object)Kroastructeur.Apparence.Instance.Lumiere, 3011));
				Material val = Garder(Materiaux.Profondeur("RTFMB_CorbeauProfondeur", 3005, deuxFaces: true));
				Material val2 = Garder(Materiaux.Additif("RTFMB_CorbeauBord", null, 3012));
				float num = 0.9f + 1.6f * Plugin.EclatYeuxCorbeau.Value;
				Material val3 = Garder(Materiaux.Decoupe("RTFMB_RegardDuCorbeau", (Texture)(object)Ressources.Texture("yeux_couleur.png", (FilterMode)1), (Texture)(object)Ressources.Texture("yeux_lueur.png", (FilterMode)1), new Color(num, num, num)));
				if ((Object)(object)val != (Object)null)
				{
					val3.renderQueue = 3006;
				}
				((Renderer)corps).sharedMaterial = fond;
				if ((Object)(object)val != (Object)null)
				{
					Couches.Doubler(corps, "profondeur", corps.sharedMesh, (Material[])(object)new Material[1] { val }).updateWhenOffscreen = true;
				}
				Couches.Doubler(corps, "lueur", corps.sharedMesh, (Material[])(object)new Material[1] { lueur }).updateWhenOffscreen = true;
				maillageBord = Object.Instantiate<Mesh>(corps.sharedMesh);
				((Object)maillageBord).name = "RTFMB_CorbeauBord";
				SkinnedMeshRenderer val4 = Couches.Doubler(corps, "bord", maillageBord, (Material[])(object)new Material[1] { val2 });
				val4.updateWhenOffscreen = true;
				bord = new LueurParSommet(val4, Enumerable.Range(0, maillageBord.vertexCount).ToArray(), null, LueurParSommet.Vague.Corbeau);
				((Renderer)serres).sharedMaterial = fondSerres;
				Couches.Doubler(serres, "lueur", lueurSerres);
				((Renderer)marteau).sharedMaterials = (Material[])(object)new Material[3] { fondMarteau, fondMarteau, fondMarteau };
				Couches.Doubler(marteau, "lueur", lueurMarteau);
				foreach (Renderer plume in plumes)
				{
					plume.sharedMaterial = fondMarteau;
					MeshRenderer val5 = (MeshRenderer)(object)((plume is MeshRenderer) ? plume : null);
					if (val5 != null)
					{
						Couches.Doubler(val5, "lueur", lueurMarteau);
					}
				}
				Material materiau = Garder(Materiaux.Additif("RTFMB_ServiEnEsprit", null, 3013));
				List<MeshRenderer> list = new List<MeshRenderer> { serres, marteau };
				foreach (Renderer plume2 in plumes)
				{
					MeshRenderer val6 = (MeshRenderer)(object)((plume2 is MeshRenderer) ? plume2 : null);
					if (val6 != null)
					{
						list.Add(val6);
					}
				}
				foreach (MeshRenderer item in list)
				{
					Mesh val7 = Object.Instantiate<Mesh>(((Component)item).GetComponent<MeshFilter>().sharedMesh);
					((Object)val7).name = "RTFMB_EnEsprit_" + ((Object)item).name;
					copies.Add(val7);
					spectres.Add(new LueurParSommet(Couches.Doubler(item, "esprit", materiau, val7), val7, LueurParSommet.Vague.Corbeau));
				}
				yeux.sharedMaterial = val3;
				regard = yeux;
				GameObject val8 = new GameObject("lueur");
				val8.transform.SetParent(((Component)this).transform, false);
				lumiere = val8.AddComponent<Light>();
				lumiere.type = (LightType)2;
				lumiere.shadows = (LightShadows)0;
				lumiere.renderMode = (LightRenderMode)1;
				lumiere.intensity = 0f;
				etincelles = Etincelles.Creer(((Component)this).transform);
				Presence(1f);
			}

			private Material Garder(Material m)
			{
				if ((Object)(object)m != (Object)null)
				{
					crees.Add(m);
				}
				return m;
			}

			internal void Presence(float p)
			{
				presence = Mathf.Clamp01(p);
				if ((Object)(object)regard != (Object)null)
				{
					regard.enabled = presence > 0.35f;
				}
			}

			private void LateUpdate()
			{
				//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_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_0079: 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_0095: 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_00ba: 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_00d4: 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_0109: 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_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: 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_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0263: Unknown result type (might be due to invalid IL or missing references)
				if (presence < 0f)
				{
					return;
				}
				float num = presence;
				float alpha = Plugin.OpaciteCorbeau.Value * num;
				float value = Plugin.EclatCorbeau.Value;
				float num2 = Plugin.LueurCorbeau.Value * num * value;
				float value2 = Plugin.PastelCorbeau.Value;
				Color val = Color.Lerp(new Color(0.42f, 0.24f, 1f), Color.white, value2);
				Color val2 = Color.Lerp(new Color(0.42f, 0.14f, 1f), Color.white, Mathf.Min(1f, value2 + 0.15f)) * value;
				Materiaux.Teinter(fond, new Color(sombre, sombre, sombre), alpha);
				Materiaux.Teinter(lueur, val * (0.55f * num2), 1f);
				Materiaux.Teinter(fondSerres, new Color(0.02f, 0.008f, 0.05f), alpha);
				Materiaux.Teinter(lueurSerres, val * (0.3f * num2), 1f);
				Materiaux.Teinter(fondMarteau, new Color(0.2f, 0.15f, 0.3f), alpha);
				Materiaux.Teinter(lueurMarteau, val * (0.9f * num2), 1f);
				float num3 = Mathf.Max(((Component)this).transform.lossyScale.x, 0.001f);
				float num4 = 0.06f + 0.55f * Plugin.LueurCorbeau.Value;
				if (bord != null && num > 0f)
				{
					bord.Mettre(val2, val2, num, 0f, num4, ((Component)this).transform, num3);
					etincelles?.Mettre(bord.Monde, num, num3, value);
				}
				foreach (LueurParSommet spectre in spectres)
				{
					if (num > 0f)
					{
						spectre.Mettre(val * value, val2, num, 0.7f * Plugin.LueurCorbeau.Value, num4 * 1.6f, ((Component)this).transform, num3);
					}
				}
				if ((Object)(object)lumiere != (Object)null)
				{
					lumiere.color = ((Color)(ref val)).gamma;
					lumiere.range = Plugin.PorteeLueurCorbeau.Value;
					lumiere.intensity = Plugin.ForceLueurCorbeau.Value * num;
					((Behaviour)lumiere).enabled = lumiere.range > 0f && lumiere.intensity > 0f;
				}
			}

			private void OnDestroy()
			{
				foreach (Material cree in crees)
				{
					if ((Object)(object)cree != (Object)null)
					{
						Object.Destroy((Object)(object)cree);
					}
				}
				bord?.Detruire();
				if ((Object)(object)maillageBord != (Object)null)
				{
					Object.Destroy((Object)(object)maillageBord);
				}
				foreach (LueurParSommet spectre in spectres)
				{
					spectre.Detruire();
				}
				foreach (Mesh copy in copies)
				{
					if ((Object)(object)copy != (Object)null)
					{
						Object.Destroy((Object)(object)copy);
					}
				}
			}
		}

		internal const float Taille = 0.5f;

		internal const float VitesseBattement = 0.7f;

		private static readonly Color Violet = new Color(0.42f, 0.24f, 1f);

		internal static GameObject Creer(bool spectral, out Spectre spectre)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_005e: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: 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)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(spectral ? "RTFMB_CorbeauEsprit" : "RTFMB_OmbreDuCorbeau");
			val.transform.localScale = Vector3.one * 0.5f;
			GameObject val2 = new GameObject("modele");
			val2.transform.SetParent(val.transform, false);
			val2.transform.localPosition = Ressources.Vecteur("corbeau.modele");
			string[] array = Ressources.Texte("corbeau.noms").Split('\n');
			int[] array2 = Ressources.I("corbeau.parents");
			Transform[] noeuds = (Transform[])(object)new Transform[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				noeuds[i] = new GameObject(array[i]).transform;
				noeuds[i].SetParent((array2[i] < 0) ? val2.transform : noeuds[array2[i]], false);
				noeuds[i].localPosition = Ressources.Vecteur("corbeau.t", i);
				noeuds[i].localRotation = Ressources.Rotation("corbeau.q", i);
				noeuds[i].localScale = Ressources.Vecteur("corbeau.s", i);
			}
			Transform[] os = (from num2 in Ressources.I("corbeau.os")
				select noeuds[num2]).ToArray();
			Transform parent = noeuds[Ressources.I("corbeau.smr")[0]];
			Donnees instance = Donnees.Instance;
			List<Renderer> list = new List<Renderer>();
			SkinnedMeshRenderer val3 = Peau(parent, "corps", instance.Corps, os);
			SkinnedMeshRenderer val4 = Peau(parent, "regard", instance.Regard, os);
			list.Add((Renderer)(object)val3);
			list.Add((Renderer)(object)val4);
			Transform transform = new GameObject("porte").transform;
			transform.SetParent(noeuds[Ressources.I("porte.os")[0]], false);
			transform.localPosition = Ressources.Vecteur("porte.t");
			transform.localRotation = Ressources.Rotation("porte.q");
			transform.localScale = Ressources.Vecteur("porte.s");
			GameObject val5 = new GameObject("serres");
			val5.transform.SetParent(transform, false);
			val5.AddComponent<MeshFilter>().sharedMesh = instance.Serres;
			list.Add((Renderer)(object)val5.AddComponent<MeshRenderer>());
			Transform transform2 = new GameObject("kroastructeur").transform;
			transform2.SetParent(transform, false);
			transform2.localPosition = Ressources.Vecteur("marteau_serres.t");
			transform2.localRotation = Ressources.Rotation("marteau_serres.q");
			transform2.localScale = Ressources.Vecteur("marteau_serres.s");
			GameObject val6 = new GameObject("modele");
			val6.transform.SetParent(transform2, false);
			val6.AddComponent<MeshFilter>().sharedMesh = instance.Marteau;
			MeshRenderer val7 = val6.AddComponent<MeshRenderer>();
			list.Add((Renderer)(object)val7);
			List<Transform> list2 = new List<Transform>();
			List<Renderer> list3 = new List<Renderer>();
			for (int num = 0; num < 2; num++)
			{
				string text = "plume_" + (num + 1);
				GameObject val8 = new GameObject(text);
				val8.transform.SetParent(transform2, false);
				val8.transform.localPosition = Ressources.Vecteur(text + ".pos");
				val8.transform.localRotation = Ressources.Rotation(text + ".rot");
				val8.AddComponent<MeshFilter>().sharedMesh = instance.Plumes[num];
				MeshRenderer item = val8.AddComponent<MeshRenderer>();
				list3.Add((Renderer)(object)item);
				list.Add((Renderer)(object)item);
				list2.Add(val8.transform);
			}
			((Component)transform2).gameObject.AddComponent<PlumesPendantes>().Plumes = list2.ToArray();
			val.AddComponent<VolCorbeau>().Noeuds = noeuds;
			spectre = null;
			if (spectral)
			{
				foreach (Renderer item2 in list)
				{
					item2.shadowCastingMode = (ShadowCastingMode)0;
				}
				spectre = val.AddComponent<Spectre>();
				spectre.Preparer(val3, (Renderer)(object)val4, val5.GetComponent<MeshRenderer>(), val7, list3);
			}
			else
			{
				Material ombre = instance.Ombre;
				foreach (Renderer item3 in list)
				{
					MeshRenderer val9 = (MeshRenderer)(object)((item3 is MeshRenderer) ? item3 : null);
					item3.sharedMaterials = Enumerable.Repeat<Material>(ombre, (val9 == null || ((Component)val9).GetComponent<MeshFilter>().sharedMesh.subMeshCount <= 1) ? 1 : ((Component)val9).GetComponent<MeshFilter>().sharedMesh.subMeshCount).ToArray();
					item3.shadowCastingMode = (ShadowCastingMode)3;
					item3.receiveShadows = false;
				}
				((Renderer)val4).enabled = false;
			}
			foreach (Renderer item4 in list)
			{
				SkinnedMeshRenderer val10 = (SkinnedMeshRenderer)(object)((item4 is SkinnedMeshRenderer) ? item4 : null);
				if (val10 != null)
				{
					val10.updateWhenOffscreen = true;
				}
			}
			return val;
		}

		private static SkinnedMeshRenderer Peau(Transform parent, string nom, Mesh maillage, Transform[] os)
		{
			//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)
			GameObject val = new GameObject(nom);
			val.transform.SetParent(parent, false);
			SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>();
			obj.sharedMesh = maillage;
			obj.bones = os;
			obj.rootBone = os[0];
			return obj;
		}
	}
	internal sealed class VolCorbeau : MonoBehaviour
	{
		internal Transform[] Noeuds;

		private static float[] temps;

		private static (int noeud, int genre, float[] valeurs)[] pistes;

		private float t;

		private static void Lire()
		{
			if (pistes == null)
			{
				temps = Ressources.F("anim.temps");
				int[] array = Ressources.I("anim.pistes");
				pistes = new(int, int, float[])[array.Length / 2];
				for (int i = 0; i < pistes.Length; i++)
				{
					int item = array[2 * i];
					int num = array[2 * i + 1];
					pistes[i] = (noeud: item, genre: num, valeurs: Ressources.F("anim." + "tqs"[num] + "." + item));
				}
			}
		}

		private void Awake()
		{
			Lire();
			t = Random.value * temps[temps.Length - 1];
		}

		private void LateUpdate()
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_0188: 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)
			if (Noeuds == null)
			{
				return;
			}
			float num = temps[temps.Length - 1];
			t = Mathf.Repeat(t + Time.deltaTime * 0.7f, num);
			int i;
			for (i = 0; i < temps.Length - 2 && temps[i + 1] <= t; i++)
			{
			}
			float num2 = Mathf.Clamp01((t - temps[i]) / Mathf.Max(temps[i + 1] - temps[i], 1E-05f));
			(int, int, float[])[] array = pistes;
			Quaternion val2 = default(Quaternion);
			Quaternion val3 = default(Quaternion);
			Vector3 val4 = default(Vector3);
			Vector3 val5 = default(Vector3);
			for (int j = 0; j < array.Length; j++)
			{
				(int, int, float[]) tuple = array[j];
				int item = tuple.Item1;
				int item2 = tuple.Item2;
				float[] item3 = tuple.Item3;
				Transform val = ((item < Noeuds.Length) ? Noeuds[item] : null);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (item2 == 1)
				{
					((Quaternion)(ref val2))..ctor(item3[4 * i], item3[4 * i + 1], item3[4 * i + 2], item3[4 * i + 3]);
					((Quaternion)(ref val3))..ctor(item3[4 * i + 4], item3[4 * i + 5], item3[4 * i + 6], item3[4 * i + 7]);
					val.localRotation = Quaternion.Slerp(val2, val3, num2);
					continue;
				}
				((Vector3)(ref val4))..ctor(item3[3 * i], item3[3 * i + 1], item3[3 * i + 2]);
				((Vector3)(ref val5))..ctor(item3[3 * i + 3], item3[3 * i + 4], item3[3 * i + 5]);
				if (item2 == 0)
				{
					val.localPosition = Vector3.Lerp(val4, val5, num2);
				}
				else
				{
					val.localScale = Vector3.Lerp(val4, val5, num2);
				}
			}
		}
	}
	internal sealed class CorpsSpectral
	{
		private const int FileProfondeur = 2990;

		private const int FileFond = 3000;

		private const int FileLueur = 3001;

		private const int FileCheveux = 3002;

		private const int FileCheveuxLueur = 3003;

		private const float Recul = 0.0015f;

		private static readonly FieldRef<VisEquipment, GameObject> Cheveux = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_hairItemInstance");

		private static readonly FieldRef<VisEquipment, GameObject> Barbe = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_beardItemInstance");

		private static readonly int sMainTex = Shader.PropertyToID("_MainTex");

		private static readonly int sChestTex = Shader.PropertyToID("_ChestTex");

		private static readonly int sLegsTex = Shader.PropertyToID("_LegsTex");

		private static readonly int sSkinColor = Shader.PropertyToID("_SkinColor");

		private static readonly int sColor = Shader.PropertyToID("_Color");

		private static readonly Dictionary<int, Mesh> profondeurs = new Dictionary<int, Mesh>();

		private static readonly Dictionary<int, Mesh> blanchis = new Dictionary<int, Mesh>();

		private readonly Player joueur;

		private VisEquipment vis;

		private SkinnedMeshRenderer corps;

		private Mesh source;

		private Texture peauTex;

		private Texture torseTex;

		private Texture jambesTex;

		private GameObject cheveuxObjet;

		private GameObject barbeObjet;

		private GameObject racine;

		private readonly List<Renderer> caches = new List<Renderer>();

		private readonly List<Material> crees = new List<Material>();

		private readonly List<Object> maillages = new List<Object>();

		private Material fond;

		private Material yeux;

		private readonly List<(Material fond, Material lueur, Color couleur)> poils = new List<(Material, Material, Color)>();

		private Color couleurPeau = Color.white;

		private LueurParSommet lueur;

		private FumeeSpectrale fumee;

		private Light lumiere;

		private Light lumiereSol;

		private EtincellesDeLaPeau etincelles;

		private Transform echine;

		private float debut;

		private float prochaineVerif;

		private bool actif;

		internal bool Actif => actif;

		internal CorpsSpectral(Player p)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			joueur = p;
		}

		internal void Appliquer(float s)
		{
			if (s <= 0f)
			{
				Retirer();
				return;
			}
			if (!actif)
			{
				if (Time.time < prochaineVerif || !Construire())
				{
					prochaineVerif = Time.time + 1f;
					return;
				}
				debut = Time.time;
			}
			else if (Time.time >= prochaineVerif)
			{
				prochaineVerif = Time.time + 0.5f;
				if (Change())
				{
					Retirer();
					if (!Construire())
					{
						return;
					}
				}
			}
			Fondu(s);
		}

		private bool Change()
		{
			if ((Object)(object)corps == (Object)null || (Object)(object)vis == (Object)null || (Object)(object)corps.sharedMesh != (Object)(object)source)
			{
				return true;
			}
			Material sharedMaterial = ((Renderer)corps).sharedMaterial;
			if (!((Object)(object)sharedMaterial == (Object)null) && !((Object)(object)sharedMaterial.GetTexture(sMainTex) != (Object)(object)peauTex) && !((Object)(object)Tex(sharedMaterial, sChestTex) != (Object)(object)torseTex) && !((Object)(object)Tex(sharedMaterial, sLegsTex) != (Object)(object)jambesTex) && !((Object)(object)Cheveux.Invoke(vis) != (Object)(object)cheveuxObjet))
			{
				return (Object)(object)Barbe.Invoke(vis) != (Object)(object)barbeObjet;
			}
			return true;
		}

		private static Texture Tex(Material m, int prop)
		{
			if (!m.HasProperty(prop))
			{
				return null;
			}
			return m.GetTexture(prop);
		}

		private bool Construire()
		{
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			vis = (((Object)(object)joueur != (Object)null) ? ((Component)joueur).GetComponent<VisEquipment>() : null);
			corps = (((Object)(object)vis != (Object)null) ? vis.m_bodyModel : null);
			if ((Object)(object)corps == (Object)null || (Object)(object)corps.sharedMesh == (Object)null || (Object)(object)((Renderer)corps).sharedMaterial == (Object)null || !corps.sharedMesh.isReadable || !Materiaux.Prets(ObjectDB.instance) || !Materiaux.Transparence)
			{
				return false;
			}
			Material[] sharedMaterials = ((Renderer)corps).sharedMaterials;
			Material val = sharedMaterials[0];
			source = corps.sharedMesh;
			peauTex = val.GetTexture(sMainTex);
			torseTex = Tex(val, sChestTex);
			jambesTex = Tex(val, sLegsTex);
			couleurPeau = (val.HasProperty(sSkinColor) ? val.GetColor(sSkinColor) : Color.white);
			cheveuxObjet = Cheveux.Invoke(vis);
			barbeObjet = Barbe.Invoke(vis);
			Masques masques = Masques.Pour(peauTex, torseTex, jambesTex);
			if (masques == null)
			{
				return false;
			}
			Decoupe decoupe = Decoupage.Pour(source, masques);
			racine = new GameObject("RTFMB_CorpsEnTranse");
			racine.transform.SetParent(((Component)corps).transform, false);
			Material val2 = new Material(val)
			{
				name = "RTFMB_HabitsEnTranse"
			};
			val2.SetTexture(sMainTex, (Texture)(object)masques.Habits);
			Materiaux.Decouper(val2, 0.5f);
			crees.Add(val2);
			Copie("habits", decoupe.Habits, (Material[])(object)new Material[1] { val2 }, (ShadowCastingMode)1);
			Copie("peau_ombre", decoupe.Peau, (Material[])(object)new Material[1] { val }, (ShadowCastingMode)3);
			Material val3 = Materiaux.Profondeur("RTFMB_PeauProfondeur", 2990, deuxFaces: false);
			if ((Object)(object)val3 != (Object)null)
			{
				crees.Add(val3);
				Copie("peau_profondeur", Profondeur(decoupe.Peau, 0.0015f / Couches.Echelle(corps)), (Material[])(object)new Material[1] { val3 }, (ShadowCastingMode)0);
			}
			fond = Materiaux.Fondu("RTFMB_PeauEnTranse", (Texture)(object)masques.Peau, 3000);
			crees.Add(fond);
			Material val4 = null;
			if (sharedMaterials.Length > 1 && (Object)(object)sharedMaterials[1] != (Object)null && decoupe.Peau.subMeshCount > 1)
			{
				val4 = Poil("RTFMB_SourcilsEnTranse", sharedMaterials[1], null);
			}
			Copie("peau", decoupe.Peau, (Material[])(object)((!((Object)(object)val4 != (Object)null)) ? new Material[1] { fond } : new Material[2] { fond, val4 }), (ShadowCastingMode)0);
			Mesh val5 = Object.Instantiate<Mesh>(decoupe.Peau);
			((Object)val5).name = "RTFMB_PeauLueur";
			maillages.Add((Object)(object)val5);
			Material val6 = Materiaux.Additif("RTFMB_PeauLueur", (Texture)(object)masques.Masque, 3001);
			crees.Add(val6);
			SkinnedMeshRenderer rendu = Copie("peau_lueur", val5, (Material[])(object)new Material[1] { val6 }, (ShadowCastingMode)0);
			lueur = new LueurParSommet(rendu, decoupe.Sommets, decoupe.Part, LueurParSommet.Vague.Corps);
			yeux = Materiaux.Opaque("RTFMB_YeuxEnTranse", peauTex, null, 0f, 0.4f);
			crees.Add(yeux);
			Copie("yeux", decoupe.Yeux, (Material[])(object)new Material[1] { yeux }, (ShadowCastingMode)0);
			Cacher((Renderer)(object)corps);
			GameObject[] array = (GameObject[])(object)new GameObject[2] { cheveuxObjet, barbeObjet };
			foreach (GameObject val7 in array)
			{
				if ((Object)(object)val7 == (Object)null)
				{
					continue;
				}
				SkinnedMeshRenderer[] componentsInChildren = val7.GetComponentsInChildren<SkinnedMeshRenderer>();
				foreach (SkinnedMeshRenderer val8 in componentsInChildren)
				{
					if ((Object)(object)val8.sharedMesh == (Object)null || ((Renderer)val8).forceRenderingOff)
					{
						continue;
					}
					Mesh maillage = Blanchi(val8.sharedMesh);
					Material[] array2 = (Material[])(object)new Material[((Renderer)val8).sharedMaterials.Length];
					Material[] array3 = (Material[])(object)new Material[((Renderer)val8).sharedMaterials.Length];
					for (int k = 0; k < array2.Length; k++)
					{
						Material val9 = ((Renderer)val8).sharedMaterials[k];
						array2[k] = (((Object)(object)val9 != (Object)null) ? Poil("RTFMB_CheveuxEnTranse", val9, array3, k) : fond);
						if ((Object)(object)array3[k] == (Object)null)
						{
							array3[k] = val6;
						}
					}
					Couches.Doubler(val8, "cheveux", maillage, array2, racine.transform).updateWhenOffscreen = true;
					Couches.Doubler(val8, "cheveux_lueur", maillage, array3, racine.transform).updateWhenOffscreen = true;
					Cacher((Renderer)(object)val8);
				}
			}
			fumee = FumeeSpectrale.Creer(racine.transform, decoupe.Aires, decoupe.PartDeLaPeau);
			echine = null;
			Transform[] bones = corps.bones;
			foreach (Transform val10 in bones)
			{
				if ((Object)(object)val10 != (Object)null && ((Object)val10).name.IndexOf("spine", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					echine = val10;
				}
			}
			lumiere = Lumiere("lueur");
			lumiereSol = Lumiere("lueur_sol");
			etincelles = EtincellesDeLaPeau.Creer(racine.transform, decoupe.Aires);
			actif = true;
			return true;
		}

		private Material Poil(string nom, Material modele, Material[] lueurs, int i = 0)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Texture texture = (modele.HasProperty(sMainTex) ? modele.GetTexture(sMainTex) : null);
			Color val = (modele.HasProperty(sSkinColor) ? modele.GetColor(sSkinColor) : (modele.HasProperty(sColor) ? modele.GetColor(sColor) : Color.white));
			Material val2 = Materiaux.Fondu(nom, texture, 3002);
			Material val3 = null;
			if (lueurs != null)
			{
				val3 = (lueurs[i] = Materiaux.Additif(nom + "_Lueur", texture, 3003));
				crees.Add(val3);
			}
			crees.Add(val2);
			poils.Add((val2, val3, ((Color)(ref val)).linear));
			return val2;
		}

		private Light Lumiere(string nom)
		{
			//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)
			GameObject val = new GameObject(nom);
			val.transform.SetParent(racine.transform, false);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.shadows = (LightShadows)0;
			obj.renderMode = (LightRenderMode)1;
			obj.intensity = 0f;
			return obj;
		}

		private SkinnedMeshRenderer Copie(string nom, Mesh maillage, Material[] materiaux, ShadowCastingMode ombre)
		{
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_006f: Invalid comparison between Unknown and I4
			GameObject val = new GameObject(nom);
			val.transform.SetParent(racine.transform, false);
			SkinnedMeshRenderer obj = val.AddComponent<SkinnedMeshRenderer>();
			obj.sharedMesh = maillage;
			obj.bones = corps.bones;
			obj.rootBone = corps.rootBone;
			((Renderer)obj).localBounds = ((Renderer)corps).localBounds;
			((Renderer)obj).sharedMaterials = materiaux;
			((Renderer)obj).shadowCastingMode = ombre;
			((Renderer)obj).receiveShadows = (int)ombre != 3;
			return obj;
		}

		private void Cacher(Renderer r)
		{
			if (!((Object)(object)r == (Object)null) && !r.forceRenderingOff)
			{
				r.forceRenderingOff = true;
				caches.Add(r);
			}
		}

		private static Mesh Profondeur(Mesh peau, float recul)
		{
			int instanceID = ((Object)peau).GetInstanceID();
			if (profondeurs.TryGetValue(instanceID, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = Couches.Retreci(peau, recul, "RTFMB_PeauProfondeur");
			profondeurs[instanceID] = value;
			return value;
		}

		private static Mesh Blanchi(Mesh m)
		{
			int instanceID = ((Object)m).GetInstanceID();
			if (blanchis.TryGetValue(instanceID, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			if (!m.isReadable)
			{
				return m;
			}
			value = Object.Instantiate<Mesh>(m);
			((Object)value).name = "RTFMB_" + ((Object)m).name;
			Couches.Blanchir(value);
			blanchis[instanceID] = value;
			return value;
		}

		private void Fondu(float s)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_009f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00d5: 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_0109: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_0196: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: 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_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: 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_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: 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_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			Color val = Materiaux.Teinte(Plugin.TeinteTranse.Value);
			Color linear = ((Color)(ref val)).linear;
			float num = Time.time - debut;
			float num2 = ((num < 0.7f) ? (1f + 0.7f * Mathf.Sin(MathF.PI * num / 0.7f)) : 1f);
			float num3 = Mathf.Lerp(1f, Plugin.OpaciteTranse.Value, s);
			Color val2 = linear * 0.16f;
			float value = Plugin.PastelTranse.Value;
			float value2 = Plugin.EclatTranse.Value;
			Color val3 = Color.Lerp(linear, Color.white, value);
			Color val4 = Color.Lerp(linear, Color.white, Mathf.Min(1f, value + 0.3f));
			Materiaux.Teinter(fond, Color.Lerp(((Color)(ref couleurPeau)).linear, val2, s), num3);
			foreach (var (m, val5, val6) in poils)
			{
				Materiaux.Teinter(m, Color.Lerp(val6, val2 * 1.5f, s), num3);
				if ((Object)(object)val5 != (Object)null)
				{
					Materiaux.Teinter(val5, val3 * (value2 * s * num2 * num3 * 1.2f * Plugin.LueurTranse.Value * 0.9f), 1f);
				}
			}
			lueur?.Mettre(val3 * value2, val4 * value2, s * num2 * num3, 1.2f * Plugin.LueurTranse.Value, 1.4f * Plugin.ContourTranse.Value, ((Component)joueur).transform, 1f);
			if ((Object)(object)lumiere != (Object)null)
			{
				Vector3 val7 = (((Object)(object)echine != (Object)null) ? echine.position : (((Component)joueur).transform.position + Vector3.up * 1.2f));
				((Component)lumiere).transform.position = val7 + Vector3.up * 0.15f;
				lumiere.color = Color.Lerp(val, Color.white, value);
				lumiere.range = Plugin.PorteeLueurTranse.Value;
				lumiere.intensity = Plugin.ForceLueurTranse.Value * s * Mathf.Lerp(1f, num2, 0.5f);
				((Behaviour)lumiere).enabled = lumiere.range > 0f && lumiere.intensity > 0f;
			}
			if ((Object)(object)lumiereSol != (Object)null)
			{
				((Component)lumiereSol).transform.position = ((Component)joueur).transform.position + Vector3.up * 0.3f;
				lumiereSol.color = Color.Lerp(val, Color.white, value);
				lumiereSol.range = Plugin.PorteeSolTranse.Value;
				lumiereSol.intensity = Plugin.LueurSolTranse.Value * s * Mathf.Lerp(1f, num2, 0.5f);
				((Behaviour)lumiereSol).enabled = lumiereSol.range > 0f && lumiereSol.intensity > 0f;
			}
			etincelles?.Mettre(lueur?.Monde, lueur?.Normales, Color.Lerp(Materiaux.Teinte(Plugin.TeinteTranse.Value, 0.9f, 0.65f), Color.white, 0.3f), s, value2);
			if ((Object)(object)yeux != (Object)null)
			{
				Color val8 = Materiaux.Teinte(Plugin.TeinteTranse.Value, 0.9f, 0.62f);
				yeux.SetColor(sColor, Color.Lerp(Color.white, val8, s * 0.5f));
				Materiaux.Lueur(yeux, null, val8 * (7f * Plugin.EclatYeuxTranse.Value * s * num2));
			}
			fumee?.Mettre(Color.Lerp(Materiaux.Teinte(Plugin.TeinteTranse.Value, 0.75f, 0.55f), Color.white, value * 0.6f), s, lueur?.Monde, value2);
		}

		internal void Retirer()
		{
			if (!actif && (Object)(object)racine == (Object)null)
			{
				return;
			}
			foreach (Renderer cache in caches)
			{
				if ((Object)(object)cache != (Object)null)
				{
					cache.forceRenderingOff = false;
				}
			}
			caches.Clear();
			if ((Object)(object)racine != (Object)null)
			{
				Object.Destroy((Object)(object)racine);
			}
			racine = null;
			foreach (Material cree in crees)
			{
				if ((Object)(object)cree != (Object)null)
				{
					Object.Destroy((Object)(object)cree);
				}
			}
			crees.Clear();
			foreach (Object maillage in maillages)
			{
				if (maillage != (Object)null)
				{
					Object.Destroy(maillage);
				}
			}
			maillages.Clear();
			lueur?.Detruire();
			lueur = null;
			lumiere = null;
			lumiereSol = null;
			etincelles = null;
			echine = null;
			poils.Clear();
			fond = null;
			yeux = null;
			fumee = null;
			actif = false;
		}
	}
	internal sealed class Masques
	{
		internal const int N = 512;

		private static readonly Dictionary<string, Masques> cache = new Dictionary<string, Masques>();

		internal Texture2D Habits;

		internal Texture2D Peau;

		internal Texture2D Masque;

		private bool[] peau;

		private float[] clarte;

		internal bool EstPeau(Vector2 uv)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return peau[Indice(uv)];
		}

		internal float Clarte(Vector2 uv)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return clarte[Indice(uv)];
		}

		private static int Indice(Vector2 uv)
		{
			//IL_0000: 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)
			int num = Mathf.Clamp((int)(uv.x * 512f), 0, 511);
			return Mathf.Clamp((int)(uv.y * 512f), 0, 511) * 512 + num;
		}

		internal static bool EstOeil(Vector2 uv)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			if (uv.x >= 29f / 64f && uv.x <= 0.50390625f && uv.y >= 0.89453125f)
			{
				return uv.y <= 119f / 128f;
			}
			return false;
		}

		internal static Masques Pour(Texture peauTex, Texture torse, Texture jambes)
		{
			//IL_0169: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)peauTex == (Object)null)
			{
				return null;
			}
			string key = ((Object)peauTex).GetInstanceID() + "|" + (((Object)(object)torse != (Object)null) ? ((Object)torse).GetInstanceID() : 0) + "|" + (((Object)(object)jambes != (Object)null) ? ((Object)jambes).GetInstanceID() : 0);
			if (cache.TryGetValue(key, out var value) && (Object)(object)value.Habits != (Object)null)
			{
				return value;
			}
			Color32[] array = Lire(peauTex);
			Color32[] array2 = Lire(torse);
			Color32[] array3 = Lire(jambes);
			Color32[] array4 = (Color32[])(object)new Color32[262144];
			Color32[] array5 = (Color32[])(object)new Color32[262144];
			Color32[] array6 = (Color32[])(object)new Color32[262144];
			bool[] array7 = new bool[262144];
			float[] array8 = new float[262144];
			for (int i = 0; i < 262144; i++)
			{
				float num = (1f - ((array2 != null) ? ((float)(int)array2[i].a / 255f) : 0f)) * (1f - ((array3 != null) ? ((float)(int)array3[i].a / 255f) : 0f));
				int num2 = i % 512;
				int num3 = i / 512;
				bool flag = EstOeil(new Vector2(((float)num2 + 0.5f) / 512f, ((float)num3 + 0.5f) / 512f));
				if (flag)
				{
					num = 0f;
				}
				array7[i] = num > 0.5f;
				Color32 val = array[i];
				array8[i] = (0.299f * (float)(int)val.r + 0.587f * (float)(int)val.g + 0.114f * (float)(int)val.b) / 255f;
				byte b = (byte)Mathf.RoundToInt(255f * num);
				array4[i] = new Color32(val.r, val.g, val.b, (byte)(flag ? 255u : ((uint)(255 - b))));
				array5[i] = new Color32(val.r, val.g, val.b, b);
				array6[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
			}
			value = new Masques
			{
				Habits = Texture(array4, "RTFMB_Habits"),
				Peau = Texture(array5, "RTFMB_Peau"),
				Masque = Texture(array6, "RTFMB_MasquePeau"),
				peau = array7,
				clarte = array8
			};
			cache[key] = value;
			return value;
		}

		private static Texture2D Texture(Color32[] px, string nom)
		{
			//IL_000c: 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_0018: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true)
			{
				name = nom,
				wrapMode = (TextureWrapMode)1
			};
			val.SetPixels32(px);
			val.Apply(true, false);
			return val;
		}

		internal static Color32[] Lire(Texture t)
		{
			//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_0057: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			if ((Object)(object)t == (Object)null)
			{
				return null;
			}
			RenderTexture temporary = RenderTexture.GetTemporary(512, 512, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			try
			{
				Graphics.Blit(t, temporary);
				RenderTexture.active = temporary;
				Texture2D val = new Texture2D(512, 512, (TextureFormat)4, false);
				val.ReadPixels(new Rect(0f, 0f, 512f, 512f), 0, 0);
				val.Apply(false);
				Color32[] pixels = val.GetPixels32();
				Object.Destroy((Object)val);
				return pixels;
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}
	}
	internal sealed class Decoupe
	{
		internal Mesh Habits;

		internal Mesh Peau;

		internal Mesh Yeux;

		internal int[] Sommets;

		internal float[] Part;

		internal float[] Aires;

		internal float PartDeLaPeau;
	}
	internal static class Decoupage
	{
		private static readonly Dictionary<string, Decoupe> cache = new Dictionary<string, Decoupe>();

		internal static Decoupe Pour(Mesh source, Masques m)
		{
			//IL_00d4: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00ef: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_017c: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			string key = ((Object)source).GetInstanceID() + "|" + m.GetHashCode();
			if (cache.TryGetValue(key, out var value) && (Object)(object)value.Habits != (Object)null)
			{
				return value;
			}
			Vector2[] uv = source.uv;
			Vector3[] vertices = source.vertices;
			int[] triangles = source.GetTriangles(0);
			int[] array = ((source.subMeshCount > 1) ? source.GetTriangles(1) : new int[0]);
			List<int> list = new List<int>();
			List<int> list2 = new List<int>();
			List<int> list3 = new List<int>();
			float[] array2 = new float[vertices.Length];
			bool[] array3 = new bool[vertices.Length];
			float num = 0f;
			float num2 = 0f;
			for (int i = 0; i + 2 < triangles.Length; i += 3)
			{
				int num3 = triangles[i];
				int num4 = triangles[i + 1];
				int num5 = triangles[i + 2];
				Vector2 val = uv[num3];
				Vector2 val2 = uv[num4];
				Vector2 val3 = uv[num5];
				Vector2 uv2 = (val + val2 + val3) / 3f;
				Vector3 val4 = Vector3.Cross(vertices[num4] - vertices[num3], vertices[num5] - vertices[num3]);
				float num6 = ((Vector3)(ref val4)).magnitude * 0.5f;
				num += num6;
				if (Masques.EstOeil(uv2))
				{
					list3.Add(num3);
					list3.Add(num4);
					list3.Add(num5);
					continue;
				}
				int num7 = (m.EstPeau(val) ? 1 : 0) + (m.EstPeau(val2) ? 1 : 0) + (m.EstPeau(val3) ? 1 : 0) + (m.EstPeau(uv2) ? 1 : 0);
				if (num7 < 4)
				{
					list.Add(num3);
					list.Add(num4);
					list.Add(num5);
				}
				if (num7 > 0)
				{
					list2.Add(num3);
					list2.Add(num4);
					list2.Add(num5);
					float num8 = num6 * (float)num7 / 4f;
					num2 += num8;
					array2[num3] += num8 / 3f;
					array2[num4] += num8 / 3f;
					array2[num5] += num8 / 3f;
					bool flag;
					array3[num4] = (flag = (array3[num5] = true));
					array3[num3] = flag;
				}
			}
			List<int> list4 = new List<int>();
			List<float> list5 = new List<float>();
			float[] array4 = new float[vertices.Length];
			for (int j = 0; j < vertices.Length; j++)
			{
				if (array3[j])
				{
					list4.Add(j);
					list5.Add(array2[j]);
					array4[j] = 0.45f + 0.8f * m.Clarte(uv[j]);
				}
			}
			Mesh val5 = Copie(source, "peau", list2.ToArray(), array);
			Couches.Blanchir(val5);
			Decoupe decoupe = new Decoupe();
			decoupe.Habits = Copie(source, "habits", list.ToArray());
			decoupe.Peau = val5;
			decoupe.Yeux = Copie(source, "yeux", list3.ToArray());
			decoupe.Sommets = list4.ToArray();
			decoupe.Part = array4;
			decoupe.Aires = list5.ToArray();
			decoupe.PartDeLaPeau = ((num > 0f) ? (num2 / num) : 0f);
			value = decoupe;
			cache[key] = value;
			return value;
		}

		private static Mesh Copie(Mesh source, string nom, params int[][] sous)
		{
			Mesh val = Object.Instantiate<Mesh>(source);
			((Object)val).name = "RTFMB_" + nom;
			val.subMeshCount = sous.Length;
			for (int i = 0; i < sous.Length; i++)
			{
				val.SetTriangles(sous[i], i, false);
			}
			val.RecalculateBounds();
			return val;
		}
	}
	internal static class Kroastructeur
	{
		internal sealed class Apparence
		{
			private static Apparence instance;

			internal readonly Material Bois;

			internal readonly Material Fer;

			internal readonly Material Cristal;

			internal readonly Material Plume;

			internal readonly Texture2D Couleur;

			internal readonly Texture2D Lumiere;

			internal static Apparence Instance => instance ?? (instance = new Apparence());

			private Apparence()
			{
				Couleur = Ressources.Texture("marteau_couleur.png", (FilterMode)0);
				Lumiere = Ressources.Texture("marteau_lueur.png", (FilterMode)0);
				Bois = Materiaux.Opaque("RTFMB_Kroastructeur_bois", (Texture)(object)Couleur, (Texture)(object)Lumiere, 0f, 0.15f);
				Fer = Materiaux.Opaque("RTFMB_Kroastructeur_fer", (Texture)(object)Couleur, (Texture)(object)Lumiere, 0.45f, 0.45f);
				Cristal = Materiaux.Opaque("RTFMB_Kroastructeur_cristal", (Texture)(object)Couleur, (Texture)(object)Lumiere, 0f, 0.8f);
				Plume = Materiaux.Opaque("RTFMB_Kroastructeur_plume", (Texture)(object)Couleur, null, 0f, 0.35f, deuxFaces: true);
			}
		}

		internal const string NomPrefab = "RTFMB_Cawnstructor";

		internal const string NomRecette = "Recipe_RTFMB_Cawnstructor";

		private const string CleNom = "rtfmb_cawnstructor";

		private const string CleDescription = "rtfmb_cawnstructor_description";

		internal static GameObject Prefab;

		private static GameObject conteneur;

		private static readonly FieldRef<Humanoid, ItemData> MainDroite = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_rightItem");

		internal static bool EnMain(Humanoid h)
		{
			ItemData val = (((Object)(object)h != (Object)null) ? MainDroite.Invoke(h) : null);
			if (val != null && (Object)(object)val.m_dropPrefab != (Object)null)
			{
				return ((Object)val.m_dropPrefab).name == "RTFMB_Cawnstructor";
			}
			return false;
		}

		internal static void EnregistrerDansObjectDB(ObjectDB db)
		{
			if ((Object)(object)db == (Object)null || db.m_items.Count == 0 || (Object)(object)db.GetItemPrefab("Hammer") == (Object)null)
			{
				return;
			}
			if ((Object)(object)Prefab == (Object)null)
			{
				try
				{
					Prefab = Creer(db);
				}
				catch (Exception e)
				{
					Plugin.Erreur("création du Kroââ-structeur", e);
					return;
				}
			}
			if (!db.m_items.Contains(Prefab))
			{
				db.m_items.Add(Prefab);
			}
			if (!db.m_recipes.Exists((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name == "Recipe_RTFMB_Cawnstructor"))
			{
				Recipe val = Recette(db);
				if ((Object)(object)val != (Object)null)
				{
					db.m_recipes.Add(val);
				}
			}
			AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null)?.Invoke(db, null);
			EnregistrerDansZNetScene(ZNetScene.instance);
		}

		internal static void EnregistrerDansZNetScene(ZNetScene scene)
		{
			if (!((Object)(object)scene == (Object)null) && !((Object)(object)Prefab == (Object)null))
			{
				if (!scene.m_prefabs.Contains(Prefab))
				{
					scene.m_prefabs.Add(Prefab);
				}
				AccessTools.FieldRefAccess<ZNetScene, Dictionary<int, GameObject>>("m_namedPrefabs").Invoke(scene)[StringExtensionMethods.GetStableHashCode("RTFMB_Cawnstructor")] = Prefab;
			}
		}

		private static GameObject Creer(ObjectDB db)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			if (!Materiaux.Prets(db))
			{
				throw new InvalidOperationException("matériau du marteau du jeu introuvable");
			}
			if ((Object)(object)conteneur == (Object)null)
			{
				conteneur = new GameObject("RTFMB_Prefabs");
				conteneur.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)conteneur);
			}
			GameObject val = Object.Instantiate<GameObject>(db.GetItemPrefab("Hammer"), conteneur.transform, false);
			((Object)val).name = "RTFMB_Cawnstructor";
			ItemDrop component = val.GetComponent<ItemDrop>();
			component.m_itemData.m_dropPrefab = val;
			SharedData shared = component.m_itemData.m_shared;
			shared.m_name = Textes.Jeton("rtfmb_cawnstructor");
			shared.m_description = Textes.Jeton("rtfmb_cawnstructor_description");
			shared.m_maxDurability *= 4f;
			shared.m_durabilityPerLevel *= 4f;
			shared.m_maxQuality = Mathf.Max(3, shared.m_maxQuality);
			if (shared.m_attack != null)
			{
				Attack attack = shared.m_attack;
				attack.m_attackStamina *= 0.5f;
			}
			Sprite val2 = Icone();
			if ((Object)(object)val2 != (Object)null)
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 };
			}
			Habiller(val.transform.Find("attach"));
			return val;
		}

		private static void Habiller(Transform attach)
		{
			//IL_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)attach == (Object)null)
			{
				throw new InvalidOperationException("enfant « attach » du marteau introuvable");
			}
			MeshFilter componentInChildren = ((Component)attach).GetComponentInChildren<MeshFilter>(true);
			MeshRenderer val = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).GetComponent<MeshRenderer>() : null);
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("maillage du marteau introuvable");
			}
			Transform transform = ((Component)componentInChildren).transform;
			transform.localPosition = Vector3.zero;
			transform.localRotation = Quaternion.identity;
			transform.localScale = Vector3.one;
			componentInChildren.sharedMesh = Ressources.Maillage("marteau", "RTFMB_Kroastructeur", "marteau.T0", "marteau.T1", "marteau.T2");
			Apparence instance = Apparence.Instance;
			((Renderer)val).sharedMaterials = (Material[])(object)new Material[3] { instance.Bois, instance.Fer, instance.Cristal };
			((Component)val).gameObject.AddComponent<LueurPulsee>();
			List<Transform> list = new List<Transform>();
			string[] array = new string[2] { "plume_1", "plume_2" };
			foreach (string text in array)
			{
				GameObject val2 = new GameObject(text);
				val2.transform.SetParent(attach, false);
				val2.transform.localPosition = Ressources.Vecteur(text + ".pos");
				val2.transform.localRotation = Ressources.Rotation(text + ".rot");
				val2.AddComponent<MeshFilter>().sharedMesh = Ressources.Maillage(text, "RTFMB_" + text);
				((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = instance.Plume;
				list.Add(val2.transform);
			}
			((Component)attach).gameObject.AddComponent<PlumesPendantes>().Plumes = list.ToArray();
		}

		private static Sprite Icone()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Texture2D val = Ressources.Texture("icone_kroastructeur.png", (FilterMode)1);
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
			catch (Exception e)
			{
				Plugin.Erreur("icône du Kroââ-structeur", e);
				return null;
			}
		}

		private static Recipe Recette(ObjectDB db)
		{
			CraftingStation val = Station(db, Plugin.Etabli.Value) ?? Station(db, "piece_workbench");
			Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
			((Object)val2).name = "Recipe_RTFMB_Cawnstructor";
			val2.m_item = Prefab.GetComponent<ItemDrop>();
			val2.m_amount = 1;
			val2.m_enabled = true;
			val2.m_minStationLevel = 1;
			val2.m_craftingStation = val;
			val2.m_repairStation = val;
			val2.m_resources = ((IEnumerable<Requirement>)(object)new Requirement[6]
			{
				Ingredient(db, "SurtlingCore", 1, 0),
				Ingredient(db, "GreydwarfEye", 2, 0),
				Ingredient(db, "Feathers", 2, 4),
				Ingredient(db, "RoundLog", 3, 6),
				Ingredient(db, "Tin", 2, 4),
				Ingredient(db, "Thistle", 5, 0)
			}).Where((Requirement x) => x != null).ToArray();
			return val2;
		}

		private static CraftingStation Station(ObjectDB db, string nom)
		{
			if (string.IsNullOrEmpty(nom))
			{
				return null;
			}
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(nom) : null);
			return (((Object)(object)val != (Object)null) ? val.GetComponent<CraftingStation>() : null) ?? db.m_recipes.Select((Recipe x) => (!((Object)(object)x != (Object)null)) ? null : x.m_craftingStation).FirstOrDefault((Func<CraftingStation, bool>)((CraftingStation x) => (Object)(object)x != (Object)null && string.Equals(((Object)x).name, nom, StringComparison.OrdinalIgnoreCase)));
		}

		private static Requirement Ingredient(ObjectDB db, string nom, int quantite, int parNiveau)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			//IL_004f: Expected O, but got Unknown
			GameObject itemPrefab = db.GetItemPrefab(nom);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Recette du Kroââ-structeur : ingrédient introuvable, " + nom));
				return null;
			}
			return new Requirement
			{
				m_resItem = itemPrefab.GetComponent<ItemDrop>(),
				m_amount = quantite,
				m_amountPerLevel = parNiveau,
				m_recover = true
			};
		}
	}
	internal static class Textes
	{
		private static readonly string[] Jetons = new string[2] { "rtfmb_cawnstructor", "rtfmb_cawnstructor_description" };

		private static readonly Action<Localization, string, string> AjouterMot = AccessTools.MethodDelegate<Action<Localization, string, string>>(AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null), (object)null, true);

		private static readonly ConditionalWeakTable<Localization, string> Enregistrees = new ConditionalWeakTable<Localization, string>();

		internal static string Jeton(string cle)
		{
			Verifier();
			return "$" + cle;
		}

		internal static void Verifier()
		{
			Localization instance = Localization.instance;
			if (instance != null && !Enre