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 Vinjeora LeftyVikings v0.1.0
BepInEx/plugins/Vinjeøra/Vinjeøra.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Vinjeøra")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+86f216b437477d5c7af89d42a8ea6ce2b8daf0d9")] [assembly: AssemblyProduct("Vinjeøra")] [assembly: AssemblyTitle("Vinjeøra")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Vinjeøra { public class ModMenu : MonoBehaviour { private enum RebindTarget { None, ToggleKey, MenuKey } private static readonly KeyCode[] AllKeys = (KeyCode[])Enum.GetValues(typeof(KeyCode)); private bool _open; private RebindTarget _rebind; private GUIStyle _boxStyle; private GUIStyle _titleStyle; private GUIStyle _buttonStyle; private void Update() { //IL_0021: 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) Plugin instance = Plugin.Instance; if (!((Object)(object)instance == (Object)null)) { if (_rebind != RebindTarget.None) { HandleRebind(instance); } else if ((int)instance.MenuKey != 0 && (Object)(object)Player.m_localPlayer != (Object)null && Input.GetKeyDown(instance.MenuKey)) { _open = !_open; } } } private void HandleRebind(Plugin plugin) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!Input.anyKeyDown) { return; } if (Input.GetKeyDown((KeyCode)27)) { SetKey(plugin, _rebind, (KeyCode)0); _rebind = RebindTarget.None; return; } KeyCode[] allKeys = AllKeys; foreach (KeyCode val in allKeys) { if ((int)val != 27 && Input.GetKeyDown(val)) { SetKey(plugin, _rebind, val); _rebind = RebindTarget.None; break; } } } private static void SetKey(Plugin plugin, RebindTarget target, KeyCode value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) switch (target) { case RebindTarget.ToggleKey: plugin.ToggleKey = value; break; case RebindTarget.MenuKey: plugin.MenuKey = value; break; } } private static bool IsLocalLeft() { Player localPlayer = Player.m_localPlayer; ZDO val = (((Object)(object)localPlayer != (Object)null && (Object)(object)((Character)localPlayer).m_nview != (Object)null) ? ((Character)localPlayer).m_nview.GetZDO() : null); if (val != null) { return val.GetBool("vinjeora_handed", false); } return false; } private static void SetLocalLeft(bool left) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)((Character)localPlayer).m_nview == (Object)null)) { ((Character)localPlayer).m_nview.GetZDO().Set("vinjeora_handed", left); Plugin.Instance.SetHandedness(left ? Handedness.Left : Handedness.Right); } } private unsafe static string KeyName(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); } return "None"; } private void OnGUI() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00f2: 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) if (_open && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Plugin.Instance == (Object)null)) { EnsureStyles(); float num = 300f; float num2 = 230f; Rect val = new Rect(((float)Screen.width - num) * 0.5f, (float)Screen.height * 0.25f, num, num2); Color color = GUI.color; GUI.color = new Color(0.07f, 0.08f, 0.1f, 0.94f); GUI.BeginGroup(val, _boxStyle); GUI.color = color; GUILayout.Label("Vinjeøra", _titleStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); bool flag = IsLocalLeft(); if (GUILayout.Button("Handedness: " + (flag ? "Left" : "Right"), _buttonStyle, Array.Empty<GUILayoutOption>())) { SetLocalLeft(!flag); } string text = ((_rebind == RebindTarget.ToggleKey) ? "Press a key... (Esc clears)" : KeyName(Plugin.Instance.ToggleKey)); if (GUILayout.Button("Handedness hotkey: " + text, _buttonStyle, Array.Empty<GUILayoutOption>())) { _rebind = RebindTarget.ToggleKey; } string text2 = ((_rebind == RebindTarget.MenuKey) ? "Press a key... (Esc clears)" : KeyName(Plugin.Instance.MenuKey)); if (GUILayout.Button("Menu key: " + text2, _buttonStyle, Array.Empty<GUILayoutOption>())) { _rebind = RebindTarget.MenuKey; } GUILayout.Space(8f); if (GUILayout.Button("Close", _buttonStyle, Array.Empty<GUILayoutOption>())) { _open = false; _rebind = RebindTarget.None; } GUI.EndGroup(); } } private void EnsureStyles() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if (_boxStyle == null) { _boxStyle = new GUIStyle(); _boxStyle.normal.background = Texture2D.whiteTexture; _titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 14, fixedHeight = 32f }; } } } [HarmonyPatch(typeof(Player), "Start")] internal static class Patch_Player_Start { [HarmonyPostfix] private static void Postfix(Player __instance) { if ((Object)(object)((Component)__instance).GetComponent<VinjeøraPlayer>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<VinjeøraPlayer>(); } } } [HarmonyPatch(typeof(Attack), "Start")] internal static class Patch_Attack_Start { [HarmonyPostfix] private static void Postfix(Attack __instance, Humanoid character) { Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { ZDO val2 = (((Object)(object)((Character)val).m_nview != (Object)null) ? ((Character)val).m_nview.GetZDO() : null); if (val2 != null && val2.GetBool("vinjeora_handed", false)) { __instance.m_attackOffset = 0f - __instance.m_attackOffset; } } } } public enum Handedness { Right, Left } [BepInPlugin("com.andre.vinjeora", "Vinjeøra", "0.1.0")] [BepInProcess("valheim.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.andre.vinjeora"; public const string PluginName = "Vinjeøra"; public const string PluginVersion = "0.1.0"; private Harmony _harmony; private ConfigEntry<Handedness> _handedness; private ConfigEntry<KeyCode> _toggleKey; private ConfigEntry<bool> _debug; private ConfigEntry<KeyCode> _menuKey; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public Handedness Handedness => _handedness.Value; public KeyCode ToggleKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _toggleKey.Value; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _toggleKey.Value = value; } } public bool Debug => _debug.Value; public KeyCode MenuKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _menuKey.Value; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _menuKey.Value = value; } } public void SetHandedness(Handedness value) { _handedness.Value = value; } public static void LogDebug(string message) { if ((Object)(object)Instance != (Object)null && Instance.Debug) { Log.LogInfo((object)message); } } private void Awake() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown Instance = this; Log = Logger.CreateLogSource("Vinjeøra"); Log.LogInfo((object)"Vinjeøra 0.1.0 loaded"); _handedness = ((BaseUnityPlugin)this).Config.Bind<Handedness>("Combat", "Handedness", Handedness.Right, "Primary hand used for weapons and attacks."); _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Combat", "ToggleKey", (KeyCode)0, "Hotkey to toggle handedness in game. No key is bound by default; one can also be picked from the in-game menu (see MenuKey). Set to NONE to disable."); _debug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug", false, "Enable verbose debug logging."); _menuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "MenuKey", (KeyCode)277, "Key to open/close the Vinjeøra in-game menu. Set to NONE to disable the menu key."); _harmony = new Harmony("com.andre.vinjeora"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ((Component)this).gameObject.AddComponent<ModMenu>(); } } public class VinjeøraPlayer : MonoBehaviour { private class BonePair { public Transform Left; public Transform Right; public Quaternion KLeft; public Quaternion KRight; public Quaternion KLeftInv; public Quaternion KRightInv; } private class SoloBone { public Transform Bone; public Quaternion K; public Quaternion KInv; } public const string ZdoKey = "vinjeora_handed"; private static readonly HumanBodyBones[] PairLeft; private static readonly HumanBodyBones[] PairRight; private static readonly HumanBodyBones[] SoloBones; private Player _player; private Animator _animator; private VisEquipment _visEquipment; private bool _isLocal; private bool _leftActive; private readonly List<BonePair> _pairs = new List<BonePair>(); private readonly List<SoloBone> _solos = new List<SoloBone>(); private float[] _layerTimes; private int[] _layerHashes; private float _lastLogTime; private float _lastApplyTime = -10f; private Quaternion _rawLeftHandRot; private Quaternion _rawRightHandRot; private float _lastDiagTime = -10f; private GameObject _leftInstance; private GameObject _rightInstance; private Vector3 _leftLocalPos; private Quaternion _leftLocalRot; private Vector3 _rightLocalPos; private Quaternion _rightLocalRot; private Vector3 _leftExt; private Vector3 _rightExt; private void Start() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //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_010a: 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_0117: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0163: 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_0195: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) _player = ((Component)this).GetComponent<Player>(); _animator = ((Character)_player).m_animator; _visEquipment = ((Component)_player).GetComponentInChildren<VisEquipment>(); _isLocal = (Object)(object)_player == (Object)(object)Player.m_localPlayer; Animator[] componentsInChildren = ((Component)_player).GetComponentsInChildren<Animator>(); foreach (Animator val in componentsInChildren) { if ((int)val.updateMode != 1) { val.updateMode = (AnimatorUpdateMode)1; } } if ((Object)(object)_animator != (Object)null && (Object)(object)_animator.avatar != (Object)null && _animator.avatar.isHuman) { Quaternion val2 = Quaternion.Inverse(((Component)_player).transform.rotation); for (int j = 0; j < PairLeft.Length; j++) { Transform boneTransform = _animator.GetBoneTransform(PairLeft[j]); Transform boneTransform2 = _animator.GetBoneTransform(PairRight[j]); if (!((Object)(object)boneTransform == (Object)null) && !((Object)(object)boneTransform2 == (Object)null)) { Quaternion val3 = val2 * boneTransform.rotation; Quaternion val4 = val2 * boneTransform2.rotation; _pairs.Add(new BonePair { Left = boneTransform, Right = boneTransform2, KLeft = val3, KRight = val4, KLeftInv = Quaternion.Inverse(val3), KRightInv = Quaternion.Inverse(val4) }); } } HumanBodyBones[] soloBones = SoloBones; foreach (HumanBodyBones val5 in soloBones) { Transform boneTransform3 = _animator.GetBoneTransform(val5); if (!((Object)(object)boneTransform3 == (Object)null)) { Quaternion val6 = val2 * boneTransform3.rotation; _solos.Add(new SoloBone { Bone = boneTransform3, K = val6, KInv = Quaternion.Inverse(val6) }); } } } Log(string.Format("init pairs={0} solos={1} animator={2}", _pairs.Count, _solos.Count, ((Object)(object)_animator != (Object)null) ? ((Object)((Component)_animator).gameObject).name : "none")); } private void Update() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_player == (Object)null || ((Character)_player).IsDead()) { return; } bool flag = IsLeftHanded(); if (flag != _leftActive) { _leftActive = flag; if (!flag) { RestoreSockets(); } Plugin.LogDebug((_isLocal ? "[mirror:local]" : "[mirror:remote]") + " STATE -> " + (flag ? "LEFT" : "RIGHT")); } if (_isLocal && (Object)(object)Plugin.Instance != (Object)null && (int)Plugin.Instance.ToggleKey != 0 && Input.GetKeyDown(Plugin.Instance.ToggleKey)) { Toggle(); } if (_leftActive) { ApplyBoneMirror(isUpdatePass: true); UpdateSockets(); } } private void LateUpdate() { if (_leftActive && (Object)(object)_player != (Object)null && !((Character)_player).IsDead()) { ApplyBoneMirror(isUpdatePass: false); } } private bool IsLeftHanded() { ZDO val = (((Object)(object)((Character)_player).m_nview != (Object)null) ? ((Character)_player).m_nview.GetZDO() : null); if (val != null) { return val.GetBool("vinjeora_handed", false); } return false; } private void Toggle() { if (!((Object)(object)Plugin.Instance == (Object)null)) { Handedness handedness = ((Plugin.Instance.Handedness != Handedness.Left) ? Handedness.Left : Handedness.Right); Plugin.Instance.SetHandedness(handedness); ((Character)_player).m_nview.GetZDO().Set("vinjeora_handed", handedness == Handedness.Left); _layerTimes = null; Plugin.LogDebug($"Handedness set to {handedness}"); } } private static Quaternion Flip(Quaternion q) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(q.x, 0f - q.y, 0f - q.z, q.w); } private void ApplyBoneMirror(bool isUpdatePass) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_animator == (Object)null || !((Behaviour)_animator).enabled || _pairs.Count == 0) { return; } if (!AnimatorAdvanced()) { if (Time.time - _lastApplyTime > 1f) { Log($"stale: no animation advance for {Time.time - _lastApplyTime:0.0}s"); _lastApplyTime = Time.time; } return; } if ((Object)(object)_visEquipment != (Object)null && (Object)(object)_visEquipment.m_leftHand != (Object)null && (Object)(object)_visEquipment.m_rightHand != (Object)null) { _rawLeftHandRot = _visEquipment.m_leftHand.rotation; _rawRightHandRot = _visEquipment.m_rightHand.rotation; } Transform val = null; Transform val2 = null; Quaternion q = Quaternion.identity; Quaternion q2 = Quaternion.identity; for (int i = 0; i < _pairs.Count; i++) { BonePair bonePair = _pairs[i]; Quaternion localRotation = bonePair.Left.localRotation; Quaternion localRotation2 = bonePair.Right.localRotation; if (i == 1) { q = localRotation; q2 = localRotation2; val = bonePair.Left; val2 = bonePair.Right; } bonePair.Right.localRotation = bonePair.KRightInv * Flip(bonePair.KLeft * localRotation); bonePair.Left.localRotation = bonePair.KLeftInv * Flip(bonePair.KRight * localRotation2); } for (int j = 0; j < _solos.Count; j++) { SoloBone soloBone = _solos[j]; Quaternion localRotation3 = soloBone.Bone.localRotation; soloBone.Bone.localRotation = soloBone.KInv * Flip(soloBone.K * localRotation3); } _lastApplyTime = Time.time; if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { string text = (isUpdatePass ? "U" : "L"); Log("mirror " + text + " raw L" + Euler(q) + " R" + Euler(q2) + " set L" + Euler(val.localRotation) + " R" + Euler(val2.localRotation)); } } private static string Euler(Quaternion q) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0023: Unknown result type (might be due to invalid IL or missing references) Vector3 eulerAngles = ((Quaternion)(ref q)).eulerAngles; return $"({eulerAngles.x:0.0},{eulerAngles.y:0.0},{eulerAngles.z:0.0})"; } private bool AnimatorAdvanced() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) int layerCount = _animator.layerCount; if (_layerTimes == null || _layerTimes.Length != layerCount) { _layerTimes = new float[layerCount]; _layerHashes = new int[layerCount]; return true; } bool result = false; for (int i = 0; i < layerCount; i++) { AnimatorStateInfo currentAnimatorStateInfo = _animator.GetCurrentAnimatorStateInfo(i); if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime != _layerTimes[i] || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash != _layerHashes[i]) { result = true; } _layerTimes[i] = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime; _layerHashes[i] = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash; } return result; } private void UpdateSockets() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visEquipment == (Object)null || (Object)(object)_visEquipment.m_leftHand == (Object)null || (Object)(object)_visEquipment.m_rightHand == (Object)null) { return; } GameObject leftItemInstance = _visEquipment.m_leftItemInstance; GameObject rightItemInstance = _visEquipment.m_rightItemInstance; if ((Object)(object)leftItemInstance != (Object)(object)_leftInstance || (Object)(object)rightItemInstance != (Object)(object)_rightInstance) { RestoreSockets(); if ((Object)(object)leftItemInstance != (Object)null) { _leftLocalPos = leftItemInstance.transform.localPosition; _leftLocalRot = leftItemInstance.transform.localRotation; _leftExt = LocalExtents(leftItemInstance); leftItemInstance.transform.SetParent(_visEquipment.m_leftHand, false); } if ((Object)(object)rightItemInstance != (Object)null) { _rightLocalPos = rightItemInstance.transform.localPosition; _rightLocalRot = rightItemInstance.transform.localRotation; _rightExt = LocalExtents(rightItemInstance); rightItemInstance.transform.SetParent(_visEquipment.m_rightHand, false); } if ((Object)(object)leftItemInstance != (Object)null && (Object)(object)rightItemInstance != (Object)null) { leftItemInstance.transform.SetParent(_visEquipment.m_rightHand, false); rightItemInstance.transform.SetParent(_visEquipment.m_leftHand, false); } else if ((Object)(object)rightItemInstance != (Object)null) { rightItemInstance.transform.SetParent(_visEquipment.m_leftHand, false); } else if ((Object)(object)leftItemInstance != (Object)null) { leftItemInstance.transform.SetParent(_visEquipment.m_rightHand, false); } Transform val = (((Object)(object)_animator != (Object)null) ? _animator.GetBoneTransform((HumanBodyBones)17) : null); Transform val2 = (((Object)(object)_animator != (Object)null) ? _animator.GetBoneTransform((HumanBodyBones)18) : null); Quaternion val3 = (((Object)(object)val != (Object)null) ? (Quaternion.Inverse(val.rotation) * _visEquipment.m_leftHand.rotation) : Quaternion.identity); Quaternion val4 = (((Object)(object)val2 != (Object)null) ? (Quaternion.Inverse(val2.rotation) * _visEquipment.m_rightHand.rotation) : Quaternion.identity); if ((Object)(object)leftItemInstance != (Object)null) { leftItemInstance.transform.localRotation = Quaternion.Inverse(val4) * Flip(val3); leftItemInstance.transform.localScale = new Vector3(-1f, 1f, 1f); } if ((Object)(object)rightItemInstance != (Object)null) { rightItemInstance.transform.localRotation = Quaternion.Inverse(val3) * Flip(val4); rightItemInstance.transform.localScale = new Vector3(-1f, 1f, 1f); } _leftInstance = leftItemInstance; _rightInstance = rightItemInstance; Log("socketOffset L" + Euler(val3) + " R" + Euler(val4)); Diag("swap"); } if ((Object)(object)_leftInstance != (Object)null || (Object)(object)_rightInstance != (Object)null) { Diag("idle"); } } private static Vector3 LocalExtents(GameObject item) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00a7: 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_00c7: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) Transform transform = item.transform; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(1E+09f, 1E+09f, 1E+09f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(-1E+09f, -1E+09f, -1E+09f); Renderer[] componentsInChildren = item.GetComponentsInChildren<Renderer>(); Vector3 val3 = default(Vector3); for (int i = 0; i < componentsInChildren.Length; i++) { Bounds bounds = componentsInChildren[i].bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; if (!(((Vector3)(ref extents)).sqrMagnitude < 1E-08f)) { for (int j = 0; j < 8; j++) { ((Vector3)(ref val3))..ctor(((j & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((j & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((j & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z); Vector3 val4 = transform.InverseTransformPoint(val3); val = Vector3.Min(val, val4); val2 = Vector3.Max(val2, val4); } } } if (val.x > val2.x) { return Vector3.zero; } return val2 - val; } private void Diag(string when) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0212: 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_025b: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_animator == (Object)null) && !((Object)(object)_player == (Object)null) && (!(when != "swap") || !(Time.time - _lastDiagTime < 1f))) { _lastDiagTime = Time.time; string text = (_isLocal ? "[mirror:local]" : "[mirror:remote]") + " diag[" + when + "]"; Quaternion rotation = ((Component)_player).transform.rotation; Quaternion rotation2 = ((Component)_animator).transform.rotation; Plugin.LogDebug($"{text} player={Euler(rotation)} visual={Euler(rotation2)} dC={Quaternion.Angle(rotation, rotation2):0.1}"); Plugin.LogDebug(text + " rawL=" + Euler(_rawLeftHandRot) + " rawR=" + Euler(_rawRightHandRot) + " sockL=" + Euler(_visEquipment.m_leftHand.rotation) + " sockR=" + Euler(_visEquipment.m_rightHand.rotation)); Transform boneTransform = _animator.GetBoneTransform((HumanBodyBones)17); Transform boneTransform2 = _animator.GetBoneTransform((HumanBodyBones)18); Plugin.LogDebug(text + " boneL=" + Euler(((Object)(object)boneTransform != (Object)null) ? boneTransform.rotation : Quaternion.identity) + " boneR=" + Euler(((Object)(object)boneTransform2 != (Object)null) ? boneTransform2.rotation : Quaternion.identity) + " authL=" + Euler(_leftLocalRot) + " authR=" + Euler(_rightLocalRot) + " posL=(" + V3(_leftLocalPos) + ") posR=(" + V3(_rightLocalPos) + ")"); Plugin.LogDebug(text + " extL=(" + V3(_leftExt) + ") extR=(" + V3(_rightExt) + ")"); if ((Object)(object)_rightInstance != (Object)null && (Object)(object)_leftInstance != (Object)null) { Plugin.LogDebug(text + " mace world=" + Euler(_rightInstance.transform.rotation) + " sockL=" + Euler(_visEquipment.m_leftHand.rotation) + " scale=" + V3(_rightInstance.transform.localScale)); Plugin.LogDebug(text + " shield world=" + Euler(_leftInstance.transform.rotation) + " sockR=" + Euler(_visEquipment.m_rightHand.rotation) + " scale=" + V3(_leftInstance.transform.localScale)); } } } private static string V3(Vector3 v) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"{v.x:0.00},{v.y:0.00},{v.z:0.00}"; } private void RestoreSockets() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visEquipment == (Object)null) { _leftInstance = null; _rightInstance = null; return; } if ((Object)(object)_leftInstance != (Object)null && (Object)(object)_visEquipment.m_leftHand != (Object)null) { Transform transform = _leftInstance.transform; transform.SetParent(_visEquipment.m_leftHand, false); transform.localPosition = _leftLocalPos; transform.localRotation = _leftLocalRot; transform.localScale = Vector3.one; } if ((Object)(object)_rightInstance != (Object)null && (Object)(object)_visEquipment.m_rightHand != (Object)null) { Transform transform2 = _rightInstance.transform; transform2.SetParent(_visEquipment.m_rightHand, false); transform2.localPosition = _rightLocalPos; transform2.localRotation = _rightLocalRot; transform2.localScale = Vector3.one; } _leftInstance = null; _rightInstance = null; } private void Log(string message) { if (!((Object)(object)Plugin.Instance == (Object)null) && Plugin.Instance.Debug && !(Time.time - _lastLogTime < 0.2f)) { _lastLogTime = Time.time; string text = (_isLocal ? "[mirror:local]" : "[mirror:remote]"); Plugin.Log.LogInfo((object)(text + " " + message)); } } static VinjeøraPlayer() { HumanBodyBones[] array = new HumanBodyBones[19]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); PairLeft = (HumanBodyBones[])(object)array; HumanBodyBones[] array2 = new HumanBodyBones[19]; RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); PairRight = (HumanBodyBones[])(object)array2; HumanBodyBones[] array3 = new HumanBodyBones[3]; RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); SoloBones = (HumanBodyBones[])(object)array3; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }