Decompiled source of FrogCourier v1.2.1

FrogCourier.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Newtonsoft.Json.Linq;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[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("FrogCourier")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("FrogCourier")]
[assembly: AssemblyTitle("FrogCourier")]
[assembly: AssemblyVersion("1.2.1.0")]
namespace FrogCourier;

internal static class FrogAudio
{
	internal enum Kind
	{
		Croak,
		Happy,
		Sad
	}

	private const int SampleRate = 22050;

	private static AudioClip _croak;

	private static AudioClip _happy;

	private static AudioClip _sad;

	internal static void Setup(AudioSource source)
	{
		if (!((Object)(object)source == (Object)null))
		{
			source.playOnAwake = false;
			source.spatialBlend = 1f;
			source.rolloffMode = (AudioRolloffMode)0;
			source.minDistance = 2f;
			source.maxDistance = 26f;
			source.dopplerLevel = 0f;
			source.volume = 0.6f;
		}
	}

	internal static void Play(AudioSource source, Kind kind, float volume = 0.55f)
	{
		if (!((Object)(object)source == (Object)null) && FrogConfig.PlaySounds.Value)
		{
			AudioClip val = Clip(kind);
			if ((Object)(object)val != (Object)null)
			{
				source.PlayOneShot(val, volume);
			}
		}
	}

	private static AudioClip Clip(Kind kind)
	{
		switch (kind)
		{
		case Kind.Happy:
			if ((Object)(object)_happy == (Object)null)
			{
				_happy = MakeCroak("FrogHappy", 260f, 330f, 0.16f, 1, 0.05f);
			}
			return _happy;
		case Kind.Sad:
			if ((Object)(object)_sad == (Object)null)
			{
				_sad = MakeCroak("FrogSad", 155f, 90f, 0.44f, 1, 0.06f);
			}
			return _sad;
		default:
			if ((Object)(object)_croak == (Object)null)
			{
				_croak = MakeCroak("FrogCroak", 170f, 215f, 0.3f, 2, 0.09f);
			}
			return _croak;
		}
	}

	private static AudioClip MakeCroak(string name, float fromHz, float toHz, float seconds, int pulses, float rasp)
	{
		int num = Mathf.Max(64, (int)(22050f * seconds));
		float[] array = new float[num];
		Random random = new Random(name.GetHashCode());
		float num2 = 0f;
		float num3 = 0f;
		float length = ((pulses == 2) ? (seconds * 0.42f) : seconds);
		float start = ((pulses == 2) ? (seconds * 0.5f) : 0f);
		for (int i = 0; i < num; i++)
		{
			float num4 = (float)i / 22050f;
			float num5 = (float)i / (float)num;
			float num6 = Mathf.Lerp(fromHz, toHz, num5);
			num2 += MathF.PI * 2f * num6 / 22050f;
			float num7 = Pulse(num4, 0f, length);
			if (pulses == 2)
			{
				num7 += 0.85f * Pulse(num4, start, length);
			}
			float num8 = 0.72f + 0.28f * Mathf.Sin(num4 * MathF.PI * 2f * 28f);
			float num9 = Mathf.Sin(num2) * 0.62f + Mathf.Sin(num2 * 2f + 0.3f) * 0.26f + Mathf.Sin(num2 * 3f) * 0.12f + ((float)random.NextDouble() * 2f - 1f) * rasp;
			num9 *= num8;
			num3 = Mathf.Lerp(num3, num9, 0.42f);
			array[i] = Mathf.Clamp(num3 * num7 * 0.85f, -1f, 1f);
		}
		AudioClip obj = AudioClip.Create(name, num, 1, 22050, false);
		obj.SetData(array, 0);
		return obj;
	}

	private static float Pulse(float t, float start, float length)
	{
		if (length <= 0f)
		{
			return 0f;
		}
		float num = (t - start) / length;
		if (num <= 0f || num >= 1f)
		{
			return 0f;
		}
		return Mathf.Sin(num * MathF.PI);
	}
}
internal static class FrogConfig
{
	public static ConfigEntry<string> CommandKey;

	public static ConfigEntry<bool> SpawnForOtherPlayers;

	public static ConfigEntry<bool> ShowHud;

	public static ConfigEntry<bool> PlaySounds;

	public static ConfigEntry<float> FrogScale;

	public static ConfigEntry<string> RotateKey;

	public static ConfigEntry<float> FrogSpeed;

	public static ConfigEntry<float> CarrySpeedMultiplier;

	public static ConfigEntry<float> FollowDistance;

	public static ConfigEntry<float> SideOffset;

	public static ConfigEntry<float> WanderRadius;

	public static ConfigEntry<float> WanderSpeedMultiplier;

	public static ConfigEntry<float> WanderIntervalMin;

	public static ConfigEntry<float> WanderIntervalMax;

	public static ConfigEntry<float> DropChance;

	public static ConfigEntry<float> BreakChanceBase;

	public static ConfigEntry<float> BreakChanceValueScale;

	public static ConfigEntry<float> BreakChanceMax;

	public static ConfigEntry<float> BreakValueLossMin;

	public static ConfigEntry<float> BreakValueLossMax;

	public static ConfigEntry<float> DistractionChance;

	public static ConfigEntry<float> HeavyItemSlowdown;

	public static ConfigEntry<float> GiveUpSeconds;

	public static ConfigEntry<float> CroakIntervalMin;

	public static ConfigEntry<float> CroakIntervalMax;

	public static ConfigEntry<float> DistractChance;

	public static ConfigEntry<float> DistractDuration;

	public static ConfigEntry<float> DistractRange;

	public static ConfigEntry<float> DistractCooldown;

	public static ConfigEntry<float> DistractEnemyDistance;

	public static void Init(ConfigFile cfg)
	{
		CommandKey = cfg.Bind<string>("1. Управление", "Кнопка", "R", "Клавиша приказа жабе. Наведись на ценный предмет и нажми — жаба понесёт его к точке сдачи. Нажатие во время переноски — вернуть жабу (предмет она бросит). По умолчанию R: G в игре занята колесом эмоций.");
		SpawnForOtherPlayers = cfg.Bind<bool>("2. Жаба", "Жабы других игроков", true, "Показывать жаб всех игроков. В мультиплеере они видны только локально (без сетевой синхронизации).");
		ShowHud = cfg.Bind<bool>("2. Жаба", "Показывать подсказку", true, "Показывать состояние твоей жабы и подсказку по кнопке в углу экрана.");
		PlaySounds = cfg.Bind<bool>("2. Жаба", "Звуки жабы", true, "Кваканье, довольное и грустное кваканье.");
		FrogScale = cfg.Bind<float>("2. Жаба", "Размер", 0.95f, "Масштаб модели жабы. 1.0 — примерно по пояс игроку.");
		RotateKey = cfg.Bind<string>("1. Управление", "Кнопка поворота груза", "T", "Пока жаба несёт предмет, нажатие поворачивает его на 90°, чтобы проходить в двери и узкие места.");
		FollowDistance = cfg.Bind<float>("3. Поведение", "Дистанция следования", 6f, "На каком расстоянии жаба держится от хозяина. Больше — не путается под ногами.");
		SideOffset = cfg.Bind<float>("3. Поведение", "Смещение вбок", 2f, "Насколько жаба смещается в сторону от хозяина, чтобы не стоять прямо за спиной.");
		WanderRadius = cfg.Bind<float>("3. Поведение", "Радиус прогулки", 8f, "Максимальный радиус, в котором жаба гуляет сама, не убегая от хозяина.");
		WanderSpeedMultiplier = cfg.Bind<float>("3. Поведение", "Скорость прогулки", 0.65f, "Множитель скорости, когда жаба просто гуляет.");
		WanderIntervalMin = cfg.Bind<float>("3. Поведение", "Прогулка: интервал мин", 6f, "Минимум секунд между самостоятельными прогулками.");
		WanderIntervalMax = cfg.Bind<float>("3. Поведение", "Прогулка: интервал макс", 15f, "Максимум секунд между самостоятельными прогулками.");
		FrogSpeed = cfg.Bind<float>("4. Баланс", "Скорость жабы", 6f, "Скорость пустой жабы, м/с. Игрок бежит быстрее — жаба экономит время только на длинных дистанциях.");
		CarrySpeedMultiplier = cfg.Bind<float>("4. Баланс", "Скорость с грузом", 0.78f, "Множитель скорости, когда жаба несёт предмет.");
		DropChance = cfg.Bind<float>("4. Баланс", "Шанс уронить предмет", 0.1f, "Вероятность, что жаба уронит предмет по дороге. Предмет падает и может разбиться сам.");
		BreakChanceBase = cfg.Bind<float>("4. Баланс", "Шанс разбить (база)", 0.06f, "Базовый шанс, что жаба разобьёт предмет по дороге.");
		BreakChanceValueScale = cfg.Bind<float>("4. Баланс", "Шанс разбить (за цену)", 0.22f, "Дополнительный шанс разбить предмет за каждые 600$. Дорогие предметы жаба бьёт чаще.");
		BreakChanceMax = cfg.Bind<float>("4. Баланс", "Шанс разбить (максимум)", 0.35f, "Потолок шанса разбить предмет.");
		BreakValueLossMin = cfg.Bind<float>("4. Баланс", "Потеря при ударе (мин)", 0.3f, "Минимальная доля стоимости, которую жаба отбивает при ударе.");
		BreakValueLossMax = cfg.Bind<float>("4. Баланс", "Потеря при ударе (макс)", 0.55f, "Максимальная доля стоимости, которую жаба отбивает при ударе. Если стоимость падает почти до нуля — предмет уничтожается.");
		DistractionChance = cfg.Bind<float>("4. Баланс", "Шанс испугаться с грузом", 0.3f, "Шанс, что жаба бросит предмет и убежит, если рядом монстр (когда она что-то несёт).");
		HeavyItemSlowdown = cfg.Bind<float>("4. Баланс", "Замедление от веса", 0.25f, "Насколько сильно тяжёлый предмет замедляет жабу (0 — не замедляет, 1 — очень сильно).");
		GiveUpSeconds = cfg.Bind<float>("4. Баланс", "Терпение жабы", 6f, "Сколько секунд жаба пытается обойти препятствие, прежде чем бросить предмет.");
		CroakIntervalMin = cfg.Bind<float>("5. Характер", "Кваканье: интервал мин", 12f, "Минимум секунд между случайными «ква» (когда жаба отдыхает рядом).");
		CroakIntervalMax = cfg.Bind<float>("5. Характер", "Кваканье: интервал макс", 34f, "Максимум секунд между случайными «ква».");
		DistractChance = cfg.Bind<float>("5. Характер", "Шанс отвлечь монстра", 0.45f, "Шанс, что жаба не прибежит к хозяину, а пойдёт отвлекать монстра (если она не несёт предмет).");
		DistractDuration = cfg.Bind<float>("5. Характер", "Сколько отвлекает", 5f, "Секунд, в течение которых жаба прыгает у монстра и зовёт его на себя.");
		DistractRange = cfg.Bind<float>("5. Характер", "Радиус поиска монстра", 14f, "С какого расстояния жаба замечает монстра и может пойти отвлекать.");
		DistractCooldown = cfg.Bind<float>("5. Характер", "Перерыв между отвлечениями", 22f, "Секунд после отвлечения, прежде чем жаба снова решит дразнить монстра.");
		DistractEnemyDistance = cfg.Bind<float>("5. Характер", "Дистанция дразнения", 4.5f, "На какое расстояние жаба подбегает к монстру, чтобы отвлечь его.");
	}
}
[BepInPlugin("com.qwerty.frogcourier", "Frog Courier", "1.2.1")]
public sealed class FrogCourierPlugin : BaseUnityPlugin
{
	public const string Guid = "com.qwerty.frogcourier";

