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 JustTheRealestBestestSuitEver v1.67.63
CocoSuit.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dissonance; using GameNetcodeStuff; using ModelReplacement; using ModelReplacement.AvatarBodyUpdater; using UnityEngine; using UnityEngine.Rendering.HighDefinition; [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("CocoSuit")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CocoSuit")] [assembly: AssemblyTitle("CocoSuit")] [assembly: AssemblyVersion("1.0.0.0")] namespace CocoSuit; public class CocoAvatarUpdater : AvatarUpdater { private class Arm { public Transform upper; public Transform lower; public Vector3 restDirChest; } private Transform chest; private Arm left; private Arm right; private const float StandingDrop = 0.709f; private const float HipAboveBottom = 0.29f; private const float FloorClearance = 0.06f; private const float BlendSeconds = 0.25f; private PlayerControllerB controller; private Transform hips; private Transform humanSpine; private Transform[] humanThighs; private Transform[] humanShins; private Transform[] cocoLowLeg; private float emoteWeight; public override void AssignModelReplacement(GameObject player, GameObject replacement) { ((AvatarUpdater)this).AssignModelReplacement(player, replacement); if (!((Object)(object)base.replacementAnimator == (Object)null)) { chest = base.replacementAnimator.GetBoneTransform((HumanBodyBones)8); controller = player.GetComponent<PlayerControllerB>(); hips = base.replacementAnimator.GetBoneTransform((HumanBodyBones)0); humanSpine = ((AvatarUpdater)this).GetPlayerTransformFromBoneName("spine"); humanThighs = (Transform[])(object)new Transform[2] { ((AvatarUpdater)this).GetPlayerTransformFromBoneName("thigh.L"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("thigh.R") }; humanShins = (Transform[])(object)new Transform[2] { ((AvatarUpdater)this).GetPlayerTransformFromBoneName("shin.L"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("shin.R") }; cocoLowLeg = (Transform[])(object)new Transform[4] { base.replacementAnimator.GetBoneTransform((HumanBodyBones)3), base.replacementAnimator.GetBoneTransform((HumanBodyBones)4), base.replacementAnimator.GetBoneTransform((HumanBodyBones)5), base.replacementAnimator.GetBoneTransform((HumanBodyBones)6) }; left = MakeArm((HumanBodyBones)13, (HumanBodyBones)15); right = MakeArm((HumanBodyBones)14, (HumanBodyBones)16); } } private Arm MakeArm(HumanBodyBones upperBone, HumanBodyBones lowerBone) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Transform boneTransform = base.replacementAnimator.GetBoneTransform(upperBone); Transform boneTransform2 = base.replacementAnimator.GetBoneTransform(lowerBone); if ((Object)(object)chest == (Object)null || (Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null) { return null; } return new Arm { upper = boneTransform, lower = boneTransform2, restDirChest = Quaternion.Inverse(chest.rotation) * boneTransform.up }; } protected override void UpdateModel() { ((AvatarUpdater)this).UpdateModel(); AdjustEmoteHeight(); if (!((Object)(object)chest == (Object)null)) { float cone = MathF.PI / 4f; float elbow = 0.61086524f; Limit(left, cone, elbow); Limit(right, cone, elbow); } } private void AdjustEmoteHeight() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00cf: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hips == (Object)null || (Object)(object)humanSpine == (Object)null || (Object)(object)controller == (Object)null) { return; } bool flag = Plugin.EmoteHeightFix.Value && controller.performingEmote; emoteWeight = Mathf.MoveTowards(emoteWeight, flag ? 1f : 0f, Time.deltaTime / 0.25f); if (emoteWeight <= 0f) { return; } float num = 0f; int num2 = 0; for (int i = 0; i < 2; i++) { if (!((Object)(object)humanThighs[i] == (Object)null) && !((Object)(object)humanShins[i] == (Object)null)) { float num3 = Vector3.Angle(humanShins[i].position - humanThighs[i].position, Vector3.down); num += Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(35f, 75f, num3)); num2++; } } if (num2 > 0) { num /= (float)num2; } Vector3 val = humanSpine.position + Vector3.up * Mathf.Lerp(-0.709f, 0.07f, num); hips.position = Vector3.Lerp(hips.position, val, emoteWeight); float y = ((Component)controller).transform.position.y; float num4 = y + 0.29f - hips.position.y; Transform[] array = cocoLowLeg; foreach (Transform val2 in array) { if ((Object)(object)val2 != (Object)null) { num4 = Mathf.Max(num4, y + 0.06f - val2.position.y); } } if (num4 > 0f) { Transform obj = hips; obj.position += Vector3.up * (num4 * emoteWeight); } } private void Limit(Arm arm, float cone, float elbow) { //IL_000a: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0027: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (arm != null) { Vector3 val = chest.rotation * arm.restDirChest; Vector3 up = arm.upper.up; if (Vector3.Angle(val, up) * (MathF.PI / 180f) > cone) { Vector3 val2 = Vector3.RotateTowards(val, up, cone, 0f); arm.upper.rotation = Quaternion.FromToRotation(up, val2) * arm.upper.rotation; } Vector3 up2 = arm.upper.up; Vector3 up3 = arm.lower.up; if (Vector3.Angle(up2, up3) * (MathF.PI / 180f) > elbow) { Vector3 val3 = Vector3.RotateTowards(up2, up3, elbow, 0f); arm.lower.rotation = Quaternion.FromToRotation(up3, val3) * arm.lower.rotation; } } } } [DefaultExecutionOrder(10001)] public class CocoEmoteProps : MonoBehaviour { private enum Anchor { Auto, LeftHand, RightHand, Mouth, Face, Ground, None } [Serializable] public class PartSetting { public string name; public string anchor = "None"; public float[] offset = new float[3]; } [Serializable] public class PropSetting { public string name; public string anchor = "Auto"; public float scale = 1f; public float[] offset = new float[3]; public float[] rotation = new float[3]; public PartSetting[] parts = Array.Empty<PartSetting>(); public bool IsNeutral { get { //IL_002f: 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_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 ((anchor ?? "Auto").Equals("Auto", StringComparison.OrdinalIgnoreCase) && scale == 1f && V(offset) == Vector3.zero && V(rotation) == Vector3.zero) { if (parts != null) { return parts.Length == 0; } return true; } return false; } } } [Serializable] private class PropSettings { public PropSetting[] props; } private class TrackedPart { public Transform t; public Anchor anchor; public Vector3 offset; public Vector3 lastSet; public Vector3 lastDelta; public bool applied; } private class Tracked { public Transform prop; public Transform wrapper; public string name; public int frames; public Anchor anchor; public PropSetting setting; public List<TrackedPart> parts = new List<TrackedPart>(); } public const string TooManyEmotesGuid = "FlipMods.TooManyEmotes"; private const float GroundScale = 0.44f; private const int SettleFrames = 3; private const float HandReach = 0.25f; private const float FloorTolerance = 0.15f; private static readonly Vector3 HumanMouth = new Vector3(0f, 0.12f, 0.13f); private static readonly Vector3 CocoMouth = new Vector3(0f, 0.16f, 0.47f); private static readonly Vector3 HumanFace = new Vector3(0f, 0.2f, 0.15f); private static readonly Vector3 CocoFace = new Vector3(0f, 0.44f, 0.48f); private static readonly Dictionary<string, PropSetting> BuiltIn = new PropSetting[9] { P("jug_prop", "Mouth", null), P("travelers.harmonica.prop", "Mouth", null), P("travelers.flute.prop", "Mouth", null), P("banjo_prop", "Auto", new float[3] { 0f, 0.05f, 0.2f }), P("guitar_prop", "Auto", new float[3] { 0f, 0.15f, 0.2f }), P("fiddle_prop", "Auto", new float[3] { 0f, 0f, 0.12f }), P("travelers.piano.prop", "None", null, Part("NomaiMask", "Face")), P("travelers.bow.prop", "None", new float[3] { 0f, 0f, 0.5f }), P("travelers.drums.prop", "None", null, Part("Chert_DrumStick_Geo1", "LeftHand")) }.ToDictionary((PropSetting p) => p.name); private static readonly string[] KnownProps = new string[27] { "afk.prop", "banjo_prop", "baseball_bat.prop", "cheer_up.prop", "dumbbell.prop", "fiddle_prop", "gamepad.prop", "guitar_prop", "jar_of_dirt.prop", "jug_prop", "junk_food.prop", "old_chair.prop", "paddle.prop", "perfect_score.prop", "planetary_vibes.prop", "red_card.prop", "sexy_saxophone.epic_sax.prop", "sexy_saxophone.sexy_sax.prop", "snake_summoner.prop", "travelers.banjo.prop", "travelers.bow.prop", "travelers.drums.prop", "travelers.flute.prop", "travelers.harmonica.prop", "travelers.piano.prop", "travelers.whistle.prop", "trombone.prop" }; private static Dictionary<string, PropSetting> settings = new Dictionary<string, PropSetting>(); private static DateTime settingsStamp; private PlayerControllerB player; private Animator coco; private Transform propsParent; private Animator human; private float nextSearch; private readonly Dictionary<Transform, Tracked> tracked = new Dictionary<Transform, Tracked>(); private readonly List<Transform> scratch = new List<Transform>(); private static string SettingsPath => Path.Combine(Paths.ConfigPath, "coco.CocoSuit.EmoteProps.json"); private static PropSetting P(string name, string anchor = "Auto", float[] offset = null, params PartSetting[] parts) { PropSetting propSetting = new PropSetting(); propSetting.name = name; propSetting.anchor = anchor; propSetting.offset = offset ?? new float[3]; propSetting.parts = parts; return propSetting; } private static PartSetting Part(string name, string anchor, float[] offset = null) { PartSetting partSetting = new PartSetting(); partSetting.name = name; partSetting.anchor = anchor; partSetting.offset = offset ?? new float[3]; return partSetting; } public void Init(PlayerControllerB controller, Animator cocoAnimator) { player = controller; coco = cocoAnimator; LoadSettings(); } private void LateUpdate() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if ((Object)(object)player == (Object)null || (Object)(object)coco == (Object)null) { return; } if ((Object)(object)propsParent == (Object)null) { if (Time.time >= nextSearch) { FindPropsParent(); } return; } scratch.Clear(); foreach (Transform item in propsParent) { Transform val = item; if (!tracked.ContainsKey(val) && !IsWrapper(val) && ((Component)val).gameObject.activeInHierarchy) { scratch.Add(val); } } foreach (Transform item2 in scratch) { Wrap(item2); } scratch.Clear(); foreach (KeyValuePair<Transform, Tracked> item3 in tracked) { if ((Object)(object)item3.Key == (Object)null || (Object)(object)item3.Key.parent != (Object)(object)item3.Value.wrapper || !((Component)item3.Key).gameObject.activeInHierarchy) { scratch.Add(item3.Key); } } foreach (Transform item4 in scratch) { Unwrap(item4); } foreach (Tracked value in tracked.Values) { UpdateWrapper(value); } } private void OnDestroy() { foreach (Transform item in tracked.Keys.ToList()) { Unwrap(item); } } private void FindPropsParent() { nextSearch = Time.time + 1f; propsParent = ((IEnumerable<Transform>)((Component)player).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "EmoteProps")); if ((Object)(object)propsParent != (Object)null) { human = ((Component)propsParent).GetComponentInParent<Animator>(); if ((Object)(object)human != (Object)null && !human.isHuman) { human = null; } } } private static bool IsWrapper(Transform t) { return ((Object)t).name == "CocoPropAnchor"; } private static string PropKey(string instanceName) { string text = null; foreach (string item in KnownProps.Concat(BuiltIn.Keys).Concat(settings.Keys)) { if (instanceName.StartsWith(item, StringComparison.OrdinalIgnoreCase) && (text == null || item.Length > text.Length)) { text = item; } } return text ?? instanceName; } private void Wrap(Transform prop) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("CocoPropAnchor").transform; transform.SetParent(propsParent, false); prop.SetParent(transform, false); string name = PropKey(((Object)prop).name.Replace("(Clone)", "").Trim()); tracked[prop] = new Tracked { prop = prop, wrapper = transform, name = name }; } private void Unwrap(Transform key) { if (tracked.TryGetValue(key, out var value) && (Object)(object)value.wrapper != (Object)null) { if ((Object)(object)key != (Object)null && (Object)(object)key.parent == (Object)(object)value.wrapper) { key.SetParent(propsParent, true); } Object.Destroy((Object)(object)((Component)value.wrapper).gameObject); } tracked.Remove(key); } private void UpdateWrapper(Tracked t) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0071: 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) t.frames++; if (t.anchor == Anchor.Auto) { if (t.frames < 3) { return; } Classify(t); } Matrix4x4 val = Correction(t); Matrix4x4 val2 = propsParent.worldToLocalMatrix * val * propsParent.localToWorldMatrix; t.wrapper.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val2)).GetColumn(3)); t.wrapper.localRotation = ((Matrix4x4)(ref val2)).rotation; t.wrapper.localScale = ((Matrix4x4)(ref val2)).lossyScale; foreach (TrackedPart part in t.parts) { UpdatePart(part); } } private void UpdatePart(TrackedPart part) { //IL_0035: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0083: 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_0099: 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_00a0: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)part.t == (Object)null)) { Vector3 val = ((part.applied && part.t.position == part.lastSet) ? (part.lastSet - part.lastDelta) : part.t.position); Vector3 val2 = AnchorShift(part.anchor) + ((Component)player).transform.rotation * part.offset; part.t.position = val + val2; part.lastSet = part.t.position; part.lastDelta = val2; part.applied = true; } } private Vector3 AnchorShift(Anchor anchor) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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 (!AnchorPoints(anchor, out var from, out var to)) { return Vector3.zero; } return to - from; } private bool AnchorPoints(Anchor anchor, out Vector3 from, out Vector3 to) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00ec: 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_0102: Unknown result type (might be due to invalid IL or missing references) from = (to = Vector3.zero); if ((uint)(anchor - 1) > 1u) { if ((uint)(anchor - 3) <= 1u) { Transform val = PlayerBone("spine.004"); Transform boneTransform = coco.GetBoneTransform((HumanBodyBones)10); if ((Object)(object)val == (Object)null || (Object)(object)boneTransform == (Object)null) { return false; } bool flag = anchor == Anchor.Mouth; from = val.position + boneTransform.rotation * (flag ? HumanMouth : HumanFace); to = boneTransform.position + boneTransform.rotation * (flag ? CocoMouth : CocoFace); return true; } from = (to = ((Component)player).transform.position); return true; } HumanBodyBones val2 = (HumanBodyBones)((anchor == Anchor.LeftHand) ? 17 : 18); Transform val3 = HumanBone(val2); Transform boneTransform2 = coco.GetBoneTransform(val2); if ((Object)(object)val3 == (Object)null || (Object)(object)boneTransform2 == (Object)null) { return false; } from = val3.position; to = boneTransform2.position; return true; } private Matrix4x4 Correction(Tracked t) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) PropSetting setting = t.setting; Quaternion facing = ((Component)player).transform.rotation; Matrix4x4 tweak = Matrix4x4.TRS(V(setting.offset), Quaternion.Euler(V(setting.rotation)), Vector3.one * setting.scale); if (t.anchor == Anchor.Ground) { Vector3 position = ((Component)player).transform.position; return About(position, position, 0.44f); } if (!AnchorPoints(t.anchor, out var from, out var to)) { return Matrix4x4.identity; } return About(from, to, 1f); Matrix4x4 About(Vector3 val4, Vector3 val2, float scale) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) Matrix4x4 val = Matrix4x4.TRS(val2, facing, Vector3.one) * tweak * Matrix4x4.Scale(Vector3.one * scale); Matrix4x4 val3 = Matrix4x4.TRS(val4, facing, Vector3.one); return val * ((Matrix4x4)(ref val3)).inverse; } } private void Classify(Tracked t) { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) LoadSettings(); if (!settings.TryGetValue(t.name, out var value) || value.IsNeutral) { value = (BuiltIn.TryGetValue(t.name, out var value2) ? value2 : (value ?? new PropSetting { name = t.name })); } t.setting = value; Transform[] componentsInChildren = ((Component)t.prop).GetComponentsInChildren<Transform>(true); PartSetting[] array = value.parts ?? Array.Empty<PartSetting>(); foreach (PartSetting ps in array) { Transform val = ((IEnumerable<Transform>)componentsInChildren).FirstOrDefault((Func<Transform, bool>)((Transform c) => ((Object)c).name == ps.name)); if ((Object)(object)val == (Object)null || !Enum.TryParse<Anchor>(ps.anchor, ignoreCase: true, out var result)) { Plugin.Log.LogWarning((object)("Emote prop " + t.name + ": part " + ps.name + " not found or bad anchor " + ps.anchor)); } else { t.parts.Add(new TrackedPart { t = val, anchor = result, offset = V(ps.offset) }); } } Renderer[] array2 = (from r in ((Component)t.prop).GetComponentsInChildren<Renderer>() where r.enabled select r).ToArray(); string text = "no visible renderers"; Anchor anchor = Anchor.None; if (array2.Length != 0) { Bounds bounds = array2[0].bounds; foreach (Renderer item in array2.Skip(1)) { ((Bounds)(ref bounds)).Encapsulate(item.bounds); } Transform val2 = HumanBone((HumanBodyBones)17); Transform val3 = HumanBone((HumanBodyBones)18); float num = (((Object)(object)val2 != (Object)null) ? Mathf.Sqrt(((Bounds)(ref bounds)).SqrDistance(val2.position)) : float.MaxValue); float num2 = (((Object)(object)val3 != (Object)null) ? Mathf.Sqrt(((Bounds)(ref bounds)).SqrDistance(val3.position)) : float.MaxValue); float num3 = ((Bounds)(ref bounds)).min.y - ((Component)player).transform.position.y; Vector3 val4 = ((Component)player).transform.InverseTransformPoint(((Bounds)(ref bounds)).center); text = $"centre {val4.x:F2},{val4.y:F2},{val4.z:F2} m from feet (player space), size {((Bounds)(ref bounds)).size.x:F2}x{((Bounds)(ref bounds)).size.y:F2}x{((Bounds)(ref bounds)).size.z:F2}, " + $"bottom {num3:F2} m above feet, {num:F2} m from left hand, {num2:F2} m from right hand"; if (num3 >= 0.15f && Mathf.Min(num, num2) < 0.25f) { anchor = ((num <= num2) ? Anchor.LeftHand : Anchor.RightHand); } } Anchor result2; bool flag = Enum.TryParse<Anchor>(value.anchor, ignoreCase: true, out result2) && result2 != Anchor.Auto; t.anchor = (flag ? result2 : anchor); string text2 = ((t.parts.Count == 0) ? "" : ("; parts " + string.Join(", ", t.parts.Select((TrackedPart x) => $"{((Object)x.t).name} -> {x.anchor}")))); Plugin.Log.LogDebug((object)string.Format("Emote prop {0}: {1} -> {2}{3}{4}", t.name, text, t.anchor, flag ? " (override)" : "", text2)); } private Transform HumanBone(HumanBodyBones bone) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0014: 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_0023: Invalid comparison between Unknown and I4 if ((Object)(object)human != (Object)null) { return human.GetBoneTransform(bone); } string text = (((int)bone == 17) ? "hand.L" : (((int)bone == 18) ? "hand.R" : null)); if (text != null) { return PlayerBone(text); } return null; } private Transform PlayerBone(string name) { return ((IEnumerable<Transform>)player.thisPlayerModel.bones).FirstOrDefault((Func<Transform, bool>)((Transform b) => (Object)(object)b != (Object)null && ((Object)b).name == name)); } private static Vector3 V(float[] a) { //IL_0009: 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) if (a == null || a.Length != 3) { return Vector3.zero; } return new Vector3(a[0], a[1], a[2]); } private static void LoadSettings() { try { if (!File.Exists(SettingsPath)) { PropSetting value; PropSettings propSettings = new PropSettings { props = KnownProps.Select((string n) => (!BuiltIn.TryGetValue(n, out value)) ? new PropSetting { name = n } : value).ToArray() }; File.WriteAllText(SettingsPath, JsonUtility.ToJson((object)propSettings, true)); } DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(SettingsPath); if (!(lastWriteTimeUtc == settingsStamp)) { settingsStamp = lastWriteTimeUtc; settings = (from p in JsonUtility.FromJson<PropSettings>(File.ReadAllText(SettingsPath))?.props ?? Array.Empty<PropSetting>() where !string.IsNullOrEmpty(p.name) group p by p.name).ToDictionary((IGrouping<string, PropSetting> g) => g.Key, (IGrouping<string, PropSetting> g) => g.Last()); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read " + SettingsPath + ": " + ex.Message)); } } } public class CocoFace : MonoBehaviour { private const float HurtSeconds = 1.6f; private SkinnedMeshRenderer smr; private PlayerControllerB player; private int mouthOpen = -1; private int frown = -1; private int smile = -1; private int eyesSad = -1; private int eyesAngry = -1; private float mouth; private float hurtTimer; public void Init(SkinnedMeshRenderer renderer, PlayerControllerB controller) { smr = renderer; player = controller; if (!((Object)(object)smr == (Object)null) && !((Object)(object)smr.sharedMesh == (Object)null)) { mouthOpen = smr.sharedMesh.GetBlendShapeIndex("mouth_open"); frown = smr.sharedMesh.GetBlendShapeIndex("frown"); smile = smr.sharedMesh.GetBlendShapeIndex("smile"); eyesSad = smr.sharedMesh.GetBlendShapeIndex("eyes_sad"); eyesAngry = smr.sharedMesh.GetBlendShapeIndex("eyes_angry"); } } public void Hurt() { hurtTimer = 1.6f; } private void LateUpdate() { if ((Object)(object)smr == (Object)null) { return; } float num = 0f; if (Plugin.VoiceMouth.Value && (Object)(object)player != (Object)null && !player.isPlayerDead) { VoicePlayerState voicePlayerState = player.voicePlayerState; if (voicePlayerState != null && voicePlayerState.IsSpeaking) { num = Mathf.Clamp01(voicePlayerState.Amplitude * 8f); } } mouth = Mathf.MoveTowards(mouth, num, Time.deltaTime * ((num > mouth) ? 12f : 6f)); if (mouthOpen >= 0) { smr.SetBlendShapeWeight(mouthOpen, mouth * 100f); } hurtTimer = Mathf.Max(0f, hurtTimer - Time.deltaTime); float num2 = (((Object)(object)player != (Object)null && player.isPlayerDead) ? 1f : Mathf.Clamp01(hurtTimer / 0.4f)); if (frown >= 0) { smr.SetBlendShapeWeight(frown, num2 * 100f); } if (smile >= 0) { smr.SetBlendShapeWeight(smile, 0f * (1f - num2) * 100f); } float num3 = 0.35f * (1f - num2); if (eyesSad >= 0) { smr.SetBlendShapeWeight(eyesSad, (num3 + num2) * 100f); } if (eyesAngry >= 0) { smr.SetBlendShapeWeight(eyesAngry, num3 * 100f); } } } public class CocoReplacement : BodyReplacementBase { private const int EyesSlot = 1; private const int GlowSlot = 2; private static readonly Color BallColor = new Color(1f, 0.86f, 0.35f); private CocoFace face; protected override GameObject LoadAssetsAndReturnModel() { return Plugin.CocoPrefab; } protected override AvatarUpdater GetAvatarUpdater() { return (AvatarUpdater)(object)new CocoAvatarUpdater(); } protected override void AddModelScripts() { SkinnedMeshRenderer smr = base.replacementModel.GetComponentInChildren<SkinnedMeshRenderer>(); Step("materials", delegate { if ((Object)(object)smr != (Object)null) { TuneMaterials(smr); } }); Step("secondary motion", delegate { if (Plugin.SecondaryMotion.Value) { CocoSpring.Attach(base.replacementModel.transform, ((Component)((BodyReplacementBase)this).controller).transform); } }); Step("emote props", delegate { if (Plugin.AdjustEmoteProps.Value && Chainloader.PluginInfos.ContainsKey("FlipMods.TooManyEmotes")) { base.replacementModel.AddComponent<CocoEmoteProps>().Init(((BodyReplacementBase)this).controller, base.replacementModel.GetComponentInChildren<Animator>()); } }); Step("face", delegate { face = base.replacementModel.AddComponent<CocoFace>(); face.Init(smr, ((BodyReplacementBase)this).controller); }); } private static void Step(string what, Action action) { try { action(); } catch (Exception arg) { Plugin.Log.LogError((object)$"Coco setup step '{what}' failed: {arg}"); } } private static void TuneMaterials(SkinnedMeshRenderer smr) { //IL_0024: 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) Material[] materials = ((Renderer)smr).materials; if (materials.Length > 1) { TuneEyes(materials[1]); } if (materials.Length > 2) { Material obj = materials[2]; obj.SetColor("_EmissiveColor", BallColor * 0.35f); obj.SetColor("_EmissiveColorLDR", BallColor); obj.SetFloat("_EmissiveIntensity", 0.35f); obj.SetFloat("_EmissiveExposureWeight", 0f); obj.SetTexture("_MaskMap", (Texture)null); obj.SetFloat("_DoubleSidedEnable", 0f); HDMaterial.ValidateMaterial(obj); } ((Renderer)smr).materials = materials; } private static void TuneEyes(Material m) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) m.SetTexture("_MaskMap", (Texture)null); m.SetFloat("_DoubleSidedEnable", 0f); m.SetFloat("_Smoothness", 0.5f); m.SetTexture("_EmissiveColorMap", m.GetTexture("_BaseColorMap")); m.SetFloat("_UseEmissiveIntensity", 0f); m.SetColor("_EmissiveColor", Color.white * 0.0625f); m.SetColor("_EmissiveColorLDR", Color.white); m.SetFloat("_EmissiveExposureWeight", 0f); HDMaterial.ValidateMaterial(m); } protected override void OnDamageTaken(bool dead) { ((BodyReplacementBase)this).OnDamageTaken(dead); if ((Object)(object)face != (Object)null) { face.Hurt(); } } protected override void OnDeath() { ((BodyReplacementBase)this).OnDeath(); if ((Object)(object)face != (Object)null) { face.Hurt(); } } } [DefaultExecutionOrder(10000)] public class CocoSpring : MonoBehaviour { private class Chain { public string[] bones; public float stiffness; public float damping; public float gravity; } [Serializable] private class Link { public Transform bone; public Transform end; public Quaternion restLocal; public Vector3 restAxis; public float length; public Vector3 tip; public Vector3 prevTip; public Vector3 lastOrigin; } private static readonly Chain[] Chains = new Chain[5] { C(0.1f, 0.18f, 0.3f, "Coco_Tail1", "Coco_Tail2", "Coco_Tail3", "Coco_TailTip"), C(0.22f, 0.25f, 0f, "Coco_Wing_L"), C(0.22f, 0.25f, 0f, "Coco_Wing_R"), C(0.18f, 0.22f, 0.15f, "Coco_Forehead", "Coco_HeadTail"), C(0.06f, 0.12f, 0f, "Coco_EmoteBall") }; private const float TeleportDistance = 2f; private const float PlatformMoveThreshold = 0.01f; private const float PlatformTurnThreshold = 0.2f; private const float PlatformCalmSeconds = 0.3f; private const float MaxSwingDegrees = 75f; private const float ReferenceFps = 60f; [SerializeField] private List<Link> links = new List<Link>(); [SerializeField] private float stiffness; [SerializeField] private float damping; [SerializeField] private float gravity; [SerializeField] private Transform player; private bool primed; private float platformHold; private Transform frame; private Matrix4x4 frameWorldToLocal; private static Chain C(float stiffness, float damping, float gravity, params string[] bones) { return new Chain { bones = bones, stiffness = stiffness, damping = damping, gravity = gravity }; } public static void Attach(Transform root, Transform player) { //IL_00f6: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { dictionary[((Object)val).name] = val; } Chain[] chains = Chains; foreach (Chain chain in chains) { CocoSpring cocoSpring = ((Component)root).gameObject.AddComponent<CocoSpring>(); cocoSpring.stiffness = chain.stiffness; cocoSpring.damping = chain.damping; cocoSpring.gravity = chain.gravity; cocoSpring.player = player; string[] bones = chain.bones; foreach (string text in bones) { if (!dictionary.TryGetValue(text, out var value) || !dictionary.TryGetValue(text + "_end", out var value2)) { Plugin.Log.LogWarning((object)("Spring bone " + text + " not found on Coco model")); continue; } List<Link> list = cocoSpring.links; Link obj = new Link { bone = value, end = value2, restLocal = value.localRotation }; Vector3 localPosition = value2.localPosition; obj.restAxis = ((Vector3)(ref localPosition)).normalized; localPosition = value2.localPosition; obj.length = ((Vector3)(ref localPosition)).magnitude * value.lossyScale.x; list.Add(obj); } } } private void OnEnable() { primed = false; } private void LateUpdate() { //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) //IL_006c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_0234: 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_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) if (links.Count == 0) { return; } float num = Mathf.Min(Time.deltaTime, 0.05f); float num2 = num * 60f; Transform val = (((Object)(object)player != (Object)null) ? player.parent : null); Vector3 val3; if (primed && (Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)frame) { Matrix4x4 val2 = val.localToWorldMatrix * frameWorldToLocal; val3 = Vector4.op_Implicit(((Matrix4x4)(ref val2)).GetColumn(3)); float magnitude = ((Vector3)(ref val3)).magnitude; float num3 = Quaternion.Angle(Quaternion.identity, ((Matrix4x4)(ref val2)).rotation); if (magnitude > 0.01f || num3 > 0.2f) { platformHold = 0.3f; } foreach (Link link in links) { link.tip = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(link.tip); link.prevTip = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(link.prevTip); link.lastOrigin = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(link.lastOrigin); } } platformHold = Mathf.Max(0f, platformHold - num); bool flag = platformHold > 0f; frame = val; if ((Object)(object)val != (Object)null) { frameWorldToLocal = val.worldToLocalMatrix; } foreach (Link link2 in links) { link2.bone.localRotation = link2.restLocal; Vector3 position = link2.bone.position; Vector3 val4 = position + link2.bone.rotation * link2.restAxis * link2.length; if (!(!primed || flag)) { val3 = link2.tip - val4; if (!(((Vector3)(ref val3)).sqrMagnitude > 4f)) { Vector3 val5 = (position - link2.lastOrigin) * (1f - Mathf.Clamp01(Plugin.SwayAmount.Value)); link2.tip += val5; link2.prevTip += val5; link2.lastOrigin = position; Vector3 val6 = (link2.tip - link2.prevTip) * Mathf.Pow(1f - damping, num2); link2.prevTip = link2.tip; link2.tip += val6 + (val4 - link2.tip) * (1f - Mathf.Pow(1f - stiffness, num2)) + Vector3.down * (gravity * 0.02f * link2.length * num2); Vector3 val7 = val4 - position; bool flag2 = Vector3.Angle(val7, link2.tip - position) > 75f; Vector3 val8 = Vector3.RotateTowards(val7, link2.tip - position, 1.3089969f, 0f); link2.tip = position + ((Vector3)(ref val8)).normalized * link2.length; if (flag2) { link2.prevTip = link2.tip; } Vector3 val9 = link2.bone.rotation * link2.restAxis; link2.bone.rotation = Quaternion.FromToRotation(val9, link2.tip - position) * link2.bone.rotation; continue; } } val3 = (link2.tip = (link2.prevTip = val4)); link2.lastOrigin = position; } primed = true; } } [BepInPlugin("coco.CocoSuit", "Coco Suit", "1.6.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "coco.CocoSuit"; public const string Name = "Coco Suit"; public const string Version = "1.6.1"; private static readonly string[] SuitNames = new string[2] { "Coco", "Coco suit" }; internal static ManualLogSource Log; internal static GameObject CocoPrefab; internal static ConfigEntry<bool> VoiceMouth; internal static ConfigEntry<bool> SecondaryMotion; internal static ConfigEntry<float> SwayAmount; internal static ConfigEntry<bool> EmoteHeightFix; internal static ConfigEntry<bool> AdjustEmoteProps; private void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; VoiceMouth = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "MouthMovesWithVoice", true, "Open Coco's mouth while the player is talking in voice chat."); SecondaryMotion = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "SecondaryMotion", true, "Let Coco's tail, wings, head tip and emote ball sway."); SwayAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "SwayAmount", 0.08f, new ConfigDescription("How much Coco's movement swings his tail, wings, head tip and emote ball (0 = barely, 1 = fully floppy). Applies live.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); EmoteHeightFix = ((BaseUnityPlugin)this).Config.Bind<bool>("Emotes", "RaiseWhenSitting", true, "During emotes, lift Coco's model (not your hitbox) so he sits on chairs and the floor instead of sinking into them."); AdjustEmoteProps = ((BaseUnityPlugin)this).Config.Bind<bool>("Emotes", "AdjustEmoteProps", true, "Place TooManyEmotes props (instruments, masks, ...) on Coco. Per-prop placement can be tuned in coco.CocoSuit.EmoteProps.json."); DropRetiredSettings(); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "coco"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { Log.LogError((object)("Could not load asset bundle at " + text)); return; } CocoPrefab = val.LoadAsset<GameObject>("Assets/Coco/Coco.prefab"); if ((Object)(object)CocoPrefab == (Object)null) { Log.LogError((object)"Coco prefab missing from asset bundle"); return; } string[] suitNames = SuitNames; for (int i = 0; i < suitNames.Length; i++) { ModelReplacementAPI.RegisterSuitModelReplacement(suitNames[i], typeof(CocoReplacement)); } Log.LogInfo((object)"Coco Suit 1.6.1 loaded"); } private void DropRetiredSettings() { try { if (typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(((BaseUnityPlugin)this).Config) is Dictionary<ConfigDefinition, string> { Count: >0 } dictionary) { dictionary.Clear(); ((BaseUnityPlugin)this).Config.Save(); } } catch (Exception ex) { Log.LogDebug((object)("Could not tidy old config entries: " + ex.Message)); } } } internal static class Tuning { public const float EmoteBallGlow = 0.35f; public const float EyeGlow = 0.0625f; public const float EyeSquint = 0.35f; public const float MouthSmile = 0f; public const float ArmSwingLimit = 45f; public const float ElbowBendLimit = 35f; public const float SitHeightOffset = 0.07f; public const float SwayAmountDefault = 0.08f; }