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 CatCompanion v1.0.0
CatCompanion.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CatCompanion")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+46dd18b76b51aa3fb8c7e88a4b8fc6ce72ccd324")] [assembly: AssemblyProduct("CatCompanion")] [assembly: AssemblyTitle("CatCompanion")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CatCompanion { internal static class BbModelLoader { private class Context { public Dictionary<string, JObject> Elements; public Dictionary<string, JObject> Groups; public Material Material; public float TexW; public float TexH; public BoneRig Rig; } public const float UnitSize = 0.02f; private static readonly Dictionary<string, int[][]> FaceCorners = new Dictionary<string, int[][]> { ["east"] = new int[4][] { new int[3] { 1, 1, 1 }, new int[3] { 1, 1, 0 }, new int[3] { 1, 0, 1 }, new int[3] { 1, 0, 0 } }, ["west"] = new int[4][] { new int[3] { 0, 1, 0 }, new int[3] { 0, 1, 1 }, new int[3], new int[3] { 0, 0, 1 } }, ["up"] = new int[4][] { new int[3] { 0, 1, 0 }, new int[3] { 1, 1, 0 }, new int[3] { 0, 1, 1 }, new int[3] { 1, 1, 1 } }, ["down"] = new int[4][] { new int[3] { 0, 0, 1 }, new int[3] { 1, 0, 1 }, new int[3], new int[3] { 1, 0, 0 } }, ["south"] = new int[4][] { new int[3] { 0, 1, 1 }, new int[3] { 1, 1, 1 }, new int[3] { 0, 0, 1 }, new int[3] { 1, 0, 1 } }, ["north"] = new int[4][] { new int[3] { 1, 1, 0 }, new int[3] { 0, 1, 0 }, new int[3] { 1, 0, 0 }, new int[3] } }; public static GameObject Load(string path, Func<Color, Material> makeMaterial, out BoneRig rig) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Expected O, but got Unknown //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //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_0177: Expected O, but got Unknown JObject val = JObject.Parse(File.ReadAllText(path)); JToken obj = val["resolution"]; float? obj2; if (obj == null) { obj2 = null; } else { JToken obj3 = obj[(object)"width"]; obj2 = ((obj3 != null) ? new float?(Extensions.Value<float>((IEnumerable<JToken>)obj3)) : ((float?)null)); } float num = obj2 ?? 16f; JToken obj4 = val["resolution"]; float? obj5; if (obj4 == null) { obj5 = null; } else { JToken obj6 = obj4[(object)"height"]; obj5 = ((obj6 != null) ? new float?(Extensions.Value<float>((IEnumerable<JToken>)obj6)) : ((float?)null)); } float num2 = obj5 ?? 16f; Material val2 = makeMaterial(Color.white); JArray val3 = (JArray)val["textures"]; if (val3 != null && ((JContainer)val3).Count > 0) { JToken val4 = val3[0]; JToken obj7 = val4[(object)"uv_width"]; num = ((obj7 != null) ? Extensions.Value<float>((IEnumerable<JToken>)obj7) : num); JToken obj8 = val4[(object)"uv_height"]; num2 = ((obj8 != null) ? Extensions.Value<float>((IEnumerable<JToken>)obj8) : num2); JToken obj9 = val4[(object)"source"]; string text = ((obj9 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj9) : null); if (!string.IsNullOrEmpty(text) && text.Contains(",")) { Texture2D val5 = new Texture2D(2, 2); JToken obj10 = val4[(object)"name"]; ((Object)val5).name = ((obj10 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj10) : null) ?? "texture"; Texture2D val6 = val5; ImageConversion.LoadImage(val6, Convert.FromBase64String(text.Substring(text.IndexOf(',') + 1))); ((Texture)val6).filterMode = (FilterMode)0; ((Texture)val6).wrapMode = (TextureWrapMode)1; val2.mainTexture = (Texture)(object)val6; } } Dictionary<string, JObject> dictionary = new Dictionary<string, JObject>(); float num3 = float.MaxValue; foreach (JObject item in (JArray)val["elements"]) { JObject val7 = item; dictionary[Extensions.Value<string>((IEnumerable<JToken>)val7["uuid"])] = val7; num3 = Mathf.Min(new float[3] { num3, Vec(val7["from"]).y, Vec(val7["to"]).y }); } Dictionary<string, JObject> dictionary2 = new Dictionary<string, JObject>(); JToken obj11 = val["groups"]; JArray val8 = (JArray)(object)((obj11 is JArray) ? obj11 : null); if (val8 != null) { foreach (JObject item2 in val8) { JObject val9 = item2; dictionary2[Extensions.Value<string>((IEnumerable<JToken>)val9["uuid"])] = val9; } } Context context = new Context { Elements = dictionary, Groups = dictionary2, Material = val2, TexW = num, TexH = num2, Rig = new BoneRig() }; JToken obj12 = val["name"]; GameObject val10 = new GameObject(((obj12 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj12) : null) ?? "bbmodel"); Transform transform = new GameObject("Model").transform; transform.SetParent(val10.transform, false); transform.localScale = Vector3.one * 0.02f; transform.localPosition = new Vector3(0f, (0f - num3) * 0.02f, 0f); BuildChildren(context, (JArray)val["outliner"], transform, Vector3.zero); rig = context.Rig; rig.Finish(); return val10; } private static void BuildChildren(Context ctx, JArray children, Transform parent, Vector3 parentOrigin) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown if (children == null) { return; } foreach (JToken child in children) { if ((int)child.Type == 8) { if (ctx.Elements.TryGetValue(Extensions.Value<string>((IEnumerable<JToken>)child), out var value)) { BuildCube(ctx, value, parent, parentOrigin); } continue; } JObject val = (JObject)child; JObject val2 = ((val["name"] != null) ? val : ctx.Groups[Extensions.Value<string>((IEnumerable<JToken>)val["uuid"])]); JToken obj = val2["visibility"]; if (obj == null || Extensions.Value<bool>((IEnumerable<JToken>)obj)) { Vector3 val3 = Vec(val2["origin"]); Transform transform = new GameObject(Extensions.Value<string>((IEnumerable<JToken>)val2["name"])).transform; transform.SetParent(parent, false); transform.localPosition = ToUnity(val3 - parentOrigin); transform.localRotation = ToUnityRotation(Vec(val2["rotation"])); ctx.Rig.Add(transform); BuildChildren(ctx, (JArray)val["children"], transform, val3); } } } private static void BuildCube(Context ctx, JObject e, Transform parent, Vector3 parentOrigin) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00b3: 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_00b9: 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_00ca: 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_00da: 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_0101: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_036c: 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_0380: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Invalid comparison between Unknown and I4 //IL_0239: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: 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_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) JToken obj = e["type"]; if ((((obj != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj) : null) ?? "cube") != "cube") { return; } JToken obj2 = e["export"]; if (obj2 != null && !Extensions.Value<bool>((IEnumerable<JToken>)obj2)) { return; } JToken obj3 = e["visibility"]; if (obj3 != null && !Extensions.Value<bool>((IEnumerable<JToken>)obj3)) { return; } Vector3 val = Vec(e["origin"]); JToken obj4 = e["inflate"]; float num = ((obj4 != null) ? Extensions.Value<float>((IEnumerable<JToken>)obj4) : 0f); Vector3 val2 = Vec(e["from"]) - Vector3.one * num - val; Vector3 val3 = Vec(e["to"]) + Vector3.one * num - val; JToken obj5 = e["name"]; Transform transform = new GameObject(((obj5 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj5) : null) ?? "cube").transform; transform.SetParent(parent, false); transform.localPosition = ToUnity(val - parentOrigin); transform.localRotation = ToUnityRotation(Vec(e["rotation"])); ctx.Rig.Add(transform); List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); JObject val4 = (JObject)e["faces"]; foreach (KeyValuePair<string, int[][]> faceCorner in FaceCorners) { JToken val5 = ((val4 != null) ? val4[faceCorner.Key] : null); if (val5 != null && val5[(object)"texture"] != null && (int)val5[(object)"texture"].Type != 10) { float[] array = val5[(object)"uv"].ToObject<float[]>(); float num2 = array[0] / ctx.TexW; float num3 = 1f - array[1] / ctx.TexH; float num4 = array[2] / ctx.TexW; float num5 = 1f - array[3] / ctx.TexH; Vector2[] array2 = (Vector2[])(object)new Vector2[4] { new Vector2(num2, num3), new Vector2(num4, num3), new Vector2(num2, num5), new Vector2(num4, num5) }; JToken obj6 = val5[(object)"rotation"]; int steps = ((obj6 != null) ? Extensions.Value<int>((IEnumerable<JToken>)obj6) : 0) / 90; int count = list.Count; for (int i = 0; i < 4; i++) { int[] array3 = faceCorner.Value[i]; list.Add(ToUnity(new Vector3((array3[0] == 0) ? val2.x : val3.x, (array3[1] == 0) ? val2.y : val3.y, (array3[2] == 0) ? val2.z : val3.z))); list2.Add(array2[RotateCorner(i, steps)]); } list3.AddRange(new int[6] { count, count + 1, count + 2, count + 2, count + 1, count + 3 }); } } Mesh val6 = new Mesh { name = ((Object)transform).name }; val6.SetVertices(list); val6.SetUVs(0, list2); val6.SetTriangles(list3, 0); val6.RecalculateNormals(); val6.RecalculateBounds(); ((Component)transform).gameObject.AddComponent<MeshFilter>().sharedMesh = val6; ((Renderer)((Component)transform).gameObject.AddComponent<MeshRenderer>()).sharedMaterial = ctx.Material; } private static int RotateCorner(int corner, int steps) { int[] array = new int[4] { 0, 1, 3, 2 }; int[] array2 = new int[4] { 0, 1, 3, 2 }; return array[(array2[corner] + steps % 4 + 4) % 4]; } private static Vector3 Vec(JToken token) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (token == null || (int)token.Type != 2) { return Vector3.zero; } float[] array = token.ToObject<float[]>(); return new Vector3(array[0], array[1], array[2]); } private static Vector3 ToUnity(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) return new Vector3(v.x, v.y, 0f - v.z); } private static Quaternion ToUnityRotation(Vector3 euler) { //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_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (euler == Vector3.zero) { return Quaternion.identity; } Matrix4x4 val = Rot(2, euler.z) * Rot(1, euler.y) * Rot(0, euler.x); Matrix4x4 val2 = Matrix4x4.Scale(new Vector3(1f, 1f, -1f)); Matrix4x4 val3 = val2 * val * val2; return Quaternion.LookRotation(Vector4.op_Implicit(((Matrix4x4)(ref val3)).GetColumn(2)), Vector4.op_Implicit(((Matrix4x4)(ref val3)).GetColumn(1))); } private static Matrix4x4 Rot(int axis, float degrees) { //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_0054: Unknown result type (might be due to invalid IL or missing references) float num = degrees * (MathF.PI / 180f); float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); Matrix4x4 identity = Matrix4x4.identity; int num4 = (axis + 1) % 3; int num5 = (axis + 2) % 3; ((Matrix4x4)(ref identity))[num4, num4] = num2; ((Matrix4x4)(ref identity))[num4, num5] = 0f - num3; ((Matrix4x4)(ref identity))[num5, num4] = num3; ((Matrix4x4)(ref identity))[num5, num5] = num2; return identity; } } internal struct CatAnimState { public float Cycle; public float Move; public float Run; public float Sit; public float Held; public float Air; public float VerticalSpeed; public float Time; public float DeltaTime; } internal interface ICatRig { void Animate(CatAnimState s); } internal class BoneRig : ICatRig { private class Bone { public Transform T; public Vector3 RestPos; public Quaternion RestRot; public Vector3 RestScale; public Vector3 Rot; public Vector3 Pos; } private const float SitAngle = 28f; private const float SitDrop = 6f; private static readonly Vector3 SitPivot = new Vector3(0f, -2f, -6f); private static readonly float[] TailSitPitch = new float[7] { -63f, 6f, 6f, 6f, 6f, -9f, -9f }; private static readonly float[] TailSitYaw = new float[7] { 0f, 0f, 10f, 25f, 30f, 30f, 30f }; private readonly Dictionary<string, Bone> bones = new Dictionary<string, Bone>(); private Bone[] tail; private Bone[] eyes; private float nextBlink = 2f; private float blinkTimer; private float nextEarFlick = 4f; private float earFlickTimer; private string earFlickSide; public void Add(Transform t) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!bones.ContainsKey(((Object)t).name)) { bones[((Object)t).name] = new Bone { T = t, RestPos = t.localPosition, RestRot = t.localRotation, RestScale = t.localScale }; } } public void Finish() { tail = (from n in bones.Keys where n.StartsWith("tail") && int.TryParse(n.Substring(4), out var _) orderby int.Parse(n.Substring(4)) select bones[n]).ToArray(); eyes = (from n in new string[2] { "eye_left", "eye_right" }.Where(bones.ContainsKey) select bones[n]).ToArray(); Plugin.Log.LogInfo((object)$"Bone rig: {bones.Count} parts, {tail.Length} tail segments, {eyes.Length} eyes."); } public void Animate(CatAnimState s) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0357: 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_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_07e6: Unknown result type (might be due to invalid IL or missing references) //IL_07f9: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_0805: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) foreach (Bone value2 in bones.Values) { value2.Rot = Vector3.zero; value2.Pos = Vector3.zero; } float num = Smooth(s.Held); float num2 = Smooth(s.Air) * (1f - num); float num3 = Smooth(s.Sit) * (1f - num) * (1f - num2); float num4 = s.Move * (1f - num3) * (1f - num) * (1f - num2); float num5 = 1f - s.Move; float time = s.Time; float num6 = Mathf.Clamp((0f - s.VerticalSpeed) * 5f, -22f, 22f) * num2; Rot("body", num6, 0f, 0f); Rot("neck", (0f - num6) * 0.6f, 0f, 0f); Rot("leg_front_left", -55f * num2, 0f, 0f); Rot("leg_front_right", -50f * num2, 0f, 0f); Rot("leg_back_left", 55f * num2, 0f, 0f); Rot("leg_back_right", 50f * num2, 0f, 0f); for (int i = 0; i < tail.Length; i++) { Bone obj = tail[i]; obj.Rot += new Vector3((i == 0) ? (-28f) : (-8f), 0f, 0f) * num2; } float num7 = Mathf.Sin(time * 3f) * 8f * num; Rot("leg_front_left", -18f * num + num7, 0f, 0f); Rot("leg_front_right", -18f * num - num7, 0f, 0f); Rot("leg_back_left", 22f * num - num7, 0f, 0f); Rot("leg_back_right", 22f * num + num7, 0f, 0f); Rot("neck", -12f * num, 0f, 0f); for (int j = 0; j < tail.Length; j++) { Bone obj2 = tail[j]; obj2.Rot += new Vector3((j == 0) ? (-110f) : (-9f), Mathf.Sin(time * 2f - (float)j * 0.4f) * 6f, 0f) * num; } Quaternion val = Quaternion.Euler(-28f * num3, 0f, 0f); Rot("body", -28f * num3, 0f, 0f); Move("body", 0f, -6f * num3, 0f); if (bones.TryGetValue("body", out var value)) { Bone bone = value; bone.Pos += SitPivot - val * SitPivot; } Rot("leg_front_left", 26f * num3, 0f, 0f); Rot("leg_front_right", 26f * num3, 0f, 0f); Rot("leg_back_left", -52f * num3, 0f, -8f * num3); Rot("leg_back_right", -52f * num3, 0f, 8f * num3); Rot("neck", 18f * num3, 0f, 0f); Rot("head", 12f * num3, 0f, 0f); for (int k = 0; k < tail.Length; k++) { int num8 = Mathf.Min(k, TailSitPitch.Length - 1); Bone obj3 = tail[k]; obj3.Rot += new Vector3(TailSitPitch[num8], TailSitYaw[num8], 0f) * num3; } float num9 = Mathf.Lerp(26f, 42f, s.Run) * num4; float num10 = Mathf.Sin(s.Cycle); Rot("leg_front_left", num10 * num9, 0f, 0f); Rot("leg_back_right", num10 * num9, 0f, 0f); Rot("leg_front_right", (0f - num10) * num9, 0f, 0f); Rot("leg_back_left", (0f - num10) * num9, 0f, 0f); Move("body", 0f, Mathf.Abs(num10) * Mathf.Lerp(0.35f, 0.8f, s.Run) * num4, 0f); Rot("body", Mathf.Sin(s.Cycle * 2f) * 1.5f * num4, 0f, Mathf.Sin(s.Cycle) * 2f * num4); Rot("neck", (0f - Mathf.Sin(s.Cycle * 2f)) * 2.5f * num4, 0f, 0f); for (int l = 0; l < tail.Length; l++) { if (l == 0) { tail[l].Rot.x += 12f * num4; } tail[l].Rot.y += Mathf.Sin(time * 5f - (float)l * 0.7f) * 5f * num4; } Move("body", 0f, Mathf.Sin(time * 2.4f) * 0.12f * num5, 0f); float num11 = (Mathf.Sin(time * 0.37f) * 22f + Mathf.Sin(time * 1.13f) * 6f) * num5; float num12 = Mathf.Sin(time * 0.53f + 1f) * 6f * num5; Rot("neck", num12 * 0.4f, num11 * 0.4f, 0f); Rot("head", num12 * 0.6f, num11 * 0.6f, Mathf.Sin(time * 0.29f) * 5f * num5); float num13 = num5 * (1f - 0.6f * num3) * (1f - num) * (1f - num2); for (int m = 0; m < tail.Length; m++) { tail[m].Rot.y += Mathf.Sin(time * 1.7f - (float)m * 0.5f) * (4f + (float)m * 1.5f) * num13; if (m == 0) { tail[m].Rot.x += Mathf.Sin(time * 0.9f) * 4f * num13; } } EarFlick(s.DeltaTime); Blink(s.DeltaTime); foreach (Bone value3 in bones.Values) { value3.T.localPosition = value3.RestPos + value3.Pos; value3.T.localRotation = value3.RestRot * Quaternion.Euler(value3.Rot); } } private void EarFlick(float dt) { nextEarFlick -= dt; if (nextEarFlick <= 0f) { nextEarFlick = Random.Range(2.5f, 7f); earFlickTimer = 0.3f; earFlickSide = ((Random.value < 0.5f) ? "ear_left" : "ear_right"); } if (!(earFlickTimer <= 0f)) { earFlickTimer -= dt; float num = Mathf.Sin(Mathf.Clamp01(1f - earFlickTimer / 0.3f) * MathF.PI * 2f); float num2 = ((earFlickSide == "ear_left") ? 1f : (-1f)); Rot(earFlickSide, -8f * Mathf.Abs(num), 0f, 18f * num * num2); } } private void Blink(float dt) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (eyes.Length != 0) { nextBlink -= dt; if (nextBlink <= 0f) { nextBlink = Random.Range(2.5f, 6f); blinkTimer = 0.14f; } float num = 1f; if (blinkTimer > 0f) { blinkTimer -= dt; num = Mathf.Lerp(1f, 0.15f, Mathf.Sin(Mathf.Clamp01(1f - blinkTimer / 0.14f) * MathF.PI)); } Bone[] array = eyes; foreach (Bone bone in array) { bone.T.localScale = new Vector3(bone.RestScale.x, bone.RestScale.y * num, bone.RestScale.z); } } } private void Rot(string name, float x, float y, float z) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) if (bones.TryGetValue(name, out var value)) { Bone bone = value; bone.Rot += new Vector3(x, y, z); } } private void Move(string name, float x, float y, float z) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) if (bones.TryGetValue(name, out var value)) { Bone bone = value; bone.Pos += new Vector3(x, y, z); } } private static float Smooth(float x) { return x * x * (3f - 2f * x); } } public class CatFollower : MonoBehaviour { private enum CatState { Follow, Held, Airborne } private const float Acceleration = 12f; private const float TurnSpeed = 8f; private const float SendInterval = 1f / 15f; private const float NetTimeout = 1f; private const float HolderTimeout = 2f; private const float NetSnapDistance = 3f; private PlayerAvatar owner; private Transform visual; private ICatRig rig; private Animator animator; private bool animHasSpeed; private bool animHasMoving; private Bounds localBounds; private CatState state; private bool moving; private float speed; private float animSpeed; private float walkCycle; private float idleTime; private float sit; private float held; private float air; private bool netAirborne; private float verticalSpeed; private float lastY; private float nextSend; private float lastNetTime = float.NegativeInfinity; private Vector3 netPos; private float netYaw; private const int BeamPoints = 20; private const float MaxThrowSpeed = 9f; private static readonly FieldRef<PlayerAvatar, bool> DeadSetRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("deadSet"); private static readonly FieldRef<PlayerAvatar, bool> IsDisabledRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled"); private static readonly FieldRef<PlayerController, float> InputDisableTimerRef = AccessTools.FieldRefAccess<PlayerController, float>("InputDisableTimer"); private int heldBy; private float holdDistance; private float grabTime; private Vector3 holdTarget; private Vector3 holdVelocity; private LineRenderer beam; private Material beamMaterial; private readonly Vector3[] beamPoints = (Vector3[])(object)new Vector3[20]; private const float MaxHopHeight = 1f; private const float GroundSnap = 0.25f; private static readonly float[] SteerAngles = new float[6] { 35f, -35f, 70f, -70f, 110f, -110f }; private static readonly float[] HopSamples = new float[4] { 0.03f, 0.1f, 0.2f, 0.35f }; private Rigidbody body; private BoxCollider box; private float rideHeight; private int envMask; private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[16]; private bool grounded; private Transform platform; private Vector3 platformLocal; private Vector3 platformVelocity; private float stuckTime; private float hopCooldown; private float airTime; private Collider[] localPlayerColliders; private bool ignoringLocalPlayer; private static int MyActor { get { if (!CatNet.InMultiplayer) { return -1; } return PhotonNetwork.LocalPlayer.ActorNumber; } } private bool IsAuthority { get { if (heldBy == 0) { if (CatNet.InMultiplayer) { if ((Object)(object)owner.photonView != (Object)null) { return owner.photonView.IsMine; } return false; } return true; } return heldBy == MyActor; } } private int AuthorityActor { get { if (heldBy == 0) { if (!((Object)(object)owner.photonView != (Object)null)) { return 0; } return owner.photonView.OwnerActorNr; } return heldBy; } } private bool SimulatesLocally { get { if (!IsAuthority) { if (state != CatState.Held) { return Time.time - lastNetTime >= 1f; } return false; } return true; } } private Vector3 GrabPoint => ((Component)this).transform.TransformPoint(((Bounds)(ref localBounds)).center); private static int VisionMask => LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) & ~LayerMask.GetMask(new string[1] { "Player" }); public static CatFollower Spawn(PlayerAvatar owner) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) CatFollower catFollower = new GameObject(Plugin.CatName.Value).AddComponent<CatFollower>(); catFollower.owner = owner; catFollower.Build(); catFollower.TeleportBehindOwner(); return catFollower; } private void Build() { //IL_0006: 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_003c: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Invalid comparison between Unknown and I4 visual = new GameObject("Visual").transform; visual.SetParent(((Component)this).transform, false); visual.localScale = Vector3.one * Plugin.ModelScale.Value; visual.localRotation = Quaternion.Euler(0f, Plugin.ModelYawOffset.Value, 0f); visual.localPosition = new Vector3(0f, Plugin.ModelHeightOffset.Value, 0f); GameObject val = CatModel.Create(visual, out rig); localBounds = ComputeLocalBounds(bodyOnly: false); BuildPhysics(ComputeLocalBounds(bodyOnly: true)); animator = val.GetComponentInChildren<Animator>(); if (!((Object)(object)animator != (Object)null)) { return; } AnimatorControllerParameter[] parameters = animator.parameters; foreach (AnimatorControllerParameter val2 in parameters) { if (val2.name == "Speed" && (int)val2.type == 1) { animHasSpeed = true; } if (val2.name == "Moving" && (int)val2.type == 4) { animHasMoving = true; } } } private Bounds ComputeLocalBounds(bool bodyOnly) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(new Vector3(0f, 0.2f, 0f), Vector3.zero); bool flag = true; MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshFilter>(); foreach (MeshFilter val in componentsInChildren) { if ((Object)(object)val.sharedMesh == (Object)null || (bodyOnly && IsAppendage(((Component)val).transform))) { continue; } Bounds bounds = val.sharedMesh.bounds; for (int j = 0; j < 8; j++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); Vector3 val3 = ((Component)this).transform.InverseTransformPoint(((Component)val).transform.TransformPoint(val2)); if (flag) { ((Bounds)(ref result))..ctor(val3, Vector3.zero); flag = false; } else { ((Bounds)(ref result)).Encapsulate(val3); } } } return result; } private bool IsAppendage(Transform t) { while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)((Component)this).transform) { string text = ((Object)t).name.ToLowerInvariant(); if (text.Contains("tail") || text.Contains("whisker")) { return true; } t = t.parent; } return false; } internal void ReceiveState(int senderActor, Vector3 pos, float yaw, float netSpeed, float netSit, bool airborne) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) netAirborne = airborne; if ((Object)(object)owner == (Object)null || senderActor != AuthorityActor || IsAuthority) { return; } if (!(Time.time - lastNetTime > 1f)) { Vector3 val = pos - ((Component)this).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude > 9f)) { goto IL_0072; } } Place(pos, Quaternion.Euler(0f, yaw, 0f)); goto IL_0072; IL_0072: lastNetTime = Time.time; netPos = pos; netYaw = yaw; animSpeed = netSpeed; sit = netSit; } private void Update() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)owner == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float deltaTime = Time.deltaTime; CheckHolderTimeout(); UpdateBodyMode(); if (IsAuthority && CatNet.InMultiplayer && Time.time >= nextSend) { nextSend = Time.time + 1f / 15f; CatNet.SendState(((Component)this).transform.position, ((Component)this).transform.eulerAngles.y, animSpeed, sit, state == CatState.Airborne); } if (!SimulatesLocally) { FollowNetwork(deltaTime); } held = Mathf.MoveTowards(held, (state == CatState.Held) ? 1f : 0f, deltaTime * 5f); UpdateInteraction(); UpdateBeam(); Animate(deltaTime); } private void FixedUpdate() { if (!((Object)(object)owner == (Object)null) && SimulatesLocally) { float fixedDeltaTime = Time.fixedDeltaTime; switch (state) { case CatState.Follow: SimulateFollow(fixedDeltaTime); break; case CatState.Held: SimulateHeld(fixedDeltaTime); break; case CatState.Airborne: SimulateAirborne(fixedDeltaTime); break; } } } private void FollowNetwork(float dt) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, netPos, 1f - Mathf.Exp(-12f * dt)); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.Euler(0f, netYaw, 0f), 1f - Mathf.Exp(-12f * dt)); } private void SimulateFollow(float dt) { //IL_000b: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0046: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)owner).transform.position; Vector3 position2 = body.position; Vector3 val = position - position2; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > Plugin.TeleportDistance.Value || Mathf.Abs(position.y - position2.y) > 6f || stuckTime > 2.5f) { TeleportBehindOwner(); return; } float value = Plugin.FollowDistance.Value; if (!moving && magnitude > value + 0.5f) { moving = true; } else if (moving && magnitude < value) { moving = false; } idleTime = ((moving || speed > 0.05f) ? 0f : (idleTime + dt)); float num = ((idleTime > Plugin.SitDelay.Value) ? 1f : 0f); sit = Mathf.MoveTowards(sit, num, dt * ((num > sit) ? 1.2f : 3.5f)); float num2 = 0f; if (moving && sit < 0.2f) { float num3 = magnitude - value; num2 = Mathf.Lerp(Plugin.WalkSpeed.Value, Plugin.RunSpeed.Value, Mathf.InverseLerp(0.5f, 4f, num3)); } speed = Mathf.MoveTowards(speed, num2, 12f * dt); Vector3 val2 = ((magnitude > 0.001f) ? (val / magnitude) : ((Component)this).transform.forward); if (speed > 0.05f) { val2 = Steer(val2); } if (state == CatState.Follow) { float num4 = Mathf.Min(speed, Mathf.Max(0f, magnitude - value * 0.9f) / dt); Drive(val2 * num4, dt); Vector3 val3 = ((speed > 0.1f) ? val2 : val); if (((Vector3)(ref val3)).sqrMagnitude > 0.0025f) { float num5 = ((speed > 0.1f) ? 8f : 2.4f); body.MoveRotation(Quaternion.Slerp(body.rotation, Quaternion.LookRotation(val3), 1f - Mathf.Exp((0f - num5) * dt))); } UpdateStuck(num4, dt); } } private void TeleportBehindOwner() { //IL_000b: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)owner).transform.position; Vector3 val = -FlatForward(((Component)owner).transform) * Plugin.FollowDistance.Value; Vector3 val2 = position + val; if (RaycastEnv(position + Vector3.up * 0.5f, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, out var _)) { val2 = position; } val2.y = GroundHeight(val2, position.y); Place(val2, Quaternion.LookRotation(FlatForward(((Component)owner).transform))); Land(); sit = 0f; } private void Land() { state = CatState.Follow; speed = 0f; idleTime = 0f; moving = false; stuckTime = 0f; } private void Animate(float dt) { //IL_00db: 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_0030: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) if (SimulatesLocally) { Vector3 val = (body.isKinematic ? Vector3.zero : (body.linearVelocity - platformVelocity)); val.y = 0f; float num = ((state == CatState.Follow) ? Mathf.Min(((Vector3)(ref val)).magnitude, speed + 0.5f) : 0f); animSpeed = Mathf.Lerp(animSpeed, num, 1f - Mathf.Exp(-10f * dt)); } if (dt > 0f) { verticalSpeed = Mathf.Lerp(verticalSpeed, (((Component)this).transform.position.y - lastY) / dt, 1f - Mathf.Exp(-12f * dt)); } lastY = ((Component)this).transform.position.y; bool flag = (SimulatesLocally ? (state == CatState.Airborne) : netAirborne); air = Mathf.MoveTowards(air, flag ? 1f : 0f, dt * 8f); float num2 = Mathf.Clamp01(animSpeed / Mathf.Max(0.1f, Plugin.WalkSpeed.Value)); walkCycle += dt * (4f + animSpeed * 3.5f) * num2; if ((Object)(object)animator != (Object)null) { if (animHasSpeed) { animator.SetFloat("Speed", animSpeed); } if (animHasMoving) { animator.SetBool("Moving", animSpeed > 0.1f); } } else if (rig != null) { rig.Animate(new CatAnimState { Cycle = walkCycle, Move = num2, Run = Mathf.InverseLerp(Plugin.WalkSpeed.Value, Plugin.RunSpeed.Value, animSpeed), Sit = sit, Held = held, Air = air, VerticalSpeed = verticalSpeed, Time = Time.time, DeltaTime = dt }); } else { float num3 = Mathf.Abs(Mathf.Sin(walkCycle)) * 0.03f * num2; visual.localPosition = new Vector3(0f, Plugin.ModelHeightOffset.Value + num3, 0f); } } private static Vector3 FlatForward(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) Vector3 forward = t.forward; forward.y = 0f; if (!(((Vector3)(ref forward)).sqrMagnitude > 0.0001f)) { return Vector3.forward; } return ((Vector3)(ref forward)).normalized; } private void UpdateInteraction() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d4: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; PhysGrabber instance2 = PhysGrabber.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || (Object)(object)instance.localCamera == (Object)null || (Object)(object)PlayerController.instance == (Object)null) { return; } bool flag = DeadSetRef.Invoke(instance) || IsDisabledRef.Invoke(instance); if (state == CatState.Held && heldBy == MyActor) { instance2.OverrideGrabDisable(0.1f); if ((Object)(object)Aim.instance != (Object)null) { Aim.instance.SetState((State)2); } ShowName(); Transform val = CameraTransform(instance); holdTarget = val.position + val.forward * holdDistance; if (RaycastEnv(val.position, val.forward, holdDistance, out var hit, VisionMask)) { holdTarget = ((RaycastHit)(ref hit)).point - val.forward * 0.25f; } if (!(((!((Object)(object)InputManager.instance != (Object)null) || !InputManager.instance.InputToggleGet((InputKey)10)) ? (!SemiFunc.InputHold((InputKey)10)) : (SemiFunc.InputDown((InputKey)10) && Time.time > grabTime + 0.2f)) || flag)) { Vector3 val2 = GrabPoint - val.position; if (!(((Vector3)(ref val2)).magnitude > instance2.grabRange * 2f)) { return; } } LocalRelease(); } else { if (flag || instance2.grabbed || InputDisableTimerRef.Invoke(PlayerController.instance) > 0f || !LookingAt(instance, instance2.grabRange, out var distance)) { return; } ShowName(); if (heldBy == 0) { instance2.OverrideGrabDisable(0.1f); if ((Object)(object)Aim.instance != (Object)null) { Aim.instance.SetState((State)1); } if (SemiFunc.InputDown((InputKey)10)) { LocalGrab(distance); } } } } private static void ShowName() { if ((Object)(object)ItemInfoUI.instance != (Object)null) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, Plugin.CatName.Value, false); } } private static Transform CameraTransform(PlayerAvatar me) { return me.localCamera.GetOverrideTransform(); } private bool LookingAt(PlayerAvatar me, float range, out float distance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) distance = 0f; Transform val = CameraTransform(me); Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(((Component)this).transform.InverseTransformPoint(val.position), ((Component)this).transform.InverseTransformDirection(val.forward)); Bounds val3 = localBounds; ((Bounds)(ref val3)).Expand(0.05f); if (!((Bounds)(ref val3)).IntersectRay(val2, ref distance) || distance > range) { return false; } RaycastHit hit; return !RaycastEnv(val.position, val.forward, distance, out hit, VisionMask); } private void LocalGrab(float distance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) heldBy = MyActor; state = CatState.Held; grabTime = Time.time; holdDistance = Mathf.Clamp(distance, 0.8f, 2.5f); holdVelocity = Vector3.zero; speed = 0f; sit = 0f; platform = null; UpdateBodyMode(); if (CatNet.InMultiplayer) { CatNet.SendGrab(); } } private void LocalRelease() { //IL_000e: 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_001d: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) heldBy = 0; StartAirborne(); Vector3 val = Vector3.ClampMagnitude(holdVelocity, 9f); UpdateBodyMode(); if (!body.isKinematic) { body.useGravity = true; body.linearVelocity = val; } if (CatNet.InMultiplayer) { CatNet.SendRelease(((Component)this).transform.position, val); } } private void SimulateHeld(float dt) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00ef: 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) PlayerAvatar instance = PlayerAvatar.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.localCamera == (Object)null)) { body.useGravity = false; Vector3 val = body.position + body.rotation * ((Bounds)(ref localBounds)).center; Vector3 val2 = Vector3.ClampMagnitude((holdTarget - val) * 15f, 12f); body.linearVelocity = val2; holdVelocity = Vector3.Lerp(holdVelocity, val2, 1f - Mathf.Exp(-20f * dt)); Vector3 val3 = CameraTransform(instance).position - body.position; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 0.001f) { body.MoveRotation(Quaternion.Slerp(body.rotation, Quaternion.LookRotation(val3), 1f - Mathf.Exp(-8f * dt))); } } } internal void ReceiveGrab(int senderActor) { if (state != CatState.Held || heldBy != MyActor || senderActor <= MyActor) { heldBy = senderActor; state = CatState.Held; sit = 0f; animSpeed = 0f; lastNetTime = Time.time; UpdateBodyMode(); } } internal void ReceiveRelease(int senderActor, Vector3 pos, Vector3 velocity) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (senderActor == heldBy) { heldBy = 0; lastNetTime = float.NegativeInfinity; StartAirborne(); UpdateBodyMode(); Place(pos, ((Component)this).transform.rotation); if (!body.isKinematic) { body.useGravity = true; body.linearVelocity = velocity; } } } private void CheckHolderTimeout() { if (heldBy != 0 && heldBy != MyActor && !(Time.time - lastNetTime < 2f)) { heldBy = 0; StartAirborne(); } } private void UpdateBeam() { //IL_0097: 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_00a3: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ef: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0174: Unknown result type (might be due to invalid IL or missing references) PhysGrabBeam val = ((state != CatState.Held) ? null : FindHolder()?.physGrabber?.physGrabBeamComponent); if ((Object)(object)val == (Object)null || (Object)(object)val.PhysGrabPointOrigin == (Object)null || (Object)(object)val.lineRenderer == (Object)null) { if ((Object)(object)beam != (Object)null) { ((Renderer)beam).enabled = false; } return; } if ((Object)(object)beam == (Object)null) { CreateBeam(val.lineRenderer); } ((Renderer)beam).enabled = true; Vector3 position = val.PhysGrabPointOrigin.position; Vector3 grabPoint = GrabPoint; Vector3 val2 = ((heldBy == MyActor) ? holdTarget : Vector3.Lerp(position, grabPoint, 0.5f)); for (int i = 0; i < 20; i++) { float num = (float)i / 19f; beamPoints[i] = (1f - num) * (1f - num) * position + 2f * (1f - num) * num * val2 + num * num * grabPoint; } beam.positionCount = 20; beam.SetPositions(beamPoints); if ((Object)(object)beamMaterial != (Object)null) { beamMaterial.mainTextureOffset = new Vector2(Time.time * 5f, 0f); } } private void CreateBeam(LineRenderer template) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GrabBeam"); val.transform.SetParent(((Component)this).transform, false); beam = val.AddComponent<LineRenderer>(); beam.useWorldSpace = true; beamMaterial = ((!((Object)(object)((Renderer)template).sharedMaterial != (Object)null)) ? ((Material)null) : new Material(((Renderer)template).sharedMaterial)); ((Renderer)beam).sharedMaterial = beamMaterial; beam.widthCurve = template.widthCurve; beam.widthMultiplier = template.widthMultiplier; beam.colorGradient = template.colorGradient; beam.textureMode = template.textureMode; beam.alignment = template.alignment; beam.numCapVertices = template.numCapVertices; ((Renderer)beam).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)beam).receiveShadows = false; } private PlayerAvatar FindHolder() { if (heldBy == 0) { return null; } if (heldBy == MyActor) { return PlayerAvatar.instance; } if ((Object)(object)GameDirector.instance == (Object)null) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && (Object)(object)player.photonView != (Object)null && player.photonView.OwnerActorNr == heldBy) { return player; } } return null; } private void OnDestroy() { if ((Object)(object)beamMaterial != (Object)null) { Object.Destroy((Object)(object)beamMaterial); } if ((Object)(object)box != (Object)null && (Object)(object)((Collider)box).sharedMaterial != (Object)null) { Object.Destroy((Object)(object)((Collider)box).sharedMaterial); } } private void BuildPhysics(Bounds torso) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00a8: 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_00c6: 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_00e3: 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_00fd: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown envMask = LayerMask.GetMask(new string[5] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "StaticGrabObject" }); rideHeight = Mathf.Clamp(((Bounds)(ref torso)).size.y * 0.3f, 0.05f, 0.3f); box = ((Component)this).gameObject.AddComponent<BoxCollider>(); box.center = new Vector3(((Bounds)(ref torso)).center.x, (rideHeight + ((Bounds)(ref torso)).max.y) * 0.5f, ((Bounds)(ref torso)).center.z); box.size = new Vector3(((Bounds)(ref torso)).size.x, ((Bounds)(ref torso)).max.y - rideHeight, ((Bounds)(ref torso)).size.z); ((Collider)box).sharedMaterial = new PhysicsMaterial("Cat") { dynamicFriction = 0.3f, staticFriction = 0.3f, bounciness = 0.2f, frictionCombine = (PhysicsMaterialCombine)2, bounceCombine = (PhysicsMaterialCombine)0 }; body = ((Component)this).gameObject.AddComponent<Rigidbody>(); body.mass = 2f; body.constraints = (RigidbodyConstraints)112; body.collisionDetectionMode = (CollisionDetectionMode)3; body.interpolation = (RigidbodyInterpolation)1; } private void UpdateBodyMode() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) bool simulatesLocally = SimulatesLocally; if (simulatesLocally == !body.isKinematic) { UpdatePlayerCollision(); return; } body.isKinematic = !simulatesLocally; body.interpolation = (RigidbodyInterpolation)(simulatesLocally ? 1 : 0); if (simulatesLocally) { body.linearVelocity = Vector3.zero; } UpdatePlayerCollision(); } private void UpdatePlayerCollision() { bool flag = !SimulatesLocally || state == CatState.Held; if (localPlayerColliders == null && (Object)(object)PlayerController.instance != (Object)null) { List<Collider> list = new List<Collider>(((Component)PlayerController.instance).GetComponentsInChildren<Collider>(true)); if ((Object)(object)PlayerAvatar.instance != (Object)null) { list.AddRange(((Component)PlayerAvatar.instance).GetComponentsInChildren<Collider>(true)); } localPlayerColliders = list.ToArray(); ignoringLocalPlayer = !flag; } if (localPlayerColliders == null || flag == ignoringLocalPlayer) { return; } Collider[] array = localPlayerColliders; foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { Physics.IgnoreCollision((Collider)(object)box, val, flag); } } ignoringLocalPlayer = flag; } private void Place(Vector3 pos, Quaternion rot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0038: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.SetPositionAndRotation(pos, rot); body.position = pos; body.rotation = rot; if (!body.isKinematic) { body.linearVelocity = Vector3.zero; } platform = null; } private void Drive(Vector3 horizontal, float dt) { //IL_0023: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0057: 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_00b8: 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) grounded = ProbeGround(out var ground); TrackPlatform((RaycastHit)(grounded ? ground : default(RaycastHit)), dt); float num = (grounded ? ((RaycastHit)(ref ground)).point.y : float.MinValue); if (((Vector3)(ref horizontal)).sqrMagnitude > 0.01f && ProbeStepAhead(((Vector3)(ref horizontal)).normalized, out var stepY)) { num = Mathf.Max(num, stepY); grounded = true; } Vector3 linearVelocity = horizontal + new Vector3(platformVelocity.x, 0f, platformVelocity.z); if (grounded) { body.useGravity = false; linearVelocity.y = Mathf.Clamp((num - body.position.y) * 25f, -4f, 5f) + platformVelocity.y; } else { body.useGravity = true; linearVelocity.y = body.linearVelocity.y; } body.linearVelocity = linearVelocity; } private bool ProbeGround(out RaycastHit ground) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Vector3 origin = body.position + Vector3.up * (rideHeight + 0.05f); float distance = rideHeight + 0.05f + (grounded ? Mathf.Max(0.25f, Plugin.StepHeight.Value) : 0.03f); return SphereCastEnv(origin, 0.05f, Vector3.down, distance, out ground); } private bool ProbeStepAhead(Vector3 dir, out float stepY) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00f3: Unknown result type (might be due to invalid IL or missing references) stepY = 0f; float value = Plugin.StepHeight.Value; Vector3 position = body.position; float num = box.size.z * 0.5f + 0.1f + speed * 0.08f; Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(box.center.x, 0f, box.center.z)) + dir * num; val.y = position.y + value + 0.1f; if (Physics.CheckSphere(val, 0.05f, envMask, (QueryTriggerInteraction)1)) { return false; } if (!SphereCastEnv(val, 0.05f, Vector3.down, value + 0.1f, out var hit)) { return false; } stepY = ((RaycastHit)(ref hit)).point.y; if (stepY > position.y + 0.02f) { return stepY <= position.y + value; } return false; } private void TrackPlatform(RaycastHit ground, float dt) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)((RaycastHit)(ref ground)).collider != (Object)null && (Object)(object)((RaycastHit)(ref ground)).collider.attachedRigidbody != (Object)null) ? ((Component)((RaycastHit)(ref ground)).collider.attachedRigidbody).transform : null); platformVelocity = (((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)platform) ? ((platform.TransformPoint(platformLocal) - body.position) / dt) : Vector3.zero); platformVelocity = Vector3.ClampMagnitude(platformVelocity, 15f); platform = val; if ((Object)(object)platform != (Object)null) { platformLocal = platform.InverseTransformPoint(body.position); } } private Vector3 Steer(Vector3 desired) { //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_0031: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) hopCooldown -= Time.fixedDeltaTime; float distance = 0.2f + speed * 0.12f; if (!CastBody(desired, distance, out var hit)) { return desired; } if (TryHop(desired, hit)) { return desired; } float[] steerAngles = SteerAngles; foreach (float num in steerAngles) { Vector3 val = Quaternion.Euler(0f, num, 0f) * desired; if (!CastBody(val, distance, out var _)) { return val; } } return desired; } private bool TryHop(Vector3 dir, RaycastHit block) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00ee: 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_00b7: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) if (!grounded || hopCooldown > 0f) { return false; } Vector3 position = body.position; float num = position.y + 1f + 0.3f; float num2 = float.MinValue; RaycastHit hit = default(RaycastHit); float[] hopSamples = HopSamples; foreach (float num3 in hopSamples) { Vector3 val = new Vector3(((RaycastHit)(ref block)).point.x, num, ((RaycastHit)(ref block)).point.z) + dir * num3; if (Physics.CheckSphere(val, 0.05f, envMask, (QueryTriggerInteraction)1)) { return false; } if (!RaycastEnv(val, Vector3.down, 1.3f, out hit)) { return false; } num2 = Mathf.Max(num2, ((RaycastHit)(ref hit)).point.y); } float num4 = ((RaycastHit)(ref hit)).point.y - position.y; float num5 = num2 - position.y; if (num5 <= Plugin.StepHeight.Value || num5 > 1f) { return false; } Vector3 half = box.size * 0.45f; Vector3 center = ((RaycastHit)(ref hit)).point + Vector3.up * (box.center.y + 0.02f); if (OverlapsEnv(center, half, Quaternion.LookRotation(dir))) { return false; } Vector3 gravity = Physics.gravity; float num6 = Mathf.Max(1f, ((Vector3)(ref gravity)).magnitude); float num7 = Mathf.Sqrt(2f * num6 * (num5 + 0.25f)); float num8 = num7 / num6 + Mathf.Sqrt(2f * Mathf.Max(0.05f, num5 + 0.25f - num4) / num6); float num9 = Mathf.Max(1.2f, (Vector3.Distance(Flat(position), Flat(((RaycastHit)(ref hit)).point)) + 0.25f) / num8); body.useGravity = true; body.linearVelocity = dir * num9 + Vector3.up * num7 + new Vector3(platformVelocity.x, 0f, platformVelocity.z); StartAirborne(); hopCooldown = 0.6f; return true; } private void StartAirborne() { state = CatState.Airborne; airTime = 0f; grounded = false; platform = null; sit = 0f; } private void SimulateAirborne(float dt) { //IL_002d: 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_006e: Unknown result type (might be due to invalid IL or missing references) airTime += dt; body.useGravity = true; RaycastHit ground; if (airTime > 6f || body.position.y < ((Component)owner).transform.position.y - 30f) { TeleportBehindOwner(); } else if (airTime > 0.1f && body.linearVelocity.y <= 0.5f && ProbeGround(out ground)) { Land(); grounded = true; } } private void UpdateStuck(float wantedSpeed, float dt) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = body.linearVelocity - platformVelocity; val.y = 0f; stuckTime = ((wantedSpeed > 0.5f && ((Vector3)(ref val)).magnitude < 0.15f) ? (stuckTime + dt) : 0f); } private float GroundHeight(Vector3 at, float fallbackY) { //IL_0000: 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_001b: 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_003e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(at.y, fallbackY) + 1f; if (!RaycastEnv(new Vector3(at.x, num, at.z), Vector3.down, 4f, out var hit)) { return fallbackY; } return ((RaycastHit)(ref hit)).point.y; } private bool CastBody(Vector3 dir, float distance, out RaycastHit hit) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00f1: 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_00f9: Unknown result type (might be due to invalid IL or missing references) float num = box.center.y + box.size.y * 0.5f; float num2 = Mathf.Min(Mathf.Max(box.center.y - box.size.y * 0.5f, Plugin.StepHeight.Value), num - 0.06f); Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(box.center.x, (num + num2) * 0.5f, box.center.z)) - dir * 0.15f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(box.size.x * 0.45f, (num - num2) * 0.45f, box.size.z * 0.45f); int count = Physics.BoxCastNonAlloc(val, val2, dir, hits, Quaternion.LookRotation(dir), distance + 0.15f, envMask, (QueryTriggerInteraction)1); return Nearest(count, out hit); } private bool RaycastEnv(Vector3 origin, Vector3 dir, float distance, out RaycastHit hit, int mask = 0) { //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) int count = Physics.RaycastNonAlloc(origin, dir, hits, distance, (mask != 0) ? mask : envMask, (QueryTriggerInteraction)1); return Nearest(count, out hit); } private bool SphereCastEnv(Vector3 origin, float radius, Vector3 dir, float distance, out RaycastHit hit) { //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) int count = Physics.SphereCastNonAlloc(origin, radius, dir, hits, distance, envMask, (QueryTriggerInteraction)1); return Nearest(count, out hit); } private bool OverlapsEnv(Vector3 center, Vector3 half, Quaternion rot) { //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) Collider[] array = Physics.OverlapBox(center, half, rot, envMask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)(object)box) { return true; } } return false; } private bool Nearest(int count, out RaycastHit nearest) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0051: Unknown result type (might be due to invalid IL or missing references) nearest = default(RaycastHit); float num = float.MaxValue; for (int i = 0; i < count; i++) { RaycastHit val = hits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)(object)box) && !(((RaycastHit)(ref val)).distance >= num) && (!(((RaycastHit)(ref val)).distance <= 0f) || !(((RaycastHit)(ref val)).point == Vector3.zero))) { num = ((RaycastHit)(ref val)).distance; nearest = val; } } return num < float.MaxValue; } private static Vector3 Flat(Vector3 v) { //IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references) return new Vector3(v.x, 0f, v.z); } } public class CatManager : MonoBehaviour { internal static readonly FieldRef<PlayerAvatar, string> SteamIdRef = AccessTools.FieldRefAccess<PlayerAvatar, string>("steamID"); private float nextScan; internal static CatFollower Cat { get; private set; } private void Update() { CatNet.EnsureSubscribed(); if (Time.unscaledTime < nextScan) { return; } nextScan = Time.unscaledTime + 1f; if (!((Object)(object)Cat != (Object)null)) { PlayerAvatar val = FindOwner(); if (!((Object)(object)val == (Object)null)) { Cat = CatFollower.Spawn(val); Plugin.Log.LogInfo((object)"Spawned cat for owner."); } } } private static PlayerAvatar FindOwner() { if ((Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList == null) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && SteamIdRef.Invoke(player) == "76561198252116818") { return player; } } return null; } } internal static class CatModel { private const float ObjTargetLength = 0.5f; private static bool bundleTried; private static GameObject bundlePrefab; private static bool objTried; private static Mesh objMesh; private static Texture2D objTexture; private static Shader shader; public static GameObject Create(Transform parent, out ICatRig rig) { rig = null; GameObject obj = TryBundle() ?? TryBbModel(out rig) ?? TryObj() ?? BuildPrimitive(out rig); obj.transform.SetParent(parent, false); StripPhysics(obj); return obj; } private static GameObject TryBbModel(out ICatRig rig) { rig = null; string text = Path.Combine(Plugin.PluginDir, Plugin.BbModelFile.Value); if (!File.Exists(text)) { return null; } try { BoneRig rig2; GameObject result = BbModelLoader.Load(text, MakeMaterial, out rig2); rig = rig2; return result; } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to load {text}: {arg}"); return null; } } private static GameObject TryBundle() { if (!bundleTried) { bundleTried = true; string text = Path.Combine(Plugin.PluginDir, Plugin.BundleFile.Value); if (File.Exists(text)) { AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)("Failed to load " + text + ". Was it built with Unity 6000.3 for Windows?")); } else { string value = Plugin.BundlePrefabName.Value; bundlePrefab = (GameObject)(string.IsNullOrEmpty(value) ? ((object)val.LoadAllAssets<GameObject>().FirstOrDefault()) : ((object)val.LoadAsset<GameObject>(value))); if ((Object)(object)bundlePrefab == (Object)null) { Plugin.Log.LogError((object)("No GameObject '" + value + "' found in " + text + ".")); } else { Plugin.Log.LogInfo((object)("Using bundle model '" + ((Object)bundlePrefab).name + "'.")); } } } } if (!((Object)(object)bundlePrefab != (Object)null)) { return null; } return Object.Instantiate<GameObject>(bundlePrefab); } private static GameObject TryObj() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown if (!objTried) { objTried = true; string text = Path.Combine(Plugin.PluginDir, Plugin.ObjFile.Value); if (File.Exists(text)) { try { objMesh = ObjLoader.Load(text); Plugin.Log.LogInfo((object)$"Using OBJ model ({objMesh.vertexCount} vertices)."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to load {text}: {arg}"); } string path = Path.Combine(Plugin.PluginDir, Plugin.TextureFile.Value); if ((Object)(object)objMesh != (Object)null && File.Exists(path)) { objTexture = new Texture2D(2, 2); ImageConversion.LoadImage(objTexture, File.ReadAllBytes(path)); ((Texture)objTexture).filterMode = (FilterMode)0; } } } if ((Object)(object)objMesh == (Object)null) { return null; } Bounds bounds = objMesh.bounds; float num = 0.5f / Mathf.Max(0.0001f, Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z)); GameObject val = new GameObject("CatObj"); GameObject val2 = new GameObject("Mesh"); val2.transform.SetParent(val.transform, false); val2.transform.localScale = Vector3.one * num; val2.transform.localPosition = new Vector3(0f - ((Bounds)(ref bounds)).center.x, 0f - ((Bounds)(ref bounds)).min.y, 0f - ((Bounds)(ref bounds)).center.z) * num; val2.AddComponent<MeshFilter>().sharedMesh = objMesh; Material