	internal static FrogCourierPlugin Instance;

	internal static ManualLogSource Log;

	private FrogManager _manager;

	private FrogHud _hud;

	private void Awake()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		FrogConfig.Init(((BaseUnityPlugin)this).Config);
		GameObject val = new GameObject("FrogCourier");
		Object.DontDestroyOnLoad((Object)(object)val);
		_manager = val.AddComponent<FrogManager>();
		_hud = val.AddComponent<FrogHud>();
		Log.LogInfo((object)("Frog Courier v1.2.1 loaded. " + FrogConfig.CommandKey.Value + " = отправить/вернуть жабу."));
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}
}
internal static class FrogGlbModel
{
	private sealed class BuildContext
	{
		public JArray Nodes;

		public JArray Meshes;

		public JArray Materials;

		public JArray Accessors;

		public JArray BufferViews;

		public byte[] Bin;

		public int BinStart;

		public Transform Model;

		public Dictionary<int, Material> MaterialCache;

		public Color Accent;

		public float MinY;

		public float MaxY;

		public int MeshCounter;
	}

	private const string ResourceName = "FrogCourier.pepe_frog_santa.glb";

	private static readonly Color BodyGreen = new Color(0.43f, 0.66f, 0.16f);

	internal static FrogRig TryBuild(Transform parent, Color accent)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			byte[] array = LoadResource();
			if (array == null)
			{
				return null;
			}
			return Build(parent, accent, array);
		}
		catch (Exception ex)
		{
			FrogCourierPlugin.Log.LogWarning((object)("Не удалось загрузить GLB-модель жабы: " + ex.Message));
			return null;
		}
	}

	private static byte[] LoadResource()
	{
		using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FrogCourier.pepe_frog_santa.glb");
		if (stream == null)
		{
			return null;
		}
		using MemoryStream memoryStream = new MemoryStream();
		stream.CopyTo(memoryStream);
		return memoryStream.ToArray();
	}

	private static FrogRig Build(Transform parent, Color accent, byte[] data)
	{
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: 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_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		if (data.Length < 20)
		{
			return null;
		}
		if (BitConverter.ToInt32(data, 0) != 1179937895)
		{
			return null;
		}
		int num = BitConverter.ToInt32(data, 12);
		int num2 = 20;
		string text = Encoding.UTF8.GetString(data, num2, num).TrimEnd('\0', ' ');
		int num3 = num2 + num;
		int num4 = BitConverter.ToInt32(data, num3);
		int num5 = num3 + 8;
		if (num4 <= 0 || num5 + num4 > data.Length)
		{
			return null;
		}
		JObject obj = JObject.Parse(text);
		JToken obj2 = obj["nodes"];
		JArray val = (JArray)(object)((obj2 is JArray) ? obj2 : null);
		JToken obj3 = obj["meshes"];
		JArray val2 = (JArray)(object)((obj3 is JArray) ? obj3 : null);
		JToken obj4 = obj["materials"];
		JArray materials = (JArray)(object)((obj4 is JArray) ? obj4 : null);
		JToken obj5 = obj["accessors"];
		JArray val3 = (JArray)(object)((obj5 is JArray) ? obj5 : null);
		JToken obj6 = obj["bufferViews"];
		JArray val4 = (JArray)(object)((obj6 is JArray) ? obj6 : null);
		JToken obj7 = obj["scenes"];
		JArray val5 = (JArray)(object)((obj7 is JArray) ? obj7 : null);
		if (val == null || val2 == null || val3 == null || val4 == null)
		{
			return null;
		}
		Transform transform = new GameObject("Visual").transform;
		transform.SetParent(parent, false);
		Transform transform2 = new GameObject("Model").transform;
		transform2.SetParent(transform, false);
		Dictionary<int, Material> materialCache = new Dictionary<int, Material>();
		float minY = float.MaxValue;
		float maxY = float.MinValue;
		BuildContext buildContext = new BuildContext
		{
			Nodes = val,
			Meshes = val2,
			Materials = materials,
			Accessors = val3,
			BufferViews = val4,
			Bin = data,
			BinStart = num5,
			Model = transform2,
			MaterialCache = materialCache,
			Accent = accent,
			MinY = minY,
			MaxY = maxY
		};
		JArray val6 = (JArray)((val5 != null && ((JContainer)val5).Count > 0) ? /*isinst with value type is only supported in some contexts*/: null);
		if (val6 != null)
		{
			foreach (JToken item in val6)
			{
				Walk(buildContext, (int)item, Matrix4x4.identity);
			}
		}
		else
		{
			for (int i = 0; i < ((JContainer)val).Count; i++)
			{
				Walk(buildContext, i, Matrix4x4.identity);
			}
		}
		if (buildContext.MinY > buildContext.MaxY)
		{
			return null;
		}
		transform2.localPosition = new Vector3(0f, 0f - buildContext.MinY, 0f);
		FrogRig obj8 = new FrogRig
		{
			Visual = transform,
			Hat = null,
			HatBaseRotation = Quaternion.identity
		};
		Transform transform3 = new GameObject("CarryPoint").transform;
		transform3.SetParent(transform, false);
		float num6 = Mathf.Clamp((buildContext.MaxY - buildContext.MinY) * 0.82f, 0.55f, 1.1f);
		transform3.localPosition = new Vector3(0f, num6, -0.3f);
		obj8.CarryPoint = transform3;
		return obj8;
	}

	private static void Walk(BuildContext ctx, int nodeIndex, Matrix4x4 parent)
	{
		//IL_0029: 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_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_004c: 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)
		if (nodeIndex < 0 || nodeIndex >= ((JContainer)ctx.Nodes).Count)
		{
			return;
		}
		JToken obj = ctx.Nodes[nodeIndex];
		JObject val = (JObject)(object)((obj is JObject) ? obj : null);
		if (val == null)
		{
			return;
		}
		Matrix4x4 val2 = parent * NodeMatrix(val);
		JToken val3 = val["mesh"];
		if (val3 != null)
		{
			BuildNodeMesh(ctx, (int)val3, val2, (val["name"] != null) ? ((object)val["name"]).ToString() : "FrogPart");
		}
		JToken obj2 = val["children"];
		JArray val4 = (JArray)(object)((obj2 is JArray) ? obj2 : null);
		if (val4 == null)
		{
			return;
		}
		foreach (JToken item in val4)
		{
			Walk(ctx, (int)item, val2);
		}
	}

	private static void BuildNodeMesh(BuildContext ctx, int meshIndex, Matrix4x4 world, string nodeName)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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_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_015f: 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_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		if (meshIndex < 0 || meshIndex >= ((JContainer)ctx.Meshes).Count)
		{
			return;
		}
		JToken obj = ctx.Meshes[meshIndex];
		JObject val = (JObject)(object)((obj is JObject) ? obj : null);
		if (val == null)
		{
			return;
		}
		JToken obj2 = val["primitives"];
		JArray val2 = (JArray)(object)((obj2 is JArray) ? obj2 : null);
		if (val2 == null)
		{
			return;
		}
		Matrix4x4 inverse = ((Matrix4x4)(ref world)).inverse;
		Matrix4x4 transpose = ((Matrix4x4)(ref inverse)).transpose;
		bool flag = ((Matrix4x4)(ref world)).determinant < 0f;
		for (int i = 0; i < ((JContainer)val2).Count; i++)
		{
			JToken obj3 = val2[i];
			JObject val3 = (JObject)(object)((obj3 is JObject) ? obj3 : null);
			if (val3 == null)
			{
				continue;
			}
			JToken obj4 = val3["attributes"];
			JObject val4 = (JObject)(object)((obj4 is JObject) ? obj4 : null);
			if (val4 == null)
			{
				continue;
			}
			JToken val5 = val4["POSITION"];
			if (val5 == null)
			{
				continue;
			}
			Vector3[] array = ReadVec3(ctx, (int)val5);
			if (array == null || array.Length == 0)
			{
				continue;
			}
			Vector3[] array2 = ((val4["NORMAL"] != null) ? ReadVec3(ctx, (int)val4["NORMAL"]) : null);
			int[] array3 = ((val3["indices"] != null) ? ReadIndices(ctx, (int)val3["indices"]) : null);
			if (array3 == null)
			{
				array3 = new int[array.Length];
				for (int j = 0; j < array3.Length; j++)
				{
					array3[j] = j;
				}
			}
			for (int k = 0; k < array.Length; k++)
			{
				array[k] = ((Matrix4x4)(ref world)).MultiplyPoint3x4(array[k]);
				if (array[k].y < ctx.MinY)
				{
					ctx.MinY = array[k].y;
				}
				if (array[k].y > ctx.MaxY)
				{
					ctx.MaxY = array[k].y;
				}
			}
			if (array2 != null)
			{
				for (int l = 0; l < array2.Length; l++)
				{
					int num = l;
					Vector3 val6 = ((Matrix4x4)(ref transpose)).MultiplyVector(array2[l]);
					array2[num] = ((Vector3)(ref val6)).normalized;
				}
			}
			if (flag)
			{
				for (int m = 0; m + 2 < array3.Length; m += 3)
				{
					int num2 = array3[m + 1];
					array3[m + 1] = array3[m + 2];
					array3[m + 2] = num2;
				}
			}
			Mesh val7 = new Mesh
			{
				name = nodeName + "_" + i
			};
			val7.SetVertices(new List<Vector3>(array));
			if (array2 != null)
			{
				val7.SetNormals(new List<Vector3>(array2));
			}
			val7.SetTriangles(array3, 0);
			if (array2 == null)
			{
				val7.RecalculateNormals();
			}
			val7.RecalculateBounds();
			GameObject val8 = new GameObject(nodeName + "_" + ctx.MeshCounter++);
			val8.transform.SetParent(ctx.Model, false);
			val8.AddComponent<MeshFilter>().sharedMesh = val7;
			int index = ((val3["material"] != null) ? ((int)val3["material"]) : 0);
			MeshRenderer obj5 = val8.AddComponent<MeshRenderer>();
			((Renderer)obj5).sharedMaterial = GetMaterial(ctx, index);
			((Renderer)obj5).shadowCastingMode = (ShadowCastingMode)1;
		}
	}

	private static Material GetMaterial(BuildContext ctx, int index)
	{
		//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_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_011b: 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)
		if (ctx.MaterialCache.TryGetValue(index, out var value))
		{
			return value;
		}
		Color color = BodyGreen;
		float num = 0.55f;
		if (ctx.Materials != null && index >= 0 && index < ((JContainer)ctx.Materials).Count)
		{
			JToken obj = ctx.Materials[index];
			JObject val = (JObject)(object)((obj is JObject) ? obj : null);
			if (val != null)
			{
				JToken obj2 = val["pbrMetallicRoughness"];
				JObject val2 = (JObject)(object)((obj2 is JObject) ? obj2 : null);
				if (val2 != null)
				{
					JToken obj3 = val2["baseColorFactor"];
					JArray val3 = (JArray)(object)((obj3 is JArray) ? obj3 : null);
					if (val3 != null && ((JContainer)val3).Count >= 3)
					{
						((Color)(ref color))..ctor((float)val3[0], (float)val3[1], (float)val3[2], (((JContainer)val3).Count > 3) ? ((float)val3[3]) : 1f);
					}
					if (val2["roughnessFactor"] != null)
					{
						num = (float)val2["roughnessFactor"];
					}
				}
			}
		}
		if (index == 0)
		{
			color = BodyGreen;
		}
		if (index == 2)
		{
			color = ctx.Accent;
		}
		Material val4 = FrogShader.Make(color, Mathf.Clamp01(1f - num));
		((Object)val4).name = "FrogGlbMat_" + index;
		ctx.MaterialCache[index] = val4;
		return val4;
	}

	private static Matrix4x4 NodeMatrix(JObject node)
	{
		//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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_0228: 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_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		JToken obj = node["matrix"];
		JArray val = (JArray)(object)((obj is JArray) ? obj : null);
		if (val != null && ((JContainer)val).Count == 16)
		{
			return new Matrix4x4(new Vector4((float)val[0], (float)val[1], (float)val[2], (float)val[3]), new Vector4((float)val[4], (float)val[5], (float)val[6], (float)val[7]), new Vector4((float)val[8], (float)val[9], (float)val[10], (float)val[11]), new Vector4((float)val[12], (float)val[13], (float)val[14], (float)val[15]));
		}
		Vector3 zero = Vector3.zero;
		Quaternion identity = Quaternion.identity;
		Vector3 one = Vector3.one;
		JToken obj2 = node["translation"];
		JArray val2 = (JArray)(object)((obj2 is JArray) ? obj2 : null);
		if (val2 != null && ((JContainer)val2).Count >= 3)
		{
			((Vector3)(ref zero))..ctor((float)val2[0], (float)val2[1], (float)val2[2]);
		}
		JToken obj3 = node["rotation"];
		JArray val3 = (JArray)(object)((obj3 is JArray) ? obj3 : null);
		if (val3 != null && ((JContainer)val3).Count >= 4)
		{
			((Quaternion)(ref identity))..ctor((float)val3[0], (float)val3[1], (float)val3[2], (float)val3[3]);
		}
		JToken obj4 = node["scale"];
		JArray val4 = (JArray)(object)((obj4 is JArray) ? obj4 : null);
		if (val4 != null && ((JContainer)val4).Count >= 3)
		{
			((Vector3)(ref one))..ctor((float)val4[0], (float)val4[1], (float)val4[2]);
		}
		return Matrix4x4.TRS(zero, identity, one);
	}

	private static Vector3[] ReadVec3(BuildContext ctx, int accessorIndex)
	{
		//IL_0113: 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)
		JToken obj = ctx.Accessors[accessorIndex];
		JObject val = (JObject)(object)((obj is JObject) ? obj : null);
		if (val == null)
		{
			return null;
		}
		int num = (int)val["count"];
		int num2 = 3;
		if (val["bufferView"] == null)
		{
			return null;
		}
		JToken obj2 = ctx.BufferViews[(int)val["bufferView"]];
		JObject val2 = (JObject)(object)((obj2 is JObject) ? obj2 : null);
		if (val2 == null)
		{
			return null;
		}
		int num3 = ((val2["byteStride"] != null) ? ((int)val2["byteStride"]) : (num2 * 4));
		int num4 = ctx.BinStart + ((val2["byteOffset"] != null) ? ((int)val2["byteOffset"]) : 0) + ((val["byteOffset"] != null) ? ((int)val["byteOffset"]) : 0);
		Vector3[] array = (Vector3[])(object)new Vector3[num];
		for (int i = 0; i < num; i++)
		{
			int num5 = num4 + i * num3;
			array[i] = new Vector3(BitConverter.ToSingle(ctx.Bin, num5), BitConverter.ToSingle(ctx.Bin, num5 + 4), BitConverter.ToSingle(ctx.Bin, num5 + 8));
		}
		return array;
	}

	private static int[] ReadIndices(BuildContext ctx, int accessorIndex)
	{
		JToken obj = ctx.Accessors[accessorIndex];
		JObject val = (JObject)(object)((obj is JObject) ? obj : null);
		if (val == null || val["bufferView"] == null)
		{
			return null;
		}
		int num = (int)val["count"];
		int num2 = (int)val["componentType"];
		JToken obj2 = ctx.BufferViews[(int)val["bufferView"]];
		JObject val2 = (JObject)(object)((obj2 is JObject) ? obj2 : null);
		if (val2 == null)
		{
			return null;
		}
		int num3 = num2 switch
		{
			5123 => 2, 
			5125 => 4, 
			_ => 1, 
		};
		int num4 = ((val2["byteStride"] != null) ? ((int)val2["byteStride"]) : num3);
		int num5 = ctx.BinStart + ((val2["byteOffset"] != null) ? ((int)val2["byteOffset"]) : 0) + ((val["byteOffset"] != null) ? ((int)val["byteOffset"]) : 0);
		int[] array = new int[num];
		for (int i = 0; i < num; i++)
		{
			int num6 = num5 + i * num4;
			switch (num2)
			{
			case 5125:
				array[i] = (int)BitConverter.ToUInt32(ctx.Bin, num6);
				break;
			case 5123:
				array[i] = BitConverter.ToUInt16(ctx.Bin, num6);
				break;
			default:
				array[i] = ctx.Bin[num6];
				break;
			}
		}
		return array;
	}
}
internal sealed class FrogHud : MonoBehaviour
{
	private static FrogHud _instance;

