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 Billy Commando v0.5.1
plugins/BillyCommando/BillyCommando.dll
Decompiled 11 hours 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.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using R2API; using RoR2; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.UI; [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("BillyCommando")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BillyCommando")] [assembly: AssemblyTitle("BillyCommando")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BillyCommando { internal sealed class BillyData { internal sealed class Bone { public string Name; public int Parent; public Vector3 Pos; public int InheritFrom; public float InheritRatio; } internal sealed class Particle { public int Bone; public Vector3 Tip; public int Parent; public int Anchor; public int Group; public float Limit; public float Stiff; public float Drag; public float Grav; public float Radius; } internal sealed class Collider { public int Bone; public Vector3 A; public Vector3 B; public float Radius; } internal sealed class Gun { public Mesh Mesh; public Vector3 Muzzle; } public Bone[] Bones; public Mesh Body; public string[] SubmeshTextures; public Dictionary<int, Quaternion> FingerCurl = new Dictionary<int, Quaternion>(); public Vector3[] Palm = (Vector3[])(object)new Vector3[2]; public Gun[] Guns = new Gun[2]; public Particle[] Particles; public (int a, int b, float rest)[] Links; public Collider[] Colliders; public Dictionary<string, int> Index = new Dictionary<string, int>(); public int this[string name] { get { if (!Index.TryGetValue(name, out var value)) { return -1; } return value; } } private static Vector3 V(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } private static string S(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(r.ReadInt32())); } public static BillyData Load(string path) { //IL_0079: 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_00f3: 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_0112: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: 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_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036b: 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_03aa: 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_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) BillyData billyData = new BillyData(); using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "BILLY001") { throw new InvalidDataException("bad billy.bin"); } int num = binaryReader.ReadInt32(); billyData.Bones = new Bone[num]; for (int i = 0; i < num; i++) { billyData.Bones[i] = new Bone { Name = S(binaryReader), Parent = binaryReader.ReadInt32(), Pos = V(binaryReader), InheritFrom = binaryReader.ReadInt32(), InheritRatio = binaryReader.ReadSingle() }; billyData.Index[billyData.Bones[i].Name] = i; } int num2 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num2]; for (int j = 0; j < num2; j++) { array[j] = V(binaryReader); } for (int k = 0; k < num2; k++) { array2[k] = V(binaryReader); } for (int l = 0; l < num2; l++) { array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int m = 0; m < num2; m++) { int boneIndex = binaryReader.ReadInt32(); int boneIndex2 = binaryReader.ReadInt32(); int boneIndex3 = binaryReader.ReadInt32(); int boneIndex4 = binaryReader.ReadInt32(); int num3 = m; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = boneIndex; ((BoneWeight)(ref val)).boneIndex1 = boneIndex2; ((BoneWeight)(ref val)).boneIndex2 = boneIndex3; ((BoneWeight)(ref val)).boneIndex3 = boneIndex4; ((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle(); array4[num3] = val; } Mesh val2 = new Mesh { name = "BillyKid", indexFormat = (IndexFormat)1 }; val2.vertices = array; val2.normals = array2; val2.uv = array3; val2.boneWeights = array4; int num4 = (val2.subMeshCount = binaryReader.ReadInt32()); billyData.SubmeshTextures = new string[num4]; for (int n = 0; n < num4; n++) { billyData.SubmeshTextures[n] = S(binaryReader); int num6 = binaryReader.ReadInt32(); int[] array5 = new int[num6]; for (int num7 = 0; num7 < num6; num7++) { array5[num7] = binaryReader.ReadInt32(); } val2.SetTriangles(array5, n); } Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[num]; for (int num8 = 0; num8 < num; num8++) { array6[num8] = Matrix4x4.Translate(-billyData.Bones[num8].Pos); } val2.bindposes = array6; val2.RecalculateBounds(); val2.RecalculateTangents(); ((Object)val2).hideFlags = (HideFlags)32; billyData.Body = val2; int num9 = binaryReader.ReadInt32(); for (int num10 = 0; num10 < num9; num10++) { int key = binaryReader.ReadInt32(); billyData.FingerCurl[key] = new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } billyData.Palm[0] = V(binaryReader); billyData.Palm[1] = V(binaryReader); for (int num11 = 0; num11 < 2; num11++) { int num12 = binaryReader.ReadInt32(); Vector3[] array7 = (Vector3[])(object)new Vector3[num12]; Vector3[] array8 = (Vector3[])(object)new Vector3[num12]; Vector2[] array9 = (Vector2[])(object)new Vector2[num12]; for (int num13 = 0; num13 < num12; num13++) { array7[num13] = V(binaryReader); } for (int num14 = 0; num14 < num12; num14++) { array8[num14] = V(binaryReader); } for (int num15 = 0; num15 < num12; num15++) { array9[num15] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int num16 = binaryReader.ReadInt32(); int[] array10 = new int[num16]; for (int num17 = 0; num17 < num16; num17++) { array10[num17] = binaryReader.ReadInt32(); } Mesh val3 = new Mesh { name = ((num11 == 0) ? "BillyGunL" : "BillyGunR") }; val3.vertices = array7; val3.normals = array8; val3.uv = array9; val3.triangles = array10; val3.RecalculateBounds(); val3.RecalculateTangents(); ((Object)val3).hideFlags = (HideFlags)32; billyData.Guns[num11] = new Gun { Mesh = val3, Muzzle = V(binaryReader) }; } int num18 = binaryReader.ReadInt32(); billyData.Particles = new Particle[num18]; for (int num19 = 0; num19 < num18; num19++) { Particle particle = new Particle { Bone = binaryReader.ReadInt32(), Tip = V(binaryReader), Parent = binaryReader.ReadInt32(), Anchor = binaryReader.ReadInt32(), Group = binaryReader.ReadInt32() }; particle.Limit = binaryReader.ReadSingle(); particle.Stiff = binaryReader.ReadSingle(); particle.Drag = binaryReader.ReadSingle(); particle.Grav = binaryReader.ReadSingle(); particle.Radius = binaryReader.ReadSingle(); billyData.Particles[num19] = particle; } int num20 = binaryReader.ReadInt32(); billyData.Links = new(int, int, float)[num20]; for (int num21 = 0; num21 < num20; num21++) { billyData.Links[num21] = (a: binaryReader.ReadInt32(), b: binaryReader.ReadInt32(), rest: binaryReader.ReadSingle()); } int num22 = binaryReader.ReadInt32(); billyData.Colliders = new Collider[num22]; for (int num23 = 0; num23 < num22; num23++) { billyData.Colliders[num23] = new Collider { Bone = binaryReader.ReadInt32(), A = V(binaryReader), B = V(binaryReader), Radius = binaryReader.ReadSingle() }; } return billyData; } } internal static class BillyAssets { private static BillyData data; private static readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>(); internal static bool Failed; internal static BillyData Data { get { if (data != null && !Object.op_Implicit((Object)(object)data.Body)) { data = null; } if (data == null && !Failed) { try { data = BillyData.Load(Path.Combine(Plugin.AssetsDir, "billy.bin")); } catch (Exception ex) { Failed = true; Plugin.Log.LogError((object)("Could not load billy.bin: " + ex)); } } return data; } } internal static Texture2D Texture(string file) { //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_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (textures.TryGetValue(file, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } value = new Texture2D(2, 2, (TextureFormat)4, true) { name = file, wrapMode = (TextureWrapMode)0, anisoLevel = 4, hideFlags = (HideFlags)32 }; try { ImageConversion.LoadImage(value, File.ReadAllBytes(Path.Combine(Plugin.AssetsDir, file)), true); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not load texture " + file + ": " + ex.Message)); } textures[file] = value; return value; } } [DefaultExecutionOrder(10000)] public sealed class BillyModel : MonoBehaviour { private sealed class Map { public int Bone; public Transform Src; public Transform SrcB; public Quaternion Bind; public Quaternion BindB; public Quaternion Fix = Quaternion.identity; } private static readonly PropertyInfo currentSkinIndex = typeof(ModelSkinController).GetProperty("currentSkinIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly Dictionary<Mesh, Mesh> blanks = new Dictionary<Mesh, Mesh>(); private static bool rigLogged; private CharacterModel model; private ModelSkinController skins; private ChildLocator locator; private SkinnedMeshRenderer vanillaMain; private int requestedSkin = -1; private bool active; private bool broken; private BillyData data; private GameObject root; private Transform[] bones; private Vector3[] restLocalPos; private SkinnedMeshRenderer body; private GameObject[] guns = (GameObject[])(object)new GameObject[2]; private Material[] gunMaterials = (Material[])(object)new Material[2]; private readonly float[] heat = new float[2]; private readonly float[] flash = new float[2]; private readonly float[] sinceShot = new float[2] { 99f, 99f }; private float scale = 1f; private readonly List<(Renderer renderer, Mesh mesh)> hidden = new List<(Renderer, Mesh)>(); private readonly Dictionary<Transform, Vector3> muzzleRest = new Dictionary<Transform, Vector3>(); private readonly ItemDisplayHider itemHider = new ItemDisplayHider(); private float nextItemScan; private readonly List<Map> maps = new List<Map>(); private Quaternion restRot = Quaternion.identity; private int[] hipBones = new int[2]; private Transform[] vHip = (Transform[])(object)new Transform[2]; private Transform[] vHand = (Transform[])(object)new Transform[2]; private Transform[] vMuzzle = (Transform[])(object)new Transform[2]; private Transform[] vGun = (Transform[])(object)new Transform[2]; private Transform[] vFinger = (Transform[])(object)new Transform[2]; private Transform[] vIndex = (Transform[])(object)new Transform[2]; private Transform[] vPinky = (Transform[])(object)new Transform[2]; private int[] handBone = new int[2]; private int[] indexBone = new int[2]; private int[] pinkyBone = new int[2]; private int[] middleBone = new int[2]; private int centreBone; private static readonly Vector3 GripCentre = new Vector3(0f, 0.608f, -0.692f); private static readonly Vector3 GripAxis; private const float GripAlong = 0.3f; private const float PalmDepth = 0.25f; private const float PalmAlong = 0.55f; private readonly Quaternion[] handFrame = (Quaternion[])(object)new Quaternion[2]; private readonly Vector3[] palmLocal = (Vector3[])(object)new Vector3[2]; private readonly float[] gunSign = new float[2] { 1f, -1f }; private static readonly Quaternion gripFrame; private static readonly FieldInfo mainSkinnedMeshRenderer; private static readonly FieldInfo invisibilityCount; private CharacterBody portraitBody; private Texture portraitOriginal; private static Material baseMaterial; private static readonly Dictionary<string, Material> materials; private static Texture2D heatMask; private static bool heatMaskTried; private static readonly int EmColor; private Vector3[] px; private Vector3[] pprev; private Vector3[] restLocal; private float[] plen; private Quaternion[] prot; private int[][] groups; private Vector3 lastRootPos; private Quaternion lastRootRot; private float accumulator; private bool physicsReady; private const float Step = 1f / 60f; internal bool ShowsBilly { get { if (!active) { return WantBilly(); } return true; } } private int Invisibility() { if (!Object.op_Implicit((Object)(object)model) || invisibilityCount == null) { return 0; } try { return (int)invisibilityCount.GetValue(model); } catch { return 0; } } internal void SkinRequested(int index) { requestedSkin = index; } private void SetPortrait(bool billy) { if (billy) { CharacterBody val = (Object.op_Implicit((Object)(object)model) ? model.body : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)BillyUI.Portrait) && Plugin.Portrait.Value) { if ((Object)(object)val != (Object)(object)portraitBody) { portraitBody = val; portraitOriginal = val.portraitIcon; } if ((Object)(object)val.portraitIcon != (Object)(object)BillyUI.Portrait) { val.portraitIcon = BillyUI.Portrait; } } } else if (Object.op_Implicit((Object)(object)portraitBody)) { if ((Object)(object)portraitBody.portraitIcon == (Object)(object)BillyUI.Portrait) { portraitBody.portraitIcon = portraitOriginal; } portraitBody = null; portraitOriginal = null; } } private void Awake() { model = ((Component)this).GetComponent<CharacterModel>(); skins = ((Component)this).GetComponent<ModelSkinController>(); locator = ((Component)this).GetComponent<ChildLocator>(); } private int CurrentSkin() { if (currentSkinIndex != null && Object.op_Implicit((Object)(object)skins)) { try { int num = (int)currentSkinIndex.GetValue(skins); if (num >= 0) { return num; } } catch { } } return requestedSkin; } private bool WantBilly() { if (broken || !Object.op_Implicit((Object)(object)Plugin.Skin) || !Object.op_Implicit((Object)(object)skins) || skins.skins == null) { return false; } int num = CurrentSkin(); if (num >= 0 && num < skins.skins.Length) { return (Object)(object)skins.skins[num] == (Object)(object)Plugin.Skin; } return false; } private void LateUpdate() { bool flag = WantBilly() && BillyAssets.Data != null; if (flag && !active) { Activate(); } else if (!flag && active) { Deactivate(); } if (!active) { return; } try { KeepVanillaHidden(); SetPortrait(billy: true); if (Plugin.HideItems.Value) { if (Time.unscaledTime >= nextItemScan) { nextItemScan = Time.unscaledTime + 0.25f; itemHider.Scan(((Component)this).transform); } itemHider.KeepHidden(); } else { itemHider.Restore(); } Pose(Time.deltaTime); } catch (Exception ex) { Plugin.Log.LogError((object)("Billy disabled on " + ((Object)this).name + ": " + ex)); broken = true; Deactivate(); } } private void OnDisable() { if (active) { Deactivate(); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)root)) { Object.Destroy((Object)(object)root); } Material[] array = gunMaterials; foreach (Material val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } private void Activate() { try { if (!Object.op_Implicit((Object)(object)root) && !Build()) { broken = true; return; } root.SetActive(true); active = true; HideVanilla(); ResetPhysics(); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not build Billy: " + ex)); broken = true; if (Object.op_Implicit((Object)(object)root)) { root.SetActive(false); } } } private void Deactivate() { //IL_003f: 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) active = false; for (int i = 0; i < 2; i++) { heat[i] = (flash[i] = 0f); if (Object.op_Implicit((Object)(object)gunMaterials[i])) { gunMaterials[i].SetColor(EmColor, Color.black); } } if (Object.op_Implicit((Object)(object)root)) { root.SetActive(false); } MeshFilter val3 = default(MeshFilter); foreach (var (val, sharedMesh) in hidden) { if (Object.op_Implicit((Object)(object)val)) { SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); if (val2 != null) { val2.sharedMesh = sharedMesh; } else if (((Component)val).TryGetComponent<MeshFilter>(ref val3)) { val3.sharedMesh = sharedMesh; } } } hidden.Clear(); itemHider.Restore(); SetPortrait(billy: false); foreach (KeyValuePair<Transform, Vector3> item in muzzleRest) { if (Object.op_Implicit((Object)(object)item.Key)) { item.Key.localPosition = item.Value; } } } private static Mesh Blank(Mesh original) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)original)) { return null; } if (blanks.TryGetValue(original, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } value = new Mesh { name = ((Object)original).name + "_hiddenByBilly", hideFlags = (HideFlags)32 }; value.vertices = (Vector3[])(object)new Vector3[3]; value.boneWeights = (BoneWeight[])(object)new BoneWeight[3]; value.triangles = new int[3]; value.bindposes = original.bindposes; value.bounds = original.bounds; blanks[original] = value; return value; } private void HideVanilla() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)model) || model.baseRendererInfos == null) { return; } RendererInfo[] baseRendererInfos = model.baseRendererInfos; MeshFilter val2 = default(MeshFilter); for (int i = 0; i < baseRendererInfos.Length; i++) { Renderer renderer = baseRendererInfos[i].renderer; if (!Object.op_Implicit((Object)(object)renderer)) { continue; } SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val != null) { if (Object.op_Implicit((Object)(object)val.sharedMesh) && !((Object)val.sharedMesh).name.EndsWith("_hiddenByBilly")) { hidden.Add(((Renderer)(object)val, val.sharedMesh)); val.sharedMesh = Blank(val.sharedMesh); } } else if (((Component)renderer).TryGetComponent<MeshFilter>(ref val2) && Object.op_Implicit((Object)(object)val2.sharedMesh) && !((Object)val2.sharedMesh).name.EndsWith("_hiddenByBilly")) { hidden.Add((renderer, val2.sharedMesh)); val2.sharedMesh = Blank(val2.sharedMesh); } } } private void KeepVanillaHidden() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) RendererInfo[] baseRendererInfos = model.baseRendererInfos; for (int i = 0; i < baseRendererInfos.Length; i++) { Renderer renderer = baseRendererInfos[i].renderer; SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val != null && Object.op_Implicit((Object)(object)val.sharedMesh) && !((Object)val.sharedMesh).name.EndsWith("_hiddenByBilly")) { HideVanilla(); break; } } } private Transform Find(params string[] names) { string[] array = names; foreach (string text in array) { Transform val = (Object.op_Implicit((Object)(object)locator) ? locator.FindChild(text) : null); if (Object.op_Implicit((Object)(object)val)) { return val; } } Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); array = names; foreach (string text2 in array) { string k = text2.ToLowerInvariant(); Transform val2 = ((IEnumerable<Transform>)componentsInChildren).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name.ToLowerInvariant() == k)); if (Object.op_Implicit((Object)(object)val2)) { return val2; } } return null; } private bool VanillaBind(Transform t, out Quaternion rot, out Vector3 pos) { //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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_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_00ae: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 worldToLocalMatrix = ((Component)this).transform.worldToLocalMatrix; int num = (Object.op_Implicit((Object)(object)vanillaMain) ? Array.IndexOf(vanillaMain.bones, t) : (-1)); if (num >= 0 && Object.op_Implicit((Object)(object)vanillaMain.sharedMesh) && num < vanillaMain.sharedMesh.bindposes.Length) { Matrix4x4 val = worldToLocalMatrix * ((Component)vanillaMain).transform.localToWorldMatrix * ((Matrix4x4)(ref vanillaMain.sharedMesh.bindposes[num])).inverse; rot = ((Matrix4x4)(ref val)).rotation; pos = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3)); return true; } rot = Quaternion.Inverse(((Component)this).transform.rotation) * t.rotation; pos = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(t.position); return false; } private Vector3 BindPos(Transform t) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) VanillaBind(t, out var _, out var pos); return pos; } private bool Build() { //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_0674: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e8: Expected O, but got Unknown //IL_0726: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_08db: Unknown result type (might be due to invalid IL or missing references) //IL_08e2: Expected O, but got Unknown //IL_096d: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_0842: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_082d: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_0bc1: Unknown result type (might be due to invalid IL or missing references) //IL_0bc6: Unknown result type (might be due to invalid IL or missing references) //IL_0bce: Unknown result type (might be due to invalid IL or missing references) //IL_0bd3: Unknown result type (might be due to invalid IL or missing references) //IL_0bdf: Unknown result type (might be due to invalid IL or missing references) //IL_0be4: Unknown result type (might be due to invalid IL or missing references) //IL_0c06: Unknown result type (might be due to invalid IL or missing references) //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c1d: Unknown result type (might be due to invalid IL or missing references) //IL_0c27: Unknown result type (might be due to invalid IL or missing references) //IL_0c29: Unknown result type (might be due to invalid IL or missing references) //IL_0c2b: Unknown result type (might be due to invalid IL or missing references) //IL_0c5a: Unknown result type (might be due to invalid IL or missing references) //IL_0c6c: Unknown result type (might be due to invalid IL or missing references) //IL_0c71: Unknown result type (might be due to invalid IL or missing references) //IL_0c7b: Unknown result type (might be due to invalid IL or missing references) //IL_0c7d: Unknown result type (might be due to invalid IL or missing references) //IL_0c7f: Unknown result type (might be due to invalid IL or missing references) //IL_0cb2: Unknown result type (might be due to invalid IL or missing references) //IL_0cc4: Unknown result type (might be due to invalid IL or missing references) //IL_0cc9: Unknown result type (might be due to invalid IL or missing references) //IL_0cd3: Unknown result type (might be due to invalid IL or missing references) //IL_0cd5: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0cf0: Unknown result type (might be due to invalid IL or missing references) //IL_0cf5: Unknown result type (might be due to invalid IL or missing references) //IL_0cfd: Unknown result type (might be due to invalid IL or missing references) //IL_0d02: Unknown result type (might be due to invalid IL or missing references) //IL_0d0a: Unknown result type (might be due to invalid IL or missing references) //IL_0d0f: Unknown result type (might be due to invalid IL or missing references) //IL_0d35: Unknown result type (might be due to invalid IL or missing references) //IL_0d47: Unknown result type (might be due to invalid IL or missing references) //IL_0d4c: Unknown result type (might be due to invalid IL or missing references) //IL_0d56: Unknown result type (might be due to invalid IL or missing references) //IL_0d58: Unknown result type (might be due to invalid IL or missing references) //IL_0d5a: Unknown result type (might be due to invalid IL or missing references) //IL_0d89: Unknown result type (might be due to invalid IL or missing references) //IL_0d9b: Unknown result type (might be due to invalid IL or missing references) //IL_0da0: Unknown result type (might be due to invalid IL or missing references) //IL_0daa: Unknown result type (might be due to invalid IL or missing references) //IL_0dac: Unknown result type (might be due to invalid IL or missing references) //IL_0dae: Unknown result type (might be due to invalid IL or missing references) //IL_0b78: Unknown result type (might be due to invalid IL or missing references) //IL_0b8a: Unknown result type (might be due to invalid IL or missing references) //IL_0b8f: Unknown result type (might be due to invalid IL or missing references) //IL_0b9f: Unknown result type (might be due to invalid IL or missing references) //IL_0ba7: Unknown result type (might be due to invalid IL or missing references) //IL_0bac: Unknown result type (might be due to invalid IL or missing references) //IL_11fb: Unknown result type (might be due to invalid IL or missing references) //IL_104d: Unknown result type (might be due to invalid IL or missing references) //IL_1054: Expected O, but got Unknown //IL_0f0d: Unknown result type (might be due to invalid IL or missing references) //IL_0f12: Unknown result type (might be due to invalid IL or missing references) //IL_0f21: Unknown result type (might be due to invalid IL or missing references) //IL_0f26: Unknown result type (might be due to invalid IL or missing references) //IL_0f28: Unknown result type (might be due to invalid IL or missing references) //IL_0f2d: Unknown result type (might be due to invalid IL or missing references) //IL_0f3c: Unknown result type (might be due to invalid IL or missing references) //IL_0f4e: Unknown result type (might be due to invalid IL or missing references) //IL_0f53: Unknown result type (might be due to invalid IL or missing references) //IL_0f58: Unknown result type (might be due to invalid IL or missing references) //IL_0f62: Unknown result type (might be due to invalid IL or missing references) //IL_0f64: Unknown result type (might be due to invalid IL or missing references) //IL_0f66: Unknown result type (might be due to invalid IL or missing references) //IL_0f6b: Unknown result type (might be due to invalid IL or missing references) //IL_0f70: Unknown result type (might be due to invalid IL or missing references) //IL_0f72: Unknown result type (might be due to invalid IL or missing references) //IL_0f74: Unknown result type (might be due to invalid IL or missing references) //IL_0f79: Unknown result type (might be due to invalid IL or missing references) //IL_0f7d: Unknown result type (might be due to invalid IL or missing references) //IL_0f82: Unknown result type (might be due to invalid IL or missing references) //IL_0e18: Unknown result type (might be due to invalid IL or missing references) //IL_0e2a: Unknown result type (might be due to invalid IL or missing references) //IL_0e2f: Unknown result type (might be due to invalid IL or missing references) //IL_0e3c: Unknown result type (might be due to invalid IL or missing references) //IL_0e41: Unknown result type (might be due to invalid IL or missing references) //IL_0e43: Unknown result type (might be due to invalid IL or missing references) //IL_1111: Unknown result type (might be due to invalid IL or missing references) //IL_0fdb: Unknown result type (might be due to invalid IL or missing references) //IL_0fe2: Unknown result type (might be due to invalid IL or missing references) //IL_0fe7: Unknown result type (might be due to invalid IL or missing references) //IL_0fee: Unknown result type (might be due to invalid IL or missing references) //IL_0ff3: Unknown result type (might be due to invalid IL or missing references) //IL_0ff8: Unknown result type (might be due to invalid IL or missing references) //IL_0fb0: Unknown result type (might be due to invalid IL or missing references) //IL_0fb5: Unknown result type (might be due to invalid IL or missing references) //IL_0fb7: Unknown result type (might be due to invalid IL or missing references) //IL_0fbc: Unknown result type (might be due to invalid IL or missing references) //IL_0fca: Unknown result type (might be due to invalid IL or missing references) //IL_0fcc: Unknown result type (might be due to invalid IL or missing references) //IL_0fd1: Unknown result type (might be due to invalid IL or missing references) //IL_1168: Unknown result type (might be due to invalid IL or missing references) //IL_1195: Unknown result type (might be due to invalid IL or missing references) data = BillyAssets.Data; if (data == null) { return false; } vanillaMain = (SkinnedMeshRenderer)(Object.op_Implicit((Object)(object)model) ? /*isinst with value type is only supported in some contexts*/: null); if (!Object.op_Implicit((Object)(object)vanillaMain)) { vanillaMain = (from r in ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true) orderby Object.op_Implicit((Object)(object)r.sharedMesh) ? r.sharedMesh.vertexCount : 0 descending select r).FirstOrDefault(); } if (!Object.op_Implicit((Object)(object)vanillaMain)) { Plugin.Log.LogError((object)("No Commando mesh found on " + ((Object)this).name)); return false; } Transform val = Find("Pelvis", "pelvis"); Transform val2 = Find("Stomach", "stomach"); Transform val3 = Find("Chest", "chest"); Transform val4 = Find("Head", "head"); Transform[] array = (Transform[])(object)new Transform[2] { Find("UpperArmL", "upper_arm.l"), Find("UpperArmR", "upper_arm.r") }; Transform[] array2 = (Transform[])(object)new Transform[2] { Find("LowerArmL", "lower_arm.l", "forearm.l"), Find("LowerArmR", "lower_arm.r", "forearm.r") }; vHand = (Transform[])(object)new Transform[2] { Find("HandL", "hand.l"), Find("HandR", "hand.r") }; vHip = (Transform[])(object)new Transform[2] { Find("ThighL", "thigh.l"), Find("ThighR", "thigh.r") }; Transform[] array3 = (Transform[])(object)new Transform[2] { Find("CalfL", "calf.l", "shin.l"), Find("CalfR", "calf.r", "shin.r") }; Transform[] array4 = (Transform[])(object)new Transform[2] { Find("FootL", "foot.l"), Find("FootR", "foot.r") }; vMuzzle = (Transform[])(object)new Transform[2] { Find("MuzzleLeft", "MuzzleL"), Find("MuzzleRight", "MuzzleR") }; vGun = (Transform[])(object)new Transform[2] { Find("GunL", "gun.l"), Find("GunR", "gun.r") }; vFinger = (Transform[])(object)new Transform[2] { Find("finger2.1.l"), Find("finger2.1.r") }; vIndex = (Transform[])(object)new Transform[2] { Find("finger1.1.l"), Find("finger1.1.r") }; vPinky = (Transform[])(object)new Transform[2] { Find("finger4.1.l"), Find("finger4.1.r") }; if (Plugin.DebugLog.Value && !rigLogged) { rigLogged = true; LogRig(); } if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4) || vHip.Any((Transform x) => !Object.op_Implicit((Object)(object)x)) || array3.Any((Transform x) => !Object.op_Implicit((Object)(object)x)) || array4.Any((Transform x) => !Object.op_Implicit((Object)(object)x)) || array.Any((Transform x) => !Object.op_Implicit((Object)(object)x)) || array2.Any((Transform x) => !Object.op_Implicit((Object)(object)x)) || vHand.Any((Transform x) => !Object.op_Implicit((Object)(object)x))) { Plugin.Log.LogError((object)"Commando rig not recognised, Billy cannot be shown. Send the BepInEx log to the mod author."); return false; } if (!Object.op_Implicit((Object)(object)val2)) { val2 = ((Object.op_Implicit((Object)(object)val3.parent) && (Object)(object)val3.parent != (Object)(object)val) ? val3.parent : val3); } Vector3 val5 = BindPos(vHip[1]) - BindPos(vHip[0]); Vector3 val6 = BindPos(val4) - BindPos(val); Vector3 val7 = Vector3.Cross(val5, val6); val6 = Vector3.Cross(val7, val5); restRot = Quaternion.LookRotation(((Vector3)(ref val7)).normalized, ((Vector3)(ref val6)).normalized); Vector3 val8 = BindPos(array3[0]) - BindPos(vHip[0]); float magnitude = ((Vector3)(ref val8)).magnitude; val8 = BindPos(array4[0]) - BindPos(array3[0]); float num = magnitude + ((Vector3)(ref val8)).magnitude; val8 = P("左ひざ") - P("左足"); float magnitude2 = ((Vector3)(ref val8)).magnitude; val8 = P("左足首") - P("左ひざ"); float num2 = magnitude2 + ((Vector3)(ref val8)).magnitude; scale = num / Mathf.Max(num2, 0.0001f) * Mathf.Max(0.05f, Plugin.SizeMultiplier.Value); root = new GameObject("BillyKid"); root.layer = ((Component)vanillaMain).gameObject.layer; root.transform.SetParent(((Component)this).transform, false); root.transform.localRotation = restRot; root.transform.localScale = Vector3.one * scale; int num3 = data.Bones.Length; bones = (Transform[])(object)new Transform[num3]; restLocalPos = (Vector3[])(object)new Vector3[num3]; for (int num4 = 0; num4 < num3; num4++) { Transform transform = new GameObject(data.Bones[num4].Name).transform; ((Component)transform).gameObject.layer = root.layer; bones[num4] = transform; } for (int num5 = 0; num5 < num3; num5++) { int parent = data.Bones[num5].Parent; bones[num5].SetParent((parent >= 0) ? bones[parent] : root.transform, false); restLocalPos[num5] = ((parent >= 0) ? (data.Bones[num5].Pos - data.Bones[parent].Pos) : data.Bones[num5].Pos); bones[num5].localPosition = restLocalPos[num5]; } centreBone = data["センター"]; hipBones = new int[2] { data["左足"], data["右足"] }; GameObject val9 = new GameObject("BillyMesh"); val9.layer = root.layer; val9.transform.SetParent(root.transform, false); body = val9.AddComponent<SkinnedMeshRenderer>(); body.sharedMesh = data.Body; body.bones = bones; body.rootBone = bones[centreBone]; ((Renderer)body).localBounds = new Bounds(new Vector3(0f, -2f, 0f), new Vector3(40f, 40f, 40f)); body.updateWhenOffscreen = false; body.quality = (SkinQuality)4; ((Renderer)body).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)body).sharedMaterials = data.SubmeshTextures.Select(MakeMaterial).ToArray(); Transform val10 = ((Object.op_Implicit((Object)(object)val4.parent) && (Object)(object)val4.parent != (Object)(object)val3) ? val4.parent : null); Add("下半身", val); Add("上半身", val2); Add("上半身1", val2, val3); Add("上半身2", val3); if (Object.op_Implicit((Object)(object)val10)) { Add("首", val10); } else { Add("首", val3, val4); } Add("頭", val4); string[] array5 = new string[2] { "左", "右" }; for (int num6 = 0; num6 < 2; num6++) { string text = array5[num6]; Transform val11 = ((Object.op_Implicit((Object)(object)array[num6].parent) && (Object)(object)array[num6].parent != (Object)(object)val3) ? array[num6].parent : null); if (Object.op_Implicit((Object)(object)val11)) { Add(text + "肩", val11, null, P(text + "腕") - P(text + "肩"), BindPos(array[num6]) - BindPos(val11)); } Vector3 val12 = BindPos(array[num6]); Vector3 val13 = BindPos(array2[num6]); Vector3 val14 = BindPos(vHand[num6]); Add(text + "腕", array[num6], null, P(text + "ひじ") - P(text + "腕"), val13 - val12); Add(text + "ひじ", array2[num6], null, P(text + "手首") - P(text + "ひじ"), val14 - val13); Add(text + "手首", vHand[num6], null, P(text + "手首") - P(text + "ひじ"), val14 - val13); Vector3 val15 = BindPos(vHip[num6]); Vector3 val16 = BindPos(array3[num6]); Vector3 val17 = BindPos(array4[num6]); Add(text + "足", vHip[num6], null, P(text + "ひざ") - P(text + "足"), val16 - val15); Add(text + "ひざ", array3[num6], null, P(text + "足首") - P(text + "ひざ"), val17 - val16); Transform val18 = ((array4[num6].childCount > 0) ? array4[num6].GetChild(0) : null); if (Object.op_Implicit((Object)(object)val18) && Array.IndexOf(vanillaMain.bones, val18) >= 0) { Add(text + "足首", array4[num6], null, P(text + "つま先") - P(text + "足首"), BindPos(val18) - val17); } else { Add(text + "足首", array4[num6]); } handBone[num6] = data[text + "手首"]; indexBone[num6] = data[text + "人指1"]; pinkyBone[num6] = data[text + "小指1"]; middleBone[num6] = data[text + "中指1"]; Vector3 val19 = P(text + "手首"); Vector3 val20 = P(text + "中指1") - val19; Vector3 val21 = P(text + "小指1") - P(text + "人指1"); handFrame[num6] = Quaternion.LookRotation(val20, val21); val8 = Vector3.Cross(val20, val21); Vector3 val22 = ((Vector3)(ref val8)).normalized; int num7 = data[text + "親指先"]; if (num7 >= 0 && Vector3.Dot(data.Bones[num7].Pos - val19, val22) < 0f) { val22 = -val22; } palmLocal[num6] = val20 * 0.55f + val22 * 0.25f; } maps.Sort((Map a, Map b) => a.Bone.CompareTo(b.Bone)); for (int num8 = 0; num8 < 2; num8++) { GameObject val23 = new GameObject((num8 == 0) ? "BillyGunL" : "BillyGunR"); val23.layer = root.layer; val23.transform.SetParent(root.transform, false); val23.AddComponent<MeshFilter>().sharedMesh = data.Guns[num8].Mesh; MeshRenderer obj = val23.AddComponent<MeshRenderer>(); gunMaterials[num8] = GunMaterial(); ((Renderer)obj).sharedMaterial = gunMaterials[num8]; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; guns[num8] = val23; if (Object.op_Implicit((Object)(object)vMuzzle[num8]) && !muzzleRest.ContainsKey(vMuzzle[num8])) { muzzleRest[vMuzzle[num8]] = vMuzzle[num8].localPosition; } if (Object.op_Implicit((Object)(object)vGun[num8]) && Object.op_Implicit((Object)(object)vMuzzle[num8]) && (Object)(object)vMuzzle[num8].parent == (Object)(object)vGun[num8] && Mathf.Abs(muzzleRest[vMuzzle[num8]].x) > 0.0001f) { gunSign[num8] = Mathf.Sign(muzzleRest[vMuzzle[num8]].x); } } BuildPhysics(); Plugin.Log.LogInfo((object)$"Billy built on {((Object)this).name}: scale {scale:0.000}, {maps.Count} mapped bones, facing {((Quaternion)(ref restRot)).eulerAngles}"); return true; void Add(string billy, Transform src, Transform srcB = null, Vector3? billyDir = null, Vector3? srcDir = null) { //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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00b0: 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_00ba: Unknown result type (might be due to invalid IL or missing references) int num9 = data[billy]; if (num9 >= 0 && Object.op_Implicit((Object)(object)src)) { Map map = new Map { Bone = num9, Src = src, SrcB = srcB }; VanillaBind(src, out map.Bind, out var pos); if (Object.op_Implicit((Object)(object)srcB)) { VanillaBind(srcB, out map.BindB, out pos); } if (billyDir.HasValue && srcDir.HasValue) { pos = billyDir.Value; if (((Vector3)(ref pos)).sqrMagnitude > 1E-08f) { pos = srcDir.Value; if (((Vector3)(ref pos)).sqrMagnitude > 1E-08f) { map.Fix = Quaternion.FromToRotation(restRot * billyDir.Value, srcDir.Value); } } } maps.Add(map); } } Vector3 P(string n) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return data.Bones[data[n]].Pos; } } private Material BaseMaterial() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)baseMaterial)) { return baseMaterial; } Material val = null; if (Object.op_Implicit((Object)(object)model) && model.baseRendererInfos != null) { val = model.baseRendererInfos.Select((RendererInfo x) => x.defaultMaterial).FirstOrDefault((Func<Material, bool>)((Material x) => Object.op_Implicit((Object)(object)x) && Object.op_Implicit((Object)(object)x.shader) && ((Object)x.shader).name.Contains("HGStandard"))); } if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)vanillaMain)) { val = ((IEnumerable<Material>)((Renderer)vanillaMain).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material x) => Object.op_Implicit((Object)(object)x) && Object.op_Implicit((Object)(object)x.shader) && ((Object)x.shader).name.Contains("HGStandard"))); } if (!Object.op_Implicit((Object)(object)val)) { val = Plugin.LoadAsset<Material>("RoR2/Base/Commando/matCommandoDualies.mat"); } if (Object.op_Implicit((Object)(object)val)) { baseMaterial = new Material(val); } else { Shader val2 = Plugin.LoadAsset<Shader>("RoR2/Base/Shaders/HGStandard.shader"); if (!Object.op_Implicit((Object)(object)val2)) { val2 = Shader.Find("Standard"); } baseMaterial = new Material(val2); Plugin.Log.LogWarning((object)("No Commando material found, using shader " + (Object.op_Implicit((Object)(object)val2) ? ((Object)val2).name : "null"))); } ((Object)baseMaterial).name = "matBillyBase"; ((Object)baseMaterial).hideFlags = (HideFlags)32; return baseMaterial; } private Material MakeMaterial(string texture) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (materials.TryGetValue(texture, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } Material val = new Material(BaseMaterial()) { name = "matBilly_" + texture, hideFlags = (HideFlags)32 }; val.mainTexture = (Texture)(object)BillyAssets.Texture(texture); if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } string[] array = new string[4] { "_NormalTex", "_EmTex", "_FlowHeightmap", "_FresnelRamp" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)null); } } if (val.HasProperty("_EmColor")) { val.SetColor("_EmColor", Color.black); } if (val.HasProperty("_EmPower")) { val.SetFloat("_EmPower", 0f); } if (val.HasProperty("_NormalStrength")) { val.SetFloat("_NormalStrength", 0f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.35f); } if (val.HasProperty("_SpecularStrength")) { val.SetFloat("_SpecularStrength", 0.2f); } materials[texture] = val; return val; } private Material GunMaterial() { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(MakeMaterial("billy_gun.png")) { name = "matBillyGun", hideFlags = (HideFlags)32 }; if (!heatMaskTried) { heatMaskTried = true; if (File.Exists(Path.Combine(Plugin.AssetsDir, "billy_gun_heat.png"))) { heatMask = BillyAssets.Texture("billy_gun_heat.png"); } else { Plugin.Log.LogWarning((object)"billy_gun_heat.png missing: no barrel heat"); } } if (Object.op_Implicit((Object)(object)heatMask) && val.HasProperty("_EmTex")) { val.SetTexture("_EmTex", (Texture)(object)heatMask); if (val.HasProperty("_EmPower")) { val.SetFloat("_EmPower", 1f); } } if (val.HasProperty("_EmColor")) { val.SetColor("_EmColor", Color.black); } return val; } internal void Shot(int side, float amount) { if (!active) { return; } for (int i = 0; i < 2; i++) { if (side < 0 || side == i) { heat[i] = Mathf.Min(1f, heat[i] + amount); flash[i] = 1f; sinceShot[i] = 0f; } } } private void UpdateHeat(float dt) { //IL_00fe: 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_0135: Unknown result type (might be due to invalid IL or missing references) bool flag = Plugin.Overheat.Value && Object.op_Implicit((Object)(object)heatMask); for (int i = 0; i < 2; i++) { if (!flag) { heat[i] = (flash[i] = 0f); } sinceShot[i] += dt; if (sinceShot[i] > 0.25f) { heat[i] = Mathf.Max(0f, heat[i] - dt * (0.22f + heat[i] * 0.5f)); } flash[i] = Mathf.Max(0f, flash[i] - dt / 0.12f); Material val = gunMaterials[i]; if (Object.op_Implicit((Object)(object)val) && val.HasProperty(EmColor)) { Color val2 = HeatRamp(Mathf.Clamp01(heat[i] + flash[i] * 0.2f * Mathf.Max(heat[i], 0.3f))) * (1.4f * Mathf.Max(0f, Plugin.OverheatBrightness.Value)); val2.a = 1f; val.SetColor(EmColor, val2); } } } private static Color HeatRamp(float h) { //IL_0008: 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_002a: 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_008e: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) if (h <= 0f) { return Color.black; } if (h < 0.3f) { return Color.Lerp(Color.black, new Color(0.55f, 0.05f, 0f), h / 0.3f); } if (h < 0.65f) { return Color.Lerp(new Color(0.55f, 0.05f, 0f), new Color(1.2f, 0.25f, 0.03f), (h - 0.3f) / 0.35f); } return Color.Lerp(new Color(1.2f, 0.25f, 0.03f), new Color(1.6f, 0.55f, 0.12f), (h - 0.65f) / 0.35f); } private void LogRig() { //IL_0111: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder("Commando rig (" + ((Object)this).name + ")\nChildLocator:"); if (Object.op_Implicit((Object)(object)locator)) { for (int i = 0; i < locator.Count; i++) { Transform val = locator.FindChild(i); stringBuilder.Append(' ').Append(locator.FindChildName(i)).Append('=') .Append(Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "null"); } } stringBuilder.Append("\nBones:"); if (Object.op_Implicit((Object)(object)vanillaMain)) { Transform[] array = vanillaMain.bones; foreach (Transform val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { VanillaBind(val2, out var rot, out var pos); stringBuilder.Append(string.Format("\n {0} (parent {1}) pos {2:0.000},{3:0.000},{4:0.000} rot {5}", ((Object)val2).name, Object.op_Implicit((Object)(object)val2.parent) ? ((Object)val2.parent).name : "-", pos.x, pos.y, pos.z, ((Quaternion)(ref rot)).eulerAngles)); } } } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } private void Pose(float dt) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_0193: 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_027a: 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_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) int num = bones.Length; for (int i = 0; i < num; i++) { bones[i].localPosition = restLocalPos[i]; bones[i].localRotation = Quaternion.identity; } Quaternion rotation = ((Component)this).transform.rotation; Quaternion val = Quaternion.Inverse(rotation); foreach (Map map in maps) { Quaternion val2 = val * map.Src.rotation * Quaternion.Inverse(map.Bind); if (Object.op_Implicit((Object)(object)map.SrcB)) { val2 = Quaternion.Slerp(val2, val * map.SrcB.rotation * Quaternion.Inverse(map.BindB), 0.5f); } bones[map.Bone].rotation = rotation * (val2 * map.Fix * restRot); } for (int j = 0; j < num; j++) { BillyData.Bone bone = data.Bones[j]; if (bone.InheritFrom >= 0 && bone.InheritFrom < num) { Quaternion localRotation = bones[bone.InheritFrom].localRotation; bones[j].localRotation = ((bone.InheritRatio >= 0f) ? Quaternion.SlerpUnclamped(Quaternion.identity, localRotation, bone.InheritRatio) : Quaternion.SlerpUnclamped(Quaternion.identity, Quaternion.Inverse(localRotation), 0f - bone.InheritRatio)); } } Vector3 val3 = (vHip[0].position + vHip[1].position) * 0.5f; Vector3 val4 = (bones[hipBones[0]].position + bones[hipBones[1]].position) * 0.5f; Transform obj = bones[centreBone]; obj.position += val3 - val4; if (Plugin.Guns.Value) { for (int k = 0; k < 2; k++) { if (GunRotation(k, out var rot)) { bones[handBone[k]].rotation = rot * gripFrame * Quaternion.Inverse(handFrame[k]); } } foreach (KeyValuePair<int, Quaternion> item in data.FingerCurl) { bones[item.Key].localRotation = item.Value; } } if (Plugin.Physics.Value) { StepPhysics(dt); } for (int l = 0; l < 2; l++) { PlaceGun(l); } UpdateHeat(dt); bool flag = Object.op_Implicit((Object)(object)vanillaMain) && ((Renderer)vanillaMain).enabled && ((Component)vanillaMain).gameObject.activeInHierarchy && Invisibility() <= 0; ((Renderer)body).enabled = flag; for (int m = 0; m < 2; m++) { ((Renderer)guns[m].GetComponent<MeshRenderer>()).enabled = flag && Plugin.Guns.Value; } } private bool GunRotation(int s, out Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0029: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0051: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e4: 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) rot = Quaternion.identity; Transform val = vGun[s]; if (!Object.op_Implicit((Object)(object)val)) { return false; } Vector3 val2 = val.TransformDirection(Vector3.right); float num = gunSign[s]; if (Object.op_Implicit((Object)(object)vFinger[s]) && Object.op_Implicit((Object)(object)vHand[s])) { float num2 = Vector3.Dot(val2, vFinger[s].position - vHand[s].position); if (Mathf.Abs(num2) > 1E-06f) { num = Mathf.Sign(num2); } } Vector3 val3 = val.TransformDirection(Vector3.up); if (Object.op_Implicit((Object)(object)vIndex[s]) && Object.op_Implicit((Object)(object)vPinky[s]) && Vector3.Dot(val3, vIndex[s].position - vPinky[s].position) < 0f) { val3 = -val3; } Vector3 val4 = val2 * num; Vector3 val5 = val3; if (((Vector3)(ref val4)).sqrMagnitude < 1E-10f || ((Vector3)(ref val5)).sqrMagnitude < 1E-10f) { return false; } rot = Quaternion.LookRotation(val4, val5); return true; } private void PlaceGun(int s) { //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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) GameObject val = guns[s]; if (!Plugin.Guns.Value) { if (Object.op_Implicit((Object)(object)vMuzzle[s]) && muzzleRest.TryGetValue(vMuzzle[s], out var value)) { vMuzzle[s].localPosition = value; } return; } Transform val2 = bones[handBone[s]]; Vector3 pos = data.Bones[handBone[s]].Pos; if (GunRotation(s, out var rot)) { val.transform.rotation = rot; Transform transform = val.transform; transform.position += val2.TransformPoint(palmLocal[s]) - val.transform.TransformPoint(GripCentre + GripAxis * 0.3f); } else { Vector3 val3 = val2.TransformPoint(data.Palm[s] - pos); Vector3 val4 = val2.TransformDirection(data.Bones[middleBone[s]].Pos - pos); if (Object.op_Implicit((Object)(object)vMuzzle[s]) && Object.op_Implicit((Object)(object)vHand[s]) && muzzleRest.TryGetValue(vMuzzle[s], out var value2)) { Vector3 val5 = (Object.op_Implicit((Object)(object)vMuzzle[s].parent) ? vMuzzle[s].parent.TransformPoint(value2) : vMuzzle[s].position) - vHand[s].position; if (((Vector3)(ref val5)).sqrMagnitude > 1E-08f) { val4 = val5; } } Vector3 val6 = val2.TransformDirection(data.Bones[indexBone[s]].Pos - data.Bones[pinkyBone[s]].Pos); val6 = Vector3.ProjectOnPlane(val6, ((Vector3)(ref val4)).normalized); if (((Vector3)(ref val6)).sqrMagnitude < 1E-08f) { val6 = ((Component)this).transform.up; } val.transform.SetPositionAndRotation(val3, Quaternion.LookRotation(((Vector3)(ref val4)).normalized, ((Vector3)(ref val6)).normalized)); } if (Plugin.MoveMuzzles.Value && Object.op_Implicit((Object)(object)vMuzzle[s])) { vMuzzle[s].position = val.transform.TransformPoint(data.Guns[s].Muzzle); } } private void BuildPhysics() { //IL_0067: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00d7: 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_00dc: Unknown result type (might be due to invalid IL or missing references) int num = data.Particles.Length; px = (Vector3[])(object)new Vector3[num]; pprev = (Vector3[])(object)new Vector3[num]; restLocal = (Vector3[])(object)new Vector3[num]; plen = new float[num]; prot = (Quaternion[])(object)new Quaternion[num]; for (int i = 0; i < num; i++) { BillyData.Particle particle = data.Particles[i]; restLocal[i] = particle.Tip - data.Bones[particle.Bone].Pos; plen[i] = ((Vector3)(ref restLocal[i])).magnitude; restLocal[i] = ((plen[i] > 1E-06f) ? (restLocal[i] / plen[i]) : Vector3.down); } groups = (from x in data.Particles.Select((BillyData.Particle p, int item) => (Group: p.Group, i: item)) group x by x.Group into g orderby g.Key select g.Select(((int Group, int i) x) => x.i).ToArray()).ToArray(); } private void ResetPhysics() { physicsReady = false; accumulator = 0f; } private Vector3 Head(int i) { //IL_0036: 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) BillyData.Particle particle = data.Particles[i]; if (particle.Parent < 0) { return bones[particle.Bone].position; } return px[particle.Parent]; } private Quaternion BaseRot(int i) { //IL_0036: 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) BillyData.Particle particle = data.Particles[i]; if (particle.Parent < 0) { return bones[particle.Bone].rotation; } return prot[particle.Parent]; } private void StepPhysics(float dt) { //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_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_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_0090: 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_00ae: 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_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_00cd: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0109: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //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_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_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0326: 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_0330: 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_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) float x = root.transform.lossyScale.x; Vector3 position = ((Component)this).transform.position; Quaternion rotation = ((Component)this).transform.rotation; Vector3 val; int num; if (physicsReady) { val = position - lastRootPos; num = ((((Vector3)(ref val)).sqrMagnitude > 25f) ? 1 : 0); } else { num = 1; } bool flag = (byte)num != 0; float num2 = 1f - Mathf.Clamp01(Plugin.Inertia.Value); if (!flag && num2 > 0f) { Quaternion val2 = rotation * Quaternion.Inverse(lastRootRot); for (int i = 0; i < px.Length; i++) { ref Vector3 reference = ref px[i]; reference += (position + val2 * (px[i] - lastRootPos) - px[i]) * num2; ref Vector3 reference2 = ref pprev[i]; reference2 += (position + val2 * (pprev[i] - lastRootPos) - pprev[i]) * num2; } } lastRootPos = position; lastRootRot = rotation; int num3 = 0; if (flag) { accumulator = 0f; } else { accumulator = Mathf.Min(accumulator + dt, 1f / 15f); while (accumulator >= 1f / 60f && num3 < 4) { accumulator -= 1f / 60f; num3++; } } Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, -9.81f, 0f); int[][] array = groups; foreach (int[] array2 in array) { int[] array3; if (flag) { array3 = array2; foreach (int num4 in array3) { Quaternion val4 = BaseRot(num4); val = (px[num4] = (pprev[num4] = Head(num4) + val4 * restLocal[num4] * (plen[num4] * x))); prot[num4] = val4; } } for (int l = 0; l < num3; l++) { array3 = array2; foreach (int num5 in array3) { BillyData.Particle particle = data.Particles[num5]; Vector3 val5 = (px[num5] - pprev[num5]) * (1f - particle.Drag); pprev[num5] = px[num5]; ref Vector3 reference3 = ref px[num5]; reference3 += val5 + val3 * (particle.Grav * (1f / 60f) * (1f / 60f)); } Solve(array2, x, pull: true); for (int m = 0; m < 2; m++) { SolveLinks(array2, x); } } Solve(array2, x, pull: false); array3 = array2; foreach (int num6 in array3) { Transform val6 = bones[data.Particles[num6].Bone]; Vector3 val7 = val6.rotation * restLocal[num6]; Vector3 val8 = px[num6] - val6.position; if (((Vector3)(ref val8)).sqrMagnitude > 1E-10f) { val6.rotation = Quaternion.FromToRotation(val7, val8) * val6.rotation; } } } physicsReady = true; } private void Solve(int[] group, float s, bool pull) { //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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_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_0065: 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_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_008a: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_010f: 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_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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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) foreach (int num in group) { BillyData.Particle particle = data.Particles[num]; Vector3 val = Head(num); Quaternion val2 = BaseRot(num); Vector3 val3 = val2 * restLocal[num]; float num2 = plen[num] * s; if (pull) { ref Vector3 reference = ref px[num]; reference += (val + val3 * num2 - px[num]) * particle.Stiff; } Collide(ref px[num], particle.Radius * s, s); Vector3 val4 = px[num] - val; if (((Vector3)(ref val4)).sqrMagnitude < 1E-12f) { val4 = val3; } if (Vector3.Angle(val3, val4) * ((float)Math.PI / 180f) > particle.Limit) { val4 = Vector3.RotateTowards(val3, val4, particle.Limit, 0f); } px[num] = val + ((Vector3)(ref val4)).normalized * num2; prot[num] = Quaternion.FromToRotation(val3, val4) * val2; } } private void SolveLinks(int[] group, float s) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00de: 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_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_00fc: 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_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) (int, int, float)[] links = data.Links; for (int i = 0; i < links.Length; i++) { var (num, num2, num3) = links[i]; if (data.Particles[num].Group == data.Particles[num2].Group && data.Particles[num].Group == data.Particles[group[0]].Group) { Vector3 val = px[num2] - px[num]; float magnitude = ((Vector3)(ref val)).magnitude; float num4 = num3 * s; if (!(magnitude < 1E-06f)) { Vector3 val2 = val * (0.5f * (magnitude - num4) / magnitude); ref Vector3 reference = ref px[num]; reference += val2; ref Vector3 reference2 = ref px[num2]; reference2 -= val2; } } } } private void Collide(ref Vector3 x, float radius, float s) { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_007b: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) BillyData.Collider[] colliders = data.Colliders; foreach (BillyData.Collider collider in colliders) { Transform obj = bones[collider.Bone]; Vector3 val = obj.TransformPoint(collider.A); Vector3 val2 = obj.TransformPoint(collider.B) - val; float num = ((((Vector3)(ref val2)).sqrMagnitude > 1E-10f) ? Mathf.Clamp01(Vector3.Dot(x - val, val2) / ((Vector3)(ref val2)).sqrMagnitude) : 0f); Vector3 val3 = val + val2 * num; Vector3 val4 = x - val3; float num2 = collider.Radius * s + radius; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude < num2 && magnitude > 1E-06f) { x = val3 + val4 * (num2 / magnitude); } } } static BillyModel() { //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) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(0.007f, 0.824f, 0.566f); GripAxis = ((Vector3)(ref val)).normalized; gripFrame = Quaternion.LookRotation(Vector3.ProjectOnPlane(Vector3.forward, GripAxis), -GripAxis); mainSkinnedMeshRenderer = typeof(CharacterModel).GetField("mainSkinnedMeshRenderer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); invisibilityCount = typeof(CharacterModel).GetField("invisibilityCount", BindingFlags.Instance |