Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Animal Leash v1.2.0
plugins/AnimalLeash.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
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 AnimalLeash.Core; using AnimalLeash.Dev; using AnimalLeash.Gameplay; using AnimalLeash.Visual; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [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 AnimalLeash { public static class Cfg { public static ConfigEntry<int> MaxLed; public static ConfigEntry<float> RopeLength; public static ConfigEntry<string> Excluded; public static ConfigEntry<bool> WardProtectsTied; public static ConfigEntry<bool> ThroughPortals; public static ConfigEntry<bool> OnShips; public static readonly ConfigEntry<string>[] Recipe = new ConfigEntry<string>[4]; public static readonly ConfigEntry<string>[] Station = new ConfigEntry<string>[4]; public static readonly ConfigEntry<float>[] TieLength = new ConfigEntry<float>[4]; public static ConfigEntry<string> RailRecipe; public static ConfigEntry<bool> HoverHints; private static HashSet<string> _excluded; private static string _excludedSource; public static HashSet<string> ExcludedSet { get { if (_excluded == null || _excludedSource != Excluded.Value) { _excludedSource = Excluded.Value; _excluded = RecipeText.Names(_excludedSource); } return _excluded; } } 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Expected O, but got Unknown //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Expected O, but got Unknown //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Expected O, but got Unknown //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Expected O, but got Unknown //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; MaxLed = c.Bind<int>("1 - Leash", "MaxLed", 3, new ConfigDescription("How many animals one player can lead at once, each on its own leash.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), new object[1] { val })); RopeLength = c.Bind<float>("1 - Leash", "RopeLength", 2.2f, new ConfigDescription("Length of the rope in metres from your hand to the animal's neck. Big animals get their body length on top.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), new object[1] { val })); Excluded = c.Bind<string>("1 - Leash", "Excluded", "", new ConfigDescription("Creatures that never take a leash (prefab names, comma separated, e.g. CF_CluckFighter). Every other tame creature does, also those of other mods; summoned helpers and tame people (thralls) never do.", (AcceptableValueBase)null, new object[1] { val })); TieLength[0] = c.Bind<float>("1 - Leash", "RopeTieLength", 4f, new ConfigDescription("Length of the hemp leash in metres when you tie the animal to a wall, post, tree or rock.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { val })); TieLength[1] = c.Bind<float>("1 - Leash", "BronzeChainLength", 10f, new ConfigDescription("Length of the bronze chain in metres when tied fast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { val })); TieLength[2] = c.Bind<float>("1 - Leash", "IronChainLength", 20f, new ConfigDescription("Length of the iron chain in metres when tied fast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { val })); TieLength[3] = c.Bind<float>("1 - Leash", "BlackMetalChainLength", 30f, new ConfigDescription("Length of the black metal chain in metres when tied fast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { val })); WardProtectsTied = c.Bind<bool>("1 - Leash", "WardProtectsTied", true, new ConfigDescription("Inside a ward, only players with access can untie an animal or take a loose leash.", (AcceptableValueBase)null, new object[1] { val })); ThroughPortals = c.Bind<bool>("2 - Travel", "ThroughPortals", true, new ConfigDescription("Animals on your leash come with you through portals. Off: the leash slips from your hand and the animal stays at the portal.", (AcceptableValueBase)null, new object[1] { val })); OnShips = c.Bind<bool>("2 - Travel", "OnShips", true, new ConfigDescription("Animals on your leash jump aboard after you and can be tied to the ship, so they sail with it.", (AcceptableValueBase)null, new object[1] { val })); Recipe[0] = c.Bind<string>("3 - Recipes", "Leash", "LeatherScraps:2,DeerHide:1", new ConfigDescription("Cost of one hemp leash.", (AcceptableValueBase)null, new object[1] { val })); Station[0] = c.Bind<string>("3 - Recipes", "LeashStation", "piece_workbench:1", new ConfigDescription("Where the leash is made: station prefab and level.", (AcceptableValueBase)null, new object[1] { val })); Recipe[1] = c.Bind<string>("3 - Recipes", "BronzeChain", "Bronze:2,LeatherScraps:2", new ConfigDescription("Cost of one bronze chain leash.", (AcceptableValueBase)null, new object[1] { val })); Station[1] = c.Bind<string>("3 - Recipes", "BronzeChainStation", "forge:1", new ConfigDescription("Where the bronze chain is made.", (AcceptableValueBase)null, new object[1] { val })); Recipe[2] = c.Bind<string>("3 - Recipes", "IronChain", "Iron:2,Chain:1", new ConfigDescription("Cost of one iron chain leash.", (AcceptableValueBase)null, new object[1] { val })); Station[2] = c.Bind<string>("3 - Recipes", "IronChainStation", "forge:2", new ConfigDescription("Where the iron chain is made.", (AcceptableValueBase)null, new object[1] { val })); Recipe[3] = c.Bind<string>("3 - Recipes", "BlackMetalChain", "BlackMetal:3,LoxPelt:1", new ConfigDescription("Cost of one black metal chain leash.", (AcceptableValueBase)null, new object[1] { val })); Station[3] = c.Bind<string>("3 - Recipes", "BlackMetalChainStation", "forge:3", new ConfigDescription("Where the black metal chain is made.", (AcceptableValueBase)null, new object[1] { val })); RailRecipe = c.Bind<string>("3 - Recipes", "HitchingRail", "Wood:6,LeatherScraps:2", new ConfigDescription("Cost of the hitching rail (built with the hammer near a workbench).", (AcceptableValueBase)null, new object[1] { val })); HoverHints = c.Bind<bool>("4 - Client", "HoverHints", true, "Show how to leash an animal on its hover text while you carry a leash."); c.SettingChanged += delegate(object _, SettingChangedEventArgs a) { if (a != null) { ConfigEntryBase changedSetting = a.ChangedSetting; if (((changedSetting != null) ? new bool?(changedSetting.Definition.Section.StartsWith("3")) : ((bool?)null)) == true) { Cfg.RecipesChanged?.Invoke(); } } _excluded = null; }; SynchronizationManager.OnConfigurationSynchronized += delegate { _excluded = null; Cfg.RecipesChanged?.Invoke(); }; } } public static class Lang { private static readonly (string key, string en, string de)[] Texts = new(string, string, string)[53] { ("al_item_leash", "Leash", "Tierleine"), ("al_item_leash_desc", "A hemp lead with a leather collar. Put it on a tame animal and it walks behind you – a hen to her new coop, a boar across the river, a wolf onto your ship.", "Ein Hanfstrick mit Lederhalsband. Leg es einem zahmen Tier an, und es läuft hinter dir her – das Huhn zum neuen Stall, den Eber über den Fluss, den Wolf aufs Schiff."), ("al_item_chainbronze", "Bronze chain leash", "Bronze-Tierkette"), ("al_item_chainbronze_desc", "A bronze chain with a collar of bronze. It leads an animal like a leash, and chains it to a wall, a post or a tree with a long reach.", "Eine Bronzekette mit Halsring aus Bronze. Sie führt ein Tier wie eine Leine und kettet es mit langer Reichweite an eine Wand, einen Pfosten oder einen Baum."), ("al_item_chainiron", "Iron chain leash", "Eisen-Tierkette"), ("al_item_chainiron_desc", "A heavy iron chain with an iron collar. Chain a wolf to the wall of your keep and let it guard the yard.", "Eine schwere Eisenkette mit eisernem Halsring. Kette einen Wolf an die Mauer deiner Burg und lass ihn den Hof bewachen."), ("al_item_chainblack", "Black metal chain leash", "Schwarzmetall-Tierkette"), ("al_item_chainblack_desc", "A dark chain of black metal, the longest of all. It holds a lox on a wide pasture.", "Eine dunkle Kette aus Schwarzmetall, die längste von allen. Sie hält einen Lox auf einer weiten Weide."), ("al_tt_use", "Use it from the hotbar while you look at a tame animal. Up to {0} at once, each on its own leash.", "Benutze sie aus der Schnellleiste, während du ein zahmes Tier ansiehst. Bis zu {0} zugleich, jedes an seiner eigenen Leine."), ("al_tt_tie", "Tied fast to a wall, post, tree or rock: <color=orange>{0} m</color>. Look at it while you lead the animal: E lets it roam and guard within reach, Shift+E makes it keep still.", "Angebunden an Wand, Pfosten, Baum oder Fels: <color=orange>{0} m</color>. Sieh es an, während du das Tier führst: E lässt es frei im Bereich laufen und wachen, Umschalt+E lässt es stillhalten."), ("al_piece_rail", "Hitching rail", "Anbindebalken"), ("al_piece_rail_desc", "Two posts and a bar with four rope rings. Lead animals here and tie them up: they wait and graze until you come back.", "Zwei Pfosten und ein Balken mit vier Seilringen. Führe Tiere hierher und binde sie an: Sie warten und grasen, bis du wiederkommst."), ("al_hover_usehint", "<color=#b0b0b0>Use a leash or chain from your hotbar to lead it</color>", "<color=#b0b0b0>Benutze eine Tierleine oder -kette aus der Schnellleiste, um es zu führen</color>"), ("al_hover_yours", "On your leash", "An deiner Leine"), ("al_hover_held", "On {0}'s leash", "An der Leine von {0}"), ("al_hover_rail", "Tied to a hitching rail", "An einen Anbindebalken gebunden"), ("al_hover_ship", "Tied to the ship", "Ans Schiff gebunden"), ("al_hover_loose", "A leash hangs from its collar", "Eine Leine hängt an seinem Halsband"), ("al_hover_post", "Tied up here ({0}, {1} m)", "Hier angebunden ({0}, {1} m)"), ("al_hover_postchain", "Chained up here ({0}, {1} m)", "Hier angekettet ({0}, {1} m)"), ("al_hover_postfree", "<color=#b0b0b0>Roams within reach and guards against foes</color>", "<color=#b0b0b0>Läuft frei im Bereich und wacht gegen Feinde</color>"), ("al_hover_postcalm", "<color=#b0b0b0>Keeps still</color>", "<color=#b0b0b0>Hält still</color>"), ("al_key_letgo", "Take the leash off", "Leine abnehmen"), ("al_key_tieship", "Tie it to the ship", "Ans Schiff binden"), ("al_key_take", "Take the lead", "An die Leine nehmen"), ("al_key_tierail", "Tie up {0}", "{0} anbinden"), ("al_key_untie", "Untie and lead them", "Losbinden und führen"), ("al_key_tiepost", "Tie up here, free within reach: {0}", "Hier anbinden, frei im Bereich: {0}"), ("al_key_tiecalm", "Tie up here, keeping still", "Hier anbinden, ruhig"), ("al_rail_tied", "Tied: {0}", "Angebunden: {0}"), ("al_rail_empty", "Nothing tied", "Nichts angebunden"), ("al_msg_leashed", "{0} is on your leash", "{0} ist an deiner Leine"), ("al_msg_letgo", "You take the leash off {0}", "Du nimmst {0} die Leine ab"), ("al_msg_tiedrail", "{0} is tied to the rail", "{0} ist am Balken angebunden"), ("al_msg_tiedship", "{0} is tied to the ship", "{0} ist ans Schiff gebunden"), ("al_msg_already", "{0} is already on your leash", "{0} ist schon an deiner Leine"), ("al_msg_held", "{0} holds {1}'s leash", "{0} hält die Leine von {1}"), ("al_msg_hands", "You cannot hold more than {0} leashes", "Mehr als {0} Leinen kannst du nicht halten"), ("al_msg_busy", "Someone else is quicker with {0}", "Jemand anderes war schneller bei {0}"), ("al_msg_cannot", "{0} will not take a leash", "{0} lässt sich nicht anleinen"), ("al_msg_nottame", "{0} is not tame – it will not take a leash", "{0} ist nicht zahm – es lässt sich nicht anleinen"), ("al_msg_ridden", "Someone is riding {0}", "Jemand reitet {0}"), ("al_msg_slipped", "The leash slipped from your hand – {0} stays behind", "Die Leine ist dir aus der Hand geglitten – {0} bleibt zurück"), ("al_msg_slipportal", "{0} will not go through the portal – the leash slipped from your hand", "{0} geht nicht durchs Portal – die Leine ist dir aus der Hand geglitten"), ("al_msg_railfull", "Every ring on this rail is taken", "Alle Ringe an diesem Balken sind belegt"), ("al_msg_slipcart", "{0} is hitched to a cart and cannot go through the portal – the leash slipped from your hand", "{0} ist vor einen Wagen gespannt und kann nicht durchs Portal – die Leine ist dir aus der Hand geglitten"), ("al_msg_cfbusy", "{0} is on its fighter's leash or in a fight", "{0} hängt an seiner Kampfhahn-Leine oder kämpft gerade"), ("al_msg_bonded", "{0} is bonded to {1}", "{0} ist an {1} gebunden"), ("al_msg_wears", "{0} already wears a leash", "{0} trägt schon eine Leine"), ("al_msg_toofar", "{0} is too far from the rail", "{0} ist zu weit vom Balken weg"), ("al_msg_toofarpost", "{0} is too far away to be tied here", "{0} ist zu weit weg, um hier angebunden zu werden"), ("al_msg_tiedpost", "{0} is tied up here", "{0} ist hier angebunden"), ("al_msg_chainedpost", "{0} is chained up here", "{0} ist hier angekettet") }; 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 text = "English"; localization.AddTranslation(ref text, dictionary); text = "German"; localization.AddTranslation(ref text, dictionary2); } public static string L(string token) { if (Localization.instance == null) { return token; } return Localization.instance.Localize(token); } 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; } } } [BepInPlugin("zap.animalleash", "AnimalLeash", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class AnimalLeashPlugin : BaseUnityPlugin { public const string PluginGuid = "zap.animalleash"; public const string PluginName = "AnimalLeash"; public const string PluginVersion = "1.2.0"; private Harmony _harmony; public static AnimalLeashPlugin 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.animalleash"); _harmony.PatchAll(typeof(AnimalLeashPlugin).Assembly); Compat.Apply(_harmony); SelfTest.TryStart(((Component)this).gameObject); } private void Update() { Leash.TickWaiting(); Patches.Sweep(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace AnimalLeash.Visual { public sealed class LeashRope : MonoBehaviour { private const int Points = 28; private Leash _leash; private LineRenderer _line; private GameObject _collar; private Transform _ring; private bool _fitted; private readonly Vector3[] _pts = (Vector3[])(object)new Vector3[28]; private readonly V3[] _curve = new V3[28]; public static bool Diagnose; private bool _byWeights; private int _linksDrawn; private static readonly Matrix4x4[] Batch = (Matrix4x4[])(object)new Matrix4x4[1023]; private GameObject _wallRing; private LeashKind _ringKind; private static int _floorMask; private static readonly RaycastHit[] FloorHits = (RaycastHit[])(object)new RaycastHit[8]; private Renderer[] _collarRenderers; private Transform _neckBone; private Vector3 _collarPos; private Quaternion _collarRot; private LeashKind _collarKind; private bool _lodJoined; private const int Samples = 10; private const float Fur = 1.1f; private static readonly List<Vector3> Verts = new List<Vector3>(); public Vector3 RingPoint { get { //IL_002a: 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_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_ring != (Object)null)) { return ((Component)this).transform.position + Vector3.up; } return _ring.position; } } public bool Visible { get { if (!((Object)(object)_line != (Object)null) || !((Renderer)_line).enabled) { return _linksDrawn > 0; } return true; } } public float NeckRadius { get; private set; } public string CollarBone { get; private set; } = ""; public LeashKind CollarKind => _collarKind; public int LinksDrawn => _linksDrawn; public GameObject WallRing { get { if (!((Object)(object)_wallRing != (Object)null) || !_wallRing.activeSelf) { return null; } return _wallRing; } } public string FitInfo { get; private set; } = ""; private void Start() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown _leash = ((Component)this).GetComponent<Leash>(); GameObject val = new GameObject("al_rope"); val.transform.SetParent(((Component)this).transform, false); _line = val.AddComponent<LineRenderer>(); _line.useWorldSpace = true; _line.positionCount = 28; _line.numCapVertices = 2; _line.textureMode = (LineTextureMode)1; _line.generateLightingData = true; ((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_line).sharedMaterial = Mats.Rope; ((Renderer)_line).enabled = false; } private void OnDestroy() { if ((Object)(object)_wallRing != (Object)null) { Object.Destroy((Object)(object)_wallRing); } } private void LateUpdate() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0294: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_02be: 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_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0358: 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_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_038f: 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_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: 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_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_052d: 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_053d: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0578: 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_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) _linksDrawn = 0; if ((Object)(object)_leash == (Object)null || (Object)(object)_line == (Object)null || !_leash.Valid) { return; } Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)mainCamera != (Object)null && Vector3.Distance(((Component)mainCamera).transform.position, ((Component)this).transform.position) > 90f) { ((Renderer)_line).enabled = false; return; } LeashState state = _leash.State; if (state == LeashState.None || _leash.Character.IsDead()) { ((Renderer)_line).enabled = false; if ((Object)(object)_collar != (Object)null) { _collar.SetActive(false); } ShowWallRing(show: false, LeashKind.Rope, default(Vector3), default(Vector3)); return; } LeashKind kind = _leash.Kind; if (!_fitted) { Fit(kind); } else if (kind != _collarKind) { BuildCollar(kind); } if ((Object)(object)_collar != (Object)null) { _collar.SetActive(true); } ClearTint(); Vector3 ringPoint = RingPoint; float bodyRadius = _leash.BodyRadius; float num = Mathf.Clamp(0.016f + bodyRadius * 0.012f, 0.018f, 0.04f); _line.widthMultiplier = num; _line.textureScale = new Vector2(1f / (num * 6f), 1f); if (state != LeashState.Post) { ShowWallRing(show: false, LeashKind.Rope, default(Vector3), default(Vector3)); } Vector3 val2; switch (state) { case LeashState.Loose: Trail(ringPoint); Present(kind, num); return; case LeashState.Led: { Player val3 = Leash.FindPlayer(_leash.HolderId); if ((Object)(object)val3 == (Object)null || Vector3.Distance(((Component)val3).transform.position, ((Component)this).transform.position) > 30f) { ((Renderer)_line).enabled = false; return; } Transform val4 = (((Object)(object)((Humanoid)val3).m_visEquipment != (Object)null) ? ((Humanoid)val3).m_visEquipment.m_leftHand : null); val2 = (((Object)(object)val4 != (Object)null) ? val4.position : (((Component)val3).transform.position + Vector3.up * 1f)); break; } case LeashState.Rail: case LeashState.Post: val2 = _leash.Zdo.GetVec3(Keys.Anchor, ((Component)this).transform.position); if (Vector3.Distance(val2, ((Component)this).transform.position) > _leash.RopeLength + 8f) { ShowWallRing(show: false, LeashKind.Rope, default(Vector3), default(Vector3)); Trail(ringPoint); Present(kind, num); return; } if (state == LeashState.Post) { val2 = ShowWallRing(show: true, kind, val2, _leash.Zdo.GetVec3(Keys.AnchorNormal, Vector3.up)); } break; default: { Ship val = _leash.TiedShip(); if ((Object)(object)val == (Object)null) { Trail(ringPoint); Present(kind, num); return; } val2 = ((Component)val).transform.TransformPoint(_leash.Zdo.GetVec3(Keys.Anchor, Vector3.zero)); if (Vector3.Distance(val2, ((Component)this).transform.position) > _leash.RopeLength + 8f) { Trail(ringPoint); Present(kind, num); return; } break; } } float length = _leash.RopeLength - bodyRadius * 0.6f + 0.35f; float sag = RopeMath.Sag(Vector3.Distance(val2, ringPoint), length); RopeMath.Curve(new V3(val2.x, val2.y, val2.z), new V3(ringPoint.x, ringPoint.y, ringPoint.z), sag, _curve); bool flag = state == LeashState.Ship || (Object)(object)_leash.ShipUnder() != (Object)null; float num2 = (Kinds.IsChain(kind) ? (num * 0.25f) : num); Vector3 val5 = ((state == LeashState.Post) ? _leash.Zdo.GetVec3(Keys.AnchorNormal, Vector3.zero) : Vector3.zero); bool flag2 = ((Vector3)(ref val5)).sqrMagnitude > 0.5f && Mathf.Abs(val5.y) < 0.7f; Vector3 val6 = val2; Camera mainCamera2 = Utils.GetMainCamera(); bool flag3 = (Object)(object)mainCamera2 != (Object)null && (Vector3.Distance(((Component)mainCamera2).transform.position, ringPoint) < 40f || Vector3.Distance(((Component)mainCamera2).transform.position, val2) < 40f); Vector3 val7 = default(Vector3); for (int i = 0; i < 28; i++) { ((Vector3)(ref val7))..ctor(_curve[i].X, _curve[i].Y, _curve[i].Z); if (flag2 && i > 0 && i < 27 && Vector3.Distance(val7, val6) < 1f) { float num3 = Vector3.Dot(val7 - val6, val5); if (num3 < 0f) { val7 -= val5 * (num3 * Mathf.Clamp01((float)(27 - i) / 4f)); } } if (!flag && (Object)(object)ZoneSystem.instance != (Object)null && i > 0 && i < 27) { float num4 = (flag3 ? FloorUnder(val7, float.NaN) : float.NaN); if (float.IsNaN(num4)) { num4 = ZoneSystem.instance.GetGroundHeight(val7); } num4 += num2; if (val7.y < num4) { val7.y = num4; } } _pts[i] = val7; } Present(kind, num); } private void Present(LeashKind kind, float width) { if (!Kinds.IsChain(kind)) { _line.SetPositions(_pts); ((Renderer)_line).enabled = true; } else { ((Renderer)_line).enabled = false; DrawChain(Mats.Metal(kind), Wire(width)); } } private static float Wire(float width) { return Mathf.Clamp(width * 0.42f, 0.007f, 0.016f); } private void DrawChain(Material mat, float d) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_016b: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)mainCamera == (Object)null || (Object)(object)mat == (Object)null) { return; } Vector3 position = ((Component)mainCamera).transform.position; if (Vector3.Distance(position, _pts[0]) > 70f && Vector3.Distance(position, _pts[27]) > 70f) { return; } Mesh linkMesh = Models.LinkMesh; float num = 3f * d; Vector3 val = Vector3.one * d; int layer = ((Component)this).gameObject.layer; int num2 = 0; int num3 = 0; float num4 = 0f; for (int i = 0; i < 27; i++) { Vector3 val2 = _pts[i]; Vector3 val3 = _pts[i + 1] - val2; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude < 1E-05f) { continue; } Vector3 val4 = val3 / magnitude; Vector3 val5 = Vector3.ProjectOnPlane(Vector3.up, val4); if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = Vector3.ProjectOnPlane(((Component)this).transform.right, val4); } Quaternion val6 = Quaternion.LookRotation(val4, val5); Quaternion val7 = val6 * Quaternion.Euler(0f, 0f, 90f); for (; num4 <= magnitude; num4 += num) { Batch[num2++] = Matrix4x4.TRS(val2 + val4 * num4, ((num3++ & 1) == 0) ? val6 : val7, val); if (num2 == Batch.Length) { Graphics.DrawMeshInstanced(linkMesh, 0, mat, Batch, num2, (MaterialPropertyBlock)null, (ShadowCastingMode)0, true, layer); _linksDrawn += num2; num2 = 0; } } num4 -= magnitude; } if (num2 > 0) { Graphics.DrawMeshInstanced(linkMesh, 0, mat, Batch, num2, (MaterialPropertyBlock)null, (ShadowCastingMode)0, true, layer); } _linksDrawn += num2; } private Vector3 ShowWallRing(bool show, LeashKind kind, Vector3 knot, Vector3 normal) { //IL_002a: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0138: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (!show) { if ((Object)(object)_wallRing != (Object)null && _wallRing.activeSelf) { _wallRing.SetActive(false); } return knot; } if ((Object)(object)_wallRing == (Object)null || _ringKind != kind) { if ((Object)(object)_wallRing != (Object)null) { Object.Destroy((Object)(object)_wallRing); } _wallRing = Models.WallRing(kind); _ringKind = kind; Items.SetLayer(_wallRing, LayerMask.NameToLayer("piece_nonsolid")); } if (!_wallRing.activeSelf) { _wallRing.SetActive(true); } Vector3 val = ((((Vector3)(ref normal)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref normal)).normalized : Vector3.up); Vector3 val2 = Vector3.ProjectOnPlane(Vector3.up, val); if (((Vector3)(ref val2)).sqrMagnitude < 0.04f) { val2 = Vector3.ProjectOnPlane(knot - ((Component)this).transform.position, val); } if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.ProjectOnPlane(Vector3.forward, val); } ((Vector3)(ref val2)).Normalize(); Quaternion val3 = Quaternion.LookRotation(val, val2); _wallRing.transform.SetPositionAndRotation(knot, val3); return knot + val3 * new Vector3(0f, -0.08f, 0.06f); } private void Trail(Vector3 neck) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0024: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_004e: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a1: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0154: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = ((Component)this).transform.forward; float num = FloorUnder(neck, ((Component)this).transform.position.y); Vector3 val = new Vector3(neck.x, num + 0.02f, neck.z) + forward * 0.25f; Vector3 val2 = val - forward * 0.4f + ((Component)this).transform.right * 0.9f; int num2 = 14; for (int i = 0; i < 28; i++) { if (i <= num2) { float num3 = (float)i / (float)num2; Vector3 val3 = Vector3.Lerp(neck, val, num3); val3.y = Mathf.Lerp(neck.y, val.y, num3 * num3); _pts[i] = val3; } else { float num4 = (float)(i - num2) / (float)(27 - num2); Vector3 val4 = Vector3.Lerp(val, val2, num4) + ((Component)this).transform.forward * (Mathf.Sin(num4 * (float)Math.PI) * 0.12f); val4.y = (((i & 1) == 0 || i == 27) ? (FloorUnder(val4, num) + 0.02f) : _pts[i - 1].y); _pts[i] = val4; } } } private float FloorUnder(Vector3 p, float fallback) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) if (_leash.Character.IsSwimming() || _leash.Character.IsFlying()) { return ((Component)this).transform.position.y; } if (_floorMask == 0) { _floorMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); } Vector3 val = new Vector3(p.x, Mathf.Max(p.y, ((Component)this).transform.position.y) + 0.5f, p.z); float num = float.MinValue; int num2 = Physics.RaycastNonAlloc(val, Vector3.down, FloorHits, 3.5f, _floorMask, (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { if ((Object)(object)((RaycastHit)(ref FloorHits[i])).collider != (Object)null && (Object)(object)((RaycastHit)(ref FloorHits[i])).collider.attachedRigidbody != (Object)(object)_leash.Character.m_body) { num = Mathf.Max(num, ((RaycastHit)(ref FloorHits[i])).point.y); } } if (!(num > float.MinValue)) { return fallback; } return num; } private void Fit(LeashKind kind) { //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_016b: 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_017d: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: 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_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0286: 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_02b2: 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_02c4: Unknown result type (might be due to invalid IL or missing references) _fitted = true; Transform head; Transform val = FindNeck(((Component)this).transform, out head); bool ok = false; List<Vector3> mesh = BakeAll(); Transform val2; if ((Object)(object)val != (Object)null && (Object)(object)head != (Object)null && (Object)(object)val != (Object)(object)head && MeasureByWeights(val, head, out var c, out var axis, out var radius)) { ok = (_byWeights = true); val2 = NearestChainBone(val, head, c); } else if ((Object)(object)val != (Object)null && (Object)(object)head != (Object)null && (Object)(object)val != (Object)(object)head) { Vector3 position = val.position; Vector3 position2 = head.position; Vector3 val3 = position2 - position; axis = ((Vector3)(ref val3)).normalized; float num = Vector3.Distance(position, position2); float num2 = float.MaxValue; c = Vector3.Lerp(position, position2, 0.3f); radius = 0f; for (int i = 0; i <= 10; i++) { float num3 = Mathf.Lerp(-0.5f, 0.75f, (float)i / 10f); Vector3 c2 = position + axis * (num * num3); bool ok2; float num4 = MeasureSlice(mesh, ref c2, axis, out ok2); if (ok2 && !(num4 >= num2)) { num2 = num4; c = c2; radius = num4; ok = true; } } val2 = NearestChainBone(val, head, c); } else { float bodyRadius = _leash.BodyRadius; axis = ((Component)this).transform.forward; c = ((Component)this).transform.position + ((Component)this).transform.forward * bodyRadius * 0.8f + Vector3.up * _leash.BodyHeight * 0.6f; radius = MeasureSlice(mesh, ref c, axis, out ok); val2 = (((Object)(object)head != (Object)null) ? head : ((Component)this).transform); } if (!ok) { radius = Mathf.Max(0.04f, _leash.BodyRadius * 0.3f); } NeckRadius = radius; Transform val4 = val2; CollarBone = ((Object)val4).name; if (Diagnose) { FitInfo += $" root {((val != null) ? ((Object)val).name : null)} {(((Object)(object)val != (Object)null) ? (val.position - ((Component)this).transform.position) : Vector3.zero):F2} head {((head != null) ? ((Object)head).name : null)} {(((Object)(object)head != (Object)null) ? (head.position - ((Component)this).transform.position) : Vector3.zero):F2} centre {c - ((Component)this).transform.position:F2} axis {axis:F2} r {radius:0.000} weights {_byWeights}"; } Vector3 val5 = Vector3.ProjectOnPlane(Vector3.up, axis); if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = Vector3.ProjectOnPlane(((Component)this).transform.forward, axis); } _neckBone = val4; _collarPos = val4.InverseTransformPoint(c); _collarRot = Quaternion.Inverse(val4.rotation) * Quaternion.LookRotation(((Vector3)(ref val5)).normalized, axis); BuildCollar(kind); } private void BuildCollar(LeashKind kind) { //IL_006c: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) _collarKind = kind; if ((Object)(object)_collar != (Object)null) { Object.Destroy((Object)(object)_collar); } if (!((Object)(object)_neckBone == (Object)null)) { float neckRadius = NeckRadius; _collar = Models.Collar(neckRadius * 1.1f, kind); _collar.transform.SetParent(_neckBone, false); _collar.transform.localPosition = _collarPos; _collar.transform.localRotation = _collarRot; _collar.transform.localScale = new Vector3(1f / Mathf.Max(0.0001f, _neckBone.lossyScale.x), 1f / Mathf.Max(0.0001f, _neckBone.lossyScale.y), 1f / Mathf.Max(0.0001f, _neckBone.lossyScale.z)); Renderer[] componentsInChildren = _collar.GetComponentsInChildren<Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].shadowCastingMode = (ShadowCastingMode)0; } Transform transform = new GameObject("al_ring").transform; transform.SetParent(_collar.transform, false); float num = Mathf.Clamp(neckRadius * 0.16f, 0.008f, 0.05f); transform.localPosition = new Vector3(0f, 0f, 0f - (neckRadius * 1.1f + num * 3.2f)); _ring = transform; Items.SetLayer(_collar, ((Component)this).gameObject.layer); _collarRenderers = _collar.GetComponentsInChildren<Renderer>(true); List<Renderer> list = new List<Renderer>(_collarRenderers); if ((Object)(object)_line != (Object)null && !_lodJoined) { list.Add((Renderer)(object)_line); } _lodJoined = true; JoinLod(list.ToArray()); } } private void JoinLod(Renderer[] extra) { LODGroup componentInChildren = ((Component)this).GetComponentInChildren<LODGroup>(); if ((Object)(object)componentInChildren == (Object)null || extra == null || extra.Length == 0) { return; } LOD[] lODs = componentInChildren.GetLODs(); for (int i = 0; i < lODs.Length; i++) { List<Renderer> list = new List<Renderer>((IEnumerable<Renderer>)(((object)lODs[i].renderers) ?? ((object)new Renderer[0]))); list.RemoveAll((Renderer r) => (Object)(object)r == (Object)null); list.AddRange(extra); lODs[i].renderers = list.ToArray(); } componentInChildren.SetLODs(lODs); } private void ClearTint() { if ((Object)(object)_line != (Object)null && ((Renderer)_line).HasPropertyBlock()) { ((Renderer)_line).SetPropertyBlock((MaterialPropertyBlock)null); } if (_collarRenderers == null) { return; } Renderer[] collarRenderers = _collarRenderers; foreach (Renderer val in collarRenderers) { if ((Object)(object)val != (Object)null && val.HasPropertyBlock()) { val.SetPropertyBlock((MaterialPropertyBlock)null); } } } private List<Vector3> BakeAll() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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_01b9: 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) List<Vector3> list = new List<Vector3>(); SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(); Bounds val4 = default(Bounds); foreach (SkinnedMeshRenderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || !((Renderer)val).enabled || (Object)(object)val.sharedMesh == (Object)null || Foreign(((Object)val).name)) { continue; } Mesh val2 = new Mesh(); try { val.BakeMesh(val2, false); val2.GetVertices(Verts); Matrix4x4 val3 = Matrix4x4.TRS(((Component)val).transform.position, ((Component)val).transform.rotation, Vector3.one); ((Bounds)(ref val4))..ctor(((Matrix4x4)(ref val3)).MultiplyPoint3x4((Verts.Count > 0) ? Verts[0] : Vector3.zero), Vector3.zero); foreach (Vector3 vert in Verts) { Vector3 val5 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(vert); list.Add(val5); ((Bounds)(ref val4)).Encapsulate(val5); } if (Diagnose) { string fitInfo = FitInfo; object[] obj = new object[7] { ((Object)val).name, ((Component)val).transform.lossyScale.x, val.sharedMesh.isReadable, ((Bounds)(ref val4)).center - ((Component)this).transform.position, ((Bounds)(ref val4)).size, null, null }; Bounds bounds = ((Renderer)val).bounds; obj[5] = ((Bounds)(ref bounds)).center - ((Component)this).transform.position; bounds = ((Renderer)val).bounds; obj[6] = ((Bounds)(ref bounds)).size; FitInfo = fitInfo + string.Format(" [{0} lossy {1:0.###} readable {2} baked {3:F2}/{4:F2} renderer {5:F2}/{6:F2}]", obj); } } catch (Exception ex) { AnimalLeashPlugin.Log.LogDebug((object)("BakeMesh: " + ex.Message)); } finally { Object.Destroy((Object)(object)val2); } } return list; } private float MeasureSlice(List<Vector3> mesh, ref Vector3 c, Vector3 axis, out bool ok) { //IL_0051: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_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_0169: 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_01b2: Unknown result type (might be due to invalid IL or missing references) ok = false; float num = Mathf.Max(0.2f, _leash.BodyRadius); float num2 = 0.03f * num + 0.008f; float num3 = Mathf.Clamp(num * 0.6f, 0.08f, 1.2f); List<Vector3> list = new List<Vector3>(); foreach (Vector3 item in mesh) { Vector3 val = item - c; float num4 = Vector3.Dot(val, axis); if (!(Mathf.Abs(num4) > num2)) { Vector3 val2 = val - axis * num4; if (!(((Vector3)(ref val2)).magnitude > num3)) { list.Add(item - axis * num4); } } } if (list.Count < 8) { return 0f; } Vector3 val3 = Vector3.zero; float num5 = 0f; for (int i = 0; i < 3; i++) { val3 = Vector3.zero; foreach (Vector3 item2 in list) { val3 += item2; } val3 /= (float)list.Count; List<float> list2 = new List<float>(list.Count); foreach (Vector3 item3 in list) { Vector3 val4 = item3 - val3; list2.Add(((Vector3)(ref val4)).magnitude); } list2.Sort(); num5 = list2[list2.Count / 2]; if (i == 2) { break; } Vector3 cc = val3; float keep = num5 * 1.5f; List<Vector3> list3 = list.FindAll(delegate(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Vector3 val5 = p - cc; return ((Vector3)(ref val5)).magnitude <= keep; }); if (list3.Count < 8) { break; } list = list3; } if (num5 < 0.01f) { return 0f; } c = val3; ok = true; return num5; } private bool MeasureByWeights(Transform root, Transform head, out Vector3 c, out Vector3 axis, out float radius) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046e: 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_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_0190: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056f: 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_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0599: 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_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: 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_02a9: Expected O, but got Unknown //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0365: 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_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) c = root.position; Vector3 val = head.position - root.position; axis = ((Vector3)(ref val)).normalized; radius = 0f; HashSet<Transform> hashSet = new HashSet<Transform>(); Transform parent = head.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)this).transform) { hashSet.Add(parent); if ((Object)(object)parent == (Object)(object)root) { break; } parent = parent.parent; } if (!hashSet.Contains(root)) { return false; } List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); int num = -1; SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || !((Renderer)val2).enabled || (Object)(object)val2.sharedMesh == (Object)null || Foreign(((Object)val2).name)) { continue; } num++; Transform[] bones = val2.bones; if (bones == null || bones.Length == 0) { continue; } bool[] array = new bool[bones.Length]; bool flag = false; for (int j = 0; j < bones.Length; j++) { if ((Object)(object)bones[j] != (Object)null && hashSet.Contains(bones[j])) { flag = (array[j] = true); } } if (!flag) { continue; } BoneWeight[] array2 = (val2.sharedMesh.isReadable ? val2.sharedMesh.boneWeights : null); Mesh val3 = new Mesh(); try { val2.BakeMesh(val3, false); val3.GetVertices(Verts); Matrix4x4 val4 = Matrix4x4.TRS(((Component)val2).transform.position, ((Component)val2).transform.rotation, Vector3.one); if (array2 != null && array2.Length == Verts.Count) { for (int k = 0; k < array2.Length; k++) { int boneIndex = ((BoneWeight)(ref array2[k])).boneIndex0; if (((BoneWeight)(ref array2[k])).weight0 >= 0.5f && boneIndex >= 0 && boneIndex < array.Length && array[boneIndex]) { list.Add(((Matrix4x4)(ref val4)).MultiplyPoint3x4(Verts[k])); list2.Add(num); } } continue; } Vector3[] array3 = (Vector3[])(object)new Vector3[bones.Length]; Vector3[] array4 = (Vector3[])(object)new Vector3[bones.Length]; HashSet<Transform> hashSet2 = new HashSet<Transform>(bones); for (int l = 0; l < bones.Length; l++) { if ((Object)(object)bones[l] == (Object)null) { continue; } val = (array3[l] = (array4[l] = bones[l].position)); foreach (Transform item in bones[l]) { Transform val5 = item; bool num2; if (!array[l]) { num2 = hashSet2.Contains(val5); } else { if ((Object)(object)val5 == (Object)(object)head) { goto IL_02d2; } num2 = head.IsChildOf(val5); } if (!num2) { continue; } goto IL_02d2; IL_02d2: array4[l] = val5.position; break; } } foreach (Vector3 vert in Verts) { Vector3 val6 = ((Matrix4x4)(ref val4)).MultiplyPoint3x4(vert); int num3 = -1; float num4 = float.MaxValue; for (int m = 0; m < bones.Length; m++) { if (!((Object)(object)bones[m] == (Object)null)) { float num5 = DistanceToSegment(val6, array3[m], array4[m]); if (num5 < num4) { num4 = num5; num3 = m; } } } if (num3 >= 0 && array[num3]) { list.Add(val6); list2.Add(num); } } } catch (Exception ex) { AnimalLeashPlugin.Log.LogDebug((object)("Neck weights: " + ex.Message)); } finally { Object.Destroy((Object)(object)val3); } } if (Diagnose) { FitInfo += $" neckverts {list.Count} chain {hashSet.Count}"; } if (list.Count < 12) { return false; } float num6 = float.MaxValue; float num7 = float.MinValue; foreach (Vector3 item2 in list) { float num8 = Vector3.Dot(item2 - root.position, axis); num6 = Mathf.Min(num6, num8); num7 = Mathf.Max(num7, num8); } float num9 = Mathf.Lerp(num6, num7, 0.3f); float num10 = Mathf.Lerp(num6, num7, 0.7f); List<int> list3 = new List<int>(); for (int n = 0; n < list.Count; n++) { float num11 = Vector3.Dot(list[n] - root.position, axis); if (num11 >= num9 && num11 <= num10) { list3.Add(n); } } if (list3.Count < 8) { list3.Clear(); for (int num12 = 0; num12 < list.Count; num12++) { list3.Add(num12); } } Vector3 val7 = Vector3.zero; foreach (int item3 in list3) { val7 += list[item3]; } val7 /= (float)list3.Count; radius = 0f; for (int num13 = 0; num13 <= num; num13++) { List<float> list4 = new List<float>(); foreach (int item4 in list3) { if (list2[item4] == num13) { Vector3 val8 = list[item4] - val7; val = val8 - axis * Vector3.Dot(val8, axis); list4.Add(((Vector3)(ref val)).magnitude); } } if (list4.Count >= 8) { list4.Sort(); radius = Mathf.Max(radius, list4[list4.Count / 2]); } } if (radius < 0.01f) { return false; } c = val7; return true; } private static float DistanceToSegment(Vector3 p, Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = ((sqrMagnitude > 1E-08f) ? Mathf.Clamp01(Vector3.Dot(p - a, val) / sqrMagnitude) : 0f); Vector3 val2 = p - (a + val * num); return ((Vector3)(ref val2)).magnitude; } private static Transform NearestChainBone(Transform root, Transform head, Vector3 p) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Transform result = root; float num = float.MaxValue; Transform val = head; Transform parent = head.parent; while ((Object)(object)parent != (Object)null) { float num2 = DistanceToSegment(p, parent.position, val.position); if (num2 < num) { num = num2; result = parent; } if ((Object)(object)parent == (Object)(object)root) { break; } val = parent; parent = parent.parent; } return result; } public static Transform FindNeck(Transform root, out Transform head) { head = FindBone(root, "head", deepest: false); if ((Object)(object)head != (Object)null) { Transform val = null; Transform parent = head.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)root) { string text = ((Object)parent).name.ToLowerInvariant(); if (text.Contains("neck") && !text.Contains("fat")) { val = parent; } else if ((Object)(object)val != (Object)null) { break; } parent = parent.parent; } if ((Object)(object)val != (Object)null) { return val; } } Transform val2 = FindBone(root, "neck", deepest: false); if ((Object)(object)val2 != (Object)null) { return val2; } if ((Object)(object)head != (Object)null && (Object)(object)head.parent != (Object)null && (Object)(object)head.parent != (Object)(object)root && ((Object)head.parent).name.ToLowerInvariant().Contains("spine")) { return head.parent; } return null; } public static Transform FindBone(Transform root, string key, bool deepest) { HashSet<Transform> hashSet = new HashSet<Transform>(); SkinnedMeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true); Transform[] bones; foreach (SkinnedMeshRenderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || val.bones == null || Foreign(((Object)val).name)) { continue; } bones = val.bones; foreach (Transform val2 in bones) { if ((Object)(object)val2 != (Object)null) { hashSet.Add(val2); } } } Transform val3 = null; int num = -1; bones = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val4 in bones) { if (hashSet.Count > 0 && !hashSet.Contains(val4)) { continue; } string text = ((Object)val4).name.ToLowerInvariant(); if (text.Contains(key) && !text.Contains("end") && !text.StartsWith("al_") && !Foreign(((Object)val4).name)) { int num2 = 0; Transform val5 = val4; while ((Object)(object)val5 != (Object)null && (Object)(object)val5 != (Object)(object)root) { num2++; val5 = val5.parent; } if ((Object)(object)val3 == (Object)null || (deepest ? (num2 > num) : (num2 < num))) { val3 = val4; num = num2; } } } return val3; } private static bool Foreign(string name) { if (!name.StartsWith("WolfRiding", StringComparison.OrdinalIgnoreCase)) { return name.StartsWith("cf_", StringComparison.OrdinalIgnoreCase); } return true; } } internal static class Mats { private static readonly Dictionary<string, Material> Cache = new Dictionary<string, Material>(); private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>(); private static Shader _standard; private static readonly int MetallicId = Shader.PropertyToID("_Metallic"); private static readonly int GlossId = Shader.PropertyToID("_Glossiness"); private static readonly int BumpId = Shader.PropertyToID("_BumpMap"); public static Shader Standard { get { if ((Object)(object)_standard == (Object)null) { _standard = Shader.Find("Standard"); } if (!((Object)(object)_standard != (Object)null)) { return Shader.Find("Legacy Shaders/Diffuse"); } return _standard; } set { if ((Object)(object)value != (Object)null && ((Object)value).name == "Standard") { _standard = value; } } } public static Material Rope => Get("rope", "rope", new Color(0.74f, 0.62f, 0.44f), 0f, 0.08f); public static Material Leather => Get("leather", "leather", new Color(0.42f, 0.27f, 0.16f), 0f, 0.3f); public static Material Iron => Get("iron", "metal", new Color(0.5f, 0.51f, 0.53f), 0.8f, 0.45f); public static Material Bronze => Get("bronze", "metal", new Color(0.72f, 0.47f, 0.22f), 0.85f, 0.55f, instanced: true); public static Material ChainIron => Get("chainiron", "metal", new Color(0.62f, 0.62f, 0.64f), 0.55f, 0.38f, instanced: true); public static Material BlackMetal => Get("blackmetal", "metal", new Color(0.09f, 0.095f, 0.11f), 0.45f, 0.62f, instanced: true); public static Material Wood => Get("wood", "wood", new Color(0.62f, 0.47f, 0.32f), 0f, 0.1f); public static Material Metal(LeashKind k) { return (Material)(k switch { LeashKind.Bronze => Bronze, LeashKind.Iron => ChainIron, LeashKind.BlackMetal => BlackMetal, _ => Iron, }); } private static Material Get(string id, string tex, Color c, float metallic, float gloss, bool instanced = false) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown if (Cache.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { return value; } value = new Material(Standard) { name = "AL_" + id, hideFlags = (HideFlags)32, color = c, enableInstancing = instanced }; if (value.HasProperty(MetallicId)) { value.SetFloat(MetallicId, metallic); } if (value.HasProperty(GlossId)) { value.SetFloat(GlossId, gloss); } if (tex != null) { Texture2D val = Load(tex + "_d.png", linear: false); if ((Object)(object)val != (Object)null) { value.mainTexture = (Texture)(object)val; } Texture2D val2 = Load(tex + "_n.png", linear: true); if ((Object)(object)val2 != (Object)null && value.HasProperty(BumpId)) { value.SetTexture(BumpId, (Texture)(object)val2); value.EnableKeyword("_NORMALMAP"); } } Cache[id] = value; return value; } private static Texture2D Load(string file, bool linear) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown if (Textures.TryGetValue(file, out var value)) { return value; } value = null; string path = AnimalLeashPlugin.AssetPath(file); try { if (File.Exists(path)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = "AL_" + Path.GetFileNameWithoutExtension(file), wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)2, anisoLevel = 4 }; if (AssetUtils.LoadImage(val, File.ReadAllBytes(path))) { value = val; } } } catch (Exception ex) { AnimalLeashPlugin.Log.LogWarning((object)("Could not load " + file + ": " + ex.Message)); } Textures[file] = value; return value; } } internal sealed class MeshBuilder { public readonly List<Vector3> Vertices = new List<Vector3>(256); public readonly List<Vector3> Normals = new List<Vector3>(256); public readonly List<Vector2> UVs = new List<Vector2>(256); public readonly List<int> Triangles = new List<int>(512); private readonly Stack<Matrix4x4> _stack = new Stack<Matrix4x4>(); private Matrix4x4 _base = Matrix4x4.identity; private Matrix4x4 _local = Matrix4x4.identity; private Matrix4x4 _m = Matrix4x4.identity; private Matrix4x4 _n = Matrix4x4.identity; private bool _flip; public bool IsEmpty => Triangles.Count == 0; public void SetBase(Matrix4x4 m) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!(m == _base)) { _base = m; Recalc(); } } public void Push(Matrix4x4 m) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) _stack.Push(_local); _local *= m; Recalc(); } public void Push(Vector3 pos, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) Push(Matrix4x4.TRS(pos, rot, Vector3.one)); } public void Pop() { //IL_001c: 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_0021: Unknown result type (might be due to invalid IL or missing references) _local = ((_stack.Count > 0) ? _stack.Pop() : Matrix4x4.identity); Recalc(); } private void Recalc() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) _m = _base * _local; Matrix4x4 inverse = ((Matrix4x4)(ref _m)).inverse; _n = ((Matrix4x4)(ref inverse)).transpose; _flip = ((Matrix4x4)(ref _m)).determinant < 0f; } public int Add(Vector3 p, Vector3 n, Vector2 uv) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Vertices.Add(((Matrix4x4)(ref _m)).MultiplyPoint3x4(p)); Vector3 val = ((Matrix4x4)(ref _n)).MultiplyVector(n); float magnitude = ((Vector3)(ref val)).magnitude; Normals.Add((magnitude > 1E-08f) ? (val / magnitude) : Vector3.up); UVs.Add(uv); return Vertices.Count - 1; } public void Tri(int a, int b, int c) { Triangles.Add(a); if (_flip) { Triangles.Add(c); Triangles.Add(b); } else { Triangles.Add(b); Triangles.Add(c); } } public void Quad(int a, int b, int c, int d) { Tri(a, b, c); Tri(a, c, d); } public Mesh ToMesh(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Mesh val = new Mesh { name = name }; if (Vertices.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.SetVertices(Vertices); val.SetNormals(Normals); val.SetUVs(0, UVs); val.SetTriangles(Triangles, 0, true); val.RecalculateTangents(); return val; } public void Clear() { Vertices.Clear(); Normals.Clear(); UVs.Clear(); Triangles.Clear(); } } internal sealed class PartSet { private readonly List<Material> _mats = new List<Material>(); private readonly List<MeshBuilder> _builders = new List<MeshBuilder>(); private readonly Stack<Matrix4x4> _stack = new Stack<Matrix4x4>(); private Matrix4x4 _current = Matrix4x4.identity; public MeshBuilder this[Material mat] { get { //IL_0059: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = null; for (int i = 0; i < _mats.Count; i++) { if (_mats[i] == mat) { meshBuilder = _builders[i]; break; } } if (meshBuilder == null) { meshBuilder = new MeshBuilder(); _mats.Add(mat); _builders.Add(meshBuilder); } meshBuilder.SetBase(_current); return meshBuilder; } } public void Push(Matrix4x4 m) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) _stack.Push(_current); _current *= m; } public void Push(Vector3 pos, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) Push(Matrix4x4.TRS(pos, rot, Vector3.one)); } public void Push(Vector3 pos, Quaternion rot, Vector3 scale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) Push(Matrix4x4.TRS(pos, rot, scale)); } public void Pop() { //IL_001c: 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_0021: Unknown result type (might be due to invalid IL or missing references) _current = ((_stack.Count > 0) ? _stack.Pop() : Matrix4x4.identity); } public List<(Mesh mesh, Material mat)> Bake(string name) { //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) List<(Mesh, Material)> list = new List<(Mesh, Material)>(); for (int i = 0; i < _builders.Count; i++) { if (!_builders[i].IsEmpty) { list.Add((_builders[i].ToMesh(name + "_" + (((Object)(object)_mats[i] != (Object)null) ? ((Object)_mats[i]).name : "Mat")), _mats[i])); } } _mats.Clear(); _builders.Clear(); _stack.Clear(); _current = Matrix4x4.identity; return list; } public void Emit(Transform parent, string name) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown for (int i = 0; i < _builders.Count; i++) { MeshBuilder meshBuilder = _builders[i]; Material val = _mats[i]; if (!meshBuilder.IsEmpty) { string text = (((Object)(object)val != (Object)null) ? ((Object)val).name.Replace("AnimalLeash_", "") : "Mat"); GameObject val2 = new GameObject(name + "_" + text); val2.transform.SetParent(parent, false); val2.AddComponent<MeshFilter>().sharedMesh = meshBuilder.ToMesh(((Object)val2).name); MeshRenderer obj = val