	private static string _message;

	private static float _messageUntil;

	private GUIStyle _label;

	private GUIStyle _title;

	private GUIStyle _messageStyle;

	private Texture2D _panel;

	private Texture2D _messagePanel;

	private void Awake()
	{
		//IL_001b: 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)
		_instance = this;
		_panel = Solid(new Color(0.04f, 0.06f, 0.05f, 0.72f));
		_messagePanel = Solid(new Color(0.04f, 0.06f, 0.05f, 0.82f));
	}

	private void OnDestroy()
	{
		if ((Object)(object)_instance == (Object)(object)this)
		{
			_instance = null;
		}
	}

	internal static void Notify(string text)
	{
		if (FrogConfig.ShowHud.Value)
		{
			_message = text;
			_messageUntil = Time.unscaledTime + 4.5f;
		}
	}

	private void OnGUI()
	{
		//IL_005e: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		if (!FrogConfig.ShowHud.Value || (Object)(object)FrogManager.Instance == (Object)null)
		{
			return;
		}
		FrogPet localFrog = FrogManager.Instance.LocalFrog;
		if (!((Object)(object)localFrog == (Object)null))
		{
			EnsureStyles();
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(16f, (float)Screen.height - 88f - 16f, 430f, 88f);
			GUI.DrawTexture(val, (Texture)(object)_panel);
			GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 8f, 406f, 22f), "ЖАБА-КУРЬЕР", _title);
			GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 30f, 406f, 22f), localFrog.StatusText, _label);
			GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 52f, 406f, 22f), localFrog.HintText, _label);
			if (!string.IsNullOrEmpty(_message) && Time.unscaledTime < _messageUntil)
			{
				float num = Mathf.Clamp01((_messageUntil - Time.unscaledTime) / 1.2f);
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor((float)Screen.width * 0.5f - 280f, (float)Screen.height - 150f, 560f, 30f);
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, Mathf.Min(1f, num));
				GUI.DrawTexture(val2, (Texture)(object)_messagePanel);
				GUI.Label(new Rect(((Rect)(ref val2)).x + 8f, ((Rect)(ref val2)).y + 5f, ((Rect)(ref val2)).width - 16f, 24f), _message, _messageStyle);
				GUI.color = color;
			}
		}
	}

	private void EnsureStyles()
	{
		//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_0021: 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_0034: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0083: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Expected O, but got Unknown
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		if (_label == null)
		{
			_label = new GUIStyle(GUI.skin.label)
			{
				fontSize = 13,
				wordWrap = false,
				alignment = (TextAnchor)3
			};
			_label.normal.textColor = new Color(0.86f, 0.93f, 0.82f);
			_title = new GUIStyle(GUI.skin.label)
			{
				fontSize = 11,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3
			};
			_title.normal.textColor = new Color(0.55f, 0.85f, 0.35f);
			_messageStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 13,
				alignment = (TextAnchor)4,
				wordWrap = true
			};
			_messageStyle.normal.textColor = new Color(1f, 0.95f, 0.7f);
		}
	}

	private static Texture2D Solid(Color color)
	{
		//IL_0004: 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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
		val.SetPixel(0, 0, color);
		val.Apply();
		((Object)val).hideFlags = (HideFlags)61;
		return val;
	}
}
internal sealed class FrogManager : MonoBehaviour
{
	private readonly List<FrogPet> _frogs = new List<FrogPet>();

