Decompiled source of CluckFighters v1.0.0

plugins/CluckFighters.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CluckFighters.Core;
using CluckFighters.Dev;
using CluckFighters.Gameplay;
using CluckFighters.Visual;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CluckFighters
{
	public static class Cfg
	{
		public static ConfigEntry<float> BaseHealth;

		public static ConfigEntry<float> BaseDamage;

		public static ConfigEntry<float> HealthPerLevel;

		public static ConfigEntry<float> DamagePerLevel;

		public static ConfigEntry<float> XpFactor;

		public static ConfigEntry<float> StarChance;

		public static ConfigEntry<int> MaxLevel;

		public static ConfigEntry<int> AbilityLevel;

		public static ConfigEntry<bool> ProtectOwner;

		public static ConfigEntry<float> WalkXpMeters;

		public static ConfigEntry<int> MeatNeeded;

		public static ConfigEntry<float> BroodDays;

		public static ConfigEntry<float> CoopMaxArea;

		public static ConfigEntry<string> MeatItems;

		public static ConfigEntry<float> PitMaxArea;

		public static ConfigEntry<float> RivalRange;

		public static ConfigEntry<bool> FightsOutsideArenas;

		public static ConfigEntry<float> DyeDays;

		public static ConfigEntry<bool> RainWashesDye;

		public static ConfigEntry<string> LeashRecipe;

		public static ConfigEntry<string> PostRecipe;

		public static ConfigEntry<string> DyeStation;

		public static readonly Dictionary<string, ConfigEntry<string>> Recipes = new Dictionary<string, ConfigEntry<string>>();

		public static readonly Dictionary<string, ConfigEntry<string>> Stations = new Dictionary<string, ConfigEntry<string>>();

		public static ConfigEntry<bool> ShowNumbers;

		private static HashSet<string> _meat;

		private static HashSet<string> _meatNames;

		private static string _meatSource;

		public static Tuning Current { get; private set; } = new Tuning();

		public static HashSet<string> Meat
		{
			get
			{
				if (_meat == null || _meatSource != MeatItems.Value)
				{
					_meatSource = MeatItems.Value;
					_meat = RecipeText.Names(_meatSource);
					_meatNames = null;
				}
				return _meat;
			}
		}

		public static event Action RecipesChanged;

		public static void Bind(ConfigFile c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Expected O, but got Unknown
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Expected O, but got Unknown
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Expected O, but got Unknown
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Expected O, but got Unknown
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Expected O, but got Unknown
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Expected O, but got Unknown
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Expected O, but got Unknown
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Expected O, but got Unknown
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Expected O, but got Unknown
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Expected O, but got Unknown
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Expected O, but got Unknown
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Expected O, but got Unknown
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
			BaseHealth = c.Bind<float>("1 - Fighters", "BaseHealth", 40f, new ConfigDescription("Health of a level 1 fighter without stars (a hen has 10). Each star multiplies it, like on any creature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 500f), new object[1] { val }));
			BaseDamage = c.Bind<float>("1 - Fighters", "BaseDamage", 6f, new ConfigDescription("Damage of a level 1 peck without stars or gear.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), new object[1] { val }));
			HealthPerLevel = c.Bind<float>("1 - Fighters", "HealthPerLevel", 0.25f, new ConfigDescription("Health gained per level as a share of the base health (0.25 = +25 % per level).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), new object[1] { val }));
			DamagePerLevel = c.Bind<float>("1 - Fighters", "DamagePerLevel", 0.1f, new ConfigDescription("Damage gained per level as a share of the base damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), new object[1] { val }));
			MaxLevel = c.Bind<int>("1 - Fighters", "MaxLevel", 10, new ConfigDescription("Highest level a fighter can reach.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), new object[1] { val }));
			AbilityLevel = c.Bind<int>("1 - Fighters", "AbilityLevel", 5, new ConfigDescription("Level at which the fighter's nature wakes its ability. At the highest level the ability grows stronger.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), new object[1] { val }));
			XpFactor = c.Bind<float>("1 - Fighters", "XpFactor", 1f, new ConfigDescription("Multiplies all experience fighters gain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), new object[1] { val }));
			StarChance = c.Bind<float>("1 - Fighters", "StarChance", 0.015f, new ConfigDescription("Chance that a won ring fight gives the winner a star (0.015 = 1.5 %). The second star is half as likely; arenas multiply it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { val }));
			ProtectOwner = c.Bind<bool>("1 - Fighters", "ProtectOwner", true, new ConfigDescription("Fighters attack creatures that threaten their owner, like a tame wolf.", (AcceptableValueBase)null, new object[1] { val }));
			WalkXpMeters = c.Bind<float>("1 - Fighters", "WalkXpMeters", 50f, new ConfigDescription("Metres a following fighter walks beside you for one experience point (0 = none).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), new object[1] { val }));
			MeatNeeded = c.Bind<int>("2 - Brooding", "MeatNeeded", 2, new ConfigDescription("Pieces of meat a hen must eat in her coop before she can turn into a fighter.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { val }));
			BroodDays = c.Bind<float>("2 - Brooding", "BroodDays", 1f, new ConfigDescription("Game days the hen must then sit alone in a small coop (one day = 30 minutes).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), new object[1] { val }));
			CoopMaxArea = c.Bind<float>("2 - Brooding", "CoopMaxArea", 16f, new ConfigDescription("Largest floor area in square metres that still counts as a small coop (16 = 4 x 4 m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), new object[1] { val }));
			MeatItems = c.Bind<string>("2 - Brooding", "MeatItems", "RawMeat,DeerMeat,NeckTail,WolfMeat,LoxMeat,SerpentMeat,BugMeat,HareMeat,ChickenMeat,AsksvinMeat,VoltureMeat,BjornMeat,MooseMeat,BoneMawSerpentMeat,CookedMeat,CookedDeerMeat,NeckTailGrilled,CookedWolfMeat,CookedLoxMeat,SerpentMeatCooked,CookedBugMeat,CookedHareMeat,CookedChickenMeat,CookedAsksvinMeat,CookedVoltureMeat,CookedBjornMeat,CookedMooseMeat,CookedBoneMawSerpentMeat", new ConfigDescription("Items that count as meat for a brooding hen (prefab names, comma separated). She only eats them while shut in her coop.", (AcceptableValueBase)null, new object[1] { val }));
			PitMaxArea = c.Bind<float>("3 - Ring", "PitMaxArea", 150f, new ConfigDescription("Largest closed space in square metres in which two fighters cannot keep out of each other's way and fight (outside arenas).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 1000f), new object[1] { val }));
			RivalRange = c.Bind<float>("3 - Ring", "RivalRange", 14f, new ConfigDescription("Distance in metres at which a fighter notices a rival.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), new object[1] { val }));
			FightsOutsideArenas = c.Bind<bool>("3 - Ring", "FightsOutsideArenas", true, new ConfigDescription("Fighters also fight in pens, coops and closed rooms, not only in arenas. Out in the open they never fight each other.", (AcceptableValueBase)null, new object[1] { val }));
			DyeDays = c.Bind<float>("4 - Dye", "DyeDays", 1f, new ConfigDescription("Game days a dye lasts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 30f), new object[1] { val }));
			RainWashesDye = c.Bind<bool>("4 - Dye", "RainWashesDye", false, new ConfigDescription("Rain washes the dye off as well (water always does).", (AcceptableValueBase)null, new object[1] { val }));
			LeashRecipe = c.Bind<string>("5 - Recipes", "Leash", "LeatherScraps:4,Resin:2", new ConfigDescription("Cost of the fighter's leash, crafted at the workbench.", (AcceptableValueBase)null, new object[1] { val }));
			PostRecipe = c.Bind<string>("5 - Recipes", "TetherPost", "Wood:4,Iron:1", new ConfigDescription("Cost of the tether post (workbench).", (AcceptableValueBase)null, new object[1] { val }));
			DyeStation = c.Bind<string>("5 - Recipes", "DyeStation", "piece_workbench:1", new ConfigDescription("Where dyes are mixed: station prefab and level.", (AcceptableValueBase)null, new object[1] { val }));
			DyeInfo[] all = DyeTable.All;
			foreach (DyeInfo dyeInfo in all)
			{
				Recipes[dyeInfo.Prefab] = c.Bind<string>("5 - Recipes", dyeInfo.Prefab, dyeInfo.DefaultRecipe, new ConfigDescription("Cost of two pots of this dye.", (AcceptableValueBase)null, new object[1] { val }));
			}
			GearInfo[] all2 = GearTable.All;
			foreach (GearInfo gearInfo in all2)
			{
				Recipes[gearInfo.Prefab] = c.Bind<string>("6 - Gear", gearInfo.Prefab, gearInfo.DefaultRecipe, new ConfigDescription("Cost of this piece of gear.", (AcceptableValueBase)null, new object[1] { val }));
				Stations[gearInfo.Prefab] = c.Bind<string>("6 - Gear", gearInfo.Prefab + "_Station", gearInfo.DefaultStation, new ConfigDescription("Where it is made: station prefab and level.", (AcceptableValueBase)null, new object[1] { val }));
			}
			ArenaInfo[] all3 = ArenaTable.All;
			foreach (ArenaInfo arenaInfo in all3)
			{
				Recipes[arenaInfo.Prefab] = c.Bind<string>("7 - Arenas", arenaInfo.Prefab, arenaInfo.DefaultRecipe, new ConfigDescription("Cost of this arena.", (AcceptableValueBase)null, new object[1] { val }));
				Stations[arenaInfo.Prefab] = c.Bind<string>("7 - Arenas", arenaInfo.Prefab + "_Station", arenaInfo.DefaultStation, new ConfigDescription("The station it is built near (prefab:level, the level is ignored for pieces).", (AcceptableValueBase)null, new object[1] { val }));
			}
			ShowNumbers = c.Bind<bool>("8 - Client", "ShowNumbers", true, "Show health, damage and experience numbers on the fighter's hover text.");
			c.SettingChanged += delegate
			{
				Rebuild();
			};
			Rebuild();
			c.SettingChanged += delegate(object _, SettingChangedEventArgs a)
			{
				if (a != null)
				{
					ConfigEntryBase changedSetting = a.ChangedSetting;
					if (((changedSetting != null) ? new bool?(changedSetting.Definition.Section.StartsWith("5")) : ((bool?)null)) == true)
					{
						goto IL_00b1;
					}
				}
				if (a != null)
				{
					ConfigEntryBase changedSetting2 = a.ChangedSetting;
					if (((changedSetting2 != null) ? new bool?(changedSetting2.Definition.Section.StartsWith("6")) : ((bool?)null)) == true)
					{
						goto IL_00b1;
					}
				}
				if (a == null)
				{
					return;
				}
				ConfigEntryBase changedSetting3 = a.ChangedSetting;
				if (((changedSetting3 != null) ? new bool?(changedSetting3.Definition.Section.StartsWith("7")) : ((bool?)null)) != true)
				{
					return;
				}
				goto IL_00b1;
				IL_00b1:
				Cfg.RecipesChanged?.Invoke();
			};
			SynchronizationManager.OnConfigurationSynchronized += delegate
			{
				Rebuild();
				Cfg.RecipesChanged?.Invoke();
			};
		}

		private static void Rebuild()
		{
			Current = new Tuning
			{
				BaseHealth = BaseHealth.Value,
				BaseDamage = BaseDamage.Value,
				HealthPerLevel = HealthPerLevel.Value,
				DamagePerLevel = DamagePerLevel.Value,
				MaxLevel = MaxLevel.Value,
				AbilityLevel = Math.Min(AbilityLevel.Value, MaxLevel.Value),
				MasteryLevel = MaxLevel.Value,
				XpFactor = XpFactor.Value,
				StarChance = StarChance.Value
			};
			_meat = null;
		}

		public static bool IsMeat(ItemData item)
		{
			if (item == null)
			{
				return false;
			}
			if ((Object)(object)item.m_dropPrefab != (Object)null)
			{
				return Meat.Contains(((Object)item.m_dropPrefab).name);
			}
			if (_meatNames == null && (Object)(object)ObjectDB.instance != (Object)null)
			{
				HashSet<string> hashSet = new HashSet<string>();
				foreach (string item2 in Meat)
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item2);
					ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val != (Object)null)
					{
						hashSet.Add(val.m_itemData.m_shared.m_name);
					}
				}
				if (hashSet.Count > 0)
				{
					_meatNames = hashSet;
				}
			}
			if (_meatNames != null && item.m_shared != null)
			{
				return _meatNames.Contains(item.m_shared.m_name);
			}
			return false;
		}
	}
	public static class Lang
	{
		private static readonly (string key, string en, string de)[] Texts = new(string, string, string)[74]
		{
			("cf_fighter", "Cluck Fighter", "Kampfhuhn"),
			("cf_nature_stormbeak", "Stormbeak", "Sturmschnabel"),
			("cf_nature_runeclaw", "Runeclaw", "Runenklaue"),
			("cf_nature_berserker", "Berserker Hans", "Berserker Hans"),
			("cf_nature_valhalla", "Valhalla Striker", "Walhallstreiter"),
			("cf_ab_thunderpeck", "Thunder Peck", "Donnerhieb"),
			("cf_ab_runeward", "Rune Ward", "Runenwehr"),
			("cf_ab_frenzy", "Blood Frenzy", "Blutrausch"),
			("cf_ab_valkyriedive", "Valkyrie Dive", "Walkürensturz"),
			("cf_hover_level", "level {0}/{1}", "Stufe {0}/{1}"),
			("cf_hover_xp", "{0}/{1} XP", "{0}/{1} EP"),
			("cf_hover_stats", "Health {0}/{1} · peck {2} · wins {3}", "Leben {0}/{1} · Hieb {2} · Siege {3}"),
			("cf_hover_ability", "{0}: awake", "{0}: erwacht"),
			("cf_hover_ability_master", "{0}: mastered", "{0}: gemeistert"),
			("cf_hover_ability_sleeps", "{0}: wakes at level {1}", "{0}: erwacht mit Stufe {1}"),
			("cf_hover_gear", "Gear: {0}", "Ausrüstung: {0}"),
			("cf_hover_gear_unused", "(unused in the ring)", "(im Ring ungenutzt)"),
			("cf_hover_dye", "Dyed {0}, fades in {1} min", "Gefärbt: {0}, verblasst in {1} Min."),
			("cf_hover_fighting", "Fighting in the ring!", "Kämpft im Ring!"),
			("cf_hover_tied", "Tied to a post", "An einen Pfahl gebunden"),
			("cf_hover_leash", "On {0}'s leash", "An der Leine von {0}"),
			("cf_star1", "1 star", "1 Stern"),
			("cf_stars", "{0} stars", "{0} Sterne"),
			("cf_key_letgo", "Let go of the leash", "Leine loslassen"),
			("cf_key_untie", "Untie onto your leash", "Losbinden und an die Leine nehmen"),
			("cf_key_hold", "Hold", "Halten"),
			("cf_key_strip", "Take off its gear", "Ausrüstung abnehmen"),
			("cf_key_putin", "Put {0} into the ring", "{0} in den Ring setzen"),
			("cf_key_takeout", "Lift {0} out on your leash", "{0} an der Leine herausheben"),
			("cf_key_tie", "Tie {0} to the post", "{0} an den Pfahl binden"),
			("cf_msg_level", "{0} reached level {1}", "{0} hat Stufe {1} erreicht"),
			("cf_msg_ability", "{0} reached level {1}: its ability has woken", "{0} hat Stufe {1} erreicht: seine Fähigkeit ist erwacht"),
			("cf_msg_mastery", "{0} reached level {1}: its ability is mastered", "{0} hat Stufe {1} erreicht: seine Fähigkeit ist gemeistert"),
			("cf_msg_toowild", "{0} is fighting – no hand comes near it now", "{0} kämpft – jetzt kommt keine Hand an es heran"),
			("cf_msg_twohands", "You have only two hands for leashes", "Du hast nur zwei Hände für Leinen"),
			("cf_msg_leashed", "{0} is on your leash", "{0} ist an deiner Leine"),
			("cf_msg_already", "{0} is already on your leash", "{0} ist schon an deiner Leine"),
			("cf_msg_dyed", "{0}'s feathers are dyed {1}", "Die Federn von {0} sind {1} gefärbt"),
			("cf_msg_geared", "{0} wears {1}", "{0} trägt {1}"),
			("cf_msg_stripped", "You took {0}'s gear off", "Du hast {0} die Ausrüstung abgenommen"),
			("cf_msg_letgo", "You let go of {0}", "Du lässt {0} los"),
			("cf_msg_tied", "{0} is tied to the post", "{0} ist an den Pfahl gebunden"),
			("cf_msg_redcorner", "{0} is in the red corner", "{0} steht in der roten Ecke"),
			("cf_msg_bluecorner", "{0} is in the blue corner", "{0} steht in der blauen Ecke"),
			("cf_msg_ringfull", "There are two fighters in the ring already", "Im Ring stehen schon zwei Kämpfer"),
			("cf_msg_ringstart", "{0} and {1} stare each other down…", "{0} und {1} starren einander an …"),
			("cf_msg_win", "{0} has beaten {1}", "{0} hat {1} besiegt"),
			("cf_msg_star", "{0} won a star in the ring!", "{0} hat im Ring einen Stern gewonnen!"),
			("cf_msg_turned", "{0} has turned into a Cluck Fighter: {1}", "{0} ist zum Kampfhuhn geworden: {1}"),
			("cf_msg_onlyfighters", "Only a Cluck Fighter takes this", "Das nimmt nur ein Kampfhuhn an"),
			("cf_arena_bonus", "In this ring: {0}", "In diesem Ring: {0}"),
			("cf_arena_fight", "{0}\nversus\n{1}", "{0}\ngegen\n{1}"),
			("cf_bonus_health", "+{0} % health", "+{0} % Leben"),
			("cf_bonus_damage", "+{0} % damage", "+{0} % Schaden"),
			("cf_bonus_xp", "+{0} % experience", "+{0} % Erfahrung"),
			("cf_bonus_star", "star chance ×{0}", "Sternchance ×{0}"),
			("cf_bonus_heal", "the winner heals {0} %", "der Sieger heilt {0} %"),
			("cf_post_tied", "{0} is tied here", "{0} ist hier angebunden"),
			("cf_hen_out", "Meat eaten {0}/{1} – she broods only alone in a small coop", "Fleisch gefressen {0}/{1} – sie brütet nur allein in einem kleinen Verschlag"),
			("cf_hen_brood", "Broods alone, restless: {0} % of a day · meat {1}/{2}", "Brütet allein, unruhig: {0} % eines Tages · Fleisch {1}/{2}"),
			("cf_tt_slash", "Slash: <color=orange>+{0}</color>", "Hieb: <color=orange>+{0}</color>"),
			("cf_tt_pierce", "Pierce: <color=orange>+{0}</color>", "Stich: <color=orange>+{0}</color>"),
			("cf_tt_fire", "Fire: <color=orange>+{0}</color>", "Feuer: <color=orange>+{0}</color>"),
			("cf_tt_spirit", "Spirit: <color=orange>+{0}</color>", "Geist: <color=orange>+{0}</color>"),
			("cf_tt_frost", "Frost: <color=orange>+{0}</color>", "Frost: <color=orange>+{0}</color>"),
			("cf_tt_armor", "Armour: <color=orange>{0}</color>", "Rüstung: <color=orange>{0}</color>"),
			("cf_tt_speed", "Speed: <color=orange>{0} %</color>", "Tempo: <color=orange>{0} %</color>"),
			("cf_tt_crit", "Critical blows: <color=orange>+{0} %</color>", "Kritische Treffer: <color=orange>+{0} %</color>"),
			("cf_tt_dodge", "Dodge: <color=orange>+{0} %</color>", "Ausweichen: <color=orange>+{0} %</color>"),
			("cf_tt_fireres", "Half damage from fire", "Halber Schaden durch Feuer"),
			("cf_tt_poisonres", "Half damage from poison", "Halber Schaden durch Gift"),
			("cf_tt_gear_use", "Use it on your Cluck Fighter to strap it on. For brawls outside the ring only: in an arena and in every ring fight, fighters fight bare.", "Auf dein Kampfhuhn anwenden, um es anzuschnallen. Nur für Raufereien außerhalb des Rings: in einer Arena und in jedem Ringkampf kämpfen die Hühner ohne."),
			("cf_tt_leash_use", "Use it on your Cluck Fighter to lead it. You hold two leashes at most; tie a fighter to a tether post to free a hand.", "Auf dein Kampfhuhn anwenden, um es zu führen. Du hältst höchstens zwei Leinen; binde ein Huhn an einen Anbindepfahl, um eine Hand frei zu haben."),
			("cf_tt_dye_use", "Use it on a Cluck Fighter. The colour holds for {0} minutes, or until the bird goes into water. No effect on its strength.", "Auf ein Kampfhuhn anwenden. Die Farbe hält {0} Minuten oder bis das Huhn ins Wasser geht. Keine Wirkung auf seine Stärke.")
		};

		private static readonly (string key, string en, string de, string descEn, string descDe)[] Things = new(string, string, string, string, string)[10]
		{
			("cf_dye_red", "red", "rot", null, null),
			("cf_dye_blue", "blue", "blau", null, null),
			("cf_dye_yellow", "yellow", "gelb", null, null),
			("cf_dye_green", "green", "grün", null, null),
			("cf_dye_purple", "purple", "violett", null, null),
			("cf_dye_orange", "orange", "orange", null, null),
			("cf_dye_black", "black", "schwarz", null, null),
			("cf_dye_white", "white", "weiß", null, null),
			("cf_item_leash", "Fighter's Leash", "Kampfhuhn-Leine", "A short lead of plaited leather with a collar. A fighter on the leash strains at every rival but never fights.", "Eine kurze Leine aus geflochtenem Leder mit Halsband. Ein Huhn an der Leine zerrt zu jedem Rivalen, kämpft aber nie."),
			("cf_item_tetherpost", "Tether Post", "Anbindepfahl", "A stake with an iron ring. A fighter tied to it waits here, however much it pulls.", "Ein Pfahl mit Eisenring. Ein Huhn, das hier angebunden ist, wartet, so sehr es auch zerrt.")
		};

		private static readonly (string mat, string en, string de)[] GearMaterials = new(string, string, string)[9]
		{
			("flint", "Flint", "Feuerstein"),
			("bronze", "Bronze", "Bronze"),
			("iron", "Iron", "Eisen"),
			("silver", "Silver", "Silber"),
			("blackmetal", "Black Metal", "Schwarzmetall"),
			("flametal", "Flametal", "Flammenmetall"),
			("bone", "Bone", "Knochen"),
			("leather", "Leather", "Leder"),
			("carapace", "Carapace", "Panzer")
		};

		private static readonly (string slot, string en, string de, string descEn, string descDe)[] GearSlots = new(string, string, string, string, string)[3]
		{
			("blades", "{0} Wing Blades", "{0}-Flügelklingen", "Curved blades strapped to both wings. They add slashing damage to every blow.", "Gebogene Klingen, an beide Flügel geschnallt. Jeder Hieb schneidet stärker."),
			("spurs", "{0} Spurs", "{0}-Sporen", "Sharp spurs strapped to both legs. They add piercing damage to every blow.", "Spitze Sporen, an beide Läufe geschnallt. Jeder Hieb sticht stärker."),
			("armor", "{0} Breastplate", "{0}-Brustpanzer", "A small breastplate on straps. It takes the edge off every hit.", "Ein kleiner Brustpanzer an Riemen. Er nimmt jedem Treffer die Härte.")
		};

		private static readonly (string mat, string en, string de, string descEn, string descDe)[] Arenas = new(string, string, string, string, string)[4]
		{
			("wood", "Stake Pit", "Pfahlgrube", "A small fighting ring: a sand floor in a palisade of stakes, and a step round it to watch from. Two Cluck Fighters in it always fight.", "Ein kleiner Kampfring: Sandboden in einem Pfahlzaun, rundum eine Stufe zum Zuschauen. Zwei Kampfhühner darin kämpfen immer."),
			("stone", "Stone Ring", "Steinring", "A fighting ring walled in stone, roomier than the stake pit. Fighters in it are tougher and learn more.", "Ein Kampfring mit Steinmauer, geräumiger als die Pfahlgrube. Hühner darin halten mehr aus und lernen mehr."),
			("marble", "Marble Arena", "Marmorarena", "A black marble arena with gilded rims. Fights here are fierce, rewarding, and win stars more often.", "Eine Arena aus Schwarzmarmor mit vergoldetem Rand. Kämpfe hier sind heftig, lohnend und bringen öfter Sterne."),
			("grausten", "Grausten Arena", "Grausten-Arena", "The great arena of the Ashlands, in grausten bound with flametal. The best of all rings: the winner leaves it healed.", "Die große Arena der Aschlande, aus Grausten mit Flammenmetall. Der beste aller Ringe: der Sieger verlässt ihn geheilt.")
		};

		public static void Register()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			(string, string, string)[] texts = Texts;
			for (int i = 0; i < texts.Length; i++)
			{
				(string, string, string) tuple = texts[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				string item3 = tuple.Item3;
				dictionary[item] = item2;
				dictionary2[item] = item3;
			}
			(string, string, string, string, string)[] things = Things;
			for (int i = 0; i < things.Length; i++)
			{
				(string, string, string, string, string) tuple2 = things[i];
				dictionary[tuple2.Item1] = tuple2.Item2;
				dictionary2[tuple2.Item1] = tuple2.Item3;
				if (tuple2.Item4 != null)
				{
					dictionary[tuple2.Item1 + "_desc"] = tuple2.Item4;
					dictionary2[tuple2.Item1 + "_desc"] = tuple2.Item5;
				}
			}
			DyeInfo[] all = DyeTable.All;
			foreach (DyeInfo obj in all)
			{
				string text = Items.Token(obj.Prefab);
				string item4 = Find(obj.Token).en;
				string item5 = Find(obj.Token).de;
				dictionary[text] = Cap(item4) + " Dye";
				dictionary2[text] = Cap(item5) + ((item5 == "orange") ? " Farbe" : "e Farbe");
				dictionary[text + "_desc"] = "A pot of " + item4 + " dye for feathers, for team colours at a fight.";
				dictionary2[text + "_desc"] = "Ein Topf Federfarbe in " + Cap(item5) + ", für Mannschaftsfarben beim Kampf.";
			}
			GearInfo[] all2 = GearTable.All;
			foreach (GearInfo gearInfo in all2)
			{
				string text2 = Items.Token(gearInfo.Prefab);
				(string, string) tuple3 = FindMat(gearInfo.Material);
				(string, string, string, string) tuple4 = FindSlot((gearInfo.Slot == GearSlot.Blades) ? "blades" : ((gearInfo.Slot == GearSlot.Spurs) ? "spurs" : "armor"));
				dictionary[text2] = string.Format(tuple4.Item1, tuple3.Item1);
				dictionary2[text2] = string.Format(tuple4.Item2, tuple3.Item2);
				dictionary[text2 + "_desc"] = tuple4.Item3;
				dictionary2[text2 + "_desc"] = tuple4.Item4;
			}
			ArenaInfo[] all3 = ArenaTable.All;
			foreach (ArenaInfo arenaInfo in all3)
			{
				string text3 = Items.Token(arenaInfo.Prefab);
				(string, string, string, string, string)[] arenas = Arenas;
				for (int j = 0; j < arenas.Length; j++)
				{
					(string, string, string, string, string) tuple5 = arenas[j];
					if (tuple5.Item1 == arenaInfo.Material)
					{
						dictionary[text3] = tuple5.Item2;
						dictionary2[text3] = tuple5.Item3;
						dictionary[text3 + "_desc"] = tuple5.Item4;
						dictionary2[text3 + "_desc"] = tuple5.Item5;
					}
				}
			}
			string text4 = "English";
			localization.AddTranslation(ref text4, dictionary);
			text4 = "German";
			localization.AddTranslation(ref text4, dictionary2);
		}

		private static (string en, string de) Find(string key)
		{
			(string, string, string, string, string)[] things = Things;
			for (int i = 0; i < things.Length; i++)
			{
				(string, string, string, string, string) tuple = things[i];
				if (tuple.Item1 == key)
				{
					return (en: tuple.Item2, de: tuple.Item3);
				}
			}
			return (en: key, de: key);
		}

		private static (string en, string de) FindMat(string mat)
		{
			(string, string, string)[] gearMaterials = GearMaterials;
			for (int i = 0; i < gearMaterials.Length; i++)
			{
				(string, string, string) tuple = gearMaterials[i];
				if (tuple.Item1 == mat)
				{
					return (en: tuple.Item2, de: tuple.Item3);
				}
			}
			return (en: mat, de: mat);
		}

		private static (string en, string de, string descEn, string descDe) FindSlot(string slot)
		{
			(string, string, string, string, string)[] gearSlots = GearSlots;
			for (int i = 0; i < gearSlots.Length; i++)
			{
				(string, string, string, string, string) tuple = gearSlots[i];
				if (tuple.Item1 == slot)
				{
					return (en: tuple.Item2, de: tuple.Item3, descEn: tuple.Item4, descDe: tuple.Item5);
				}
			}
			return (en: slot, de: slot, descEn: "", descDe: "");
		}

		private static string Cap(string s)
		{
			if (!string.IsNullOrEmpty(s))
			{
				return char.ToUpperInvariant(s[0]) + s.Substring(1);
			}
			return s;
		}

		public static string T(string token, params object[] args)
		{
			string text = ((Localization.instance != null) ? Localization.instance.Localize("$" + token) : token);
			if (args == null || args.Length == 0)
			{
				return text;
			}
			try
			{
				return string.Format(text, args);
			}
			catch (FormatException)
			{
				return text;
			}
		}

		public static string L(string token)
		{
			if (Localization.instance == null)
			{
				return token;
			}
			return Localization.instance.Localize(token);
		}

		public static string Stars(int n)
		{
			if (n > 0)
			{
				if (n != 1)
				{
					return T("cf_stars", n);
				}
				return T("cf_star1");
			}
			return "";
		}
	}
	[BepInPlugin("zap.cluckfighters", "CluckFighters", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class CluckFightersPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "zap.cluckfighters";

		public const string PluginName = "CluckFighters";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		public static CluckFightersPlugin Instance { get; private set; }

		public static string PluginDir { get; private set; }

		public static ManualLogSource Log { get; private set; }

		public static string AssetPath(string fileName)
		{
			return Path.Combine(PluginDir ?? "", "Assets", fileName);
		}

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Cfg.Bind(((BaseUnityPlugin)this).Config);
			Lang.Register();
			Prefabs.Init();
			_harmony = new Harmony("zap.cluckfighters");
			_harmony.PatchAll(typeof(CluckFightersPlugin).Assembly);
			SelfTest.TryStart(((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace CluckFighters.Visual
{
	internal static class ArenaModel
	{
		public const float WallThick = 0.3f;

		public const float StepWidth = 0.75f;

		public const float StepHeight = 0.35f;

		public static float WallHeight(ArenaInfo a)
		{
			if (!(a.Material == "wood"))
			{
				if (!(a.Material == "stone"))
				{
					return 1f;
				}
				return 0.9f;
			}
			return 0.85f;
		}

		public static float OuterRadius(ArenaInfo a)
		{
			return a.Radius + 0.3f + 0.75f;
		}

		public static GameObject Build(ArenaInfo a)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: 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_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: 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_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("model");
			PartSet partSet = new PartSet();
			float radius = a.Radius;
			float num = WallHeight(a);
			Material mat = Mats.ArenaWall(a.Material);
			Material val2 = Mats.ArenaTrim(a.Material);
			Material mat2 = Mats.ArenaStep(a.Material);
			int seg = Mathf.Max(24, Mathf.RoundToInt(radius * 14f));
			MeshKit.Disc(partSet[Mats.Sand], new Vector3(0f, 0.06f, 0f), radius + 0.05f, seg, (radius + 0.05f) / 1.6f);
			MeshKit.Cylinder(partSet[Mats.Sand], new Vector3(0f, -0.25f, 0f), new Vector3(0f, 0.06f, 0f), radius + 0.05f, seg, caps: false, 4f);
			int num2 = Mathf.Max(12, Mathf.RoundToInt((float)Math.PI * 2f * radius / ((a.Material == "wood") ? 0.22f : 0.9f)));
			for (int i = 0; i < num2; i++)
			{
				float num3 = (float)i * 360f / (float)num2;
				Quaternion val3 = Quaternion.Euler(0f, num3, 0f);
				Vector3 val4 = val3 * Vector3.forward;
				float num4 = radius + 0.15f;
				if (a.Material == "wood")
				{
					float num5 = num + ((i % 2 == 0) ? 0.08f : 0f);
					Vector3 val5 = val4 * num4;
					MeshKit.Cylinder(partSet[Mats.Stake], val5 + Vector3.down * 0.3f, val5 + Vector3.up * (num5 - 0.1f), 0.11f, 7);
					MeshKit.Cylinder(partSet[Mats.Stake], val5 + Vector3.up * (num5 - 0.1f), val5 + Vector3.up * num5, 0.11f, 0.02f, 7, capA: false, capB: false);
				}
				else
				{
					float num6 = (float)Math.PI * 2f * num4 / (float)num2 + 0.02f;
					MeshKit.Box(partSet[mat], val4 * num4 + Vector3.up * (num * 0.5f - 0.15f), new Vector3(num6, num + 0.3f, 0.3f), val3, 1f);
					MeshKit.Box(partSet[val2], val4 * num4 + Vector3.up * (num + 0.03f), new Vector3(num6 + 0.02f, 0.06f, 0.36f), val3);
				}
			}
			if (a.Material == "wood")
			{
				float[] array = new float[2]
				{
					0.25f,
					num - 0.25f
				};
				foreach (float num7 in array)
				{
					MeshKit.Torus(partSet[Mats.DarkWood], new Vector3(0f, num7, 0f), Quaternion.identity, radius + 0.3f + 0.06f, 0.05f, num2 / 2, 6, 6f);
				}
			}
			int num8 = Mathf.Max(16, Mathf.RoundToInt((float)Math.PI * 2f * (radius + 0.3f + 0.75f) / 1.2f));
			for (int k = 0; k < num8; k++)
			{
				float num9 = ((float)k + 0.5f) * 360f / (float)num8;
				Quaternion val6 = Quaternion.Euler(0f, num9, 0f);
				float num10 = radius + 0.3f + 0.375f;
				float num11 = (float)Math.PI * 2f * (num10 + 0.375f) / (float)num8 + 0.02f;
				MeshKit.Box(partSet[mat2], val6 * Vector3.forward * num10 + Vector3.up * 0.024999991f, new Vector3(num11, 0.65f, 0.75f), val6, 1f);
			}
			int[] array2 = new int[2] { 1, 2 };
			foreach (int num12 in array2)
			{
				Vector3 val7 = ((num12 == 1) ? Vector3.forward : Vector3.back);
				Vector3 val8 = val7 * (radius + 0.15f);
				Material mat3 = Mats.Paint((num12 == 1) ? new Color(0.72f, 0.1f, 0.08f) : new Color(0.12f, 0.24f, 0.7f));
				MeshKit.Cylinder(partSet[(a.Material == "marble" || a.Material == "grausten") ? val2 : Mats.DarkWood], val8, val8 + Vector3.up * (num + 0.55f), 0.07f, 8);
				MeshKit.Sphere(partSet[mat3], val8 + Vector3.up * (num + 0.6f), 0.13f);
				MeshKit.Box(partSet[mat3], val8 + Vector3.up * (num + 0.32f) - val7 * 0.08f, new Vector3(0.36f, 0.3f, 0.02f), Quaternion.LookRotation(val7));
			}
			partSet.Emit(val.transform, "arena_" + a.Material);
			return val;
		}

		public static void AddColliders(GameObject prefab, ArenaInfo a)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00ef: 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_010d: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			float radius = a.Radius;
			float num = WallHeight(a);
			GameObject val = new GameObject("floor_collider");
			val.transform.SetParent(prefab.transform, false);
			val.layer = prefab.layer;
			for (int i = 0; i < 6; i++)
			{
				BoxCollider val2 = val.AddComponent<BoxCollider>();
				val2.center = new Vector3(0f, -0.1f, 0f);
				val2.size = new Vector3(radius * 2f * Mathf.Cos((float)Math.PI / 12f), 0.32f, radius * 2f * Mathf.Sin((float)Math.PI / 12f) + 0.01f);
				if (i > 0)
				{
					GameObject val3 = new GameObject("floor_" + i)
					{
						layer = prefab.layer
					};
					val3.transform.SetParent(val.transform, false);
					val3.transform.localRotation = Quaternion.Euler(0f, (float)i * 30f, 0f);
					BoxCollider obj = val3.AddComponent<BoxCollider>();
					obj.center = val2.center;
					obj.size = val2.size;
					Object.DestroyImmediate((Object)(object)val2);
				}
			}
			int num2 = Mathf.Max(12, Mathf.RoundToInt((float)Math.PI * 2f * radius / 0.9f));
			for (int j = 0; j < num2; j++)
			{
				GameObject val4 = new GameObject("wall_" + j)
				{
					layer = prefab.layer
				};
				val4.transform.SetParent(prefab.transform, false);
				val4.transform.localRotation = Quaternion.Euler(0f, (float)j * 360f / (float)num2, 0f);
				BoxCollider obj2 = val4.AddComponent<BoxCollider>();
				float num3 = radius + 0.15f;
				obj2.center = new Vector3(0f, (num + 0.3f) * 0.5f - 0.15f, num3);
				obj2.size = new Vector3((float)Math.PI * 2f * num3 / (float)num2 + 0.05f, num + 0.3f + 0.3f, 0.3f);
			}
			int num4 = Mathf.Max(16, Mathf.RoundToInt((float)Math.PI * 2f * (radius + 0.3f + 0.75f) / 1.2f));
			for (int k = 0; k < num4; k++)
			{
				GameObject val5 = new GameObject("step_" + k)
				{
					layer = prefab.layer
				};
				val5.transform.SetParent(prefab.transform, false);
				val5.transform.localRotation = Quaternion.Euler(0f, ((float)k + 0.5f) * 360f / (float)num4, 0f);
				BoxCollider obj3 = val5.AddComponent<BoxCollider>();
				float num5 = radius + 0.3f + 0.375f;
				obj3.center = new Vector3(0f, 0.024999991f, num5);
				obj3.size = new Vector3((float)Math.PI * 2f * (num5 + 0.375f) / (float)num4 + 0.02f, 0.65f, 0.75f);
			}
		}
	}
	internal static class BodyKit
	{
		internal sealed class Part
		{
			public string Bone;

			public List<(Mesh mesh, Material mat)> Meshes;

			public bool Feathers;
		}

		private static readonly Dictionary<string, Matrix4x4> Rest = new Dictionary<string, Matrix4x4>();

		private static readonly Dictionary<string, Part> Parts = new Dictionary<string, Part>();

		public static Material FeatherSlot;

		public static bool Ready => Rest.Count > 0;

		public static void Capture(GameObject hen)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			Rest.Clear();
			Parts.Clear();
			SkinnedMeshRenderer componentInChildren = hen.GetComponentInChildren<SkinnedMeshRenderer>(true);
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null)
			{
				Mats.Standard = ((Renderer)componentInChildren).sharedMaterial.shader;
			}
			if ((Object)(object)FeatherSlot == (Object)null)
			{
				FeatherSlot = new Material(Mats.Standard)
				{
					name = "CF_FeatherSlot",
					hideFlags = (HideFlags)32
				};
			}
			Transform val = hen.transform.Find("Visual");
			GameObject val2 = null;
			GameObject val3 = new GameObject("cf_sample");
			val3.SetActive(false);
			try
			{
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("no Visual");
				}
				val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, val3.transform);
				val2.transform.SetPositionAndRotation(val.localPosition, val.localRotation);
				val2.transform.localScale = val.localScale;
				Animator component = val2.GetComponent<Animator>();
				AnimationClip val4 = null;
				if ((Object)(object)component != (Object)null && (Object)(object)component.runtimeAnimatorController != (Object)null)
				{
					AnimationClip[] animationClips = component.runtimeAnimatorController.animationClips;
					foreach (AnimationClip val5 in animationClips)
					{
						if ((Object)(object)val5 != (Object)null && ((Object)val5).name == "Idle")
						{
							val4 = val5;
							break;
						}
					}
				}
				if ((Object)(object)val4 != (Object)null)
				{
					val4.SampleAnimation(val2, 0f);
				}
				Transform[] componentsInChildren = val2.GetComponentsInChildren<Transform>(true);
				foreach (Transform val6 in componentsInChildren)
				{
					if (!Rest.ContainsKey(((Object)val6).name))
					{
						Rest[((Object)val6).name] = val6.localToWorldMatrix;
					}
				}
				Body.Measure(val2.GetComponentInChildren<SkinnedMeshRenderer>(true), Rest);
				CluckFightersPlugin.Log.LogInfo((object)("Hen sampled (" + (((Object)(object)val4 != (Object)null) ? "Idle" : "rest pose") + "): " + Body.Describe()));
			}
			catch (Exception ex)
			{
				CluckFightersPlugin.Log.LogWarning((object)("Sampling the hen failed, using her rest pose: " + ex.Message));
				Rest.Clear();
				Transform[] componentsInChildren = hen.GetComponentsInChildren<Transform>(true);
				foreach (Transform val7 in componentsInChildren)
				{
					if (!Rest.ContainsKey(((Object)val7).name))
					{
						Rest[((Object)val7).name] = hen.transform.worldToLocalMatrix * val7.localToWorldMatrix;
					}
				}
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val3);
			}
		}

		public static GameObject Attach(Transform root, string id, Material feathers)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_007a: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			Part part = Get(id);
			if (part == null || part.Meshes.Count == 0)
			{
				return null;
			}
			Transform val = FindBone(root, part.Bone);
			if ((Object)(object)val == (Object)null || !Rest.TryGetValue(part.Bone, out var value))
			{
				return null;
			}
			GameObject val2 = new GameObject("cf_" + id);
			val2.layer = ((Component)root).gameObject.layer;
			Transform transform = val2.transform;
			transform.SetParent(val, false);
			Matrix4x4 inverse = ((Matrix4x4)(ref value)).inverse;
			transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(3));
			transform.localRotation = ((Matrix4x4)(ref inverse)).rotation;
			transform.localScale = ((Matrix4x4)(ref inverse)).lossyScale;
			foreach (var mesh in part.Meshes)
			{
				Mesh item = mesh.mesh;
				Material item2 = mesh.mat;
				GameObject val3 = new GameObject(((Object)item).name)
				{
					layer = val2.layer
				};
				val3.transform.SetParent(transform, false);
				val3.AddComponent<MeshFilter>().sharedMesh = item;
				MeshRenderer obj = val3.AddComponent<MeshRenderer>();
				((Renderer)obj).sharedMaterial = ((item2 == FeatherSlot) ? feathers : item2);
				((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			}
			return val2;
		}

		public static Transform FindBone(Transform root, string name)
		{
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			return null;
		}

		private static Part Get(string id)
		{
			if (Parts.TryGetValue(id, out var value))
			{
				return value;
			}
			try
			{
				value = FighterModels.Build(id);
			}
			catch (Exception ex)
			{
				CluckFightersPlugin.Log.LogWarning((object)("Part " + id + " failed: " + ex.Message));
				value = null;
			}
			Parts[id] = value;
			return value;
		}

		public static Part Make(string bone, PartSet set, string name)
		{
			List<(Mesh, Material)> list = set.Bake("cf_" + name);
			bool flag = false;
			foreach (var item in list)
			{
				flag |= item.Item2 == FeatherSlot;
				((Object)item.Item1).hideFlags = (HideFlags)32;
			}
			return new Part
			{
				Bone = bone,
				Meshes = list,
				Feathers = flag
			};
		}
	}
	internal static class Body
	{
		public static Vector3 HeadTop = new Vector3(0f, 0.785f, 0.22f);

		public static Vector3 Beak = new Vector3(0f, 0.7f, 0.36f);

		public static Vector3 HeadC = new Vector3(0f, 0.735f, 0.25f);

		public static float HeadHalfWidth = 0.065f;

		public static Vector3 Neck = new Vector3(0f, 0.645f, 0.165f);

		public static Vector3 TailBase = new Vector3(0f, 0.53f, -0.36f);

		public static Vector3 BodyC = new Vector3(0f, 0.42f, -0.03f);

		public static Vector3 BodyR = new Vector3(0.25f, 0.19f, 0.32f);

		public static Vector3 WingL = new Vector3(-0.152f, 0.509f, 0.098f);

		public static Vector3 WingR = new Vector3(0.152f, 0.509f, 0.098f);

		public static Vector3 ShinTopL = new Vector3(-0.105f, 0.191f, -0.082f);

		public static Vector3 ShinTopR = new Vector3(0.105f, 0.191f, -0.082f);

		public static Vector3 ShinBotL = new Vector3(-0.084f, 0.031f, -0.008f);

		public static Vector3 ShinBotR = new Vector3(0.084f, 0.031f, -0.008f);

		public static Vector3 ShinTop(float side)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!(side < 0f))
			{
				return ShinTopR;
			}
			return ShinTopL;
		}

		public static Vector3 ShinBot(float side)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!(side < 0f))
			{
				return ShinBotR;
			}
			return ShinBotL;
		}

		public static void Measure(SkinnedMeshRenderer smr, Dictionary<string, Matrix4x4> bones)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: 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_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			Neck = P("spine3", Neck);
			WingL = P("l.wing", WingL);
			WingR = P("r.wing", WingR);
			ShinTopL = P("l.lleg", ShinTopL);
			ShinTopR = P("r.lleg", ShinTopR);
			ShinBotL = P("l.foot", ShinBotL);
			ShinBotR = P("r.foot", ShinBotR);
			if ((Object)(object)smr == (Object)null)
			{
				return;
			}
			Mesh val = new Mesh();
			smr.BakeMesh(val, true);
			Vector3[] vertices = val.vertices;
			Object.DestroyImmediate((Object)(object)val);
			if (vertices.Length == 0)
			{
				return;
			}
			Matrix4x4 localToWorldMatrix = ((Component)smr).transform.localToWorldMatrix;
			Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length];
			for (int i = 0; i < vertices.Length; i++)
			{
				array[i] = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(vertices[i]);
			}
			Vector3 val2 = array[0];
			Vector3 val3 = array[0];
			Vector3 val4 = array[0];
			Vector3[] array2 = array;
			foreach (Vector3 val5 in array2)
			{
				if (val5.y > val2.y)
				{
					val2 = val5;
				}
				if (val5.z > val3.z)
				{
					val3 = val5;
				}
				if (val5.z < val4.z)
				{
					val4 = val5;
				}
			}
			HeadTop = new Vector3(0f, val2.y, val2.z);
			Beak = new Vector3(0f, val3.y, val3.z);
			Vector3 val6 = Vector3.one * 9f;
			Vector3 val7 = -Vector3.one * 9f;
			Vector3 val8 = Vector3.one * 9f;
			Vector3 val9 = -Vector3.one * 9f;
			float num = -9f;
			array2 = array;
			foreach (Vector3 val10 in array2)
			{
				if (val10.y > Neck.y + 0.03f && val10.z > Neck.z - 0.04f)
				{
					val6 = Vector3.Min(val6, val10);
					val7 = Vector3.Max(val7, val10);
				}
				if (val10.y > ShinTopL.y + 0.05f && val10.y < Neck.y && val10.z < Neck.z + 0.1f)
				{
					val8 = Vector3.Min(val8, val10);
					val9 = Vector3.Max(val9, val10);
				}
				if (val10.z < val4.z + 0.12f)
				{
					num = Mathf.Max(num, val10.y);
				}
			}
			if (val7.x > val6.x)
			{
				HeadC = new Vector3(0f, (val6.y + val7.y) * 0.5f, (val6.z + val7.z) * 0.5f);
				HeadHalfWidth = Mathf.Max(0.03f, (val7.x - val6.x) * 0.5f);
			}
			if (val9.x > val8.x)
			{
				BodyC = new Vector3(0f, (val8.y + val9.y) * 0.5f, (val8.z + val9.z) * 0.5f);
				BodyR = (val9 - val8) * 0.5f;
			}
			TailBase = new Vector3(0f, num - 0.03f, val4.z + 0.08f);
			Vector3 P(string b, Vector3 fallback)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				if (!bones.TryGetValue(b, out var value))
				{
					return fallback;
				}
				return Vector4.op_Implicit(((Matrix4x4)(ref value)).GetColumn(3));
			}
		}

		public static string Describe()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_004f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			return $"head top {HeadTop} beak {Beak} head {HeadC} ±{HeadHalfWidth:0.000} neck {Neck} tail {TailBase} body {BodyC} r {BodyR} wings {WingL}/{WingR} shin {ShinTopR}->{ShinBotR}";
		}
	}
	public sealed class FighterAnim : MonoBehaviour
	{
		private Fighter _f;

		private Transform _visual;

		private Transform _spine2;

		private Transform _spine3;

		private Transform _head;

		private Transform _wingL;

		private Transform _wingR;

		private Transform _ulegL;

		private Transform _ulegR;

		private Transform _llegL;

		private Transform _llegR;

		private readonly Quaternion[] _base = (Quaternion[])(object)new Quaternion[9];

		private readonly Quaternion[] _set = (Quaternion[])(object)new Quaternion[9];

		private Transform[] _bones;

		private Vector3 _visualBase;

		private Act _act;

		private float _actStart = -99f;

		private float _seed;

		private const float Chest = 1.16f;

		private const float Thigh = 1.22f;

		private void Start()
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			_f = ((Component)this).GetComponent<Fighter>();
			_visual = ((Component)this).transform.Find("Visual");
			_spine2 = BodyKit.FindBone(((Component)this).transform, "spine2");
			_spine3 = BodyKit.FindBone(((Component)this).transform, "spine3");
			_head = BodyKit.FindBone(((Component)this).transform, "head");
			_wingL = BodyKit.FindBone(((Component)this).transform, "l.wing");
			_wingR = BodyKit.FindBone(((Component)this).transform, "r.wing");
			_ulegL = BodyKit.FindBone(((Component)this).transform, "l.uleg");
			_ulegR = BodyKit.FindBone(((Component)this).transform, "r.uleg");
			_llegL = BodyKit.FindBone(((Component)this).transform, "l.lleg");
			_llegR = BodyKit.FindBone(((Component)this).transform, "r.lleg");
			_bones = (Transform[])(object)new Transform[9] { _spine2, _spine3, _head, _wingL, _wingR, _ulegL, _ulegR, _llegL, _llegR };
			for (int i = 0; i < _bones.Length; i++)
			{
				if ((Object)(object)_bones[i] != (Object)null)
				{
					_base[i] = _bones[i].localRotation;
					_set[i] = _bones[i].localRotation;
				}
			}
			if ((Object)(object)_visual != (Object)null)
			{
				_visualBase = _visual.localPosition;
			}
			_seed = Random.value * 10f;
			Animator componentInChildren = ((Component)this).GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.cullingMode = (AnimatorCullingMode)0;
			}
		}

		public void Play(Act act)
		{
			_act = act;
			_actStart = Time.time;
		}

		private static float Duration(Act a)
		{
			switch (a)
			{
			case Act.Peck:
			case Act.ThunderPeck:
				return 0.38f;
			case Act.Kick:
				return 0.6f;
			case Act.Buffet:
				return 0.5f;
			case Act.Dive:
				return 0.7f;
			case Act.Dodge:
				return 0.35f;
			case Act.Crow:
				return 1.3f;
			case Act.Flap:
				return 0.9f;
			case Act.Transform:
			case Act.StarUp:
			case Act.LevelUp:
				return 1.6f;
			default:
				return 0.8f;
			}
		}

		private static float Bump(float u, float peak = 0.45f)
		{
			if (!(u <= 0f) && !(u >= 1f))
			{
				if (!(u < peak))
				{
					return Mathf.SmoothStep(1f, 0f, (u - peak) / (1f - peak));
				}
				return Mathf.SmoothStep(0f, 1f, u / peak);
			}
			return 0f;
		}

		private void LateUpdate()
		{
			//IL_0041: 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_007d: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: 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_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_f == (Object)null || _bones == null || (Object)(object)_spine2 == (Object)null)
			{
				return;
			}
			for (int i = 0; i < _bones.Length; i++)
			{
				Transform val = _bones[i];
				if (!((Object)(object)val == (Object)null))
				{
					if (Quaternion.Angle(val.localRotation, _set[i]) > 0.01f)
					{
						_base[i] = val.localRotation;
					}
					val.localRotation = _base[i];
				}
			}
			float num = Time.time + _seed;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			float num7 = 0f;
			float num8 = 0f;
			switch (_f.Stance)
			{
			case Stance.Stare:
				num2 = 14f;
				num3 = 26f;
				num5 = 12f + 3f * Mathf.Sin(num * 30f);
				break;
			case Stance.Taunt:
				num5 = 35f + 40f * Mathf.Sin(num * 15f);
				num7 = 0.07f * Mathf.Abs(Mathf.Sin(num * 7f));
				num4 = 18f;
				break;
			case Stance.Strain:
				num2 = 22f;
				num3 = 24f;
				num5 = 28f + 26f * Mathf.Sin(num * 17f);
				num6 = 28f * Mathf.Sin(num * 19f);
				break;
			case Stance.Frenzy:
				num2 = 8f;
				num5 = 22f + 6f * Mathf.Sin(num * 35f);
				num3 = 10f;
				break;
			case Stance.Victory:
				num4 = 38f;
				num5 = 30f + 45f * Mathf.Sin(num * 12f);
				break;
			}
			float num9 = (Time.time - _actStart) / Duration(_act);
			if (num9 >= 0f && num9 < 1f)
			{
				float num10 = Bump(num9);
				switch (_act)
				{
				case Act.Peck:
				case Act.ThunderPeck:
					num3 += 60f * Bump(num9);
					num2 += 16f * num10;
					break;
				case Act.Kick:
					num7 += 0.32f * Mathf.Sin((float)Math.PI * num9);
					num6 -= 75f * Bump(num9, 0.55f);
					num5 += 70f * num10;
					num2 -= 15f * num10;
					break;
				case Act.Buffet:
					num5 += 85f * Mathf.Abs(Mathf.Sin(num9 * (float)Math.PI * 3f));
					num2 += 10f * num10;
					num7 += 0.1f * num10;
					break;
				case Act.Dive:
					num5 += 95f * num10;
					num6 -= 60f * Bump(num9, 0.7f);
					num3 += 30f * Bump(num9, 0.75f);
					break;
				case Act.Dodge:
					num8 += 0.35f * Mathf.Sin((float)Math.PI * num9) * ((Mathf.Sin(_actStart * 13f) > 0f) ? 1f : (-1f));
					num7 += 0.1f * num10;
					break;
				case Act.Crow:
					num4 += 50f * Bump(num9, 0.3f);
					num5 += 25f * num10;
					break;
				case Act.Flap:
					num5 += 70f * Mathf.Abs(Mathf.Sin(num9 * (float)Math.PI * 4f)) * (1f - num9);
					num7 += 0.05f * num10;
					break;
				case Act.Transform:
				case Act.StarUp:
				case Act.LevelUp:
					num5 += 80f * Mathf.Abs(Mathf.Sin(num9 * (float)Math.PI * 5f)) * (1f - num9 * 0.5f);
					num4 += 40f * num10;
					num7 += 0.2f * num10;
					break;
				case Act.Ward:
				case Act.Frenzy:
					num5 += 60f * num10;
					num4 += 20f * num10;
					break;
				}
			}
			Vector3 right = ((Component)this).transform.right;
			Vector3 forward = ((Component)this).transform.forward;
			Turn(0, Quaternion.AngleAxis(num2, right));
			Turn(1, Quaternion.AngleAxis(num3 - num4, right));
			Turn(2, Quaternion.AngleAxis((0f - num4) * 0.4f, right));
			Turn(3, Quaternion.AngleAxis(0f - num5, forward));
			Turn(4, Quaternion.AngleAxis(num5, forward));
			Turn(5, Quaternion.AngleAxis(num6, right));
			Turn(6, Quaternion.AngleAxis((0f - num6) * 0.6f, right));
			_spine2.localScale = Vector3.one * 1.16f;
			if ((Object)(object)_spine3 != (Object)null)
			{
				_spine3.localScale = Vector3.one * 0.8965517f;
			}
			if ((Object)(object)_ulegL != (Object)null)
			{
				_ulegL.localScale = Vector3.one * 1.22f;
			}
			if ((Object)(object)_ulegR != (Object)null)
			{
				_ulegR.localScale = Vector3.one * 1.22f;
			}
			if ((Object)(object)_llegL != (Object)null)
			{
				_llegL.localScale = Vector3.one * 0.90163934f;
			}
			if ((Object)(object)_llegR != (Object)null)
			{
				_llegR.localScale = Vector3.one * 0.90163934f;
			}
			if ((Object)(object)_visual != (Object)null)
			{
				float num11 = Mathf.Max(0.01f, ((Component)this).transform.localScale.y);
				_visual.localPosition = _visualBase + new Vector3(num8, num7, 0f) / num11;
			}
			for (int j = 0; j < _bones.Length; j++)
			{
				if ((Object)(object)_bones[j] != (Object)null)
				{
					_set[j] = _bones[j].localRotation;
				}
			}
		}

		private void Turn(int i, Quaternion q)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = _bones[i];
			if (!((Object)(object)val == (Object)null))
			{
				val.rotation = q * val.rotation;
			}
		}
	}
	internal static class FighterFx
	{
		private static readonly Dictionary<string, GameObject> Cache = new Dictionary<string, GameObject>();

		public static void Play(Fighter f, Act act)
		{
			//IL_001d: 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_0037: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)f == (Object)null) && !((Object)(object)ZNetScene.instance == (Object)null))
			{
				Vector3 val = ((Component)f).transform.position + Vector3.up * 0.5f * ((Component)f).transform.localScale.y;
				Vector3 at = Head(f);
				switch (act)
				{
				case Act.Kick:
				case Act.Buffet:
				case Act.Dodge:
				case Act.Flap:
					Spawn("sfx_chicken_idle_wingflap", val, 0.85f);
					break;
				case Act.Crow:
					Spawn("sfx_chicken_idle_vocal", at, 0.72f, 1.6f);
					break;
				case Act.ThunderPeck:
					Spawn("fx_chainlightning_hit", at, 1f);
					Spawn("sfx_StaffLightning_fire", at, 1.3f);
					break;
				case Act.Ward:
					Spawn("fx_StaffShield_Hit", val, 1f);
					Spawn("sfx_stafffrostorbs_shield_spawn", val, 1.2f);
					break;
				case Act.Frenzy:
					Spawn("vfx_BloodHit", at, 1f);
					Spawn("sfx_chicken_hurt", at, 0.6f, 1.5f);
					break;
				case Act.Dive:
					Spawn("sfx_fallenvalkyrie_wingflap", val, 1.3f);
					break;
				case Act.Wash:
					Spawn("vfx_MeadSplash", val, 1f);
					break;
				case Act.Transform:
					Spawn("fx_creature_tamed", val, 1f);
					Spawn("sfx_chicken_idle_wingflap", val, 0.8f);
					Spawn("sfx_chicken_idle_vocal", at, 0.7f, 1.6f);
					LevelShine(val);
					break;
				case Act.LevelUp:
					LevelShine(val);
					break;
				case Act.StarUp:
					LevelShine(val);
					Spawn("fx_creature_tamed", val, 1f);
					break;
				}
			}
		}

		public static void Crit(Vector3 at)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Spawn("fx_crit", at, 1f);
		}

		private static Vector3 Head(Fighter f)
		{
			//IL_0061: 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_004b: 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)
			Transform val = (((Object)(object)f.Anim != (Object)null) ? BodyKit.FindBone(((Component)f).transform, "head") : null);
			if (!((Object)(object)val != (Object)null))
			{
				return ((Component)f).transform.position + Vector3.up * 0.8f * ((Component)f).transform.localScale.y;
			}
			return val.position;
		}

		private static void LevelShine(Vector3 pos)
		{
			//IL_0031: 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_0040: 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)
			GameObject prefab = ZNetScene.instance.GetPrefab("Player");
			Player obj = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Player>() : null);
			if (obj != null)
			{
				EffectList skillLevelupEffects = obj.m_skillLevelupEffects;
				if (skillLevelupEffects != null)
				{
					skillLevelupEffects.Create(pos, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
				}
			}
		}

		private static void Spawn(string name, Vector3 at, float pitch, float volume = 1f)
		{
			//IL_0032: 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)
			if (!Cache.TryGetValue(name, out var value))
			{
				value = ZNetScene.instance.GetPrefab(name);
				Cache[name] = value;
			}
			if (!((Object)(object)value == (Object)null))
			{
				AudioSource[] componentsInChildren = Object.Instantiate<GameObject>(value, at, Quaternion.identity).GetComponentsInChildren<AudioSource>();
				foreach (AudioSource obj in componentsInChildren)
				{
					obj.pitch *= pitch;
					obj.volume = Mathf.Clamp01(obj.volume * volume);
				}
			}
		}
	}
	public sealed class FighterLook : MonoBehaviour
	{
		private Fighter _f;

		private Renderer _body;

		private Material _bodyMat;

		private Material _featherMat;

		private readonly Dictionary<string, GameObject> _parts = new Dictionary<string, GameObject>();

		private string _sig;

		private float _timer;

		public static Material BodyBase;

		private float _own = 1f;

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

		private static readonly int GlossId = Shader.PropertyToID("_Glossiness");

		private static readonly int MetallicId = Shader.PropertyToID("_Metallic");

		private void Start()
		{
			//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)
			//IL_0128: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			_f = ((Component)this).GetComponent<Fighter>();
			SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if (((Object)val).name == "Hen")
				{
					_body = (Renderer)(object)val;
					break;
				}
			}
			if ((Object)(object)_body != (Object)null)
			{
				_bodyMat = new Material(((Object)(object)BodyBase != (Object)null) ? BodyBase : _body.sharedMaterial)
				{
					name = "CF_FighterBody"
				};
				_body.sharedMaterial = _bodyMat;
			}
			ZNetView component = ((Component)this).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				ZDO zDO = component.GetZDO();
				int num = zDO.GetInt(Keys.Seed, 0);
				if (num == 0 && component.IsOwner())
				{
					num = Random.Range(1, 1000);
					zDO.Set(Keys.Seed, num, false);
				}
				_own = 0.93f + 0.14f * (float)(num % 1000) / 1000f;
			}
			_featherMat = new Material(Mats.Standard)
			{
				name = "CF_FighterFeathers"
			};
			_featherMat.SetFloat(GlossId, 0.55f);
			_featherMat.SetFloat(MetallicId, 0.15f);
			Refresh();
		}

		private void OnDestroy()
		{
			if ((Object)(object)_bodyMat != (Object)null)
			{
				Object.Destroy((Object)(object)_bodyMat);
			}
			if ((Object)(object)_featherMat != (Object)null)
			{
				Object.Destroy((Object)(object)_featherMat);
			}
		}

		private void Update()
		{
			_timer -= Time.deltaTime;
			if (!(_timer > 0f))
			{
				_timer = 0.25f;
				Refresh();
			}
		}

		public void Refresh()
		{
			//IL_014b: 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_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_f == (Object)null || !_f.Valid || !BodyKit.Ready)
			{
				return;
			}
			Nature nature = _f.Nature;
			int stars = _f.Stars;
			int level = _f.Level;
			int dyeShown = _f.DyeShown;
			Stance stance = _f.Stance;
			bool gearActive = _f.GearActive;
			bool flag = _f.WardLeft > 0f;
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append((int)nature).Append('|').Append(stars)
				.Append('|')
				.Append(level)
				.Append('|')
				.Append(dyeShown)
				.Append('|')
				.Append(stance == Stance.Frenzy)
				.Append('|')
				.Append(flag)
				.Append('|')
				.Append(gearActive);
			if (gearActive)
			{
				for (int i = 0; i < Keys.Gear.Length; i++)
				{
					stringBuilder.Append('|').Append(_f.GearIn((GearSlot)i));
				}
			}
			string text = stringBuilder.ToString();
			if (text == _sig)
			{
				return;
			}
			_sig = text;
			float num = Rules.BodyScale(level, stars);
			((Component)this).transform.localScale = Vector3.one * num;
			HashSet<string> hashSet = new HashSet<string>
			{
				(nature == Nature.Berserker) ? "comb_big" : "comb",
				"wattles",
				"sickles_" + Mathf.Clamp(stars, 0, 2)
			};
			if (stars >= 2)
			{
				hashSet.Add("hackles");
			}
			if (stance == Stance.Frenzy)
			{
				hashSet.Add("eyes_rage");
			}
			else if (stars >= 2)
			{
				hashSet.Add("eyes_ember");
			}
			switch (nature)
			{
			case Nature.Stormbeak:
				hashSet.Add("crest_storm");
				break;
			case Nature.Runeclaw:
				hashSet.Add("runes_l");
				hashSet.Add("runes_r");
				break;
			case Nature.Valhalla:
				hashSet.Add("crest_valhalla");
				hashSet.Add("torc");
				break;
			}
			if (flag)
			{
				hashSet.Add("ward");
			}
			if (gearActive)
			{
				GearInfo gearInfo = GearTable.Get(_f.GearIn(GearSlot.Blades));
				GearInfo gearInfo2 = GearTable.Get(_f.GearIn(GearSlot.Spurs));
				GearInfo gearInfo3 = GearTable.Get(_f.GearIn(GearSlot.Armor));
				if (gearInfo != null)
				{
					hashSet.Add("blades_" + gearInfo.Material + "_l");
					hashSet.Add("blades_" + gearInfo.Material + "_r");
				}
				if (gearInfo2 != null)
				{
					hashSet.Add("spurs_" + gearInfo2.Material + "_l");
					hashSet.Add("spurs_" + gearInfo2.Material + "_r");
				}
				if (gearInfo3 != null)
				{
					hashSet.Add("armor_" + gearInfo3.Material);
				}
			}
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, GameObject> part in _parts)
			{
				if (!hashSet.Contains(part.Key) || (Object)(object)part.Value == (Object)null)
				{
					list.Add(part.Key);
				}
			}
			foreach (string item in list)
			{
				if ((Object)(object)_parts[item] != (Object)null)
				{
					Object.Destroy((Object)(object)_parts[item]);
				}
				_parts.Remove(item);
			}
			foreach (string item2 in hashSet)
			{
				if (!_parts.ContainsKey(item2))
				{
					GameObject val = BodyKit.Attach(((Component)this).transform, item2, _featherMat);
					if ((Object)(object)val != (Object)null)
					{
						_parts[item2] = val;
					}
				}
			}
			Color val2 = BodyTint(nature) * (1f - 0.1f * (float)stars) * _own;
			Color val3 = FeatherColor(nature) * (1f - 0.12f * (float)stars);
			DyeInfo dyeInfo = DyeTable.Get(dyeShown);
			if (dyeInfo != null)
			{
				Color val4 = default(Color);
				((Color)(ref val4))..ctor(dyeInfo.R, dyeInfo.G, dyeInfo.B);
				val2 = Color.Lerp(val2, val4 * 1.1f, 0.85f);
				val3 = Color.Lerp(val3, val4 * 0.75f, 0.75f);
			}
			val2.a = 1f;
			val3.a = 1f;
			if ((Object)(object)_bodyMat != (Object)null)
			{
				_bodyMat.SetColor(ColorId, val2);
			}
			_featherMat.SetColor(ColorId, val3);
		}

		public static Color BodyTint(Nature n)
		{
			//IL_0029: 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_0053: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(n switch
			{
				Nature.Stormbeak => new Color(0.56f, 0.64f, 0.84f), 
				Nature.Runeclaw => new Color(0.4f, 0.4f, 0.45f), 
				Nature.Berserker => new Color(0.88f, 0.5f, 0.36f), 
				Nature.Valhalla => new Color(0.92f, 0.82f, 0.58f), 
				_ => new Color(0.8f, 0.8f, 0.8f), 
			});
		}

		public static Color FeatherColor(Nature n)
		{
			//IL_0029: 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_0053: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(n switch
			{
				Nature.Stormbeak => new Color(0.16f, 0.23f, 0.45f), 
				Nature.Runeclaw => new Color(0.05f, 0.09f, 0.11f), 
				Nature.Berserker => new Color(0.38f, 0.07f, 0.04f), 
				Nature.Valhalla => new Color(0.92f, 0.76f, 0.36f), 
				_ => new Color(0.3f, 0.2f, 0.1f), 
			});
		}
	}
	internal static class FighterModels
	{
		private static Vector3 HeadTop => Body.HeadTop;

		private static Vector3 Neck => Body.Neck;

		private static Vector3 TailBase => Body.TailBase;

		private static Vector3 BodyC => Body.BodyC;

		private static Vector3 BodyR => Body.BodyR;

		private static Quaternion HeadRot
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_003a: 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_004c: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = Body.Beak - Body.HeadC;
				val.x = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
				{
					val = Vector3.forward;
				}
				Vector3 val2 = Body.HeadTop - Body.HeadC;
				val2.x = 0f;
				val2 = Vector3.ProjectOnPlane(val2, ((Vector3)(ref val)).normalized);
				if (((Vector3)(ref val2)).sqrMagnitude