Decompiled source of FeedingTrough v1.0.0

FeedingTrough.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FeedingTrough")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FeedingTrough")]
[assembly: AssemblyTitle("FeedingTrough")]
[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 FeedingTrough
{
	public static class Icone
	{
		private static readonly string[] AlimentsVitrine = new string[6] { "Carrot", "Raspberry", "Turnip", "Blueberries", "Carrot", "Raspberry" };

		public static Sprite Rendre(GameObject modele, Vector3 directionVue, string nom, List<Zone> zones)
		{
			//IL_0001: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = Photo(modele, directionVue, 128, nom, zones, 0.62f);
			if (!((Object)(object)val == (Object)null))
			{
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
			return null;
		}

		public static Texture2D Photo(GameObject modele, Vector3 directionVue, int taille, string nom, List<Zone> zones, float cadrage)
		{
			//IL_0027: 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_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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: 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_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: 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_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: 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_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Expected O, but got Unknown
			GameObject val = null;
			GameObject val2 = null;
			GameObject val3 = null;
			GameObject val4 = null;
			RenderTexture val5 = null;
			try
			{
				val = Object.Instantiate<GameObject>(modele);
				val.transform.position = new Vector3(0f, -4000f, 0f);
				val.transform.rotation = Quaternion.identity;
				if (zones != null && (Object)(object)ObjectDB.instance != (Object)null)
				{
					List<(GameObject, int)> objets = (from n in AlimentsVitrine
						select ObjectDB.instance.GetItemPrefab(n) into p
						where (Object)(object)p != (Object)null
						select (p: p, 1)).ToList();
					Garniture.Poser(val.transform, zones, objets, 7, 31);
				}
				val.SetActive(true);
				Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
				for (int num = 0; num < componentsInChildren.Length; num++)
				{
					((Component)componentsInChildren[num]).gameObject.layer = 31;
				}
				Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true);
				if (componentsInChildren2.Length == 0)
				{
					return null;
				}
				Bounds bounds = componentsInChildren2[0].bounds;
				Renderer[] array = componentsInChildren2;
				foreach (Renderer val6 in array)
				{
					((Bounds)(ref bounds)).Encapsulate(val6.bounds);
				}
				val3 = new GameObject(nom + "_IconeLumiere");
				Light obj = val3.AddComponent<Light>();
				obj.type = (LightType)1;
				obj.intensity = 1.4f;
				obj.cullingMask = int.MinValue;
				val3.transform.rotation = Quaternion.LookRotation(-directionVue + Vector3.down * 1.2f + Vector3.left * 0.6f);
				val4 = new GameObject(nom + "_IconeAppoint");
				Light obj2 = val4.AddComponent<Light>();
				obj2.type = (LightType)1;
				obj2.intensity = 0.65f;
				obj2.cullingMask = int.MinValue;
				val4.transform.rotation = Quaternion.LookRotation(directionVue + Vector3.down * 0.3f);
				val2 = new GameObject(nom + "_IconeCamera");
				Camera obj3 = val2.AddComponent<Camera>();
				((Behaviour)obj3).enabled = false;
				obj3.cullingMask = int.MinValue;
				obj3.clearFlags = (CameraClearFlags)2;
				obj3.orthographic = true;
				obj3.renderingPath = (RenderingPath)1;
				obj3.allowHDR = false;
				obj3.allowMSAA = false;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				obj3.orthographicSize = ((Vector3)(ref extents)).magnitude * cadrage;
				obj3.nearClipPlane = 0.01f;
				obj3.farClipPlane = 30f;
				val2.transform.position = ((Bounds)(ref bounds)).center + ((Vector3)(ref directionVue)).normalized * 6f;
				val2.transform.LookAt(((Bounds)(ref bounds)).center);
				val5 = RenderTexture.GetTemporary(taille, taille, 24, (RenderTextureFormat)0);
				val5.antiAliasing = 1;
				obj3.targetTexture = val5;
				Color32[] array2 = Rendu(obj3, val5, Color.black, taille);
				Color32[] array3 = Rendu(obj3, val5, Color.white, taille);
				obj3.targetTexture = null;
				Color32[] array4 = (Color32[])(object)new Color32[array2.Length];
				int num2 = 0;
				for (int num3 = 0; num3 < array4.Length; num3++)
				{
					int num4 = (array3[num3].r - array2[num3].r + (array3[num3].g - array2[num3].g) + (array3[num3].b - array2[num3].b)) / 3;
					float num5 = Mathf.Clamp01(1f - (float)num4 / 255f);
					if (num5 < 0.02f)
					{
						array4[num3] = new Color32((byte)0, (byte)0, (byte)0, (byte)0);
						continue;
					}
					num2++;
					array4[num3] = new Color32((byte)Mathf.Min(255f, (float)(int)array2[num3].r / num5), (byte)Mathf.Min(255f, (float)(int)array2[num3].g / num5), (byte)Mathf.Min(255f, (float)(int)array2[num3].b / num5), (byte)(num5 * 255f));
				}
				if (num2 < taille * taille / 40)
				{
					Debug.LogWarning((object)("[" + Plugin.Nom + "] " + Textes.T("journal_icone_vide", nom, num2)));
					return null;
				}
				Texture2D val7 = new Texture2D(taille, taille, (TextureFormat)4, false)
				{
					name = nom + "_Icone"
				};
				val7.SetPixels32(array4);
				val7.Apply();
				return val7;
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[" + Plugin.Nom + "] " + Textes.T("journal_icone", nom, ex.Message)));
				return null;
			}
			finally
			{
				if ((Object)(object)val5 != (Object)null)
				{
					RenderTexture.ReleaseTemporary(val5);
				}
				GameObject[] array5 = (GameObject[])(object)new GameObject[4] { val, val2, val3, val4 };
				foreach (GameObject val8 in array5)
				{
					if ((Object)(object)val8 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)val8);
					}
				}
			}
		}

		private static Color32[] Rendu(Camera c, RenderTexture rt, Color fond, int taille)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002b: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			c.backgroundColor = fond;
			c.Render();
			RenderTexture.active = rt;
			Texture2D val = new Texture2D(taille, taille, (TextureFormat)4, false);
			val.ReadPixels(new Rect(0f, 0f, (float)taille, (float)taille), 0, 0);
			val.Apply();
			RenderTexture.active = null;
			Color32[] pixels = val.GetPixels32();
			Object.DestroyImmediate((Object)val);
			return pixels;
		}
	}
	public class Maillage
	{
		private readonly List<Vector3> sommets = new List<Vector3>();

		private readonly List<Vector2> uvs = new List<Vector2>();

		private readonly List<List<int>> parties = new List<List<int>>();

		private List<int> Partie(int index)
		{
			while (parties.Count <= index)
			{
				parties.Add(new List<int>());
			}
			return parties[index];
		}

		private int Sommet(Vector3 p, Vector2 uv)
		{
			//IL_0006: 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)
			sommets.Add(p);
			uvs.Add(uv);
			return sommets.Count - 1;
		}

		public void Grille(int partie, int nu, int nv, Func<float, float, Vector3> position, Func<float, float, Vector2> uv, Func<Vector3, Vector3> dehors)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = Partie(partie);
			int count = sommets.Count;
			for (int i = 0; i <= nv; i++)
			{
				for (int j = 0; j <= nu; j++)
				{
					float arg = (float)j / (float)nu;
					float arg2 = (float)i / (float)nv;
					Sommet(position(arg, arg2), uv(arg, arg2));
				}
			}
			int num = nu / 2;
			int num2 = nv / 2;
			int num3 = count + num2 * (nu + 1) + num;
			bool flag = Vector3.Dot(Vector3.Cross(sommets[num3 + nu + 1] - sommets[num3], sommets[num3 + 1] - sommets[num3]), dehors(sommets[num3])) < 0f;
			for (int k = 0; k < nv; k++)
			{
				for (int l = 0; l < nu; l++)
				{
					int num4 = count + k * (nu + 1) + l;
					int num5 = num4 + 1;
					int num6 = num4 + nu + 1;
					int num7 = num6 + 1;
					if (!flag)
					{
						list.AddRange(new int[6] { num4, num6, num5, num5, num6, num7 });
					}
					else
					{
						list.AddRange(new int[6] { num4, num5, num6, num5, num7, num6 });
					}
				}
			}
		}

		public void Eventail(int partie, Vector3 centre, IList<Vector3> contour, Func<Vector3, Vector2> uv, Vector3 normale)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_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_0038: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = Partie(partie);
			int num = Sommet(centre, uv(centre));
			int count = sommets.Count;
			foreach (Vector3 item in contour)
			{
				Sommet(item, uv(item));
			}
			int count2 = contour.Count;
			for (int i = 0; i < count2; i++)
			{
				int num2 = count + i;
				int num3 = count + (i + 1) % count2;
				Vector3 val = Vector3.Cross(sommets[num2] - sommets[num], sommets[num3] - sommets[num]);
				if (!(((Vector3)(ref val)).sqrMagnitude < 1E-12f))
				{
					if (Vector3.Dot(val, normale) > 0f)
					{
						list.AddRange(new int[3] { num, num2, num3 });
					}
					else
					{
						list.AddRange(new int[3] { num, num3, num2 });
					}
				}
			}
		}

		public void Quad(int partie, Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector2 ua, Vector2 ub, Vector2 uc, Vector2 ud, Vector3 normale)
		{
			//IL_0009: 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_0013: 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_001d: 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_0028: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = Partie(partie);
			int num = Sommet(a, ua);
			int num2 = Sommet(b, ub);
			int num3 = Sommet(c, uc);
			int num4 = Sommet(d, ud);
			if (Vector3.Dot(Vector3.Cross(b - a, c - a), normale) > 0f)
			{
				list.AddRange(new int[6] { num, num2, num3, num, num3, num4 });
			}
			else
			{
				list.AddRange(new int[6] { num, num3, num2, num, num4, num3 });
			}
		}

		public void Pave(int partie, Vector3 centre, Vector3 taille, float tuile)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0142: 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_014d: 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)
			Vector3 e = taille * 0.5f;
			for (int i = 0; i < 3; i++)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					Vector3 zero = Vector3.zero;
					((Vector3)(ref zero))[i] = j;
					int ua = (i + 1) % 3;
					int va = (i + 2) % 3;
					if (i == 1)
					{
						ua = 0;
						va = 2;
					}
					Vector3 zero2 = Vector3.zero;
					Vector3 zero3 = Vector3.zero;
					((Vector3)(ref zero2))[ua] = ((Vector3)(ref e))[ua];
					((Vector3)(ref zero3))[va] = ((Vector3)(ref e))[va];
					Vector3 val = centre + zero * ((Vector3)(ref e))[i];
					Vector3 val2 = val - zero2 - zero3;
					Vector3 val3 = val + zero2 - zero3;
					Vector3 val4 = val + zero2 + zero3;
					Vector3 val5 = val - zero2 + zero3;
					Quad(partie, val2, val3, val4, val5, Uv(val2), Uv(val3), Uv(val4), Uv(val5), zero);
					Vector2 Uv(Vector3 p)
					{
						//IL_0070: Unknown result type (might be due to invalid IL or missing references)
						return new Vector2((((Vector3)(ref p))[ua] - ((Vector3)(ref centre))[ua] + ((Vector3)(ref e))[ua]) / tuile, (((Vector3)(ref p))[va] - ((Vector3)(ref centre))[va] + ((Vector3)(ref e))[va]) / tuile);
					}
				}
			}
		}

		public Mesh Construire(string nom)
		{
			//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_000d: Expected O, but got Unknown
			Mesh val = new Mesh
			{
				name = nom
			};
			if (sommets.Count > 65000)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.SetVertices(sommets);
			val.SetUVs(0, uvs);
			val.subMeshCount = parties.Count;
			for (int i = 0; i < parties.Count; i++)
			{
				val.SetTriangles(parties[i], i);
			}
			val.RecalculateNormals();
			val.RecalculateTangents();
			val.RecalculateBounds();
			return val;
		}
	}
	public class Auge : MonoBehaviour
	{
		public const string RpcManger = "FeedingTrough_Manger";

		public static readonly List<Auge> Toutes = new List<Auge>();

		public static readonly Dictionary<string, Gabarit> Formes = new Dictionary<string, Gabarit>();

		public Vector3 CentreBoite;

		public Vector3 TailleBoite;

		public bool Ronde;

		public List<Zone> Zones = new List<Zone>();

		private ZNetView nview;

		private Container coffre;

		private Transform garniture;

		private string signature = "";

		public bool Valide
		{
			get
			{
				if ((Object)(object)nview != (Object)null && nview.IsValid() && (Object)(object)coffre != (Object)null)
				{
					return coffre.GetInventory() != null;
				}
				return false;
			}
		}

		public Vector3 Centre => ((Component)this).transform.TransformPoint(CentreBoite);

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (Formes.TryGetValue(Utils.GetPrefabName(((Component)this).gameObject), out var value))
			{
				CentreBoite = value.CentreBoite;
				TailleBoite = value.TailleBoite;
				Ronde = value.Ronde;
				Zones = value.Zones;
			}
			nview = ((Component)this).GetComponent<ZNetView>();
			coffre = ((Component)this).GetComponent<Container>();
			if (!((Object)(object)nview == (Object)null) && nview.GetZDO() != null && !((Object)(object)coffre == (Object)null))
			{
				nview.Register<string>("FeedingTrough_Manger", (Action<long, string>)RPC_Manger);
				((MonoBehaviour)this).InvokeRepeating("Rafraichir", 0.3f, 1f);
			}
		}

		private void OnEnable()
		{
			Toutes.Add(this);
		}

		private void OnDisable()
		{
			Toutes.Remove(this);
		}

		public float DistanceBord(Vector3 point)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.InverseTransformPoint(point) - CentreBoite;
			if (Ronde)
			{
				Vector2 val2 = new Vector2(val.x, val.z);
				return Mathf.Max(0f, ((Vector2)(ref val2)).magnitude - TailleBoite.x / 2f);
			}
			float num = Mathf.Max(0f, Mathf.Abs(val.x) - TailleBoite.x / 2f);
			float num2 = Mathf.Max(0f, Mathf.Abs(val.z) - TailleBoite.z / 2f);
			return Mathf.Sqrt(num * num + num2 * num2);
		}

		public Vector3 PlaceRepas(Vector3 depuis, float rayon)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_003a: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_019e: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.InverseTransformPoint(depuis) - CentreBoite;
			val.y = 0f;
			Vector3 val2;
			if (Ronde)
			{
				val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward) * (TailleBoite.x / 2f + rayon + 0.1f);
			}
			else
			{
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(Mathf.Clamp(val.x, (0f - TailleBoite.x) / 2f, TailleBoite.x / 2f), 0f, Mathf.Clamp(val.z, (0f - TailleBoite.z) / 2f, TailleBoite.z / 2f));
				Vector3 val4 = val - val3;
				if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f)
				{
					((Vector3)(ref val4))..ctor(0f, 0f, (val.z >= 0f) ? 1f : (-1f));
					((Vector3)(ref val3))..ctor(val3.x, 0f, Mathf.Sign(val4.z) * TailleBoite.z / 2f);
				}
				val2 = val3 + ((Vector3)(ref val4)).normalized * (rayon + 0.1f);
			}
			Vector3 result = ((Component)this).transform.TransformPoint(val2 + new Vector3(CentreBoite.x, 0f, CentreBoite.z));
			result.y = depuis.y;
			return result;
		}

		public ItemData NourriturePour(List<ItemDrop> mange)
		{
			if (!Valide || mange == null)
			{
				return null;
			}
			foreach (ItemData allItem in coffre.GetInventory().GetAllItems())
			{
				foreach (ItemDrop item in mange)
				{
					if ((Object)(object)item != (Object)null && item.m_itemData.m_shared.m_name == allItem.m_shared.m_name)
					{
						return allItem;
					}
				}
			}
			return null;
		}

		public void Manger(string nom)
		{
			if (Valide)
			{
				nview.InvokeRPC("FeedingTrough_Manger", new object[1] { nom });
			}
		}

		private void RPC_Manger(long expediteur, string nom)
		{
			if (nview.IsOwner() && !((Object)(object)coffre == (Object)null))
			{
				Inventory inventory = coffre.GetInventory();
				ItemData val = ((inventory != null) ? inventory.GetItem(nom, -1, false) : null);
				if (val != null)
				{
					inventory.RemoveOneItem(val);
				}
			}
		}

		private void Rafraichir()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (!Valide)
			{
				return;
			}
			List<ItemData> allItems = coffre.GetInventory().GetAllItems();
			string text = string.Join("|", allItems.Select(delegate(ItemData o)
			{
				GameObject dropPrefab = o.m_dropPrefab;
				return $"{((dropPrefab != null) ? ((Object)dropPrefab).name : null)}:{Copies(o.m_stack)}";
			}));
			if (!(text == signature))
			{
				signature = text;
				if ((Object)(object)garniture != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)garniture).gameObject);
				}
				garniture = new GameObject("Garniture").transform;
				garniture.SetParent(((Component)this).transform, false);
				List<(GameObject, int)> objets = (from o in allItems
					where (Object)(object)o.m_dropPrefab != (Object)null
					select (m_dropPrefab: o.m_dropPrefab, Copies(o.m_stack))).ToList();
				Garniture.Poser(garniture, Zones, objets, ((object)Unsafe.As<ZDOID, ZDOID>(ref nview.GetZDO().m_uid)/*cast due to .constrained prefix*/).GetHashCode(), ((Component)this).gameObject.layer);
			}
		}

		private static int Copies(int pile)
		{
			return Mathf.Clamp(1 + pile / 8, 1, 4);
		}
	}
	public static class Garniture
	{
		private static readonly Dictionary<string, (GameObject modele, Bounds boite)> Modeles = new Dictionary<string, (GameObject, Bounds)>();

		private const float Echelle = 0.7f;

		private static Transform reserve;

		public static void Poser(Transform parent, List<Zone> zones, IList<(GameObject prefab, int copies)> objets, int graine, int calque)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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)
			if (zones == null || zones.Count == 0 || objets.Count == 0)
			{
				return;
			}
			Random random = new Random(graine);
			List<Vector3> list = new List<Vector3>();
			float num = zones.Sum((Zone zone) => (!zone.Ronde) ? (4f * zone.Demi.x * zone.Demi.y) : (MathF.PI * zone.Demi.x * zone.Demi.x));
			float ecart = Mathf.Clamp(Mathf.Sqrt(num / (float)Mathf.Max(1, objets.Sum(((GameObject prefab, int copies) o) => o.copies))) * 0.8f, 0.09f, 0.22f);
			foreach (var (prefab, num2) in objets)
			{
				if (!Modele(prefab, out var modele, out var boite))
				{
					continue;
				}
				for (int num3 = 0; num3 < num2; num3++)
				{
					Zone z = zones[random.Next(zones.Count)];
					Vector3 p = z.Centre;
					for (int num4 = 0; num4 < 14; num4++)
					{
						p = Tirer(z, random);
						if (list.All(delegate(Vector3 q)
						{
							//IL_0000: 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_0024: Unknown result type (might be due to invalid IL or missing references)
							//IL_0029: Unknown result type (might be due to invalid IL or missing references)
							Vector2 val5 = new Vector2(q.x - p.x, q.z - p.z);
							return ((Vector2)(ref val5)).magnitude >= ecart;
						}))
						{
							break;
						}
					}
					GameObject val = Object.Instantiate<GameObject>(modele, parent, false);
					val.SetActive(true);
					Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
					for (int num5 = 0; num5 < componentsInChildren.Length; num5++)
					{
						((Component)componentsInChildren[num5]).gameObject.layer = calque;
					}
					Quaternion val2 = Couche(((Bounds)(ref boite)).size);
					Quaternion val3 = Quaternion.Euler(0f, (float)random.NextDouble() * 360f, ((float)random.NextDouble() - 0.5f) * 16f) * val2;
					Vector2 demiEmprise;
					Vector3 val4 = BasApresRotation(boite, val3, out demiEmprise);
					p = Contenir(z, p, demiEmprise);
					list.Add(p);
					val.transform.localRotation = val3;
					val.transform.localPosition = p - val4 + Vector3.down * 0.015f;
				}
			}
		}

		private static Vector3 Tirer(Zone z, Random h)
		{
			//IL_005c: 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_0099: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (z.Ronde)
			{
				float num = (float)h.NextDouble() * MathF.PI * 2f;
				float num2 = Mathf.Sqrt((float)h.NextDouble()) * z.Demi.x;
				return z.Centre + new Vector3(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2);
			}
			return z.Centre + new Vector3(((float)h.NextDouble() * 2f - 1f) * z.Demi.x, 0f, ((float)h.NextDouble() * 2f - 1f) * z.Demi.y);
		}

		private static Quaternion Couche(Vector3 taille)
		{
			//IL_0000: 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_0022: 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)
			//IL_000e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (taille.y <= taille.x && taille.y <= taille.z)
			{
				return Quaternion.identity;
			}
			if (!(taille.x <= taille.z))
			{
				return Quaternion.Euler(90f, 0f, 0f);
			}
			return Quaternion.Euler(0f, 0f, 90f);
		}

		private static Vector3 BasApresRotation(Bounds b, Quaternion r, out Vector2 demiEmprise)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0082: 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_0094: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			Vector3 val = r * ((Bounds)(ref b)).center;
			demiEmprise = Vector2.zero;
			for (int i = 0; i < 8; i++)
			{
				Vector3 val2 = r * (((Bounds)(ref b)).center + Vector3.Scale(((Bounds)(ref b)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))));
				num = Mathf.Min(num, val2.y);
				demiEmprise = Vector2.Max(demiEmprise, new Vector2(Mathf.Abs(val2.x - val.x), Mathf.Abs(val2.z - val.z)));
			}
			return new Vector3(val.x, num, val.z);
		}

		private static Vector3 Contenir(Zone z, Vector3 p, Vector2 demi)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00ff: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_0065: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = p - z.Centre;
			if (z.Ronde)
			{
				float num = Mathf.Max(0f, z.Demi.x - Mathf.Max(demi.x, demi.y) * 0.85f);
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(val.x, val.z);
				if (((Vector2)(ref val2)).magnitude > num)
				{
					val2 = ((Vector2)(ref val2)).normalized * num;
				}
				return new Vector3(z.Centre.x + val2.x, p.y, z.Centre.z + val2.y);
			}
			float num2 = Mathf.Max(0f, z.Demi.x - demi.x);
			float num3 = Mathf.Max(0f, z.Demi.y - demi.y);
			return new Vector3(z.Centre.x + Mathf.Clamp(val.x, 0f - num2, num2), p.y, z.Centre.z + Mathf.Clamp(val.z, 0f - num3, num3));
		}

		public static bool Modele(GameObject prefab, out GameObject modele, out Bounds boite)
		{
			//IL_01e5: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_004d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			if (Modeles.TryGetValue(((Object)prefab).name, out (GameObject, Bounds) value))
			{
				(modele, boite) = value;
				return (Object)(object)modele != (Object)null;
			}
			modele = null;
			boite = default(Bounds);
			try
			{
				if ((Object)(object)reserve == (Object)null)
				{
					GameObject val = new GameObject("FeedingTrough_Garnitures");
					val.SetActive(false);
					Object.DontDestroyOnLoad((Object)val);
					reserve = val.transform;
				}
				Transform obj = prefab.transform.Find("attach") ?? prefab.transform;
				GameObject val2 = new GameObject(((Object)prefab).name + "_garniture");
				val2.transform.SetParent(reserve, false);
				GameObject val3 = Object.Instantiate<GameObject>(((Component)obj).gameObject, val2.transform, false);
				val3.transform.localPosition = Vector3.zero;
				val3.transform.localRotation = Quaternion.identity;
				val3.transform.localScale = Vector3.Scale(val3.transform.localScale, Vector3.one * 0.7f);
				val3.SetActive(true);
				Nettoyer(val3);
				boite = Boite(val2);
				if (!(((Bounds)(ref boite)).size == Vector3.zero))
				{
					Vector3 size = ((Bounds)(ref boite)).size;
					if (!(((Vector3)(ref size)).magnitude > 3f))
					{
						modele = val2;
						Modeles[((Object)prefab).name] = (modele, boite);
						return true;
					}
				}
				Object.DestroyImmediate((Object)(object)val2);
				Modeles[((Object)prefab).name] = (null, default(Bounds));
				return false;
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[" + Plugin.Nom + "] " + Textes.T("journal_apercu", ((Object)prefab).name, ex.Message)));
				Modeles[((Object)prefab).name] = (null, default(Bounds));
				return false;
			}
		}

		private static void Nettoyer(GameObject go)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			LODGroup[] componentsInChildren = go.GetComponentsInChildren<LODGroup>(true);
			foreach (LODGroup val in componentsInChildren)
			{
				LOD[] lODs = val.GetLODs();
				if (lODs.Length > 1)
				{
					HashSet<Renderer> hashSet = new HashSet<Renderer>(lODs[0].renderers.Where((Renderer r) => (Object)(object)r != (Object)null));
					foreach (LOD item in lODs.Skip(1))
					{
						Renderer[] renderers = item.renderers;
						foreach (Renderer val2 in renderers)
						{
							if ((Object)(object)val2 != (Object)null && !hashSet.Contains(val2))
							{
								Object.DestroyImmediate((Object)(object)((Component)val2).gameObject);
							}
						}
					}
				}
				Object.DestroyImmediate((Object)(object)val);
			}
			foreach (Transform item2 in (from t in go.GetComponentsInChildren<Transform>(true)
				where (Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)go.transform && !((Component)t).gameObject.activeSelf
				select t).ToList())
			{
				if ((Object)(object)item2 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)item2).gameObject);
				}
			}
			for (int num2 = 0; num2 < 3; num2++)
			{
				Component[] componentsInChildren2 = go.GetComponentsInChildren<Component>(true);
				foreach (Component val3 in componentsInChildren2)
				{
					if (!((Object)(object)val3 == (Object)null) && !(val3 is Transform) && !(val3 is MeshFilter) && !(val3 is MeshRenderer) && (val3 is ParticleSystemRenderer || !(val3 is Renderer)))
					{
						Object.DestroyImmediate((Object)(object)val3);
					}
				}
			}
		}

		private static Bounds Boite(GameObject go)
		{
			//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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 worldToLocalMatrix = go.transform.worldToLocalMatrix;
			Bounds? val = null;
			MeshFilter[] componentsInChildren = go.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				if ((Object)(object)val2.sharedMesh == (Object)null || (Object)(object)((Component)val2).GetComponent<MeshRenderer>() == (Object)null)
				{
					continue;
				}
				Matrix4x4 val3 = worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix;
				Bounds bounds = val2.sharedMesh.bounds;
				for (int j = 0; j < 8; j++)
				{
					Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))));
					if (val.HasValue)
					{
						Bounds value = val.Value;
						((Bounds)(ref value)).Encapsulate(val4);
						val = value;
					}
					else
					{
						val = new Bounds(val4, Vector3.zero);
					}
				}
			}
			return (Bounds)(((??)val) ?? new Bounds(Vector3.zero, Vector3.zero));
		}
	}
	[Serializable]
	public struct Zone
	{
		public Vector3 Centre;

		public Vector2 Demi;

		public bool Ronde;
	}
	public class Gabarit
	{
		public string Id;

		public GameObject Visuel;

		public Vector3 CentreBoite;

		public Vector3 TailleBoite;

		public bool Ronde;

		public readonly List<Zone> Zones = new List<Zone>();
	}
	public static class Materiaux
	{
		public static Mesh Planche;

		public static Mesh Rondin;

		public static Mesh BlocPierre;

		public static Material Bois;

		public static Material Ecorce;

		public static Material Paille;

		public static Material Eau;

		public static Material Tonneau;

		public static Material Pierre;

		public static Vector2 CentreCernes;

		public static float RayonCernes;

		public static Rect ZoneEcorce;

		public static bool Charger()
		{
			if ((Object)(object)Bois != (Object)null)
			{
				return true;
			}
			(Mesh, Material) tuple = Chercher("wood_floor", (MeshFilter f, MeshRenderer r) => ((Object)f.sharedMesh).name == "Cube_Cube_Material" && ((Object)((Renderer)r).sharedMaterial).name == "woodwall");
			Planche = tuple.Item1;
			Bois = tuple.Item2;
			(Mesh, Material) tuple2 = Chercher("wood_pole_log", (MeshFilter f, MeshRenderer r) => ((Object)f.sharedMesh).name == "VerticalLog" && ((Object)((Renderer)r).sharedMaterial).name == "logwall");
			Rondin = tuple2.Item1;
			Ecorce = tuple2.Item2;
			Paille = Chercher("wood_roof", (MeshFilter f, MeshRenderer r) => ((Object)((Renderer)r).sharedMaterial).name == "straw_roof").Item2;
			Eau = Chercher("piece_bathtub", (MeshFilter f, MeshRenderer r) => ((Object)((Renderer)r).sharedMaterial).name == "water_hottub").Item2;
			Tonneau = Chercher("barrell", (MeshFilter f, MeshRenderer r) => ((Object)((Renderer)r).sharedMaterial).name == "barrel_iron").Item2;
			(BlocPierre, Pierre) = Chercher("stone_wall_1x1", (MeshFilter f, MeshRenderer r) => ((Object)f.sharedMesh).name == "Cube.006_Cube.003");
			if ((Object)(object)Planche == (Object)null || (Object)(object)Bois == (Object)null || (Object)(object)Rondin == (Object)null || (Object)(object)Ecorce == (Object)null || (Object)(object)Paille == (Object)null)
			{
				Debug.LogWarning((object)("[" + Plugin.Nom + "] " + Textes.T("journal_materiaux", (Object)(object)Planche != (Object)null, (Object)(object)Bois != (Object)null, (Object)(object)Rondin != (Object)null, (Object)(object)Paille != (Object)null)));
				Bois = null;
				return false;
			}
			AnalyserRondin();
			return true;
		}

		private static (Mesh, Material) Chercher(string prefab, Func<MeshFilter, MeshRenderer, bool> filtre)
		{
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefab) : null);
			if ((Object)(object)val == (Object)null)
			{
				return (null, null);
			}
			MeshFilter[] componentsInChildren = val.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>();
				if ((Object)(object)val2.sharedMesh != (Object)null && (Object)(object)component != (Object)null && (Object)(object)((Renderer)component).sharedMaterial != (Object)null && filtre(val2, component))
				{
					return (val2.sharedMesh, ((Renderer)component).sharedMaterial);
				}
			}
			return (null, null);
		}

		private static void AnalyserRondin()
		{
			//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)
			//IL_0032: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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)
			//IL_0190: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_0279: 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)
			CentreCernes = new Vector2(0.84f, 0.25f);
			RayonCernes = 0.15f;
			ZoneEcorce = new Rect(0.01f, 0.01f, 0.61f, 0.95f);
			if (!Rondin.isReadable)
			{
				return;
			}
			Vector3[] normals = Rondin.normals;
			Vector2[] uv = Rondin.uv;
			List<Vector2> list = new List<Vector2>();
			List<Vector2> list2 = new List<Vector2>();
			for (int i = 0; i < normals.Length && i < uv.Length; i++)
			{
				if (normals[i].z > 0.9f)
				{
					list.Add(uv[i]);
				}
				else if (Mathf.Abs(normals[i].z) < 0.3f)
				{
					list2.Add(uv[i]);
				}
			}
			if (list.Count >= 4)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(list.Min((Vector2 u) => u.x), list.Min((Vector2 u) => u.y));
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(list.Max((Vector2 u) => u.x), list.Max((Vector2 u) => u.y));
				CentreCernes = (val + val2) * 0.5f;
				RayonCernes = Mathf.Min(val2.x - val.x, val2.y - val.y) * 0.5f;
			}
			if (list2.Count >= 4)
			{
				float num = list2.Min((Vector2 u) => u.x);
				float num2 = list2.Max((Vector2 u) => u.x);
				float num3 = list2.Min((Vector2 u) => u.y);
				float num4 = list2.Max((Vector2 u) => u.y);
				ZoneEcorce = new Rect(num, num3, num2 - num, num4 - num3);
			}
		}
	}
	public static class Modeles
	{
		public static readonly string[] Ids = new string[5] { "planks", "log", "tub", "feedwater", "stone" };

		private static readonly Quaternion LeLongDeX = Quaternion.Euler(0f, 90f, 0f);

		private static readonly Quaternion Debout = Quaternion.Euler(-90f, 0f, 0f);

		private static Material fondEau;

		private static Material pierreSombre;

		public const string NomEau = "eau";

		public static Gabarit Construire(string id, Transform parent)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!Materiaux.Charger())
			{
				return null;
			}
			Gabarit gabarit = new Gabarit
			{
				Id = id,
				Visuel = new GameObject("Visuel_" + id)
			};
			gabarit.Visuel.transform.SetParent(parent, false);
			switch (id)
			{
			case "planks":
				Planches(gabarit, 1.4f, avecEau: false);
				break;
			case "log":
				Tronc(gabarit);
				break;
			case "tub":
				Baquet(gabarit);
				break;
			case "feedwater":
				Planches(gabarit, 1.5f, avecEau: true);
				break;
			case "stone":
				Pierre(gabarit);
				break;
			default:
				Object.Destroy((Object)(object)gabarit.Visuel);
				return null;
			}
			return gabarit;
		}

		private static GameObject Morceau(Transform parent, string nom, Mesh maillage, Material materiau, Vector3 position, Quaternion rotation, Vector3 taille)
		{
			//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_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_0025: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_007e: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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)
			//IL_00b5: Expected O, but got Unknown
			GameObject val = new GameObject(nom);
			val.transform.SetParent(parent, false);
			Bounds bounds = maillage.bounds;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(taille.x / ((Bounds)(ref bounds)).size.x, taille.y / ((Bounds)(ref bounds)).size.y, taille.z / ((Bounds)(ref bounds)).size.z);
			val.transform.localRotation = rotation;
			val.transform.localScale = val2;
			val.transform.localPosition = position - rotation * Vector3.Scale(((Bounds)(ref bounds)).center, val2);
			val.AddComponent<MeshFilter>().sharedMesh = maillage;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = materiau;
			return val;
		}

		private static void Planche(Transform t, Vector3 centre, float longueur, float hauteur, float epaisseur, bool selonX, float inclinaison = 0f)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_0026: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = (selonX ? LeLongDeX : Quaternion.identity) * Quaternion.Euler(0f, 0f, inclinaison);
			Morceau(t, "planche", Materiaux.Planche, Materiaux.Bois, centre, rotation, new Vector3(epaisseur, hauteur, longueur));
		}

		private static void Rondin(Transform t, Vector3 a, Vector3 b, float diametre)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			Vector3 val = b - a;
			Morceau(t, "rondin", Materiaux.Rondin, Materiaux.Ecorce, (a + b) * 0.5f, Quaternion.LookRotation(((Vector3)(ref val)).normalized, (Mathf.Abs(((Vector3)(ref val)).normalized.y) > 0.9f) ? Vector3.forward : Vector3.up), new Vector3(diametre, diametre, ((Vector3)(ref val)).magnitude));
		}

		private static GameObject Surface(Transform t, string nom, Maillage m, params Material[] materiaux)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			GameObject val = new GameObject(nom);
			val.transform.SetParent(t, false);
			val.AddComponent<MeshFilter>().sharedMesh = m.Construire(nom);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = materiaux;
			return val;
		}

		private static void LitDePaille(Transform t, Zone z, float marge, int graine)
		{
			Maillage maillage = new Maillage();
			float ox = (float)graine * 3.1f;
			float oz = (float)graine * 7.7f;
			Func<float, float, Vector3> pos;
			if (z.Ronde)
			{
				pos = delegate(float s, float u)
				{
					//IL_0037: Unknown result type (might be due to invalid IL or missing references)
					//IL_005f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0064: Unknown result type (might be due to invalid IL or missing references)
					float num = s * MathF.PI * 2f;
					float num2 = z.Demi.x * u;
					float num3 = Mathf.Cos(num) * num2;
					float num4 = Mathf.Sin(num) * num2;
					return z.Centre + new Vector3(num3, Bosse(num3 + ox, num4 + oz) + 0.035f * u * u * u, num4);
				};
			}
			else
			{
				pos = delegate(float s, float u)
				{
					//IL_006e: Unknown result type (might be due to invalid IL or missing references)
					//IL_009c: 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)
					float num = (s * 2f - 1f) * z.Demi.x;
					float num2 = (u * 2f - 1f) * z.Demi.y;
					float num3 = Mathf.Max(Mathf.Abs(s * 2f - 1f), Mathf.Abs(u * 2f - 1f));
					return z.Centre + new Vector3(num, Bosse(num + ox, num2 + oz) + 0.035f * Mathf.Pow(num3, 4f), num2);
				};
			}
			maillage.Grille(0, z.Ronde ? 32 : 22, z.Ronde ? 8 : 12, pos, delegate(float s, float u)
			{
				//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)
				//IL_000e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = pos(s, u);
				return new Vector2(val.x / 0.45f, val.z / 0.45f);
			}, (Vector3 p) => Vector3.up);
			Surface(t, "paille", maillage, Materiaux.Paille);
		}

		private static float Bosse(float x, float z)
		{
			return (Mathf.PerlinNoise(x * 5f + 10f, z * 5f + 10f) - 0.5f) * 0.05f + (Mathf.PerlinNoise(x * 13f, z * 13f) - 0.5f) * 0.02f;
		}

		private static Material MateriauFondEau()
		{
			//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)
			//IL_003f: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fondEau != (Object)null)
			{
				return fondEau;
			}
			Shader val = Shader.Find("Standard");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			fondEau = new Material(val)
			{
				name = "FeedingTrough_fond_eau"
			};
			fondEau.SetColor("_Color", new Color(0.15f, 0.25f, 0.23f, 1f));
			fondEau.SetFloat("_Glossiness", 0.75f);
			fondEau.SetFloat("_Metallic", 0f);
			return fondEau;
		}

		private static void EauCalme(Transform t, Vector3 centre, Vector2 demi)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			Material val = MateriauFondEau();
			if ((Object)(object)val != (Object)null)
			{
				Maillage maillage = new Maillage();
				maillage.Grille(0, 2, 2, (float s, float u) => centre + new Vector3((s * 2f - 1f) * demi.x, -0.035f, (u * 2f - 1f) * demi.y), (float s, float u) => new Vector2(s, u), (Vector3 p) => Vector3.up);
				Surface(t, "fond_eau", maillage, val);
			}
			if (!((Object)(object)Materiaux.Eau == (Object)null))
			{
				Maillage maillage2 = new Maillage();
				maillage2.Grille(0, 6, 4, (float s, float u) => centre + new Vector3((s * 2f - 1f) * demi.x, 0f, (u * 2f - 1f) * demi.y), (float s, float u) => new Vector2(s, u), (Vector3 p) => Vector3.up);
				Surface(t, "eau", maillage2, Materiaux.Eau);
			}
		}

		private static Material PierreSombre()
		{
			//IL_002e: 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_0043: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pierreSombre != (Object)null || (Object)(object)Materiaux.Pierre == (Object)null)
			{
				return pierreSombre ?? Materiaux.Bois;
			}
			pierreSombre = new Material(Materiaux.Pierre)
			{
				name = "FeedingTrough_pierre"
			};
			if (pierreSombre.HasProperty("_Color"))
			{
				pierreSombre.SetColor("_Color", pierreSombre.GetColor("_Color") * new Color(0.72f, 0.71f, 0.69f, 1f));
			}
			return pierreSombre;
		}

		private static void Planches(Gabarit g, float longueur, bool avecEau)
		{
			//IL_008c: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: 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_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: 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_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: 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_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_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = g.Visuel.transform;
			float num = longueur / 2f;
			float num2 = 0.3575f;
			float num3 = num2 - 0.0225f - 0.055f;
			float num4 = num - 0.07f;
			float[] array = new float[2] { -1f, 1f };
			foreach (float num5 in array)
			{
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num6 in array2)
				{
					Rondin(transform, new Vector3(num5 * num4, 0f, num6 * num3), new Vector3(num5 * num4, 0.47f, num6 * num3), 0.11f);
				}
			}
			array = new float[2] { 0.155f, 0.335f };
			foreach (float num7 in array)
			{
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num8 in array2)
				{
					Planche(transform, new Vector3(0f, num7, num8 * num2), longueur, 0.17f, 0.045f, selonX: true);
				}
				array2 = new float[2] { -1f, 1f };
				foreach (float num9 in array2)
				{
					Planche(transform, new Vector3(num9 * (num - 0.0225f), num7, 0f), 0.66999996f, 0.17f, 0.045f, selonX: false);
				}
			}
			Planche(transform, new Vector3(0f, 0.07f, 0f), longueur - 0.05f, 0.04f, 0.71f, selonX: true);
			array = new float[2] { -1f, 1f };
			foreach (float num10 in array)
			{
				Morceau(transform, "lisse", Materiaux.Planche, Materiaux.Bois, new Vector3(0f, 0.428f, num10 * 0.33499998f), LeLongDeX, new Vector3(0.11f, 0.03f, longueur + 0.04f));
			}
			float num11 = num - 0.045f - 0.01f;
			float num12 = 0.325f;
			if (!avecEau)
			{
				Zone z = new Zone
				{
					Centre = new Vector3(0f, 0.27f, 0f),
					Demi = new Vector2(num11, num12)
				};
				LitDePaille(transform, z, 0f, 1);
				g.Zones.Add(new Zone
				{
					Centre = z.Centre + Vector3.up * 0.02f,
					Demi = z.Demi - new Vector2(0.02f, 0.02f)
				});
			}
			else
			{
				Planche(transform, new Vector3(0f, 0.245f, 0f), 0.66999996f, 0.35f, 0.045f, selonX: false);
				Zone z2 = new Zone
				{
					Centre = new Vector3((0f - (num11 + 0.0225f)) / 2f, 0.27f, 0f),
					Demi = new Vector2((num11 - 0.0225f) / 2f, num12)
				};
				LitDePaille(transform, z2, 0f, 4);
				g.Zones.Add(new Zone
				{
					Centre = z2.Centre + Vector3.up * 0.02f,
					Demi = z2.Demi - new Vector2(0.02f, 0.02f)
				});
				EauCalme(transform, new Vector3((num11 + 0.0225f) / 2f, 0.37f, 0f), new Vector2((num11 - 0.0225f) / 2f + 0.005f, num12 + 0.005f));
				Planche(transform, new Vector3((num11 + 0.0225f) / 2f, 0.12f, 0f), num11 - 0.0225f + 0.01f, 0.04f, 2f * num12, selonX: true);
			}
			g.CentreBoite = new Vector3(0f, 0.22f, 0f);
			g.TailleBoite = new Vector3(longueur + 0.04f, 0.44f, 0.76f);
		}

		private static void Tronc(Gabarit g)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_015d: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: 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_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: 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_02f7: 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_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = g.Visuel.transform;
			float demiL = 0.725f;
			float phiExt = Mathf.Acos(-0.24137929f);
			float phiInt = Mathf.Acos(-0.3111111f);
			float num = Mathf.Sqrt(0.07919999f);
			float num2 = Mathf.Sqrt(0.045724995f);
			Rect ec = Materiaux.ZoneEcorce;
			Maillage maillage = new Maillage();
			maillage.Grille(0, 26, 2, (float s, float u) => Cercle(0f - demiL + u * 1.45f, 0.29f, Mathf.Lerp(0f - phiExt, phiExt, s)), (float s, float u) => new Vector2(((Rect)(ref ec)).xMin + s * ((Rect)(ref ec)).width, ((Rect)(ref ec)).yMin + u * ((Rect)(ref ec)).height * 0.75f), (Vector3 p) => new Vector3(0f, p.y - 0.36f, p.z));
			float xi = demiL - 0.08f;
			maillage.Grille(1, 22, 6, (float s, float u) => Cercle(0f - xi + u * 2f * xi, 0.225f, Mathf.Lerp(0f - phiInt, phiInt, s)), (float s, float u) => new Vector2(Cercle(0f - xi + u * 2f * xi, 0.225f, Mathf.Lerp(0f - phiInt, phiInt, s)).x / 0.7f, Mathf.Lerp(0f - phiInt, phiInt, s) * 0.225f / 0.7f), (Vector3 p) => new Vector3(0f, 0.36f - p.y, 0f - p.z));
			float[] array = new float[2] { -1f, 1f };
			foreach (float num4 in array)
			{
				maillage.Quad(1, new Vector3(0f - xi, 0.43f, num4 * num2), new Vector3(xi, 0.43f, num4 * num2), new Vector3(xi, 0.43f, num4 * num), new Vector3(0f - xi, 0.43f, num4 * num), new Vector2((0f - xi) / 0.7f, num2 / 0.7f), new Vector2(xi / 0.7f, num2 / 0.7f), new Vector2(xi / 0.7f, num / 0.7f), new Vector2((0f - xi) / 0.7f, num / 0.7f), Vector3.up);
			}
			array = new float[2] { -1f, 1f };
			foreach (float num5 in array)
			{
				maillage.Quad(1, new Vector3(num5 * xi, 0.43f, 0f - num), new Vector3(num5 * demiL, 0.43f, 0f - num), new Vector3(num5 * demiL, 0.43f, num), new Vector3(num5 * xi, 0.43f, num), new Vector2(0f, (0f - num) / 0.7f), new Vector2(4f / 35f, (0f - num) / 0.7f), new Vector2(4f / 35f, num / 0.7f), new Vector2(0f, num / 0.7f), Vector3.up);
				List<Vector3> list = new List<Vector3>();
				for (int num6 = 0; num6 <= 16; num6++)
				{
					list.Add(Cercle(num5 * xi, 0.225f, Mathf.Lerp(0f - phiInt, phiInt, (float)num6 / 16f)));
				}
				maillage.Eventail(1, new Vector3(num5 * xi, 0.36f, 0f), list, (Vector3 p) => new Vector2(p.z / 0.7f, p.y / 0.7f), new Vector3(0f - num5, 0f, 0f));
				List<Vector3> list2 = new List<Vector3>();
				for (int num7 = 0; num7 <= 20; num7++)
				{
					list2.Add(Cercle(num5 * demiL, 0.29f, Mathf.Lerp(0f - phiExt, phiExt, (float)num7 / 20f)));
				}
				maillage.Eventail(2, new Vector3(num5 * demiL, 0.36f, 0f), list2, (Vector3 p) => Materiaux.CentreCernes + new Vector2(p.z, p.y - 0.36f) / 0.29f * Materiaux.RayonCernes * 0.95f, new Vector3(num5, 0f, 0f));
			}
			Surface(transform, "tronc", maillage, Materiaux.Ecorce, Materiaux.Bois, Materiaux.Ecorce);
			array = new float[2] { -1f, 1f };
			foreach (float num8 in array)
			{
				Rondin(transform, new Vector3(num8 * 0.46f, 0.05f, -0.3f), new Vector3(num8 * 0.46f, 0.05f, 0.3f), 0.1f);
			}
			float num9 = 0.29000002f;
			float num10 = Mathf.Sqrt(0.050624996f - (0.36f - num9) * (0.36f - num9)) - 0.012f;
			Zone z = new Zone
			{
				Centre = new Vector3(0f, num9, 0f),
				Demi = new Vector2(xi - 0.01f, num10)
			};
			LitDePaille(transform, z, 0f, 2);
			g.Zones.Add(new Zone
			{
				Centre = z.Centre + Vector3.up * 0.02f,
				Demi = new Vector2(xi - 0.03f, num10 - 0.03f)
			});
			g.CentreBoite = new Vector3(0f, 0.215f, 0f);
			g.TailleBoite = new Vector3(1.45f, 0.43f, 0.58f);
			static Vector3 Cercle(float x, float rayon, float phi)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(x, 0.36f - rayon * Mathf.Cos(phi), rayon * Mathf.Sin(phi));
			}
		}

		private static void Baquet(Gabarit g)
		{
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: 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_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_066b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = g.Visuel.transform;
			Material val = Materiaux.Tonneau ?? Materiaux.Bois;
			Maillage maillage = new Maillage();
			maillage.Grille(0, 48, 2, (float s, float u) => P(s * (MathF.PI * 2f), Rayon(u * 0.4f), u * 0.4f), (float s, float u) => new Vector2(s * 2f, Mathf.Lerp(0.278f, 0.378f, u)), (Vector3 p) => new Vector3(p.x, 0f, p.z));
			maillage.Grille(0, 48, 2, (float s, float u) => P(s * (MathF.PI * 2f), Rayon(u * 0.4f) - 0.03f, 0.04f + u * 0.36f), (float s, float u) => new Vector2(s * 2f, Mathf.Lerp(0.278f, 0.378f, u)), (Vector3 p) => new Vector3(0f - p.x, 0f, 0f - p.z));
			maillage.Grille(0, 48, 1, (float s, float u) => P(s * (MathF.PI * 2f), 0.42f + u * 0.03f, 0.4f), (float s, float u) => new Vector2(s * 2f, 0.33f), (Vector3 p) => Vector3.up);
			float[] array = new float[2] { 0.055f, 0.315f };
			foreach (float y0 in array)
			{
				maillage.Grille(0, 48, 1, (float s, float u) => P(s * (MathF.PI * 2f), Rayon(y0 + u * 0.045f) + 0.008f, y0 + u * 0.045f), (float s, float u) => new Vector2(s * 2f, 0.54f), (Vector3 p) => new Vector3(p.x, 0f, p.z));
				maillage.Grille(0, 48, 1, (float s, float u) => P(s * (MathF.PI * 2f), Rayon(y0 + 0.045f) + u * 0.008f, y0 + 0.045f), (float s, float u) => new Vector2(s * 2f, 0.54f), (Vector3 p) => Vector3.up);
				maillage.Grille(0, 48, 1, (float s, float u) => P(s * (MathF.PI * 2f), Rayon(y0) + u * 0.008f, y0), (float s, float u) => new Vector2(s * 2f, 0.54f), (Vector3 p) => Vector3.down);
			}
			array = new float[2] { -1f, 1f };
			foreach (float num2 in array)
			{
				float num3 = num2 * 0.42f;
				float num4 = num2 * 0.45f;
				float num5 = 0.4f;
				float num6 = 0.49f;
				maillage.Quad(0, new Vector3(num4, num5, -0.055f), new Vector3(num4, num6, -0.044f), new Vector3(num4, num6, 0.044f), new Vector3(num4, num5, 0.055f), new Vector2(0.1f, 0.278f), new Vector2(0.1f, 0.378f), new Vector2(0.16f, 0.378f), new Vector2(0.16f, 0.278f), new Vector3(num2, 0f, 0f));
				maillage.Quad(0, new Vector3(num3, num5, -0.055f), new Vector3(num3, num6, -0.044f), new Vector3(num3, num6, 0.044f), new Vector3(num3, num5, 0.055f), new Vector2(0.1f, 0.278f), new Vector2(0.1f, 0.378f), new Vector2(0.16f, 0.378f), new Vector2(0.16f, 0.278f), new Vector3(0f - num2, 0f, 0f));
				maillage.Quad(0, new Vector3(num3, num6, -0.044f), new Vector3(num4, num6, -0.044f), new Vector3(num4, num6, 0.044f), new Vector3(num3, num6, 0.044f), new Vector2(0.1f, 0.278f), new Vector2(0.1f, 0.288f), new Vector2(0.16f, 0.288f), new Vector2(0.16f, 0.278f), Vector3.up);
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num8 in array2)
				{
					maillage.Quad(0, new Vector3(num3, num5, num8 * 0.055f), new Vector3(num4, num5, num8 * 0.055f), new Vector3(num4, num6, num8 * 0.055f * 0.8f), new Vector3(num3, num6, num8 * 0.055f * 0.8f), new Vector2(0.1f, 0.278f), new Vector2(0.11f, 0.278f), new Vector2(0.11f, 0.378f), new Vector2(0.1f, 0.378f), new Vector3(0f, 0f, num8));
				}
			}
			Surface(transform, "baquet", maillage, val);
			Zone z = new Zone
			{
				Centre = new Vector3(0f, 0.27f, 0f),
				Demi = new Vector2(Rayon(0.27f) - 0.03f - 0.005f, 0f),
				Ronde = true
			};
			LitDePaille(transform, z, 0f, 3);
			g.Zones.Add(new Zone
			{
				Centre = z.Centre + Vector3.up * 0.02f,
				Demi = new Vector2(z.Demi.x - 0.02f, 0f),
				Ronde = true
			});
			g.CentreBoite = new Vector3(0f, 0.2f, 0f);
			g.TailleBoite = new Vector3(0.9f, 0.4f, 0.9f);
			g.Ronde = true;
			static Vector3 P(float a, float rayon, float num9)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(Mathf.Cos(a) * rayon, num9, Mathf.Sin(a) * rayon);
			}
			static float Rayon(float num9)
			{
				return Mathf.Lerp(0.4f, 0.45f, num9 / 0.4f);
			}
		}

		private static void Pierre(Gabarit g)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0155: 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)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_019b: 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_01aa: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = g.Visuel.transform;
			Mesh maillage = Materiaux.BlocPierre ?? Materiaux.Planche;
			Material materiau = PierreSombre();
			Morceau(transform, "socle", maillage, materiau, new Vector3(0f, 0.06f, 0f), Quaternion.identity, new Vector3(1.4f, 0.12f, 0.74f));
			float[] array = new float[2] { -1f, 1f };
			foreach (float num in array)
			{
				Morceau(transform, "flanc", maillage, materiau, new Vector3(0f, 0.26999998f, num * 0.315f), Quaternion.identity, new Vector3(1.4f, 0.29999998f, 0.11f));
			}
			array = new float[2] { -1f, 1f };
			foreach (float num2 in array)
			{
				Morceau(transform, "bout", maillage, materiau, new Vector3(num2 * 0.645f, 0.26999998f, 0f), Quaternion.identity, new Vector3(0.11f, 0.29999998f, 0.53999996f));
			}
			Zone z = new Zone
			{
				Centre = new Vector3(0f, 0.28f, 0f),
				Demi = new Vector2(0.585f, 0.255f)
			};
			LitDePaille(transform, z, 0f, 5);
			g.Zones.Add(new Zone
			{
				Centre = z.Centre + Vector3.up * 0.02f,
				Demi = z.Demi - new Vector2(0.02f, 0.02f)
			});
			g.CentreBoite = new Vector3(0f, 0.21f, 0f);
			g.TailleBoite = new Vector3(1.4f, 0.42f, 0.74f);
		}
	}
	[BepInPlugin("com.Azura.feedingtrough", "FeedingTrough", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.Azura.feedingtrough";

		public const string PluginName = "FeedingTrough";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<float> Portee;

		public static ConfigEntry<bool> NourrirSauvages;

		public static ConfigEntry<bool> JournalRepas;

		private static ManualLogSource journal;

		public static readonly Dictionary<string, GameObject> Pieces = new Dictionary<string, GameObject>();

		private static GameObject conteneur;

		public static string Nom => "FeedingTrough";

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			journal = ((BaseUnityPlugin)this).Logger;
			Portee = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SearchRange", 15f, new ConfigDescription("How far (meters) hungry animals look for a feeding trough.\nDistance (en mètres) à laquelle les animaux affamés cherchent une mangeoire.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 50f), Array.Empty<object>()));
			NourrirSauvages = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FeedWildAnimals", false, "true = wild (not yet tamed) animals also eat from troughs, which tames them over time like food on the ground.\ntrue = les animaux sauvages (pas encore apprivoisés) mangent aussi dans les mangeoires, ce qui les apprivoise peu à peu comme la nourriture au sol.");
			JournalRepas = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LogMeals", false, "Log every meal taken from a trough (debugging).\nNote chaque repas pris à une mangeoire dans le journal (dépannage).");
			new Harmony("com.Azura.feedingtrough").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)Textes.T("journal_charge", "FeedingTrough", "1.0.0"));
		}

		public static void Journal(string message)
		{
			if (JournalRepas != null && JournalRepas.Value)
			{
				ManualLogSource obj = journal;
				if (obj != null)
				{
					obj.LogInfo((object)message);
				}
			}
		}

		public static string NomPrefab(string id)
		{
			return "piece_feedingtrough_" + id;
		}

		private static Transform Conteneur()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)conteneur == (Object)null)
			{
				conteneur = new GameObject("FeedingTrough_Prefabs");
				conteneur.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)conteneur);
			}
			return conteneur.transform;
		}

		public static void Enregistrer(ZNetScene scene)
		{
			if ((Object)(object)scene == (Object)null)
			{
				return;