	private float _nextScan;

	private float _nextDiag;

	private string _lastScene;

	private Key _key = (Key)32;

	private string _keyName;

	private Key _rotateKey = (Key)34;

	private string _rotateKeyName;

	internal static FrogManager Instance { get; private set; }

	internal FrogPet LocalFrog
	{
		get
		{
			for (int i = 0; i < _frogs.Count; i++)
			{
				FrogPet frogPet = _frogs[i];
				if (!((Object)(object)frogPet == (Object)null) && !((Object)(object)frogPet.Owner == (Object)null) && PlayerInfo.IsLocal(frogPet.Owner))
				{
					return frogPet;
				}
			}
			return null;
		}
	}

	private void Awake()
	{
		Instance = this;
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	private void Update()
	{
		//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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Invalid comparison between Unknown and I4
		RunManager instance = RunManager.instance;
		Scene activeScene = SceneManager.GetActiveScene();
		string name = ((Scene)(ref activeScene)).name;
		if (name != _lastScene)
		{
			_lastScene = name;
			FrogCourierPlugin.Log.LogInfo((object)("Frog scene: " + name));
		}
		bool flag = name == "Main";
		if (!flag && (Object)(object)instance != (Object)null)
		{
			object obj = Ref.Get<object>(instance, "levelCurrent");
			object obj2 = Ref.Get<object>(instance, "levelMainMenu");
			if (obj != null && obj2 != null)
			{
				flag = obj == obj2;
			}
		}
		int num = ExtractionPoints.All()?.Count ?? 0;
		bool flag2 = num > 0 || (int)Cursor.lockState == 1;
		if ((Object)(object)RoundDirector.instance == (Object)null || !flag2)
		{
			return;
		}
		if (_frogs.Count == 0 && Time.unscaledTime >= _nextDiag)
		{
			_nextDiag = Time.unscaledTime + 5f;
			string text = "null";
			string text2 = "null";
			if ((Object)(object)instance != (Object)null)
			{
				object obj3 = Ref.Get<object>(instance, "levelCurrent");
				Object val = (Object)((obj3 is Object) ? obj3 : null);
				object obj4 = Ref.Get<object>(instance, "levelMainMenu");
				Object val2 = (Object)((obj4 is Object) ? obj4 : null);
				if (val != (Object)null)
				{
					text = val.name;
				}
				if (val2 != (Object)null)
				{
					text2 = val2.name;
				}
			}
			FrogCourierPlugin.Log.LogInfo((object)("Frog diag: scene=" + name + " points=" + num + " inMenu=" + flag + " current=" + text + " menu=" + text2));
		}
		if (Time.unscaledTime >= _nextScan)
		{
			_nextScan = Time.unscaledTime + 0.5f;
			Scan();
		}
		HandleInput();
	}

	private void Scan()
	{
		PlayerAvatar[] array;
		try
		{
			array = Object.FindObjectsByType<PlayerAvatar>((FindObjectsSortMode)0);
		}
		catch (Exception ex)
		{
			FrogCourierPlugin.Log.LogWarning((object)("Не удалось получить список игроков: " + ex.Message));
			return;
		}
		for (int num = _frogs.Count - 1; num >= 0; num--)
		{
			FrogPet frogPet = _frogs[num];
			if ((Object)(object)frogPet == (Object)null)
			{
				_frogs.RemoveAt(num);
			}
			else if ((Object)(object)frogPet.Owner == (Object)null || !Contains(array, frogPet.Owner))
			{
				Object.Destroy((Object)(object)((Component)frogPet).gameObject);
				_frogs.RemoveAt(num);
			}
		}
		foreach (PlayerAvatar val in array)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val.playerTransform == (Object)null))
			{
				bool flag = PlayerInfo.IsLocal(val);
				if ((PlayerInfo.IsSpawned(val) || flag) && (!PlayerInfo.IsDisabled(val) || flag) && (flag || FrogConfig.SpawnForOtherPlayers.Value) && !HasFrog(val))
				{
					Spawn(val);
				}
			}
		}
	}

	private void Spawn(PlayerAvatar player)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_0027: 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_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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)
		//IL_005a: 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_005c: 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_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)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("FrogCourier_" + SafeName(PlayerInfo.Name(player)));
		Transform transform = val.transform;
		Vector3 val2 = player.playerTransform.position + player.playerTransform.forward * 1.3f + Vector3.up * 0.15f;
		RaycastHit val3 = default(RaycastHit);
		if (Physics.Raycast(val2 + Vector3.up * 2f, Vector3.down, ref val3, 6f, -5, (QueryTriggerInteraction)1))
		{
			val2.y = ((RaycastHit)(ref val3)).point.y + 0.02f;
		}
		transform.position = val2;
		FrogPet frogPet = val.AddComponent<FrogPet>();
		try
		{
			frogPet.Initialize(player);
			_frogs.Add(frogPet);
			ManualLogSource log = FrogCourierPlugin.Log;
			string[] obj = new string[7]
			{
				"Жаба создана для ",
				PlayerInfo.Name(player),
				" (local=",
				PlayerInfo.IsLocal(player).ToString(),
				", scene=",
				null,
				null
			};
			Scene activeScene = SceneManager.GetActiveScene();
			obj[5] = ((Scene)(ref activeScene)).name;
			obj[6] = ")";
			log.LogInfo((object)string.Concat(obj));
		}
		catch (Exception ex)
		{
			FrogCourierPlugin.Log.LogError((object)("Не удалось создать жабу: " + ex));
			Object.Destroy((Object)(object)val);
		}
	}

	private bool HasFrog(PlayerAvatar player)
	{
		for (int i = 0; i < _frogs.Count; i++)
		{
			FrogPet frogPet = _frogs[i];
			if ((Object)(object)frogPet != (Object)null && (Object)(object)frogPet.Owner == (Object)(object)player)
			{
				return true;
			}
		}
		return false;
	}

	private static bool Contains(PlayerAvatar[] players, PlayerAvatar player)
	{
		for (int i = 0; i < players.Length; i++)
		{
			if ((Object)(object)players[i] == (Object)(object)player)
			{
				return true;
			}
		}
		return false;
	}

	private void HandleInput()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Invalid comparison between Unknown and I4
		//IL_0084: 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_00bb: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		Keyboard current = Keyboard.current;
		if (current == null || ((Object)(object)GameDirector.instance != (Object)null && GameDirector.instance.DisableInput) || ((int)Cursor.lockState != 1 && Cursor.visible))
		{
			return;
		}
		InputManager instance = InputManager.instance;
		if ((Object)(object)instance != (Object)null && instance.textInputsActivePrevFrame)
		{
			return;
		}
		string value = FrogConfig.CommandKey.Value;
		if (_keyName != value)
		{
			_keyName = value;
			if (!Enum.TryParse<Key>(value, ignoreCase: true, out _key))
			{
				_key = (Key)32;
			}
		}
		string value2 = FrogConfig.RotateKey.Value;
		if (_rotateKeyName != value2)
		{
			_rotateKeyName = value2;
			if (!Enum.TryParse<Key>(value2, ignoreCase: true, out _rotateKey))
			{
				_rotateKey = (Key)34;
			}
		}
		FrogPet localFrog = LocalFrog;
		if ((Object)(object)localFrog == (Object)null)
		{
			return;
		}
		if ((int)_key != 0)
		{
			KeyControl val = current[_key];
			if (val != null && ((ButtonControl)val).wasPressedThisFrame)
			{
				localFrog.Command();
				return;
			}
		}
		if ((int)_rotateKey != 0)
		{
			KeyControl val2 = current[_rotateKey];
			if (val2 != null && ((ButtonControl)val2).wasPressedThisFrame)
			{
				localFrog.RotateCarried();
			}
		}
	}

	private void ClearAll()
	{
		for (int i = 0; i < _frogs.Count; i++)
		{
			FrogPet frogPet = _frogs[i];
			if ((Object)(object)frogPet != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)frogPet).gameObject);
			}
		}
		_frogs.Clear();
	}

	private static string SafeName(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			return "player";
		}
		return name.Replace(" ", "_");
	}
}
internal static class FrogShader
{
	private static Shader _lit;

