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 Kaine Suit v0.1.16
plugins/AJ-KaineSuit/Kaine.dll
Decompiled a day 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.Reflection; using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using ModelReplacement; using ModelReplacement.AvatarBodyUpdater; using ModelReplacement.Monobehaviors.Enemies; using ModelReplacement.Scripts.Enemies; using ModelReplacement.Scripts.Player; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace KaineSuit { [BepInPlugin("aj.kaine.reincarnation", "Kaine Suit", "0.1.16")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal const float BodyScale = 0.8808894f; internal static GameObject Prefab; internal static Vector3 OriginalScale; private AssetBundle bundle; private void Awake() { //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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0639: 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_0676: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_072d: 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_076a: Unknown result type (might be due to invalid IL or missing references) //IL_0783: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_0821: Unknown result type (might be due to invalid IL or missing references) //IL_083a: Unknown result type (might be due to invalid IL or missing references) //IL_085e: Unknown result type (might be due to invalid IL or missing references) //IL_0877: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08b4: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0952: Unknown result type (might be due to invalid IL or missing references) //IL_096b: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_09a8: Unknown result type (might be due to invalid IL or missing references) //IL_09cc: Unknown result type (might be due to invalid IL or missing references) //IL_09e5: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a22: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "kaineassets")); if (!Object.op_Implicit((Object)(object)bundle)) { throw new Exception("Kaine asset bundle missing"); } Prefab = bundle.LoadAsset<GameObject>("Assets/Kaine/Kaine.prefab"); if (!Object.op_Implicit((Object)(object)Prefab)) { throw new Exception("Kaine prefab missing"); } OriginalScale = Prefab.transform.localScale; Animator componentInChildren = Prefab.GetComponentInChildren<Animator>(); if (!Object.op_Implicit((Object)(object)componentInChildren) || !componentInChildren.isHuman || !componentInChildren.avatar.isValid) { throw new Exception("Kaine humanoid avatar invalid"); } OffsetBuilder obj = ((Component)componentInChildren).gameObject.AddComponent<OffsetBuilder>(); obj.rootScale = Vector3.one * 0.8808894f; obj.rootPositionOffset = Vector3.zero; obj.GenerateViewModel = true; Apply(componentInChildren, "LeftLowerArm", new Quaternion(-0.7046245f, 0.70844114f, 0.033515144f, -0.022199526f), new Quaternion(-0.0105037745f, -0.09538018f, 0.045421287f, 0.9943487f)); Apply(componentInChildren, "Head", new Quaternion(0.017403882f, 1.1210217E-07f, 5.577656E-08f, 0.99984884f), new Quaternion(-0.0053172777f, 2.3251351E-07f, 5.1505566E-08f, 0.9999861f)); Apply(componentInChildren, "Left Thumb Proximal", new Quaternion(-0.21466082f, 0.6048781f, 0.749175f, 0.16364832f), new Quaternion(0.104095966f, (float)Math.E * 77f / 310f, 0.25973865f, 0.68251306f)); Apply(componentInChildren, "Hips", new Quaternion(-0.7071069f, 5.744918E-15f, -1.0986727E-14f, 0.70710677f), new Quaternion(-0.79081154f, 1.4592635E-07f, 1.885441E-07f, 0.6120598f)); Apply(componentInChildren, "LeftUpperArm", new Quaternion(0.7289471f, -0.68451166f, 0.0013474178f, 0.00886638f), new Quaternion(-0.026259882f, 0.07833261f, -0.011584526f, -0.99651414f)); Apply(componentInChildren, "Right Middle Intermediate", new Quaternion(0.46973386f, 0.43143642f, 0.6687906f, -0.3820114f), new Quaternion(-0.10425274f, 0.5968648f, 0.07843716f, -0.7916644f)); Apply(componentInChildren, "RightToes", new Quaternion(5.889287E-07f, 0.674072f, 0.73866564f, 6.397197E-08f), new Quaternion(0.001572002f, 0.024189109f, -0.028645046f, 0.999296f)); Apply(componentInChildren, "Right Thumb Proximal", new Quaternion(0.21466017f, 0.60487825f, 0.7491752f, -0.16364768f), new Quaternion(-0.05024603f, 0.6675385f, 0.25531194f, -0.6976277f)); Apply(componentInChildren, "Left Index Proximal", new Quaternion(-0.48711988f, 0.47100183f, 0.6308608f, 0.37800378f), new Quaternion(-0.013938686f, 0.6819777f, 0.19358613f, 0.70515054f)); Apply(componentInChildren, "UpperChest", new Quaternion(-0.13728917f, 1.07006876E-07f, 7.2030645E-08f, 0.99053127f), new Quaternion(-0.10182974f, 2.2341894E-07f, 8.5647365E-08f, 0.9948019f)); Apply(componentInChildren, "Right Little Intermediate", new Quaternion(0.53814834f, 0.47355324f, 0.610485f, -0.336827f), new Quaternion(-0.16132891f, 0.6320671f, 0.1863722f, -0.7346634f)); Apply(componentInChildren, "LeftShoulder", new Quaternion(-0.46142855f, 0.5315864f, 0.46571925f, 0.5362888f), new Quaternion(0.05987964f, 0.005299839f, -0.0009534326f, 0.9981913f)); Apply(componentInChildren, "RightUpperLeg", new Quaternion(0.9978794f, 0.05348973f, 0.0004051795f, 0.037087627f), new Quaternion(-0.020566516f, 0.032673806f, -0.041166347f, 0.9984061f)); Apply(componentInChildren, "Chest", new Quaternion(-0.09277f, 1.1544902E-07f, 5.5689824E-08f, 0.9956877f), new Quaternion(-0.11028221f, 2.3512912E-07f, 6.446378E-08f, 0.9939004f)); Apply(componentInChildren, "RightLowerLeg", new Quaternion(0.9987851f, 0.015411388f, -0.00027104645f, -0.046805833f), new Quaternion(0.028484266f, 0.029245792f, -0.015293689f, 0.99904937f)); Apply(componentInChildren, "Right Middle Proximal", new Quaternion(0.4859401f, 0.47129986f, 0.62978125f, -0.38093945f), new Quaternion(0.04448355f, 0.6578162f, 0.17750603f, -0.73061043f)); Apply(componentInChildren, "LeftLowerLeg", new Quaternion(0.9987852f, -0.015411392f, 0.00027105297f, -0.046805844f), new Quaternion(17f / (164f * (float)Math.PI), -0.02966162f, 0.017516213f, 0.9988618f)); Apply(componentInChildren, "Spine", new Quaternion(0.0050373916f, 1.0927937E-07f, 9.043406E-09f, 0.9999875f), new Quaternion(-0.090695515f, 2.283612E-07f, 9.354435E-09f, 0.9958787f)); Apply(componentInChildren, "LeftHand", new Quaternion(0.7641798f, -0.64218247f, -0.05502292f, 0.024576299f), new Quaternion(0.1462848f, -0.68713367f, -0.0068933833f, -0.7116184f)); Apply(componentInChildren, "RightUpperArm", new Quaternion(0.728947f, 0.68451184f, -0.0013476958f, 0.008866387f), new Quaternion(-0.003734426f, 0.6880562f, 0.00029217143f, -0.72564846f)); Apply(componentInChildren, "Right Ring Proximal", new Quaternion(0.48196203f, 0.468968f, 0.6268595f, -0.39348376f), new Quaternion(0.022951754f, 0.6427967f, 0.22274269f, -0.7325793f)); Apply(componentInChildren, "Left Ring Proximal", new Quaternion(-0.48196164f, 0.4689686f, 0.62685907f, 0.39348432f), new Quaternion(0.037790608f, 0.6583081f, 0.2626676f, 0.70442104f)); Apply(componentInChildren, "RightLowerArm", new Quaternion(0.70462453f, 0.70844114f, 0.033515204f, 0.022199588f), new Quaternion(0.036936495f, -0.1675329f, 0.039932106f, -0.9843653f)); Apply(componentInChildren, "Left Middle Intermediate", new Quaternion(-0.46973544f, 0.43143392f, 0.6687935f, 0.38200715f), new Quaternion(0.13288003f, 0.6527844f, 0.060467158f, 0.74334383f)); Apply(componentInChildren, "RightFoot", new Quaternion(0.89587235f, 4.2992934E-07f, 7.5390126E-08f, 0.44431153f), new Quaternion(-0.0015695206f, 0.03569569f, 0.011470113f, 0.99929583f)); Apply(componentInChildren, "Right Index Intermediate", new Quaternion(0.51879776f, 0.46810317f, 0.6291544f, -0.34043184f), new Quaternion(-0.09156327f, 0.6723106f, 0.050513975f, -0.7328465f)); Apply(componentInChildren, "LeftFoot", new Quaternion(0.8958725f, -4.0969712E-07f, -6.58795E-08f, 0.44431162f), new Quaternion(0.0029454872f, -0.037284967f, -0.010713695f, 0.99924314f)); Apply(componentInChildren, "Left Little Proximal", new Quaternion(-0.42731124f, 0.43113172f, 0.66927296f, 0.4284914f), new Quaternion(0.049730502f, 0.6636151f, 0.25199392f, 0.7025965f)); Apply(componentInChildren, "RightShoulder", new Quaternion(-0.46142697f, -0.53158784f, -0.46571773f, 0.53629017f), new Quaternion(0.061919242f, -0.0053016753f, 0.0009424845f, 0.9980669f)); Apply(componentInChildren, "Left Index Intermediate", new Quaternion(-0.5187976f, 0.46810392f, 0.6291542f, 0.34043142f), new Quaternion(0.16441715f, 0.7087535f, 0.0039437767f, 0.68601793f)); Apply(componentInChildren, "LeftToes", new Quaternion(-5.731474E-07f, 0.6740723f, 0.7386655f, -5.111725E-08f), new Quaternion(-0.0029435526f, -0.02593908f, 0.028846247f, 0.9992432f)); Apply(componentInChildren, "Right Index Proximal", new Quaternion(0.48711902f, 0.47100252f, 0.63086075f, -0.37800395f), new Quaternion(0.066287056f, 0.6718245f, 0.1096749f, -0.72954106f)); Apply(componentInChildren, "Left Middle Proximal", new Quaternion(-0.48594126f, 0.471299f, 0.6297812f, 0.38093925f), new Quaternion(0.02288521f, 0.6746723f, 0.18444186f, 0.71433556f)); Apply(componentInChildren, "Right Ring Intermediate", new Quaternion(0.509517f, 0.47900414f, 0.62906045f, -0.33945718f), new Quaternion(-0.15616556f, 0.63118553f, 0.15121324f, -0.74454886f)); Apply(componentInChildren, "Right Little Proximal", new Quaternion(0.4273102f, 0.43113294f, 0.66927266f, -0.4284917f), new Quaternion(0.03761272f, 0.5724875f, 0.29404625f, -0.7644481f)); Apply(componentInChildren, "Left Ring Intermediate", new Quaternion(-0.5095167f, 0.4790051f, 0.6290594f, 0.33945817f), new Quaternion(0.17432314f, 0.6889039f, 11f / (36f * (float)Math.PI), 0.6968238f)); Apply(componentInChildren, "LeftUpperLeg", new Quaternion(0.99787945f, -0.05348973f, -0.0004051795f, 0.037087627f), new Quaternion(-0.016086996f, -0.033524282f, 0.04332151f, 0.9983691f)); Apply(componentInChildren, "RightHand", new Quaternion(0.76418f, 0.64218235f, 0.05502296f, 0.024576146f), new Quaternion(0.13572784f, 0.6610523f, -0.016803715f, -0.7377711f)); Apply(componentInChildren, "Left Little Intermediate", new Quaternion(-0.53814787f, 0.47355482f, 0.6104829f, 0.33682948f), new Quaternion(193f / (279f * (float)Math.PI), 0.6290908f, 0.2238834f, 0.7110817f)); new Harmony("aj.kaine.reincarnation").PatchAll(typeof(Plugin).Assembly); ModelReplacementAPI.RegisterSuitModelReplacement("Kaine", typeof(KaineBody)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"KAINE_READY: original rig; generated first-person arms; measured vanilla mesh height; suit name Kaine."); } private static void Apply(Animator anim, string human, Quaternion referenceRotation, Quaternion referenceOffset) { //IL_002c: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0043: Unknown result type (might be due to invalid IL or missing references) int num = Array.IndexOf(HumanTrait.BoneName, human); if (num >= 0) { Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)num); if (Object.op_Implicit((Object)(object)boneTransform)) { ((Component)boneTransform).gameObject.AddComponent<RotationOffset>().offset = referenceOffset * Quaternion.Inverse(referenceRotation) * boneTransform.rotation; } } } } public class KaineBody : BodyReplacementBase { private readonly HashSet<int> fixedModels = new HashSet<int>(); private readonly List<Material> ownedMaterials = new List<Material>(); private Transform nameHead; private Transform billboard; private Vector3 originalNamePosition; private float nameClearance; private bool nameReady; private GameObject sourceCopy; internal void ApplyGrip(GrabbableObject item, Vector3 delta) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) Transform parentObject = item.parentObject; Item itemProperties = item.itemProperties; ((Component)item).transform.SetPositionAndRotation(HoldPlacement.Position(parentObject, itemProperties.positionOffset, delta), parentObject.rotation * Quaternion.Euler(itemProperties.rotationOffset)); } protected override ViewModelUpdater GetViewModelUpdater() { return (ViewModelUpdater)(object)new PortViewModelUpdater(); } protected override AvatarUpdater GetAvatarUpdater() { return (AvatarUpdater)(object)new GroundedAvatarUpdater(); } protected override GameObject LoadAssetsAndReturnModel() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) sourceCopy = Object.Instantiate<GameObject>(Plugin.Prefab); sourceCopy.transform.localScale = Plugin.OriginalScale; return sourceCopy; } protected override void AddModelScripts() { ((BodyReplacementBase)this).AddModelScripts(); RepairMaterials(base.replacementModel); PrepareName(); if (Object.op_Implicit((Object)(object)sourceCopy)) { Object.Destroy((Object)(object)sourceCopy); sourceCopy = null; } } private void RepairMaterials(GameObject model) { if (Object.op_Implicit((Object)(object)model) && !fixedModels.Contains(((Object)model).GetInstanceID()) && Object.op_Implicit((Object)(object)((BodyReplacementBase)this).controller) && Object.op_Implicit((Object)(object)((BodyReplacementBase)this).controller.thisPlayerModel)) { ownedMaterials.AddRange(SuitMaterials.Apply(model, ((Renderer)((BodyReplacementBase)this).controller.thisPlayerModel).sharedMaterial)); fixedModels.Add(((Object)model).GetInstanceID()); Debug.Log((object)("KAINE_MATERIALS_READY: " + ((Object)model).name + " renderers=" + model.GetComponentsInChildren<Renderer>(true).Length)); } } public override void LateUpdate() { //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_0074: 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) ((BodyReplacementBase)this).LateUpdate(); RepairMaterials(base.replacementModel); RepairMaterials(base.replacementViewModel); RepairMaterials(base.replacementDeadBody); RepairMaterials(base.replacementModelShadow); if (nameReady && Object.op_Implicit((Object)(object)nameHead) && Object.op_Implicit((Object)(object)billboard)) { billboard.position = nameHead.position + Vector3.up * nameClearance; } } protected override void OnDestroy() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (nameReady && Object.op_Implicit((Object)(object)billboard)) { billboard.localPosition = originalNamePosition; } ((BodyReplacementBase)this).OnDestroy(); foreach (Material ownedMaterial in ownedMaterials) { if (Object.op_Implicit((Object)(object)ownedMaterial)) { Object.Destroy((Object)(object)ownedMaterial); } } } private void PrepareName() { //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_0070: 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_0081: Expected O, but got Unknown //IL_0101: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)base.replacementModel) || !Object.op_Implicit((Object)(object)((BodyReplacementBase)this).controller.usernameBillboard)) { return; } Animator componentInChildren = base.replacementModel.GetComponentInChildren<Animator>(); nameHead = componentInChildren.GetBoneTransform((HumanBodyBones)10); if (!Object.op_Implicit((Object)(object)nameHead)) { return; } billboard = ((BodyReplacementBase)this).controller.usernameBillboard; originalNamePosition = billboard.localPosition; float num = nameHead.position.y; Mesh val = new Mesh(); SkinnedMeshRenderer[] componentsInChildren = base.replacementModel.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val2 in componentsInChildren) { val2.BakeMesh(val); Vector3[] vertices = val.vertices; foreach (Vector3 val3 in vertices) { num = Mathf.Max(num, ((Component)val2).transform.TransformPoint(val3).y); } } Object.Destroy((Object)(object)val); nameClearance = Mathf.Max(0.3f, num - nameHead.position.y + 0.2f); nameReady = true; } } public class GroundedAvatarUpdater : AvatarUpdater { private sealed class FootMesh { internal Transform[] Bones; internal Matrix4x4[] Bind; internal Matrix4x4[] Pose; internal Vector3[] Vertices; internal BoneWeight[] Weights; internal int[] Used; } private readonly List<FootMesh> feet = new List<FootMesh>(); private bool initialized; private bool reported; private CharacterController capsule; private float lastLift; private LegAlignment leftLeg; private LegAlignment rightLeg; private ForearmDeformation leftRoll; private ForearmDeformation rightRoll; private ThumbMotion leftThumb; private ThumbMotion rightThumb; private PlayerFingerPose[] fingerPoses; public override void AssignModelReplacement(GameObject source, GameObject model) { ((AvatarUpdater)this).AssignModelReplacement(source, model); if (Object.op_Implicit((Object)(object)model)) { fingerPoses = PlayerFingerPose.Create(base.replacementAnimator, (Func<string, Transform>)base.GetPlayerTransformFromBoneName); leftLeg = new LegAlignment(base.replacementAnimator, left: true, ((AvatarUpdater)this).GetPlayerTransformFromBoneName("thigh.L"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("shin.L"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("foot.L")); rightLeg = new LegAlignment(base.replacementAnimator, left: false, ((AvatarUpdater)this).GetPlayerTransformFromBoneName("thigh.R"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("shin.R"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("foot.R")); leftRoll = new ForearmDeformation(base.replacementAnimator, left: true); rightRoll = new ForearmDeformation(base.replacementAnimator, left: false); leftThumb = new ThumbMotion(((AvatarUpdater)this).GetPlayerTransformFromBoneName("finger1.L"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("finger1.L.001"), base.replacementAnimator, left: true); rightThumb = new ThumbMotion(((AvatarUpdater)this).GetPlayerTransformFromBoneName("finger1.R"), ((AvatarUpdater)this).GetPlayerTransformFromBoneName("finger1.R.001"), base.replacementAnimator, left: false); } } private static bool IsFoot(Transform bone) { if (!Object.op_Implicit((Object)(object)bone)) { return false; } string text = ((Object)bone).name.ToLowerInvariant(); switch (text) { default: return text == "right_toe"; case "left_foot": case "right_foot": case "left_toe": return true; } } private static float FootWeight(BoneWeight w, Transform[] b) { float num = 0f; if (((BoneWeight)(ref w)).weight0 > 0f && IsFoot(b[((BoneWeight)(ref w)).boneIndex0])) { num += ((BoneWeight)(ref w)).weight0; } if (((BoneWeight)(ref w)).weight1 > 0f && IsFoot(b[((BoneWeight)(ref w)).boneIndex1])) { num += ((BoneWeight)(ref w)).weight1; } if (((BoneWeight)(ref w)).weight2 > 0f && IsFoot(b[((BoneWeight)(ref w)).boneIndex2])) { num += ((BoneWeight)(ref w)).weight2; } if (((BoneWeight)(ref w)).weight3 > 0f && IsFoot(b[((BoneWeight)(ref w)).boneIndex3])) { num += ((BoneWeight)(ref w)).weight3; } return num; } private void InitializeFeet() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) initialized = true; capsule = base.player.GetComponent<CharacterController>(); SkinnedMeshRenderer[] componentsInChildren = base.replacement.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val in componentsInChildren) { Mesh sharedMesh = val.sharedMesh; if (!Object.op_Implicit((Object)(object)sharedMesh) || !sharedMesh.isReadable) { continue; } Transform[] bones = val.bones; BoneWeight[] boneWeights = sharedMesh.boneWeights; Vector3[] vertices = sharedMesh.vertices; if (boneWeights.Length != vertices.Length) { continue; } List<Vector3> list = new List<Vector3>(); List<BoneWeight> list2 = new List<BoneWeight>(); HashSet<int> hashSet = new HashSet<int>(); for (int j = 0; j < vertices.Length; j++) { BoneWeight val2 = boneWeights[j]; if (!(FootWeight(val2, bones) < 0.5f)) { list.Add(vertices[j]); list2.Add(val2); if (((BoneWeight)(ref val2)).weight0 > 0f) { hashSet.Add(((BoneWeight)(ref val2)).boneIndex0); } if (((BoneWeight)(ref val2)).weight1 > 0f) { hashSet.Add(((BoneWeight)(ref val2)).boneIndex1); } if (((BoneWeight)(ref val2)).weight2 > 0f) { hashSet.Add(((BoneWeight)(ref val2)).boneIndex2); } if (((BoneWeight)(ref val2)).weight3 > 0f) { hashSet.Add(((BoneWeight)(ref val2)).boneIndex3); } } } if (list.Count != 0) { int[] array = new int[hashSet.Count]; hashSet.CopyTo(array); feet.Add(new FootMesh { Bones = bones, Bind = sharedMesh.bindposes, Pose = (Matrix4x4[])(object)new Matrix4x4[bones.Length], Vertices = list.ToArray(), Weights = list2.ToArray(), Used = array }); } } } protected override void UpdateModel() { //IL_010f: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0336: 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_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_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) ((AvatarUpdater)this).UpdateModel(); if (!Object.op_Implicit((Object)(object)base.replacement)) { return; } leftRoll?.Update(); rightRoll?.Update(); leftThumb?.Update(); rightThumb?.Update(); if (fingerPoses != null) { PlayerFingerPose[] array = fingerPoses; for (int i = 0; i < array.Length; i++) { array[i].Update(); } } leftLeg?.Update(); rightLeg?.Update(); if (!initialized) { InitializeFeet(); } if (!Object.op_Implicit((Object)(object)capsule) || feet.Count == 0) { return; } float num = float.PositiveInfinity; foreach (FootMesh foot in feet) { int[] used = foot.Used; foreach (int num2 in used) { foot.Pose[num2] = foot.Bones[num2].localToWorldMatrix * foot.Bind[num2]; } for (int j = 0; j < foot.Vertices.Length; j++) { BoneWeight val = foot.Weights[j]; Vector3 val2 = foot.Vertices[j]; float num3 = 0f; if (((BoneWeight)(ref val)).weight0 > 0f) { num3 += ((Matrix4x4)(ref foot.Pose[((BoneWeight)(ref val)).boneIndex0])).MultiplyPoint3x4(val2).y * ((BoneWeight)(ref val)).weight0; } if (((BoneWeight)(ref val)).weight1 > 0f) { num3 += ((Matrix4x4)(ref foot.Pose[((BoneWeight)(ref val)).boneIndex1])).MultiplyPoint3x4(val2).y * ((BoneWeight)(ref val)).weight1; } if (((BoneWeight)(ref val)).weight2 > 0f) { num3 += ((Matrix4x4)(ref foot.Pose[((BoneWeight)(ref val)).boneIndex2])).MultiplyPoint3x4(val2).y * ((BoneWeight)(ref val)).weight2; } if (((BoneWeight)(ref val)).weight3 > 0f) { num3 += ((Matrix4x4)(ref foot.Pose[((BoneWeight)(ref val)).boneIndex3])).MultiplyPoint3x4(val2).y * ((BoneWeight)(ref val)).weight3; } num = Mathf.Min(num, num3); } } float num4 = GripGeometry.CapsuleBottom(capsule) + 0.002f; lastLift = Mathf.Clamp(num4 - num, 0f, 0.5f); if (!reported) { Debug.LogWarning((object)("Kaine sole placement: meshes=" + feet.Count + ", soleY=" + num + ", controllerBottom=" + num4 + ", lift=" + lastLift)); reported = true; } Transform transform = base.replacement.transform; transform.position += Vector3.up * lastLift; } } [HarmonyPatch(typeof(EnemyAI), "DisableAnimatorWhenNotVisible")] internal static class KaineMaskedAnimationVisibility { [HarmonyPrefix] private static bool Before(EnemyAI __instance) { KaineMaskedVisual component = ((Component)__instance).GetComponent<KaineMaskedVisual>(); if (!Object.op_Implicit((Object)(object)component) || !component.HasBoundModel) { return true; } component.KeepSourceAnimating(); return false; } } [HarmonyPatch] internal static class KaineMaskedRegistryGuard { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(MaskedReplacementBase).Assembly.GetType("ModelReplacement.Patches.MaskedPlayerEnemyPatch"), "ManageRegistryBodyReplacements", (Type[])null, (Type[])null); } [HarmonyPrefix] private static bool Before(ref EnemyAI __0) { if (Object.op_Implicit((Object)(object)__0)) { return !Object.op_Implicit((Object)(object)((Component)__0).GetComponent<KaineMaskedVisual>()); } return true; } } [HarmonyPatch(typeof(MaskedReplacementBase), "SetReplacement")] internal static class KaineMaskedPlayerSourcePatch { [HarmonyPostfix] private static void After(MaskedReplacementBase __instance, PlayerControllerB __0) { BodyReplacementBase val = default(BodyReplacementBase); if (!Object.op_Implicit((Object)(object)__0) || !ModelReplacementAPI.GetPlayerModelReplacement(__0, ref val) || !(val is KaineBody)) { return; } MaskedPlayerEnemy component = ((Component)__instance).GetComponent<MaskedPlayerEnemy>(); if (Object.op_Implicit((Object)(object)component)) { KaineMaskedVisual kaineMaskedVisual = ((Component)component).GetComponent<KaineMaskedVisual>(); if (!Object.op_Implicit((Object)(object)kaineMaskedVisual)) { kaineMaskedVisual = ((Component)component).gameObject.AddComponent<KaineMaskedVisual>(); } kaineMaskedVisual.Initialize(component); } } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "SetSuit")] internal static class KaineMaskedSuitPatch { [HarmonyPostfix] private static void After(MaskedPlayerEnemy __instance, int __0) { if (Object.op_Implicit((Object)(object)StartOfRound.Instance)) { List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; if (__0 >= 0 && __0 < unlockables.Count) { KaineMaskedTracker.Get(__instance).SetSuit(__0); } } } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "LateUpdate")] internal static class KaineMaskedLateAssignmentPatch { [HarmonyPostfix] private static void After(MaskedPlayerEnemy __instance) { KaineMaskedTracker.Get(__instance).Refresh(); } } public sealed class KaineMaskedTracker : MonoBehaviour { private MaskedPlayerEnemy enemy; private readonly MaskedSuitSelection selection = new MaskedSuitSelection(); private float nextCheck; internal static KaineMaskedTracker Get(MaskedPlayerEnemy enemy) { KaineMaskedTracker kaineMaskedTracker = ((Component)enemy).GetComponent<KaineMaskedTracker>(); if (!Object.op_Implicit((Object)(object)kaineMaskedTracker)) { kaineMaskedTracker = ((Component)enemy).gameObject.AddComponent<KaineMaskedTracker>(); kaineMaskedTracker.enemy = enemy; } return kaineMaskedTracker; } private void Snapshot(out int player, out int suit) { PlayerControllerB mimickingPlayer = enemy.mimickingPlayer; player = (Object.op_Implicit((Object)(object)mimickingPlayer) ? ((Object)mimickingPlayer).GetInstanceID() : 0); suit = (Object.op_Implicit((Object)(object)mimickingPlayer) ? mimickingPlayer.currentSuitID : (-1)); } internal void SetSuit(int suit) { Snapshot(out var player, out var suit2); selection.SetSuit(suit, player, suit2); nextCheck = 0f; Refresh(); } internal void Refresh() { if (!Object.op_Implicit((Object)(object)enemy) || Time.time < nextCheck) { return; } nextCheck = Time.time + 0.25f; Snapshot(out var player, out var suit); int num = selection.Resolve(player, suit); if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || num < 0) { return; } List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; if (num >= unlockables.Count) { return; } bool num2 = Regex.Replace(unlockables[num].unlockableName.ToLowerInvariant(), "[^a-z0-9]", "").Contains("kaine"); KaineMaskedVisual kaineMaskedVisual = ((Component)enemy).GetComponent<KaineMaskedVisual>(); if (num2) { if (!Object.op_Implicit((Object)(object)kaineMaskedVisual)) { kaineMaskedVisual = ((Component)enemy).gameObject.AddComponent<KaineMaskedVisual>(); Debug.LogWarning((object)("KAINE_MASKED_SELECTED: suit=" + num + " mimic=" + player)); } kaineMaskedVisual.Initialize(enemy); } else if (Object.op_Implicit((Object)(object)kaineMaskedVisual)) { ((Behaviour)kaineMaskedVisual).enabled = false; Object.Destroy((Object)(object)kaineMaskedVisual); } } } internal sealed class KaineMaskedUpdater : MaskedAvatarUpdater { private readonly MaskedPoseLinks links = new MaskedPoseLinks(); private LegAlignment leftLeg; private LegAlignment rightLeg; private FingerCurl[] fingers; private ThumbMotion leftThumb; private ThumbMotion rightThumb; private Transform sourceHips; private Transform targetHips; private ForearmDeformation leftRoll; private ForearmDeformation rightRoll; private MaskedPoseProbe renderProbe; private Transform probeTarget; private Quaternion probeOffset; private Transform probeSource; private Quaternion initialSource; private float checkAt; private bool checkedMotion; public override void AssignModelReplacement(GameObject source, GameObject model) { //IL_020a: 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_0237: 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_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) ((MaskedAvatarUpdater)this).AssignModelReplacement(source, model); leftRoll = new ForearmDeformation(base.replacementAnimator, left: true); rightRoll = new ForearmDeformation(base.replacementAnimator, left: false); Animator val = KaineMaskedVisual.FindSourceAnimator(source.GetComponent<MaskedPlayerEnemy>()); MaskedSkinning.DescribeSource("KAINE_MASKED", source, ((EnemyAI)source.GetComponent<MaskedPlayerEnemy>()).creatureAnimator, val); Dictionary<string, Transform> dictionary = MaskedPoseLinks.SourceBones(val, source.GetComponent<MaskedPlayerEnemy>().rendererLOD0.bones); fingers = FingerCurl.Create(base.replacementAnimator); if (dictionary.ContainsKey("finger1.l") && dictionary.ContainsKey("finger1.l.001")) { leftThumb = new ThumbMotion(dictionary["finger1.l"], dictionary["finger1.l.001"], base.replacementAnimator, left: true); } if (dictionary.ContainsKey("finger1.r") && dictionary.ContainsKey("finger1.r.001")) { rightThumb = new ThumbMotion(dictionary["finger1.r"], dictionary["finger1.r.001"], base.replacementAnimator, left: false); } if (dictionary.ContainsKey("thigh.l") && dictionary.ContainsKey("shin.l") && dictionary.ContainsKey("foot.l")) { leftLeg = new LegAlignment(base.replacementAnimator, left: true, dictionary["thigh.l"], dictionary["shin.l"], dictionary["foot.l"]); } if (dictionary.ContainsKey("thigh.r") && dictionary.ContainsKey("shin.r") && dictionary.ContainsKey("foot.r")) { rightLeg = new LegAlignment(base.replacementAnimator, left: false, dictionary["thigh.r"], dictionary["shin.r"], dictionary["foot.r"]); } foreach (string item in new List<string>(MaskedAvatarUpdater.modelToAvatarBone.Keys) { "spine.002", "spine.003" }) { Transform avatarTransformFromBoneName = ((MaskedAvatarUpdater)this).GetAvatarTransformFromBoneName(item); if (!Object.op_Implicit((Object)(object)avatarTransformFromBoneName)) { continue; } HumanBodyBones value; if (item == "spine.002") { value = (HumanBodyBones)8; } else if (item == "spine.003") { value = (HumanBodyBones)((val.isHuman && Object.op_Implicit((Object)(object)val.GetBoneTransform((HumanBodyBones)54))) ? 54 : 8); } else if (!MaskedAvatarUpdater.modelToAvatarBone.TryGetValue(item, out value)) { continue; } Transform value2 = (val.isHuman ? val.GetBoneTransform(value) : null); if (!Object.op_Implicit((Object)(object)value2)) { dictionary.TryGetValue(Normalize(item), out value2); } if (Object.op_Implicit((Object)(object)value2)) { RotationOffset component = ((Component)avatarTransformFromBoneName).GetComponent<RotationOffset>(); links.Add(value2, avatarTransformFromBoneName, Object.op_Implicit((Object)(object)component) ? component.offset : Quaternion.identity); if (item == "spine") { sourceHips = value2; targetHips = avatarTransformFromBoneName; } if (item == "arm.R_upper") { probeSource = value2; probeTarget = avatarTransformFromBoneName; probeOffset = (Object.op_Implicit((Object)(object)component) ? component.offset : Quaternion.identity); } } } links.Sort(); if (links.Count < 12 || !Object.op_Implicit((Object)(object)sourceHips)) { throw new Exception("Masked animated skeleton mapping incomplete: " + links.Count); } if (Object.op_Implicit((Object)(object)probeSource) && Object.op_Implicit((Object)(object)probeTarget)) { renderProbe = new MaskedPoseProbe("KAINE_MASKED", probeSource, probeTarget, probeOffset, model.GetComponentsInChildren<SkinnedMeshRenderer>(true)); } if (Object.op_Implicit((Object)(object)probeSource)) { initialSource = probeSource.localRotation; } checkAt = Time.time + 2f; Debug.LogWarning((object)("KAINE_MASKED_ANIMATION_BOUND: " + links.Count + " bones on " + ((Object)val).name + " enabled=" + ((Behaviour)val).enabled + " active=" + ((Component)val).gameObject.activeInHierarchy + " controller=" + (Object.op_Implicit((Object)(object)val.runtimeAnimatorController) ? ((Object)val.runtimeAnimatorController).name : "none"))); } private static int Depth(Transform node) { int num = 0; while (Object.op_Implicit((Object)(object)node)) { num++; node = node.parent; } return num; } private static string Normalize(string name) { return name.Replace('_', '.').ToLowerInvariant(); } protected override void UpdateModel() { //IL_00a6: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!checkedMotion && Time.time >= checkAt) { checkedMotion = true; Debug.LogWarning((object)("KAINE_MASKED_POSE_CHECK: bindings=" + links.Count + " sourceUpperArmLocalDelta=" + (Object.op_Implicit((Object)(object)probeSource) ? Quaternion.Angle(initialSource, probeSource.localRotation) : (-1f)))); } links.Apply(); if (Object.op_Implicit((Object)(object)sourceHips) && Object.op_Implicit((Object)(object)targetHips)) { targetHips.position = sourceHips.position + sourceHips.TransformVector(base.rootPositionOffset); } leftRoll?.Update(); rightRoll?.Update(); leftLeg?.Update(); rightLeg?.Update(); leftThumb?.Update(); rightThumb?.Update(); if (fingers != null) { FingerCurl[] array = fingers; for (int i = 0; i < array.Length; i++) { array[i].Update(); } } } internal void ApplyPose() { ((MaskedAvatarUpdater)this).UpdateModel(); } internal void ReportRender() { renderProbe?.Report(); } } [DefaultExecutionOrder(10000)] public sealed class KaineMaskedVisual : MonoBehaviour { private MaskedBadgeMaterials badges; private MaskedPlayerEnemy enemy; private GameObject model; private KaineMaskedUpdater updater; private Renderer[] originals; private bool[] previousForceOff; private MaskedReplacementBase prior; private GameObject priorModel; private bool priorEnabled; private bool priorModelActive; private bool failed; private SkinnedMeshRenderer[] skins; private Material[] converted; private Animator sourceAnimator; private Animator targetAnimator; private AnimatorCullingMode previousCulling; private int bindAfterFrame = -1; private readonly MaskedControllerRecovery recovery = new MaskedControllerRecovery("KAINE_MASKED"); private static readonly FieldInfo runningState = AccessTools.Field(typeof(MaskedPlayerEnemy), "running"); private static readonly FieldInfo crouchingState = AccessTools.Field(typeof(MaskedPlayerEnemy), "crouching"); private static readonly FieldInfo handsState = AccessTools.Field(typeof(MaskedPlayerEnemy), "handsOut"); private static readonly FieldInfo killingState = AccessTools.Field(typeof(MaskedPlayerEnemy), "inKillAnimation"); internal bool HasBoundModel { get { if (((Behaviour)this).isActiveAndEnabled && Object.op_Implicit((Object)(object)model)) { return updater != null; } return false; } } private void SyncRecoveredState(Animator animator) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)enemy)) { return; } AnimatorControllerParameter[] parameters = animator.parameters; foreach (AnimatorControllerParameter val in parameters) { if ((int)val.type == 4) { FieldInfo fieldInfo = null; switch (val.name) { case "HandsOut": fieldInfo = handsState; break; case "Running": fieldInfo = runningState; break; case "Crouching": fieldInfo = crouchingState; break; case "killing": fieldInfo = killingState; break; case "Dead": animator.SetBool(val.name, ((EnemyAI)enemy).isEnemyDead); continue; default: continue; } if (fieldInfo != null) { animator.SetBool(val.name, (bool)fieldInfo.GetValue(enemy)); } } } } internal void KeepSourceAnimating() { if (Object.op_Implicit((Object)(object)sourceAnimator)) { recovery.Ensure(((Component)enemy).gameObject, sourceAnimator); MaskedSkinning.KeepSourceAnimating(sourceAnimator); } } internal static Animator FindSourceAnimator(MaskedPlayerEnemy target) { return HoldPlacement.MaskedAnimator(((Component)target).gameObject, target.animationContainer, (Renderer)(object)target.rendererLOD0, ((EnemyAI)target).creatureAnimator); } internal void Initialize(MaskedPlayerEnemy target) { //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)model) || failed) { return; } if (!Object.op_Implicit((Object)(object)enemy)) { enemy = target; recovery.OnRecovered = SyncRecoveredState; bindAfterFrame = Time.frameCount + 2; recovery.Remember(FindSourceAnimator(target)); if (Object.op_Implicit((Object)(object)((EnemyAI)target).enemyType) && Object.op_Implicit((Object)(object)((EnemyAI)target).enemyType.enemyPrefab)) { recovery.Remember(((EnemyAI)target).enemyType.enemyPrefab.GetComponentInChildren<Animator>(true)); } } if (Time.frameCount < bindAfterFrame || !Object.op_Implicit((Object)(object)((EnemyAI)target).creatureAnimator)) { return; } Animator val = FindSourceAnimator(target); if (!Object.op_Implicit((Object)(object)val) || !recovery.Ensure(((Component)target).gameObject, val)) { return; } try { model = Object.Instantiate<GameObject>(Plugin.Prefab); ((Object)model).name = "Kaine (Masked)"; model.SetActive(true); skins = model.GetComponentsInChildren<SkinnedMeshRenderer>(true); if (skins.Length == 0) { throw new Exception("Kaine has no skinned meshes"); } Bounds bounds = ((Renderer)skins[0]).bounds; SkinnedMeshRenderer[] array = skins; foreach (SkinnedMeshRenderer val2 in array) { ((Bounds)(ref bounds)).Encapsulate(((Renderer)val2).bounds); } if (((Bounds)(ref bounds)).extents.y < 0.001f) { throw new Exception("Kaine bounds invalid"); } model.transform.localScale = Plugin.OriginalScale * (1.465f / ((Bounds)(ref bounds)).extents.y) * 0.8808894f; converted = SuitMaterials.Apply(model, ((Renderer)enemy.rendererLOD0).sharedMaterial); model.transform.position = ((Component)enemy).transform.position; model.transform.rotation = ((Component)enemy).transform.rotation; Animator componentInChildren = model.GetComponentInChildren<Animator>(); MaskedSkinning.Initialize(componentInChildren); OffsetBuilder component = ((Component)componentInChildren).GetComponent<OffsetBuilder>(); if (!Object.op_Implicit((Object)(object)component)) { throw new Exception("Kaine OffsetBuilder missing"); } component.rootScale = Vector3.one * 0.8808894f; if (!Object.op_Implicit((Object)(object)component.itemHolder)) { component.itemHolder = new GameObject("MaskedItemHolder"); component.itemHolder.transform.SetParent(componentInChildren.GetBoneTransform((HumanBodyBones)18), false); } originals = (Renderer[])(object)new Renderer[3] { (Renderer)enemy.rendererLOD0, (Renderer)enemy.rendererLOD1, (Renderer)enemy.rendererLOD2 }; previousForceOff = new bool[originals.Length]; for (int j = 0; j < originals.Length; j++) { if (Object.op_Implicit((Object)(object)originals[j])) { previousForceOff[j] = originals[j].forceRenderingOff; } } prior = ((Component)enemy).GetComponent<MaskedReplacementBase>(); if (Object.op_Implicit((Object)(object)prior)) { priorEnabled = ((Behaviour)prior).enabled; ((Behaviour)prior).enabled = false; ref GameObject reference = ref priorModel; object? obj = typeof(MaskedReplacementBase).GetField("replacementModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(prior); reference = (GameObject)((obj is GameObject) ? obj : null); if (Object.op_Implicit((Object)(object)priorModel)) { priorModelActive = priorModel.activeSelf; priorModel.SetActive(false); } } sourceAnimator = val; if (!Object.op_Implicit((Object)(object)sourceAnimator)) { throw new Exception("Masked source animator missing"); } previousCulling = sourceAnimator.cullingMode; sourceAnimator.cullingMode = (AnimatorCullingMode)0; updater = new KaineMaskedUpdater(); ((MaskedAvatarUpdater)updater).AssignModelReplacement(((Component)enemy).gameObject, model); targetAnimator = componentInChildren; MaskedSkinning.UseExternalPose(targetAnimator); Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { Transform val4 = ((Component)val3).transform; while (Object.op_Implicit((Object)(object)val4) && (Object)(object)val4 != (Object)(object)model.transform) { ((Component)val4).gameObject.SetActive(true); val4 = val4.parent; } ((Component)val3).gameObject.layer = 0; val3.enabled = true; val3.forceRenderingOff = false; SkinnedMeshRenderer val5 = (SkinnedMeshRenderer)(object)((val3 is SkinnedMeshRenderer) ? val3 : null); if (Object.op_Implicit((Object)(object)val5)) { MaskedSkinning.Prepare(val5); } } updater.ApplyPose(); try { badges = new MaskedBadgeMaterials(((Component)enemy).gameObject); } catch (Exception ex) { Debug.LogWarning((object)("KAINE_MASKED_BADGE_SKIPPED: " + ex.Message)); } Debug.LogWarning((object)("KAINE_MASKED_MODEL_READY: active-renderer model rooted at " + ((object)model.transform.position/*cast due to .constrained prefix*/).ToString() + "; skins=" + model.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length)); } catch (Exception ex2) { failed = true; Debug.LogException(ex2); Object.Destroy((Object)(object)this); } } private void LateUpdate() { //IL_006e: 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) if (Object.op_Implicit((Object)(object)enemy) && !Object.op_Implicit((Object)(object)model) && !failed) { Initialize(enemy); } else { if (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)model) || updater == null) { return; } KeepSourceAnimating(); model.transform.position = ((Component)enemy).transform.position; model.transform.rotation = ((Component)enemy).transform.rotation; updater.ApplyPose(); SkinnedMeshRenderer[] array = skins; for (int i = 0; i < array.Length; i++) { MaskedSkinning.Prepare(array[i]); } Renderer[] array2 = originals; foreach (Renderer val in array2) { if (Object.op_Implicit((Object)(object)val)) { val.forceRenderingOff = true; } } if (Object.op_Implicit((Object)(object)priorModel)) { priorModel.SetActive(false); } badges?.Hide(); } } private void OnEnable() { RenderPipelineManager.beginCameraRendering += BeforeRendering; RenderPipelineManager.endCameraRendering += AfterRendering; } private void BeforeRendering(ScriptableRenderContext context, Camera camera) { if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)model) && updater != null) { if (Object.op_Implicit((Object)(object)targetAnimator)) { MaskedSkinning.UseExternalPose(targetAnimator); } updater.ApplyPose(); badges?.Hide(); } } private void AfterRendering(ScriptableRenderContext context, Camera camera) { updater?.ReportRender(); } private void OnDestroy() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) badges?.Dispose(); RenderPipelineManager.beginCameraRendering -= BeforeRendering; RenderPipelineManager.endCameraRendering -= AfterRendering; if (Object.op_Implicit((Object)(object)sourceAnimator)) { sourceAnimator.cullingMode = previousCulling; } if (converted != null) { Material[] array = converted; foreach (Material val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } if (Object.op_Implicit((Object)(object)model)) { Object.Destroy((Object)(object)model); } if (originals != null) { for (int j = 0; j < originals.Length; j++) { if (Object.op_Implicit((Object)(object)originals[j])) { originals[j].forceRenderingOff = previousForceOff[j]; } } } if (Object.op_Implicit((Object)(object)prior)) { ((Behaviour)prior).enabled = priorEnabled; if (Object.op_Implicit((Object)(object)priorModel)) { priorModel.SetActive(priorModelActive); } } } } internal static class SuitMaterials { internal static Material[] Apply(GameObject model, Material native) { //IL_015c: 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_0175: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)model) || !Object.op_Implicit((Object)(object)native)) { throw new Exception("Kaine material setup needs a model and native game material"); } Dictionary<string, Material> dictionary = new Dictionary<string, Material>(); Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (!Object.op_Implicit((Object)(object)val2)) { continue; } string name = ((Object)val2).name; Texture val3 = (val2.HasProperty("_BaseColorMap") ? val2.GetTexture("_BaseColorMap") : val2.mainTexture); if (!Object.op_Implicit((Object)(object)val3)) { val3 = val2.mainTexture; } if (!Object.op_Implicit((Object)(object)val3)) { throw new Exception("Missing Kaine texture on " + name); } string name2 = ((Object)val3).name; string obj = (name2.Contains("Hair") ? "Hair" : (name2.Contains("Face") ? "Face" : "Body")); bool flag = ((Object)val).name.Contains("eye") && !((Object)val).name.Contains("eyelash"); bool flag2 = obj != "Face"; string text = obj + (flag2 ? "_Cutout" : "_Opaque") + (flag ? "_Eye" : ""); if (!dictionary.TryGetValue(text, out var value)) { value = new Material(native) { name = "Kaine_Game_" + text }; string[] array = new string[4] { "_NormalMap", "_MaskMap", "_EmissiveColorMap", "_DetailMap" }; foreach (string text2 in array) { if (value.HasProperty(text2)) { value.SetTexture(text2, (Texture)null); } } array = new string[5] { "_NORMALMAP_TANGENT_SPACE", "_MASKMAP", "_EMISSIVE_COLOR_MAP", "_DETAIL_MAP", "_SURFACE_TYPE_TRANSPARENT" }; foreach (string text3 in array) { value.DisableKeyword(text3); } value.SetTexture("_BaseColorMap", val3); value.SetColor("_BaseColor", Color.white); value.SetTextureScale("_BaseColorMap", Vector2.one); value.SetTextureOffset("_BaseColorMap", Vector2.zero); Set(value, "_UVBase", 0f); value.SetVector("_UVMappingMask", new Vector4(1f, 0f, 0f, 0f)); value.DisableKeyword("_MAPPING_PLANAR"); value.DisableKeyword("_MAPPING_TRIPLANAR"); Set(value, "_Metallic", 0f); Set(value, "_Smoothness", flag ? 0.35f : 0.25f); Set(value, "_NormalScale", 0f); Set(value, "_AORemapMin", 1f); Set(value, "_AORemapMax", 1f); Set(value, "_SurfaceType", 0f); Set(value, "_AlphaRemapMin", 0f); Set(value, "_AlphaRemapMax", 1f); Set(value, "_AlphaCutoffEnable", flag2 ? 1 : 0); Set(value, "_AlphaCutoff", 0.4f); Set(value, "_AlphaCutoffShadow", 0.4f); Set(value, "_AlphaCutoffPrepass", 0.4f); Set(value, "_AlphaCutoffPostpass", 0.4f); Set(value, "_DoubleSidedEnable", 1f); Set(value, "_DoubleSidedNormalMode", 1f); Set(value, "_CullMode", 0f); Set(value, "_CullModeForward", 0f); Set(value, "_OpaqueCullMode", 0f); if (value.HasProperty("_EmissiveColor")) { value.SetColor("_EmissiveColor", (Color)(flag ? new Color(0.015f, 0.015f, 0.015f) : Color.black)); } if (flag) { value.SetTexture("_EmissiveColorMap", val3); } HDMaterial.ValidateMaterial(value); value.renderQueue = (flag2 ? 2450 : 2000); value.SetOverrideTag("RenderType", flag2 ? "TransparentCutout" : "Opaque"); if (flag2) { value.EnableKeyword("_ALPHATEST_ON"); } else { value.DisableKeyword("_ALPHATEST_ON"); } value.EnableKeyword("_DOUBLESIDED_ON"); dictionary.Add(text, value); } sharedMaterials[j] = value; } val.sharedMaterials = sharedMaterials; val.renderingLayerMask = 513u; SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); if (Object.op_Implicit((Object)(object)val4)) { val4.updateWhenOffscreen = true; } } Material[] array2 = (Material[])(object)new Material[dictionary.Count]; dictionary.Values.CopyTo(array2, 0); return array2; } private static void Set(Material m, string name, float value) { if (m.HasProperty(name)) { m.SetFloat(name, value); } } } public sealed class PortViewModelUpdater : ViewModelUpdater { private Transform leftElbow; private Transform rightElbow; private Transform leftWrist; private Transform rightWrist; private Transform customLeftElbow; private Transform customRightElbow; private Transform leftIndex; private Transform leftLittle; private Transform rightIndex; private Transform rightLittle; private Transform customLeftIndex; private Transform customLeftLittle; private Transform customRightIndex; private Transform customRightLittle; private ForearmDeformation leftRoll; private ForearmDeformation rightRoll; private ThumbMotion leftThumb; private ThumbMotion rightThumb; private PlayerFingerPose[] fingerPoses; private ArmReach leftReach; private ArmReach rightReach; public override void AssignViewModelReplacement(GameObject player, GameObject model) { ((ViewModelUpdater)this).AssignViewModelReplacement(player, model); if (Object.op_Implicit((Object)(object)model)) { fingerPoses = PlayerFingerPose.Create(model.GetComponentInChildren<Animator>(), (Func<string, Transform>)base.GetArmTransformFromBoneName); leftElbow = ((ViewModelUpdater)this).GetArmTransformFromBoneName("arm.L_lower"); rightElbow = ((ViewModelUpdater)this).GetArmTransformFromBoneName("arm.R_lower"); leftWrist = ((ViewModelUpdater)this).HandTransformLeft; rightWrist = ((ViewModelUpdater)this).HandTransformRight; customLeftElbow = ((ViewModelUpdater)this).GetViewModelTransformFromBoneName("arm.L_lower"); customRightElbow = ((ViewModelUpdater)this).GetViewModelTransformFromBoneName("arm.R_lower"); leftReach = new ArmReach(((ViewModelUpdater)this).GetViewModelTransformFromBoneName("arm.L_upper"), customLeftElbow, ((ViewModelUpdater)this).CustomHandTransformLeft, leftElbow, leftWrist); rightReach = new ArmReach(((ViewModelUpdater)this).GetViewModelTransformFromBoneName("arm.R_upper"), customRightElbow, ((ViewModelUpdater)this).CustomHandTransformRight, rightElbow, rightWrist); leftIndex = ((ViewModelUpdater)this).GetArmTransformFromBoneName("finger2.L"); leftLittle = ((ViewModelUpdater)this).GetArmTransformFromBoneName("finger5.L"); rightIndex = ((ViewModelUpdater)this).GetArmTransformFromBoneName("finger2.R"); rightLittle = ((ViewModelUpdater)this).GetArmTransformFromBoneName("finger5.R"); customLeftIndex = ((ViewModelUpdater)this).GetViewModelTransformFromBoneName("finger2.L"); customLeftLittle = ((ViewModelUpdater)this).GetViewModelTransformFromBoneName("finger5.L"); customRightIndex = ((ViewModelUpdater)this).GetViewModelTransformFromBoneName("finger2.R"); customRightLittle = ((ViewModelUpdater)this).GetViewModelTransformFromBoneName("finger5.R"); leftRoll = new ForearmDeformation(model.GetComponentInChildren<Animator>(), left: true); rightRoll = new ForearmDeformation(model.GetComponentInChildren<Animator>(), left: false); leftThumb = new ThumbMotion(((ViewModelUpdater)this).GetArmTransformFromBoneName("finger1.L"), ((ViewModelUpdater)this).GetArmTransformFromBoneName("finger1.L.001"), model.GetComponentInChildren<Animator>(), left: true); rightThumb = new ThumbMotion(((ViewModelUpdater)this).GetArmTransformFromBoneName("finger1.R"), ((ViewModelUpdater)this).GetArmTransformFromBoneName("finger1.R.001"), model.GetComponentInChildren<Animator>(), left: false); } } protected override void UpdateViewModel() { ((ViewModelUpdater)this).UpdateViewModel(); leftReach?.Update(); rightReach?.Update(); leftRoll?.Update(); rightRoll?.Update(); leftThumb?.Update(); rightThumb?.Update(); if (fingerPoses != null) { PlayerFingerPose[] array = fingerPoses; for (int i = 0; i < array.Length; i++) { array[i].Update(); } } } internal Vector3 GripOffset(bool twoHanded) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //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_0077: 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) Vector3 val = GripGeometry.Palm(((ViewModelUpdater)this).CustomHandTransformRight, customRightIndex, customRightLittle) - GripGeometry.Palm(rightWrist, rightIndex, rightLittle); if (!twoHanded) { return val; } return (val + GripGeometry.Palm(((ViewModelUpdater)this).CustomHandTransformLeft, customLeftIndex, customLeftLittle) - GripGeometry.Palm(leftWrist, leftIndex, leftLittle)) * 0.5f; } } [HarmonyPatch(typeof(BodyReplacementBase), "UpdateItemTransform")] internal static class PortItemGripPatch { [HarmonyPrefix] private static bool Before(BodyReplacementBase __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) KaineBody kaineBody = __instance as KaineBody; if (!Object.op_Implicit((Object)(object)kaineBody)) { return true; } if (!(((BodyReplacementBase)kaineBody).viewModelAvatar is PortViewModelUpdater portViewModelUpdater) || !Object.op_Implicit((Object)(object)((BodyReplacementBase)kaineBody).replacementViewModel) || (int)((BodyReplacementBase)kaineBody).viewState.GetViewState() != 2) { return true; } GrabbableObject heldItem = ((BodyReplacementBase)kaineBody).heldItem; if (!Object.op_Implicit((Object)(object)heldItem) || !Object.op_Implicit((Object)(object)heldItem.parentObject) || (Object)(object)heldItem.playerHeldBy != (Object)(object)((BodyReplacementBase)kaineBody).controller || heldItem.isPocketed || !Object.op_Implicit((Object)(object)heldItem.itemProperties) || heldItem is JetpackItem) { return true; } kaineBody.ApplyGrip(heldItem, portViewModelUpdater.GripOffset(heldItem.itemProperties.twoHandedAnimation)); return false; } } internal static class GripGeometry { internal static float CapsuleBottom(CharacterController capsule) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) return ((Component)capsule).transform.TransformPoint(capsule.center).y - Mathf.Max(capsule.height * 0.5f, capsule.radius) * Mathf.Abs(((Component)capsule).transform.lossyScale.y); } internal static Vector3 Palm(Transform wrist, Transform index, Transform little) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) if (!Object.op_Implicit((Object)(object)index) || !Object.op_Implicit((Object)(object)little)) { return wrist.position; } return Vector3.Lerp(wrist.position, (index.position + little.position) * 0.5f, 0.5f); } } internal sealed class ThumbMotion { private readonly Transform sourceRoot; private readonly Transform sourceTip; private readonly Transform root; private readonly Transform middle; private readonly Transform tip; private readonly Quaternion sourceRest; private readonly Quaternion sourceToTarget; private readonly Quaternion middleRest; private readonly Quaternion tipRest; private readonly Vector3 bendAxis; internal static Quaternion SourceRootReference(bool left) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Quaternion val = (left ? new Quaternion(-0.21466082f, 0.6048781f, 0.749175f, 0.16364832f) : new Quaternion(0.21466017f, 0.60487825f, 0.7491752f, -0.16364768f)); Quaternion val2 = (left ? new Quaternion(0.104095966f, (float)Math.E * 77f / 310f, 0.25973865f, 0.68251306f) : new Quaternion(-0.05024603f, 0.6675385f, 0.25531194f, -0.6976277f)); return val * Quaternion.Inverse(val2); } internal static Quaternion SourceTipReference(bool left) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!left) { return new Quaternion(0.3253256f, 0.6001833f, 0.7231062f, -0.10517466f); } return new Quaternion(-0.32532394f, 0.6001865f, 0.7231043f, 0.10517379f); } internal ThumbMotion(Transform root, Transform end, Animator model, bool left) { //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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) sourceRoot = root; sourceTip = end; this.root = model.GetBoneTransform((HumanBodyBones)(left ? 24 : 39)); middle = model.GetBoneTransform((HumanBodyBones)(left ? 25 : 40)); tip = model.GetBoneTransform((HumanBodyBones)(left ? 26 : 41)); if (Object.op_Implicit((Object)(object)this.root) && Object.op_Implicit((Object)(object)middle) && Object.op_Implicit((Object)(object)tip)) { middleRest = middle.localRotation; tipRest = tip.localRotation; Quaternion val = SourceRootReference(left); sourceRest = Quaternion.Inverse(val) * SourceTipReference(left); sourceToTarget = Quaternion.Inverse(this.root.rotation) * val; Vector3 val2 = Vector3.Cross(middle.position - this.root.position, tip.position - middle.position); bendAxis = this.root.InverseTransformDirection(((Vector3)(ref val2)).normalized); Transform boneTransform = model.GetBoneTransform((HumanBodyBones)(left ? 27 : 42)); if (Object.op_Implicit((Object)(object)boneTransform) && Vector3.Dot(Vector3.Cross(this.root.TransformDirection(bendAxis), tip.position - this.root.position), boneTransform.position - tip.position) < 0f) { bendAxis = -bendAxis; } } } internal void Update() { //IL_0048: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_008f: 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_0092: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_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_00dc: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0113: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)sourceRoot) && Object.op_Implicit((Object)(object)sourceTip) && Object.op_Implicit((Object)(object)root) && Object.op_Implicit((Object)(object)middle) && Object.op_Implicit((Object)(object)tip)) { Quaternion val = Quaternion.Inverse(sourceRoot.rotation) * sourceTip.rotation * Quaternion.Inverse(sourceRest); val = sourceToTarget * val * Quaternion.Inverse(sourceToTarget); float num = Flex(val, bendAxis); middle.localRotation = middleRest; tip.localRotation = tipRest; Quaternion rotation = tip.rotation; Vector3 val2 = root.TransformDirection(bendAxis); middle.rotation = Quaternion.AngleAxis(num * 0.65f, val2) * middle.rotation; tip.rotation = Quaternion.AngleAxis(num, val2) * rotation; } } internal static float Flex(Quaternion delta, Vector3 axis) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref axis)).Normalize(); float num = Vector3.Dot(new Vector3(delta.x, delta.y, delta.z), axis); return Mathf.Clamp(Mathf.DeltaAngle(0f, 2f * Mathf.Atan2(num, delta.w) * 57.29578f), -10f, 80f); } } internal sealed class ArmReach { private readonly Transform upper; private readonly Transform elbow; private readonly Transform wrist; private readonly Transform sourceElbow; private readonly Transform sourceWrist; private readonly Vector3 elbowRest; private readonly Vector3 wristRest; internal ArmReach(Transform upper, Transform elbow, Transform wrist, Transform sourceElbow, Transform sourceWrist) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) this.upper = upper; this.elbow = elbow; this.wrist = wrist; this.sourceElbow = sourceElbow; this.sourceWrist = sourceWrist; if (Object.op_Implicit((Object)(object)elbow)) { elbowRest = elbow.localPosition; } if (Object.op_Implicit((Object)(object)wrist)) { wristRest = wrist.localPosition; } } internal void Update() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)upper) && Object.op_Implicit((Object)(object)elbow) && Object.op_Implicit((Object)(object)wrist) && Object.op_Implicit((Object)(object)sourceElbow) && Object.op_Implicit((Object)(object)sourceWrist)) { Quaternion rotation = wrist.rotation; elbow.localPosition = elbowRest; wrist.localPosition = wristRest; Solve(upper, elbow, wrist, sourceWrist.position, sourceElbow.position); wrist.rotation = rotation; } } internal static void Solve(Transform upper, Transform elbow, Transform wrist, Vector3 target, Vector3 hint) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_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_0129: 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_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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00da: 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_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) Vector3 position = upper.position; float num = Vector3.Distance(position, elbow.position); float num2 = Vector3.Distance(elbow.position, wrist.position); if (num < 0.0001f || num2 < 0.0001f) { return; } Vector3 val = target - position; if (!(((Vector3)(ref val)).sqrMagnitude < 1E-07f)) { Vector3 normalized = ((Vector3)(ref val)).normalized; float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, Mathf.Abs(num - num2) + 0.0001f, num + num2 - 0.0001f); Vector3 val2 = Vector3.ProjectOnPlane(hint - position, normalized); if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { val2 = Vector3.ProjectOnPlane(elbow.position - position, normalized); } if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f) { val2 = Vector3.Cross(normalized, (Mathf.Abs(normalized.y) < 0.9f) ? Vector3.up : Vector3.right); } float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3); float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4)); Vector3 val3 = position + normalized * num4 + ((Vector3)(ref val2)).normalized * num5; upper.rotation = Quaternion.FromToRotation(elbow.position - position, val3 - position) * upper.rotation; elbow.rotation = Quaternion.FromToRotation(wrist.position - elbow.position, position + normalized * num3 - elbow.position) * elbow.rotation; } } } internal sealed class ForearmDeformation { private readonly Transform elbow; private readonly Transform hand; private readonly Transform middle; private readonly Transform end; private readonly Quaternion handRest; private readonly Quaternion middleRest; private readonly Quaternion endRest; internal ForearmDeformation(Animator model, bool left) { //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_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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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) elbow = model.GetBoneTransform((HumanBodyBones)(left ? 15 : 16)); hand = model.GetBoneTransform((HumanBodyBones)(left ? 17 : 18)); if (!Object.op_Implicit((Object)(object)elbow) || !Object.op_Implicit((Object)(object)hand)) { return; } Transform[] componentsInChildren = ((Component)elbow).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val.parent != (Object)(object)elbow)) { if (((Object)val).name == (left ? "sub_20" : "sub_10")) { middle = val; } if (((Object)val).name == (left ? "sub_21" : "sub_11")) { end = val; } } } handRest = Quaternion.Inverse(elbow.rotation) * hand.rotation; if (Object.op_Implicit((Object)(object)middle)) { middleRest = middle.localRotation; } if (Object.op_Implicit((Object)(object)end)) { endRest = end.localRotation; } } internal void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00c7: 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_00d9: 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) if (Object.op_Implicit((Object)(object)elbow) && Object.op_Implicit((Object)(object)hand)) { Vector3 val = hand.position - elbow.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Quaternion val2 = Twist(hand.rotation * Quaternion.Inverse(elbow.rotation * handRest), normalized); if (Object.op_Implicit((Object)(object)middle)) { middle.rotation = Quaternion.Slerp(Quaternion.identity, val2, 0.5f) * elbow.rotation * middleRest; } if (Object.op_Implicit((Object)(object)end)) { end.rotation = val2 * elbow.rotation * endRest; } } } internal static Quaternion Twist(Quaternion delta, Vector3 axis) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_0027: 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_0033: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006d: 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_0091: 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_00a1: 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_00b6: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00da: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref axis)).Normalize(); Vector3 val = Vector3.Project(new Vector3(delta.x, delta.y, delta.z), axis); Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(val.x, val.y, val.z, delta.w); float num = Mathf.Sqrt(val2.x * val2.x + val2.y * val2.y + val2.z * val2.z + val2.w * val2.w); if (num < 1E-05f) { return Quaternion.identity; } ((Quaternion)(ref val2))..ctor(val2.x / num, val2.y / num, val2.z / num, val2.w / num); if (val2.w < 0f) { ((Quaternion)(ref val2))..ctor(0f - val2.x, 0f - val2.y, 0f - val2.z, 0f - val2.w); } return val2; } } internal static class HoldPlacement { internal static Vector3 Position(Transform holder, Vector3 itemOffset, Vector3 palmOffset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return holder.position + holder.rotation * itemOffset + palmOffset; } internal static Animator MaskedAnimator(GameObject root, Transform con