	internal static Material Make(Color color, float smoothness = 0.5f)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_0044: 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_0080: 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)
		if ((Object)(object)_lit == (Object)null)
		{
			_lit = FindLit();
		}
		if ((Object)(object)_lit == (Object)null)
		{
			_lit = Shader.Find("Hidden/InternalErrorShader");
		}
		Material val = new Material(_lit);
		((Object)val).name = "FrogMat_" + ColorUtility.ToHtmlStringRGB(color);
		if (val.HasProperty("_BaseColor"))
		{
			val.SetColor("_BaseColor", color);
		}
		if (val.HasProperty("_Color"))
		{
			val.SetColor("_Color", color);
		}
		if (val.HasProperty("_Smoothness"))
		{
			val.SetFloat("_Smoothness", smoothness);
		}
		if (val.HasProperty("_Glossiness"))
		{
			val.SetFloat("_Glossiness", smoothness);
		}
		if (val.HasProperty("_Metallic"))
		{
			val.SetFloat("_Metallic", 0f);
		}
		if (val.HasProperty("_EmissionColor"))
		{
			val.SetColor("_EmissionColor", Color.black);
		}
		val.DisableKeyword("_EMISSION");
		return val;
	}

	private static Shader FindLit()
	{
		string[] array = new string[5] { "Universal Render Pipeline/Lit", "HDRP/Lit", "Standard", "Legacy Shaders/Diffuse", "Sprites/Default" };
		for (int i = 0; i < array.Length; i++)
		{
			Shader val = Shader.Find(array[i]);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return Shader.Find("Sprites/Default");
	}
}
internal sealed class FrogRig
{
	public Transform Visual;

	public Transform Hat;

	public Quaternion HatBaseRotation;

	public Transform CarryPoint;
}
internal static class FrogModel
{
	private static Mesh _bodyMesh;

	private static Mesh _lipsMesh;

	private static Mesh _seamMesh;

	private static Mesh _starMesh;

	private static Mesh _coneMesh;

	private static Mesh _brimMesh;

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

	internal static FrogRig Build(Transform parent, Color accent)
	{
		//IL_0001: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: 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_0140: 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_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: 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_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0571: 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_05a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ed: 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_0626: Unknown result type (might be due to invalid IL or missing references)
		//IL_062b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0630: Unknown result type (might be due to invalid IL or missing references)
		//IL_066e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0673: Unknown result type (might be due to invalid IL or missing references)
		//IL_0687: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_072c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_0763: Unknown result type (might be due to invalid IL or missing references)
		//IL_0777: Unknown result type (might be due to invalid IL or missing references)
		//IL_0797: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: 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_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		//IL_092f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0955: Unknown result type (might be due to invalid IL or missing references)
		//IL_0970: Unknown result type (might be due to invalid IL or missing references)
		//IL_0985: Unknown result type (might be due to invalid IL or missing references)
		//IL_098a: 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_04a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0834: Unknown result type (might be due to invalid IL or missing references)
		//IL_0848: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0905: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aaf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b27: Unknown result type (might be due to invalid IL or missing references)
		//IL_0543: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b68: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b6d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b77: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b7c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b81: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b95: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bd8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be4: Unknown result type (might be due to invalid IL or missing references)
		FrogRig frogRig = FrogGlbModel.TryBuild(parent, accent);
		if (frogRig != null)
		{
			return frogRig;
		}
		FrogRig frogRig2 = new FrogRig();
		Transform transform = new GameObject("Visual").transform;
		transform.SetParent(parent, false);
		frogRig2.Visual = transform;
		Material mat = FrogShader.Make(new Color(0.44f, 0.64f, 0.16f), 0.55f);
		Material mat2 = FrogShader.Make(new Color(0.66f, 0.8f, 0.3f), 0.55f);
		Material mat3 = FrogShader.Make(new Color(0.82f, 0.29f, 0.21f), 0.55f);
		Material mat4 = FrogShader.Make(new Color(0.52f, 0.13f, 0.11f), 0.4f);
		Material mat5 = FrogShader.Make(new Color(0.83f, 0.1f, 0.11f), 0.4f);
		Material mat6 = FrogShader.Make(new Color(0.97f, 0.96f, 0.93f), 0.2f);
		Material mat7 = FrogShader.Make(new Color(0.42f, 0.24f, 0.72f), 0.8f);
		Material mat8 = FrogShader.Make(new Color(0.03f, 0.03f, 0.04f), 0.85f);
		Material mat9 = FrogShader.Make(new Color(0.95f, 0.94f, 0.82f), 0.65f);
		Material mat10 = FrogShader.Make(new Color(0.4f, 0.25f, 0.12f), 0.35f);
		Material mat11 = FrogShader.Make(new Color(0.25f, 0.15f, 0.07f), 0.3f);
		Material mat12 = FrogShader.Make(accent, 0.6f);
		Material mat13 = FrogShader.Make(new Color(0.15f, 0.23f, 0.05f), 0f);
		Material mat14 = FrogShader.Make(new Color(0.38f, 0.04f, 0.04f), 0f);
		Material mat15 = FrogShader.Make(new Color(0.45f, 0.32f, 0.05f), 0f);
		Material mat16 = FrogShader.Make(new Color(0.16f, 0.09f, 0.04f), 0f);
		Transform transform2 = new GameObject("Body").transform;
		transform2.SetParent(transform, false);
		transform2.localPosition = new Vector3(0f, 0.34f, 0f);
		if ((Object)(object)_bodyMesh == (Object)null)
		{
			_bodyMesh = BuildBodyMesh();
		}
		Outline(MeshObj("BodyMesh", transform2, _bodyMesh, mat, Vector3.zero, Vector3.one, Quaternion.identity), mat13, 1.035f);
		Prim((PrimitiveType)0, transform, "Belly", new Vector3(0f, 0.27f, 0.4f), new Vector3(0.5f, 0.4f, 0.12f), mat2);
		for (int i = 0; i < 2; i++)
		{
			float num = ((i == 0) ? (-0.185f) : 0.185f);
			Transform transform3 = new GameObject((i == 0) ? "EyeL" : "EyeR").transform;
			transform3.SetParent(transform, false);
			Outline(Prim((PrimitiveType)0, transform3, "Bulge", new Vector3(num, 0.64f, 0.3f), new Vector3(0.25f, 0.23f, 0.25f), mat), mat13, 1.06f);
			Prim((PrimitiveType)0, transform3, "Sclera", new Vector3(num, 0.645f, 0.385f), new Vector3(0.16f, 0.15f, 0.11f), mat9);
			Prim((PrimitiveType)0, transform3, "Iris", new Vector3(num * 1.02f, 0.642f, 0.447f), new Vector3(0.09f, 0.09f, 0.045f), mat7);
			Prim((PrimitiveType)0, transform3, "Pupil", new Vector3(num * 1.02f, 0.64f, 0.468f), new Vector3(0.045f, 0.06f, 0.018f), mat8);
			Prim((PrimitiveType)0, transform3, "Glint", new Vector3(num * 1.02f + 0.02f, 0.665f, 0.479f), new Vector3(0.018f, 0.018f, 0.01f), mat6);
			Prim((PrimitiveType)0, transform3, "Eyelid", new Vector3(num, 0.692f, 0.362f), new Vector3(0.185f, 0.075f, 0.15f), mat).transform.localRotation = Quaternion.Euler(-12f, 0f, (i == 0) ? (-6f) : 6f);
			Prim((PrimitiveType)3, transform3, "LidCrease", new Vector3(num, 0.665f, 0.44f), new Vector3(0.16f, 0.01f, 0.02f), mat4).transform.localRotation = Quaternion.Euler(0f, 0f, (i == 0) ? (-5f) : 5f);
			Prim((PrimitiveType)0, transform3, "Brow", new Vector3(num, 0.74f, 0.285f), new Vector3(0.17f, 0.05f, 0.13f), mat).transform.localRotation = Quaternion.Euler(0f, 0f, (i == 0) ? (-7f) : 7f);
		}
		Prim((PrimitiveType)0, transform, "NostrilL", new Vector3(-0.05f, 0.5f, 0.415f), new Vector3(0.022f, 0.022f, 0.012f), mat8);
		Prim((PrimitiveType)0, transform, "NostrilR", new Vector3(0.05f, 0.5f, 0.415f), new Vector3(0.022f, 0.022f, 0.012f), mat8);
		if ((Object)(object)_lipsMesh == (Object)null)
		{
			_lipsMesh = BuildLipsMesh();
		}
		MeshObj("Lips", transform, _lipsMesh, mat3, Vector3.zero, Vector3.one, Quaternion.identity);
		if ((Object)(object)_seamMesh == (Object)null)
		{
			_seamMesh = BuildSeamMesh();
		}
		MeshObj("MouthSeam", transform, _seamMesh, mat4, Vector3.zero, Vector3.one, Quaternion.identity);
		if ((Object)(object)_starMesh == (Object)null)
		{
			_starMesh = BuildStarMesh();
		}
		Outline(MeshObj("Star", transform, _starMesh, mat12, new Vector3(0.405f, 0.4f, 0.06f), Vector3.one, Quaternion.Euler(0f, 72f, 12f)), mat15, 1.05f);
		Outline(Prim((PrimitiveType)0, transform, "Backpack", new Vector3(0f, 0.35f, -0.4f), new Vector3(0.44f, 0.38f, 0.24f), mat10), mat16, 1.05f);
		Prim((PrimitiveType)0, transform, "BackpackFlap", new Vector3(0f, 0.47f, -0.43f), new Vector3(0.4f, 0.15f, 0.18f), mat11);
		Prim((PrimitiveType)3, transform, "Buckle", new Vector3(0f, 0.44f, -0.52f), new Vector3(0.06f, 0.05f, 0.02f), mat12);
		Prim((PrimitiveType)3, transform, "StrapL", new Vector3(-0.24f, 0.52f, -0.1f), new Vector3(0.05f, 0.34f, 0.05f), mat11).transform.localRotation = Quaternion.Euler(-10f, 0f, 20f);
		Prim((PrimitiveType)3, transform, "StrapR", new Vector3(0.24f, 0.52f, -0.1f), new Vector3(0.05f, 0.34f, 0.05f), mat11).transform.localRotation = Quaternion.Euler(-10f, 0f, -20f);
		for (int j = 0; j < 2; j++)
		{
			float num2 = ((j == 0) ? (-1f) : 1f);
			Outline(Prim((PrimitiveType)0, transform, "Foot" + j, new Vector3(0.2f * num2, 0.045f, 0.3f), new Vector3(0.19f, 0.075f, 0.22f), mat), mat13, 1.06f);
			for (int k = 0; k < 3; k++)
			{
				Prim((PrimitiveType)0, transform, "Toe" + j + "_" + k, new Vector3(0.2f * num2 + (float)(k - 1) * 0.055f, 0.042f, 0.405f), new Vector3(0.045f, 0.035f, 0.06f), mat);
			}
			Outline(Prim((PrimitiveType)0, transform, "BackFoot" + j, new Vector3(0.3f * num2, 0.05f, -0.13f), new Vector3(0.23f, 0.08f, 0.26f), mat), mat13, 1.06f);
		}
		Transform transform4 = new GameObject("Hat").transform;
		transform4.SetParent(transform, false);
		transform4.localPosition = new Vector3(0f, 0.675f, -0.09f);
		transform4.localRotation = Quaternion.Euler(-18f, -8f, 7f);
		frogRig2.Hat = transform4;
		frogRig2.HatBaseRotation = transform4.localRotation;
		if ((Object)(object)_coneMesh == (Object)null)
		{
			_coneMesh = BuildConeMesh(0.27f, 0.55f, 0.34f, 24, 16);
		}
		Outline(MeshObj("HatCone", transform4, _coneMesh, mat5, Vector3.zero, Vector3.one, Quaternion.identity), mat14, 1.03f);
		if ((Object)(object)_brimMesh == (Object)null)
		{
			_brimMesh = BuildTorusMesh(0.275f, 0.075f, 0f, 360f, 40, 12);
		}
		MeshObj("HatBrim", transform4, _brimMesh, mat6, new Vector3(0f, 0.015f, 0f), new Vector3(1f, 1f, 0.58f), Quaternion.Euler(90f, 0f, 0f));
		for (int l = 0; l < 14; l++)
		{
			float num3 = MathF.PI * 2f * (float)l / 14f;
			Prim((PrimitiveType)0, transform4, "Fluff" + l, new Vector3(Mathf.Cos(num3) * 0.275f, 0.012f, Mathf.Sin(num3) * 0.275f), Vector3.one * Random.Range(0.045f, 0.065f), mat6);
		}
		Outline(Prim((PrimitiveType)0, transform4, "HatPom", new Vector3(0.34f, 0.55f, 0f), new Vector3(0.13f, 0.13f, 0.13f), mat6), FrogShader.Make(new Color(0.72f, 0.71f, 0.66f), 0f), 1.05f);
		for (int m = 0; m < 4; m++)
		{
			Prim((PrimitiveType)0, transform4, "PomFluff" + m, new Vector3(0.34f, 0.55f, 0f) + Random.insideUnitSphere * 0.07f, Vector3.one * Random.Range(0.04f, 0.06f), mat6);
		}
		Transform transform5 = new GameObject("CarryPoint").transform;
		transform5.SetParent(transform, false);
		transform5.localPosition = new Vector3(0f, 0.64f, -0.36f);
		transform5.localRotation = Quaternion.identity;
		frogRig2.CarryPoint = transform5;
		return frogRig2;
	}

	private static GameObject Prim(PrimitiveType type, Transform parent, string name, Vector3 pos, Vector3 scale, Material mat)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = GameObject.CreatePrimitive(type);
		((Object)obj).name = name;
		Collider component = obj.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			component.enabled = false;
			Object.Destroy((Object)(object)component);
		}
		Transform transform = obj.transform;
		transform.SetParent(parent, false);
		transform.localPosition = pos;
		transform.localScale = scale;
		transform.localRotation = Quaternion.identity;
		Renderer component2 = obj.GetComponent<Renderer>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.sharedMaterial = mat;
			component2.shadowCastingMode = (ShadowCastingMode)1;
		}
		return obj;
	}

	private static GameObject MeshObj(string name, Transform parent, Mesh mesh, Material mat, Vector3 pos, Vector3 scale, Quaternion rot)
	{
		//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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		val.transform.localPosition = pos;
		val.transform.localScale = scale;
		val.transform.localRotation = rot;
		val.AddComponent<MeshFilter>().sharedMesh = mesh;
		MeshRenderer obj = val.AddComponent<MeshRenderer>();
		((Renderer)obj).sharedMaterial = mat;
		((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
		return val;
	}

	private static void Outline(GameObject part, Material mat, float scale)
	{
		//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)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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)
		MeshFilter component = part.GetComponent<MeshFilter>();
		if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null))
		{
			GameObject val = new GameObject("Outline");
			val.transform.SetParent(part.transform, false);
			val.transform.localScale = Vector3.one * scale;
			val.AddComponent<MeshFilter>().sharedMesh = Inverted(component.sharedMesh);
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = mat;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		}
	}

	private static Mesh Inverted(Mesh source)
	{
		//IL_0018: 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_0034: Expected O, but got Unknown
		int instanceID = ((Object)source).GetInstanceID();
		if (InvertedCache.TryGetValue(instanceID, out var value))
		{
			return value;
		}
		Mesh val = new Mesh
		{
			name = ((Object)source).name + "_Outline"
		};
		val.SetVertices(new List<Vector3>(source.vertices));
		int[] triangles = source.triangles;
		for (int i = 0; i < triangles.Length; i += 3)
		{
			int num = triangles[i];
			triangles[i] = triangles[i + 2];
			triangles[i + 2] = num;
		}
		val.SetTriangles(triangles, 0);
		val.RecalculateNormals();
		val.RecalculateBounds();
		InvertedCache[instanceID] = val;
		return val;
	}

	private static void EnsureOutward(Mesh mesh)
	{
		//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_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] vertices = mesh.vertices;
		int[] triangles = mesh.triangles;
		float num = 0f;
		for (int i = 0; i < triangles.Length; i += 3)
		{
			Vector3 val = vertices[triangles[i]];
			Vector3 val2 = vertices[triangles[i + 1]];
			Vector3 val3 = vertices[triangles[i + 2]];
			num += Vector3.Dot(Vector3.Cross(val2 - val, val3 - val), val + val2 + val3);
		}
		if (!(num >= 0f))
		{
			for (int j = 0; j < triangles.Length; j += 3)
			{
				int num2 = triangles[j];
				triangles[j] = triangles[j + 2];
				triangles[j + 2] = num2;
			}
			mesh.triangles = triangles;
		}
	}

	private static Mesh BuildBodyMesh()
	{
		//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_001c: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Expected O, but got Unknown
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Expected O, but got Unknown
		int num = 44;
		int num2 = 30;
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		Vector3 item = Deform(Vector3.up);
		list.Add(item);
		Vector3 dir = default(Vector3);
		for (int i = 1; i < num2; i++)
		{
			float num3 = MathF.PI * (float)i / (float)num2;
			float num4 = Mathf.Cos(num3);
			float num5 = Mathf.Sin(num3);
			for (int j = 0; j < num; j++)
			{
				float num6 = MathF.PI * 2f * (float)j / (float)num;
				((Vector3)(ref dir))..ctor(Mathf.Cos(num6) * num5, num4, Mathf.Sin(num6) * num5);
				list.Add(Deform(dir));
			}
		}
		Vector3 item2 = Deform(Vector3.down);
		int count = list.Count;
		list.Add(item2);
		int num7 = 1;
		for (int k = 0; k < num; k++)
		{
			int num8 = (k + 1) % num;
			list2.Add(0);
			list2.Add(num7 + k);
			list2.Add(num7 + num8);
		}
		for (int l = 0; l < num2 - 2; l++)
		{
			int num9 = 1 + l * num;
			int num10 = num9 + num;
			for (int m = 0; m < num; m++)
			{
				int num11 = (m + 1) % num;
				list2.Add(num9 + m);
				list2.Add(num10 + m);
				list2.Add(num9 + num11);
				list2.Add(num9 + num11);
				list2.Add(num10 + m);
				list2.Add(num10 + num11);
			}
		}
		int num12 = 1 + (num2 - 2) * num;
		for (int n = 0; n < num; n++)
		{
			int num13 = (n + 1) % num;
			list2.Add(num12 + n);
			list2.Add(count);
			list2.Add(num12 + num13);
		}
		Mesh val = new Mesh
		{
			name = "FrogBody"
		};
		val.SetVertices(list);
		val.SetTriangles(list2, 0);
		EnsureOutward(val);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	private static Vector3 Deform(Vector3 dir)
	{
		//IL_0000: 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_0036: 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_0049: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: 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_012a: 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_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp01(dir.y);
		float num2 = 1f - 0.18f * num * num;
		float num3 = 1f - 0.08f * num * num;
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(dir.x * num2, dir.y, dir.z * num3);
		float num4 = Mathf.Exp(0f - Mathf.Pow((dir.y + 0.02f) / 0.28f, 2f)) * Mathf.Clamp01(dir.z) * 0.1f;
		val.z += num4;
		float num5 = Mathf.Abs(dir.x) - 0.5f;
		float num6 = dir.y - 0.58f;
		float num7 = dir.z - 0.52f;
		float num8 = Mathf.Exp((0f - (num5 * num5 + num6 * num6 + num7 * num7)) * 12f);
		val += dir * (0.045f * num8);
		float num9 = Mathf.Clamp01(0f - dir.y) * 0.05f;
		val.x *= 1f + num9;
		val.z *= 1f + num9 * 0.5f;
		if (val.z < 0f)
		{
			val.z *= 0.94f;
		}
		return new Vector3(val.x * 0.43f, val.y * 0.34f, val.z * 0.44f);
	}

	private static Mesh BuildLipsMesh()
	{
		return BuildSweep(0.042f, 0.05f, 0.255f, 0.435f, 0.055f, 0.395f, 0.045f, 42, 12);
	}

	private static Mesh BuildSeamMesh()
	{
		return BuildSweep(0.012f, 0.012f, 0.235f, 0.392f, 0.045f, 0.412f, 0.035f, 36, 8);
	}

	private static Mesh BuildSweep(float rv, float rd, float halfWidth, float baseY, float cornerLift, float baseZ, float zFalloff, int segU, int segV)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//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_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: 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_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Expected O, but got Unknown
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Expected O, but got Unknown
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		Vector3 val2 = default(Vector3);
		for (int i = 0; i <= segU; i++)
		{
			float num = -1f + 2f * (float)i / (float)segU;
			float num2 = halfWidth * num;
			float num3 = baseY + cornerLift * num * num;
			float num4 = baseZ + zFalloff * (1f - num * num);
			float num5 = 2f * cornerLift * num;
			float num6 = -2f * zFalloff * num;
			Vector3 val = new Vector3(halfWidth * 2f, num5, num6);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			((Vector3)(ref val2))..ctor(0f, 1f, 0f);
			val = Vector3.Cross(normalized, val2);
			val = Vector3.Cross(((Vector3)(ref val)).normalized, normalized);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			for (int j = 0; j < segV; j++)
			{
				float num7 = MathF.PI * 2f * (float)j / (float)segV;
				list.Add(new Vector3(num2, num3, num4) + val2 * (Mathf.Cos(num7) * rv) + normalized2 * (Mathf.Sin(num7) * rd));
			}
		}
		for (int k = 0; k < segU; k++)
		{
			for (int l = 0; l < segV; l++)
			{
				int num8 = (l + 1) % segV;
				int item = k * segV + l;
				int item2 = k * segV + num8;
				int item3 = (k + 1) * segV + l;
				int item4 = (k + 1) * segV + num8;
				list2.Add(item);
				list2.Add(item3);
				list2.Add(item2);
				list2.Add(item2);
				list2.Add(item3);
				list2.Add(item4);
			}
		}
		Vector3 item5 = default(Vector3);
		((Vector3)(ref item5))..ctor(0f - halfWidth, baseY + cornerLift, baseZ);
		Vector3 item6 = default(Vector3);
		((Vector3)(ref item6))..ctor(halfWidth, baseY + cornerLift, baseZ);
		int count = list.Count;
		list.Add(item5);
		int count2 = list.Count;
		list.Add(item6);
		for (int m = 0; m < segV; m++)
		{
			int num9 = (m + 1) % segV;
			list2.Add(count);
			list2.Add(num9);
			list2.Add(m);
			int num10 = segU * segV;
			list2.Add(count2);
			list2.Add(num10 + m);
			list2.Add(num10 + num9);
		}
		Mesh val3 = new Mesh
		{
			name = "FrogSweep"
		};
		val3.SetVertices(list);
		val3.SetTriangles(list2, 0);
		EnsureOutward(val3);
		val3.RecalculateNormals();
		val3.RecalculateBounds();
		return val3;
	}

	private static Mesh BuildStarMesh()
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: 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_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Expected O, but got Unknown
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Expected O, but got Unknown
		int num = 5;
		float num2 = 0.16f;
		float num3 = 0.07f;
		float num4 = 0.06f;
		float num5 = 0.86f;
		List<Vector3> list = new List<Vector3>();
		for (int i = 0; i < num * 2; i++)
		{
			float num6 = MathF.PI * 2f * (float)i / (float)(num * 2) + MathF.PI / 2f;
			float num7 = ((i % 2 == 0) ? num2 : num3);
			list.Add(new Vector3(Mathf.Cos(num6) * num7, Mathf.Sin(num6) * num7, 0f));
		}
		List<Vector3> list2 = new List<Vector3>();
		List<int> list3 = new List<int>();
		int count = list2.Count;
		list2.Add(new Vector3(0f, 0f, num4 * 0.5f));
		int count2 = list2.Count;
		for (int j = 0; j < list.Count; j++)
		{
			list2.Add(list[j] + new Vector3(0f, 0f, num4 * 0.5f));
		}
		int count3 = list2.Count;
		list2.Add(new Vector3(0f, 0f, (0f - num4) * 0.5f));
		int count4 = list2.Count;
		for (int k = 0; k < list.Count; k++)
		{
			list2.Add(list[k] * num5 + new Vector3(0f, 0f, (0f - num4) * 0.5f));
		}
		for (int l = 0; l < list.Count; l++)
		{
			int num8 = (l + 1) % list.Count;
			list3.Add(count);
			list3.Add(count2 + l);
			list3.Add(count2 + num8);
			list3.Add(count3);
			list3.Add(count4 + num8);
			list3.Add(count4 + l);
			list3.Add(count4 + l);
			list3.Add(count2 + l);
			list3.Add(count4 + num8);
			list3.Add(count4 + num8);
			list3.Add(count2 + l);
			list3.Add(count2 + num8);
		}
		Mesh val = new Mesh
		{
			name = "FrogStar"
		};
		val.SetVertices(list2);
		val.SetTriangles(list3, 0);
		EnsureOutward(val);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	private static Mesh BuildConeMesh(float baseRadius, float height, float bend, int segments, int rings)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Expected O, but got Unknown
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Expected O, but got Unknown
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		for (int i = 0; i <= rings; i++)
		{
			float num = (float)i / (float)rings;
			float num2 = baseRadius * (1f - 0.985f * num);
			float num3 = bend * num * num;
			float num4 = height * num;
			for (int j = 0; j < segments; j++)
			{
				float num5 = MathF.PI * 2f * (float)j / (float)segments;
				list.Add(new Vector3(num3 + Mathf.Cos(num5) * num2, num4, Mathf.Sin(num5) * num2));
			}
		}
		for (int k = 0; k < rings; k++)
		{
			for (int l = 0; l < segments; l++)
			{
				int num6 = (l + 1) % segments;
				int item = k * segments + l;
				int item2 = k * segments + num6;
				int item3 = (k + 1) * segments + l;
				int item4 = (k + 1) * segments + num6;
				list2.Add(item);
				list2.Add(item3);
				list2.Add(item2);
				list2.Add(item2);
				list2.Add(item3);
				list2.Add(item4);
			}
		}
		int count = list.Count;
		list.Add(new Vector3(bend, height, 0f));
		int num7 = rings * segments;
		for (int m = 0; m < segments; m++)
		{
			int num8 = (m + 1) % segments;
			list2.Add(num7 + m);
			list2.Add(count);
			list2.Add(num7 + num8);
		}
		int count2 = list.Count;
		list.Add(Vector3.zero);
		for (int n = 0; n < segments; n++)
		{
			int item5 = (n + 1) % segments;
			list2.Add(count2);
			list2.Add(n);
			list2.Add(item5);
		}
		Mesh val = new Mesh
		{
			name = "FrogCone"
		};
		val.SetVertices(list);
		val.SetTriangles(list2, 0);
		EnsureOutward(val);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	private static Mesh BuildTorusMesh(float major, float tube, float arcStartDeg, float arcEndDeg, int segU, int segV)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: 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_0153: Expected O, but got Unknown
		//IL_0153: 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_0160: Expected O, but got Unknown
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		float num = arcStartDeg * (MathF.PI / 180f);
		float num2 = arcEndDeg * (MathF.PI / 180f);
		for (int i = 0; i < segU; i++)
		{
			float num3 = (float)i / (float)segU;
			float num4 = Mathf.Lerp(num, num2, num3);
			float num5 = Mathf.Cos(num4);
			float num6 = Mathf.Sin(num4);
			for (int j = 0; j < segV; j++)
			{
				float num7 = MathF.PI * 2f * (float)j / (float)segV;
				float num8 = Mathf.Cos(num7);
				float num9 = Mathf.Sin(num7);
				float num10 = major + tube * num8;
				list.Add(new Vector3(num10 * num5, num10 * num6, tube * num9));
			}
		}
		for (int k = 0; k < segU; k++)
		{
			int num11 = (k + 1) % segU;
			for (int l = 0; l < segV; l++)
			{
				int num12 = (l + 1) % segV;
				int item = k * segV + l;
				int item2 = k * segV + num12;
				int item3 = num11 * segV + l;
				int item4 = num11 * segV + num12;
				list2.Add(item);
				list2.Add(item3);
				list2.Add(item2);
				list2.Add(item2);
				list2.Add(item3);
				list2.Add(item4);
			}
		}
		Mesh val = new Mesh
		{
			name = "FrogTorus"
		};
		val.SetVertices(list);
		val.SetTriangles(list2, 0);
		EnsureOutward(val);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}
}
internal sealed class FrogPet : MonoBehaviour
{
	private enum State
	{
		Follow,
		Fetch,
		Carry,
		Distract,
		Flee,
		Grieving
	}

	private enum Mishap
	{
		None,
		Drop,
		Break
	}

	private struct ColliderState
	{
		public Collider Collider;

		public bool Enabled;
	}

	private FrogRig _rig;

	private AudioSource _source;

	private Transform _visual;

	private NavMeshAgent _agent;

	private bool _hasAgentDestination;

	private float _nextAgentWarp;

	private int _carryStuckAttempts;

	private State _state;

	private PhysGrabObject _target;

	private ExtractionPoint _dropPoint;

	private PhysGrabObject _carried;

	private bool _deliverToOwner;

	private float _carryYawOffset;

	private float _carryBaseY = 0.64f;

	private Rigidbody _carriedRb;

	private bool _carriedKinematic;

	private bool _carriedGravity;

	private bool _carriedDetect;

	private readonly List<ColliderState> _carriedColliders = new List<ColliderState>();

	private Mishap _mishap;

	private float _mishapAt;

	private float _tripStartDistance;

	private float _nextFearCheck;

	private float _nextScan;

	private float _teleportAt;

	private float _hopPhase;

	private bool _moving;

	private float _stuckCheckAt;

	private Vector3 _stuckAnchor;

	private int _stuckCount;

	private Vector3 _wanderTarget;

	private float _wanderUntil;

	private float _nextWander;

	private float _nextLook;

	private float _lookYaw;

	private float _nextCroak;

	private float _croakUntil;

	private float _nextDistract;

	private float _distractUntil;

	private float _nextTaunt;

	private float _nextSmack;

	private Enemy _distractEnemy;

	private float _stateUntil;

	private float _nextEnemyScan;

	private string _seenEnemyName;

	internal PlayerAvatar Owner { get; private set; }

	internal string StatusText
	{
		get
		{
			//IL_004d: 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)
			string text;
			switch (_state)
			{
			case State.Fetch:
				text = "Бежит за предметом";
				break;
			case State.Carry:
			{
				string text2 = "?";
				if ((Object)(object)_carried != (Object)null)
				{
					text2 = Mathf.CeilToInt(FlatDistance(((Component)this).transform.position, CarryDestination())).ToString();
				}
				text = (_deliverToOwner ? ("Несёт " + ItemName(_carried) + " тебе · " + text2 + " м") : ("Несёт " + ItemName(_carried) + " · до сдачи " + text2 + " м"));
				break;
			}
			case State.Distract:
				text = (string.IsNullOrEmpty(_seenEnemyName) ? "Отвлекает монстра на себя!" : ("Отвлекает " + _seenEnemyName + " на себя!"));
				break;
			case State.Flee:
				text = "Убегает с грузом!";
				break;
			case State.Grieving:
				text = "Сидит у тела хозяина...";
				break;
			default:
				text = ((Time.time < _wanderUntil) ? "Гуляет рядом" : "Следует за тобой");
				break;
			}
			if (!string.IsNullOrEmpty(_seenEnemyName) && _state != State.Distract)
			{
				text = text + " · видит: " + _seenEnemyName;
			}
			return text;
		}
	}

	internal string HintText
	{
		get
		{
			switch (_state)
			{
			case State.Fetch:
			case State.Carry:
				return FrogConfig.CommandKey.Value + " — вернуть жабу · " + FrogConfig.RotateKey.Value + " — повернуть груз";
			case State.Distract:
				return FrogConfig.CommandKey.Value + " — позвать жабу обратно";
			default:
				return FrogConfig.CommandKey.Value + " — отправить жабу за предметом";
			}
		}
	}

	internal void Initialize(PlayerAvatar owner)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		Owner = owner;
		_state = State.Follow;
		((Component)this).transform.localScale = Vector3.one * Mathf.Max(0.3f, FrogConfig.FrogScale.Value);
		_rig = FrogModel.Build(((Component)this).transform, AccentColor(owner));
		_visual = _rig.Visual;
		_carryBaseY = (((Object)(object)_rig.CarryPoint != (Object)null) ? _rig.CarryPoint.localPosition.y : 0.64f);
		_source = ((Component)this).gameObject.AddComponent<AudioSource>();
		FrogAudio.Setup(_source);
		_stuckAnchor = ((Component)this).transform.position;
		_stuckCheckAt = Time.time + 2f;
		_teleportAt = Time.time + 2f;
		_nextWander = Time.time + Random.Range(4f, 7f);
		_nextLook = Time.time + 0.5f;
		_nextCroak = Time.time + Random.Range(4f, 9f);
		_nextDistract = Time.time + Random.Range(8f, 14f);
		FrogHud.Notify("Жаба-курьер прибыла! " + FrogConfig.CommandKey.Value + " — отправить её за предметом.");
	}

	private static Color AccentColor(PlayerAvatar owner)
	{
		//IL_0017: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		Color val = default(Color);
		((Color)(ref val))..ctor(0.93f, 0.78f, 0.2f);
		try
		{
			val = Color.Lerp(SemiFunc.PlayerGetColorMain(owner), new Color(0.93f, 0.78f, 0.2f), 0.35f);
		}
		catch
		{
		}
		return Color.Lerp(val, Color.white, 0.08f);
	}

	private void ScanEnemy()
	{
		if (!(Time.time < _nextEnemyScan))
		{
			_nextEnemyScan = Time.time + 0.6f;
			Enemy val = FindEnemy(16f);
			_seenEnemyName = (((Object)(object)val != (Object)null) ? EnemyName(val) : null);
		}
	}

	private static string EnemyName(Enemy enemy)
	{
		if ((Object)(object)enemy == (Object)null)
		{
			return "монстр";
		}
		try
		{
			EnemyParent componentInParent = ((Component)enemy).GetComponentInParent<EnemyParent>();
			if ((Object)(object)componentInParent != (Object)null && !string.IsNullOrEmpty(componentInParent.enemyName))
			{
				return componentInParent.enemyName;
			}
			return ((object)Unsafe.As<EnemyType, EnemyType>(ref enemy.Type)/*cast due to .constrained prefix*/).ToString();
		}
		catch
		{
			return "монстр";
		}
	}

	private void Update()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Owner == (Object)null || (Object)(object)Owner.playerTransform == (Object)null)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float deltaTime = Time.deltaTime;
		if (deltaTime <= 0f)
		{
			return;
		}
		_moving = false;
		EnsureAgentOnNavMesh();
		if (((Component)this).transform.position.y < -10f)
		{
			RecoverFromFall();
			return;
		}
		ScanEnemy();
		if (IsOwnerDown())
		{
			UpdateGrieving();
		}
		else
		{
			switch (_state)
			{
			case State.Follow:
				UpdateFollow();
				break;
			case State.Fetch:
				UpdateFetch();
				break;
			case State.Carry:
				UpdateCarry();
				break;
			case State.Distract:
				UpdateDistract();
				break;
			case State.Flee:
				UpdateFlee();
				break;
			case State.Grieving:
				UpdateGrieving();
				break;
			}
		}
		Animate(deltaTime);
		CheckStuck();
	}

	private void LateUpdate()
	{
		//IL_0054: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_carried == (Object)null) && _rig != null && !((Object)(object)_rig.CarryPoint == (Object)null) && !((Object)(object)((Component)_carried).gameObject == (Object)null))
		{
			((Component)_carried).transform.position = _rig.CarryPoint.position;
			Quaternion val = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y + _carryYawOffset, 0f);
			((Component)_carried).transform.rotation = Quaternion.Slerp(((Component)_carried).transform.rotation, val, Time.deltaTime * 6f);
		}
	}

	private void OnDestroy()
	{
		//IL_0017: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_carried == (Object)null)
		{
			return;
		}
		try
		{
			ReleaseCarried(((Component)this).transform.position + ((Component)this).transform.forward * 0.3f + Vector3.up * 0.1f, toss: false, Vector3.zero);
		}
		catch
		{
		}
	}

	internal void Command()
	{
		//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)
		if ((Object)(object)Owner == (Object)null || !PlayerInfo.IsLocal(Owner))
		{
			return;
		}
		if (_state == State.Fetch || _state == State.Carry)
		{
			Recall();
			return;
		}
		if (_state == State.Distract)
		{
			_state = State.Follow;
			_nextDistract = Time.time + 12f;
			FrogHud.Notify("Жаба вернулась к хозяину.");
			return;
		}
		PhysGrabObject val = FindTarget();
		if ((Object)(object)val == (Object)null)
		{
			Croak(0.4f);
			FrogHud.Notify("Жаба не видит ценный предмет. Наведись на него или подойди ближе.");
			return;
		}
		_target = val;
		_state = State.Fetch;
		_stuckAnchor = ((Component)this).transform.position;
		_stuckCheckAt = Time.time + 2f;
		_stuckCount = 0;
		FrogHud.Notify("Жаба побежала за " + ItemName(val) + "!");
		Croak(0.7f);
	}

	private void Recall()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_carried != (Object)null)
		{
			string text = ItemName(_carried);
			ReleaseCarried(((Component)this).transform.position + ((Component)this).transform.forward * 0.3f + Vector3.up * 0.05f, toss: true, new Vector3(0f, 0.6f, 0f));
			FrogHud.Notify("Жаба вернулась и бросила " + text + ".");
		}
		else
		{
			FrogHud.Notify("Жаба вернулась.");
		}
		_target = null;
		_dropPoint = null;
		_state = State.Follow;
		_nextWander = Time.time + 4f;
	}

	private void UpdateFollow()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing re