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 VikingEyes v0.3.1
plugins/VikingEyes.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace VikingEyes; public static class VikingEyesApi { public const int ApiVersion = 1; private static readonly Dictionary<string, float> FovOffsets = new Dictionary<string, float>(); private static readonly Dictionary<string, float> StressSources = new Dictionary<string, float>(); private static readonly Dictionary<string, float> Effects = new Dictionary<string, float>(); private static readonly HashSet<string> ThirdPersonRequests = new HashSet<string>(); public static bool IsFirstPersonActive { get { if (CameraRig.Instance != null) { return CameraRig.Instance.FirstPersonWeight > 0.001f; } return false; } } public static float FirstPersonWeight { get { if (CameraRig.Instance == null) { return 0f; } return CameraRig.Instance.FirstPersonWeight; } } internal static int FovOffsetCount => FovOffsets.Count; public static void AddImpulse(Vector3 direction, float strength) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AddImpulse(direction, strength, "api"); } public static void AddImpulse(Vector3 direction, float strength, string source) { //IL_0000: 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) if (FeelMath.IsFinite(direction) && !float.IsNaN(strength)) { FeelBus.Raise(FeelEventType.Impulse, Mathf.Clamp(strength, 0f, 20f), direction, source); } } public static void AddTrauma(float amount) { AddTrauma(amount, "api"); } public static void AddTrauma(float amount, string source) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(amount)) { FeelBus.Raise(FeelEventType.Trauma, Mathf.Clamp01(amount), Vector3.zero, source); } } public static void Blink() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) FeelBus.Raise(FeelEventType.Blink, 1f, Vector3.zero, "api"); } public static void SetStress(string source, float amount) { SetValue(StressSources, source, Mathf.Clamp01(amount)); } public static void SetFovOffset(string source, float degrees) { SetValue(FovOffsets, source, Mathf.Clamp(degrees, -30f, 30f)); } public static void SetEffect(string name, float amount) { SetValue(Effects, name, Mathf.Clamp(amount, 0f, 10f)); } public static float GetEffect(string name) { if (name == null || !Effects.TryGetValue(name, out var value)) { return 0f; } return value; } public static void RequestThirdPerson(string reason) { if (!string.IsNullOrEmpty(reason)) { ThirdPersonRequests.Add(reason); } } public static void ReleaseThirdPerson(string reason) { if (!string.IsNullOrEmpty(reason)) { ThirdPersonRequests.Remove(reason); } } public static void RaiseEvent(string name, float magnitude) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) FeelBus.Raise(FeelEventType.External, magnitude, Vector3.zero, name); } internal static bool HasThirdPersonRequest(out string firstReason) { using (HashSet<string>.Enumerator enumerator = ThirdPersonRequests.GetEnumerator()) { if (enumerator.MoveNext()) { string current = enumerator.Current; firstReason = current; return true; } } firstReason = null; return false; } internal static float TotalFovOffset() { float num = 0f; foreach (KeyValuePair<string, float> fovOffset in FovOffsets) { num += fovOffset.Value; } return num; } internal static float MaxStress() { float num = 0f; foreach (KeyValuePair<string, float> stressSource in StressSources) { if (stressSource.Value > num) { num = stressSource.Value; } } return num; } private static void SetValue(Dictionary<string, float> map, string key, float value) { if (!string.IsNullOrEmpty(key) && !float.IsNaN(value)) { if (Mathf.Abs(value) < 1E-05f) { map.Remove(key); } else { map[key] = value; } } } } internal sealed class BoneTweak { public Transform Bone; private Quaternion lastPre; private Quaternion lastWritten; private bool written; private int writtenFrame = -1; public void Reset(Transform bone) { Bone = bone; written = false; } public void Rotate(Quaternion worldDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) SetRotation(worldDelta * Bone.rotation); } public void SetRotation(Quaternion world) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) int frameCount = Time.frameCount; if (!written || writtenFrame != frameCount) { lastPre = Bone.localRotation; writtenFrame = frameCount; } Bone.rotation = world; lastWritten = Bone.localRotation; written = true; } public void Restore() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0057: 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_0084: Unknown result type (might be due to invalid IL or missing references) if (!written || (Object)(object)Bone == (Object)null) { written = false; return; } written = false; Quaternion localRotation = Bone.localRotation; if (localRotation.x == lastWritten.x && localRotation.y == lastWritten.y && localRotation.z == lastWritten.z && localRotation.w == lastWritten.w) { Bone.localRotation = lastPre; } } } internal sealed class BodyPresence { private sealed class HiddenRenderer { public Renderer Renderer; public ShadowCastingMode Saved; public bool SavedForceOff; public bool Applied; } private sealed class BodyCopy { public SkinnedMeshRenderer Original; public SkinnedMeshRenderer Copy; public Mesh Mesh; public int MaterialCount; public Material FirstMaterial; } private sealed class ArmSegment { public Transform Start; public Transform End; public float Extend; public readonly List<Transform> Proxies = new List<Transform>(); public bool Collapsed; } public static BodyPresence Instance; public string StatusText = "idle"; private static readonly FieldRef<VisEquipment, GameObject> HelmetRef = VisRef<GameObject>("m_helmetItemInstance"); private static readonly FieldRef<VisEquipment, GameObject> HairRef = VisRef<GameObject>("m_hairItemInstance"); private static readonly FieldRef<VisEquipment, GameObject> BeardRef = VisRef<GameObject>("m_beardItemInstance"); private static readonly FieldRef<VisEquipment, List<GameObject>> ChestRef = VisRef<List<GameObject>>("m_chestItemInstances"); private static readonly FieldRef<VisEquipment, List<GameObject>> ShoulderRef = VisRef<List<GameObject>>("m_shoulderItemInstances"); private static readonly FieldRef<VisEquipment, List<GameObject>> LegRef = VisRef<List<GameObject>>("m_legItemInstances"); private static readonly FieldRef<VisEquipment, GameObject> LeftItemRef = VisRef<GameObject>("m_leftItemInstance"); private static readonly FieldRef<VisEquipment, GameObject> RightItemRef = VisRef<GameObject>("m_rightItemInstance"); private static readonly FieldRef<Character, Vector3> MoveDirRef = CharRef<Vector3>("m_moveDir"); private static readonly FieldRef<Humanoid, ItemData> LeftHandRef = HumanoidRef<ItemData>("m_leftItem"); private Player boundPlayer; private VisEquipment vis; private PlayerBones bones; private bool dirty = true; private float nextSyncTime; private bool hideActive; private bool cameraHooked; private readonly List<BodyCopy> copies = new List<BodyCopy>(); private readonly List<HiddenRenderer> hidden = new List<HiddenRenderer>(); private readonly List<Renderer> handItems = new List<Renderer>(); private int leftHandItems; private const float ShieldNearMargin = 0.03f; private readonly List<HiddenRenderer> capeHidden = new List<HiddenRenderer>(); private readonly List<HiddenRenderer> handHidden = new List<HiddenRenderer>(); private readonly Dictionary<Transform, Transform> proxies = new Dictionary<Transform, Transform>(); private readonly List<Transform> headProxies = new List<Transform>(); private readonly List<ArmSegment> armSegments = new List<ArmSegment>(); private readonly List<Renderer> scratchRenderers = new List<Renderer>(); private readonly List<Material> scratchMaterials = new List<Material>(); private MaterialPropertyBlock block; private readonly BoneTweak[] spineTweaks = new BoneTweak[3] { new BoneTweak(), new BoneTweak(), new BoneTweak() }; private readonly Transform[] spineChain = (Transform[])(object)new Transform[3]; private static readonly float[] SpineShares = new float[3] { 0.3f, 0.35f, 0.35f }; private readonly List<BoneTweak> guardedBones = new List<BoneTweak>(); private readonly WeaponHold hold = new WeaponHold(); private bool holdBroken; private Spring1 swayYaw; private Spring1 swayPitch; private float lastLookYaw; private float lastLookPitch; private bool lookInitialised; private bool legsTurning; private Animator forcedAnimator; private static readonly FieldRef<Humanoid, ItemData> RightHandRef = HumanoidRef<ItemData>("m_rightItem"); private readonly Dictionary<Transform, Vector3> heldOriginalScale = new Dictionary<Transform, Vector3>(); private readonly List<Transform> heldStale = new List<Transform>(); private AnimatorCullingMode savedCulling; private static readonly Vector3 Collapsed = new Vector3(0.0001f, 0.0001f, 0.0001f); private readonly Dictionary<Renderer, HiddenRenderer> handEntries = new Dictionary<Renderer, HiddenRenderer>(); public BodyPresence() { Instance = this; guardedBones.AddRange(spineTweaks); hold.AddTweaks(guardedBones); } public void Dispose() { UnhookCamera(); RestoreBones(); DestroyCopies(); SelfEffects.Uninstall(); EyeMarkers.Destroy(); if (Instance == this) { Instance = null; } } public void MarkDirty(VisEquipment source) { if ((Object)(object)vis != (Object)null && (Object)(object)source == (Object)(object)vis) { dirty = true; } } public void BeforeRig() { RestoreBones(); } public void AfterRig(CameraRig rig) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (rig == null || (Object)(object)localPlayer == (Object)null || !VeConfig.Enabled.Value) { SetHideActive(active: false); KeepAnimating(on: false); RestoreHeldItems(); if ((Object)(object)localPlayer == (Object)null) { Unbind(); } StatusText = "idle"; SelfEffects.Tick(null, null); EyeMarkers.Update(null); return; } if ((Object)(object)localPlayer != (Object)(object)boundPlayer) { Bind(localPlayer, rig); } if (bones == null || !bones.Valid) { StatusText = "no humanoid rig"; return; } float firstPersonWeight = rig.FirstPersonWeight; KeepAnimating(firstPersonWeight > 0f || rig.CalibrationViewActive); ScaleHeldItems(localPlayer, rig.CalibrationViewActive ? 0f : firstPersonWeight); if (dirty || NeedsRebuild()) { Rebuild(); } if (Time.time >= nextSyncTime) { SyncCopies(); } Vector3 val = bones.Head.position + Vector3.up * 0.08f; int num; if (firstPersonWeight > 0f) { Vector3 val2 = rig.CameraWorldPosition - val; num = ((((Vector3)(ref val2)).sqrMagnitude < 0.1444f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; bool active = VeConfig.HideHeadFromEyes.Value && flag && !rig.CalibrationViewActive; SetHideActive(active); ApplyBodyTweaks(rig, localPlayer, firstPersonWeight); UpdateNearCulling(rig, localPlayer, active); SelfEffects.Tick(rig, localPlayer); EyeMarkers.Update(rig); if (VeConfig.DebugOverlay.Value) { StatusText = (hideActive ? "headless" : "full") + ", copies " + copies.Count + ", hidden " + hidden.Count + ", hand items " + handItems.Count + (legsTurning ? ", legs turning" : "") + (holdBroken ? ", hold off (error)" : (hold.Active ? (", hold " + hold.RightKind + "/" + hold.LeftKind) : "")) + (hold.ShieldPlaced ? (", shield -" + hold.ShieldDrop.ToString("0.00") + " m" + (hold.ShieldArmShort ? " (arm short)" : "")) : "") + (Compat.IsClimbing(localPlayer) ? ", climbing" : "") + ((rig.BodyTiltDegrees > 0.5f) ? (", body tilt " + rig.BodyTiltDegrees.ToString("0") + " deg") : ""); } } private void Bind(Player player, CameraRig rig) { Unbind(); boundPlayer = player; vis = ((Component)player).GetComponent<VisEquipment>(); bones = ((rig.Bones != null && (Object)(object)rig.Bones.Player == (Object)(object)player) ? rig.Bones : PlayerBones.Find(player)); int num = ((bones != null) ? bones.GetSpineChain(spineChain) : 0); for (int i = 0; i < spineTweaks.Length; i++) { spineTweaks[i].Reset((i < num) ? spineChain[i] : null); } hold.Bind(bones); holdBroken = false; lookInitialised = false; legsTurning = false; dirty = true; HookCamera(); } private void KeepAnimating(bool on) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Animator val = ((bones != null) ? bones.Animator : null); if (on && (Object)(object)val != (Object)null) { if ((Object)(object)forcedAnimator != (Object)(object)val) { RestoreAnimating(); forcedAnimator = val; savedCulling = val.cullingMode; } if ((int)val.cullingMode != 0) { val.cullingMode = (AnimatorCullingMode)0; } } else { RestoreAnimating(); } } private void ScaleHeldItems(Player player, float weight) { ItemData item = ((RightHandRef != null) ? RightHandRef.Invoke((Humanoid)(object)player) : null); ItemData item2 = ((LeftHandRef != null) ? LeftHandRef.Invoke((Humanoid)(object)player) : null); ApplyHeldScale((RightItemRef != null && (Object)(object)vis != (Object)null) ? RightItemRef.Invoke(vis) : null, item, weight); ApplyHeldScale((LeftItemRef != null && (Object)(object)vis != (Object)null) ? LeftItemRef.Invoke(vis) : null, item2, weight); heldStale.Clear(); foreach (KeyValuePair<Transform, Vector3> item3 in heldOriginalScale) { if ((Object)(object)item3.Key == (Object)null) { heldStale.Add(item3.Key); } } for (int i = 0; i < heldStale.Count; i++) { heldOriginalScale.Remove(heldStale[i]); } } private void ApplyHeldScale(GameObject instance, ItemData item, float weight) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)instance == (Object)null)) { Transform transform = instance.transform; if (!heldOriginalScale.TryGetValue(transform, out var value)) { value = transform.localScale; heldOriginalScale[transform] = value; } float num = ((item != null && item.m_shared != null && (int)item.m_shared.m_itemType == 15) ? Mathf.Clamp(VeConfig.TorchScale.Value, 0.2f, 1f) : Mathf.Clamp(VeConfig.HeldItemScale.Value, 0.2f, 1f)); float num2 = (VeConfig.Enabled.Value ? Mathf.Lerp(1f, num, Mathf.Clamp01(weight)) : 1f); Vector3 val = value * num2; Vector3 val2 = transform.localScale - val; if (((Vector3)(ref val2)).sqrMagnitude > 1E-10f) { transform.localScale = val; } } } private void RestoreHeldItems() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Transform, Vector3> item in heldOriginalScale) { if ((Object)(object)item.Key != (Object)null) { item.Key.localScale = item.Value; } } heldOriginalScale.Clear(); } private void RestoreAnimating() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)forcedAnimator != (Object)null) { forcedAnimator.cullingMode = savedCulling; } forcedAnimator = null; } private void Unbind() { RestoreAnimating(); RestoreHeldItems(); SetHideActive(active: false); DestroyCopies(); boundPlayer = null; vis = null; bones = null; } private bool NeedsRebuild() { for (int i = 0; i < copies.Count; i++) { BodyCopy bodyCopy = copies[i]; if ((Object)(object)bodyCopy.Original == (Object)null || (Object)(object)bodyCopy.Copy == (Object)null || (Object)(object)bodyCopy.Original.sharedMesh != (Object)(object)bodyCopy.Mesh) { return true; } } return false; } private void Rebuild() { dirty = false; bool flag = hideActive; SetHideActive(active: false); DestroyCopies(); if ((Object)(object)vis == (Object)null || bones == null || !bones.Valid) { return; } try { AddHidden((HairRef != null) ? HairRef.Invoke(vis) : null); AddHidden((BeardRef != null) ? BeardRef.Invoke(vis) : null); AddHidden((HelmetRef != null) ? HelmetRef.Invoke(vis) : null); scratchRenderers.Clear(); ((Component)bones.Head).GetComponentsInChildren<Renderer>(true, scratchRenderers); for (int i = 0; i < scratchRenderers.Count; i++) { Renderer val = scratchRenderers[i]; if (!(val is ParticleSystemRenderer)) { AddHiddenRenderer(val); } } if ((Object)(object)vis.m_bodyModel != (Object)null) { AddCopy(vis.m_bodyModel); } AddCopies((ChestRef != null) ? ChestRef.Invoke(vis) : null); AddCopies((LegRef != null) ? LegRef.Invoke(vis) : null); capeHidden.Clear(); List<GameObject> list = ((ShoulderRef != null) ? ShoulderRef.Invoke(vis) : null); if (list != null) { for (int j = 0; j < list.Count; j++) { if ((Object)(object)list[j] == (Object)null) { continue; } scratchRenderers.Clear(); list[j].GetComponentsInChildren<Renderer>(true, scratchRenderers); for (int k = 0; k < scratchRenderers.Count; k++) { if ((Object)(object)scratchRenderers[k] != (Object)null && !(scratchRenderers[k] is ParticleSystemRenderer)) { capeHidden.Add(new HiddenRenderer { Renderer = scratchRenderers[k] }); } } } } handItems.Clear(); AddHandItems((LeftItemRef != null) ? LeftItemRef.Invoke(vis) : null); leftHandItems = handItems.Count; AddHandItems((RightItemRef != null) ? RightItemRef.Invoke(vis) : null); Plugin.Verbose("Body rebuilt: " + copies.Count + " copies, " + hidden.Count + " hidden renderers, " + handItems.Count + " hand items."); } catch (Exception ex) { Plugin.LogOnce("body-rebuild", "Headless body could not be built (" + ex.Message + "); the full body stays visible."); DestroyCopies(); } if (flag) { SetHideActive(active: true); } } private void AddHidden(GameObject instance) { if (!((Object)(object)instance == (Object)null)) { scratchRenderers.Clear(); instance.GetComponentsInChildren<Renderer>(true, scratchRenderers); for (int i = 0; i < scratchRenderers.Count; i++) { AddHiddenRenderer(scratchRenderers[i]); } } } private void AddHiddenRenderer(Renderer renderer) { if ((Object)(object)renderer == (Object)null) { return; } for (int i = 0; i < hidden.Count; i++) { if ((Object)(object)hidden[i].Renderer == (Object)(object)renderer) { return; } } for (int j = 0; j < copies.Count; j++) { if ((Object)(object)copies[j].Copy == (Object)(object)renderer) { return; } } hidden.Add(new HiddenRenderer { Renderer = renderer }); } private void AddCopies(List<GameObject> instances) { if (instances == null) { return; } for (int i = 0; i < instances.Count; i++) { GameObject val = instances[i]; if ((Object)(object)val == (Object)null) { continue; } scratchRenderers.Clear(); val.GetComponentsInChildren<Renderer>(true, scratchRenderers); for (int j = 0; j < scratchRenderers.Count; j++) { Renderer obj = scratchRenderers[j]; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((obj is SkinnedMeshRenderer) ? obj : null); if ((Object)(object)val2 != (Object)null) { AddCopy(val2); } } } } private void AddCopy(SkinnedMeshRenderer original) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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) if ((Object)(object)original == (Object)null || (Object)(object)original.sharedMesh == (Object)null || ((Object)original).name.StartsWith("VikingEyes_", StringComparison.Ordinal)) { return; } Transform[] array = original.bones; if (array == null || array.Length == 0) { return; } Transform[] array2 = (Transform[])(object)new Transform[array.Length]; bool flag = false; for (int i = 0; i < array.Length; i++) { Transform val = (array2[i] = array[i]); if (!((Object)(object)val == (Object)null)) { if (IsHeadBone(val)) { array2[i] = GetProxy(val, head: true); flag = true; } else if (IsArmBone(val)) { array2[i] = GetProxy(val, head: false); } } } GameObject val2 = new GameObject("VikingEyes_" + ((Object)original).name) { layer = ((Component)original).gameObject.layer }; val2.transform.SetParent(((Component)original).transform, false); SkinnedMeshRenderer val3 = val2.AddComponent<SkinnedMeshRenderer>(); val3.sharedMesh = original.sharedMesh; val3.rootBone = original.rootBone; val3.bones = array2; ((Renderer)val3).localBounds = ((Renderer)original).localBounds; val3.updateWhenOffscreen = true; val3.quality = original.quality; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = ((Renderer)original).receiveShadows; ((Renderer)val3).lightProbeUsage = ((Renderer)original).lightProbeUsage; ((Renderer)val3).reflectionProbeUsage = ((Renderer)original).reflectionProbeUsage; ((Renderer)val3).probeAnchor = ((Renderer)original).probeAnchor; val3.skinnedMotionVectors = original.skinnedMotionVectors; ((Renderer)val3).motionVectorGenerationMode = ((Renderer)original).motionVectorGenerationMode; ((Renderer)val3).enabled = false; BodyCopy bodyCopy = new BodyCopy { Original = original, Copy = val3, Mesh = original.sharedMesh }; SyncCopy(bodyCopy); copies.Add(bodyCopy); hidden.Add(new HiddenRenderer { Renderer = (Renderer)(object)original }); if (!flag) { Plugin.Verbose("Copy of " + ((Object)original).name + " has no head bones (armour piece)."); } } private void AddHandItems(GameObject instance) { if ((Object)(object)instance == (Object)null) { return; } scratchRenderers.Clear(); instance.GetComponentsInChildren<Renderer>(true, scratchRenderers); for (int i = 0; i < scratchRenderers.Count; i++) { Renderer val = scratchRenderers[i]; if (!((Object)(object)val == (Object)null) && !(val is ParticleSystemRenderer)) { handItems.Add(val); } } } private void SyncCopies() { nextSyncTime = Time.time + 0.25f; for (int i = 0; i < copies.Count; i++) { SyncCopy(copies[i]); } } private void SyncCopy(BodyCopy entry) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown if (!((Object)(object)entry.Original == (Object)null) && !((Object)(object)entry.Copy == (Object)null)) { scratchMaterials.Clear(); ((Renderer)entry.Original).GetSharedMaterials(scratchMaterials); Material val = ((scratchMaterials.Count > 0) ? scratchMaterials[0] : null); if (scratchMaterials.Count != entry.MaterialCount || (Object)(object)val != (Object)(object)entry.FirstMaterial) { ((Renderer)entry.Copy).sharedMaterials = scratchMaterials.ToArray(); entry.MaterialCount = scratchMaterials.Count; entry.FirstMaterial = val; } if (block == null) { block = new MaterialPropertyBlock(); } ((Renderer)entry.Original).GetPropertyBlock(block); ((Renderer)entry.Copy).SetPropertyBlock(block); } } private bool IsHeadBone(Transform bone) { if ((Object)(object)bones.Head != (Object)null) { if (!((Object)(object)bone == (Object)(object)bones.Head)) { return bone.IsChildOf(bones.Head); } return true; } return false; } private bool IsArmBone(Transform bone) { Transform val = (((Object)(object)bones.LeftShoulder != (Object)null) ? bones.LeftShoulder : bones.LeftUpperArm); Transform val2 = (((Object)(object)bones.RightShoulder != (Object)null) ? bones.RightShoulder : bones.RightUpperArm); if (!((Object)(object)val != (Object)null) || !bone.IsChildOf(val)) { if ((Object)(object)val2 != (Object)null) { return bone.IsChildOf(val2); } return false; } return true; } private Transform GetProxy(Transform bone, bool head) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (proxies.TryGetValue(bone, out var value) && (Object)(object)value != (Object)null) { return value; } value = new GameObject("VikingEyes_proxy") { layer = ((Component)bone).gameObject.layer }.transform; value.SetParent(bone, false); value.localPosition = Vector3.zero; value.localRotation = Quaternion.identity; value.localScale = (head ? Collapsed : Vector3.one); proxies[bone] = value; if (head) { headProxies.Add(value); } else { RegisterArmProxy(bone, value); } return value; } private void RegisterArmProxy(Transform bone, Transform proxy) { if (armSegments.Count == 0) { BuildArmSegments(); } for (int i = 0; i < armSegments.Count; i++) { ArmSegment armSegment = armSegments[i]; if ((Object)(object)armSegment.Start != (Object)null && ((Object)(object)bone == (Object)(object)armSegment.Start || bone.IsChildOf(armSegment.Start))) { armSegment.Proxies.Add(proxy); } } } private void BuildArmSegments() { if ((Object)(object)bones.LeftShoulder != (Object)null) { AddSegment(bones.LeftShoulder, bones.LeftUpperArm, 0f); } if ((Object)(object)bones.RightShoulder != (Object)null) { AddSegment(bones.RightShoulder, bones.RightUpperArm, 0f); } AddSegment(bones.LeftUpperArm, bones.LeftLowerArm, 0f); AddSegment(bones.LeftLowerArm, bones.LeftHand, 0f); AddSegment(bones.LeftHand, null, 0.12f); AddSegment(bones.RightUpperArm, bones.RightLowerArm, 0f); AddSegment(bones.RightLowerArm, bones.RightHand, 0f); AddSegment(bones.RightHand, null, 0.12f); } private void AddSegment(Transform start, Transform end, float extend) { if (!((Object)(object)start == (Object)null)) { armSegments.Add(new ArmSegment { Start = start, End = end, Extend = extend }); } } private void DestroyCopies() { for (int i = 0; i < copies.Count; i++) { if (!((Object)(object)copies[i].Copy == (Object)null)) { GameObject gameObject = ((Component)copies[i].Copy).gameObject; gameObject.transform.SetParent((Transform)null, false); Object.Destroy((Object)(object)gameObject); } } copies.Clear(); hidden.Clear(); handItems.Clear(); leftHandItems = 0; handHidden.Clear(); handEntries.Clear(); capeHidden.Clear(); foreach (KeyValuePair<Transform, Transform> proxy in proxies) { if ((Object)(object)proxy.Value != (Object)null) { Object.Destroy((Object)(object)((Component)proxy.Value).gameObject); } } proxies.Clear(); headProxies.Clear(); armSegments.Clear(); } private void SetHideActive(bool active) { if (active == hideActive) { return; } hideActive = active; for (int i = 0; i < copies.Count; i++) { if ((Object)(object)copies[i].Copy != (Object)null) { ((Renderer)copies[i].Copy).enabled = active && VeConfig.ShowBody.Value; } } } private void HookCamera() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if (!cameraHooked) { Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnPostRender)); cameraHooked = true; } } private void UnhookCamera() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if (cameraHooked) { Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnPostRender)); cameraHooked = false; } } private static bool IsMainGameplayCamera(Camera camera) { GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null && (Object)(object)camera != (Object)null) { return (Object)(object)((Component)camera).gameObject == (Object)(object)((Component)instance).gameObject; } return false; } private void OnPreCull(Camera camera) { if (!hideActive || !IsMainGameplayCamera(camera)) { return; } long start = PerfProbe.Begin(); for (int i = 0; i < hidden.Count; i++) { Hide(hidden[i]); } _ = VeConfig.ShowBody.Value; for (int j = 0; j < handHidden.Count; j++) { Hide(handHidden[j]); } if (VeConfig.HideCapeFromEyes.Value) { for (int k = 0; k < capeHidden.Count; k++) { Hide(capeHidden[k]); } } PerfProbe.End(PerfProbe.Section.PreCull, start); } private void OnPostRender(Camera camera) { if (IsMainGameplayCamera(camera)) { long start = PerfProbe.Begin(); for (int i = 0; i < hidden.Count; i++) { Restore(hidden[i]); } for (int j = 0; j < handHidden.Count; j++) { Restore(handHidden[j]); } for (int k = 0; k < capeHidden.Count; k++) { Restore(capeHidden[k]); } PerfProbe.End(PerfProbe.Section.PostRender, start); } } private static void Hide(HiddenRenderer entry) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Renderer renderer = entry.Renderer; if (!((Object)(object)renderer == (Object)null) && !entry.Applied) { entry.Saved = renderer.shadowCastingMode; entry.SavedForceOff = renderer.forceRenderingOff; if ((int)entry.Saved == 0) { renderer.forceRenderingOff = true; } else { renderer.shadowCastingMode = (ShadowCastingMode)3; } entry.Applied = true; } } private static void Restore(HiddenRenderer entry) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) Renderer renderer = entry.Renderer; if (entry.Applied) { entry.Applied = false; if (!((Object)(object)renderer == (Object)null)) { renderer.shadowCastingMode = entry.Saved; renderer.forceRenderingOff = entry.SavedForceOff; } } } private void UpdateNearCulling(CameraRig rig, Player player, bool active) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b6: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(VeConfig.NearCullRadius.Value, 0.05f, 0.5f); Vector3 cameraWorldPosition = rig.CameraWorldPosition; bool flag = ((Character)player).InDodge(); bool flag2 = false; for (int i = 0; i < armSegments.Count; i++) { ArmSegment armSegment = armSegments[i]; bool flag3 = false; if (active && (Object)(object)armSegment.Start != (Object)null) { if (flag) { flag3 = true; } else { Vector3 position = armSegment.Start.position; Vector3 val2; if (!((Object)(object)armSegment.End != (Object)null)) { Vector3 val = position - Parent(armSegment.Start); val2 = position + ((Vector3)(ref val)).normalized * armSegment.Extend; } else { val2 = armSegment.End.position; } Vector3 b = val2; flag3 = DistanceToSegment(cameraWorldPosition, position, b) < num; } } if (flag3 != armSegment.Collapsed) { armSegment.Collapsed = flag3; flag2 = true; } } int num2 = 0; while (flag2 && num2 < armSegments.Count) { List<Transform> list = armSegments[num2].Proxies; for (int j = 0; j < list.Count; j++) { if ((Object)(object)list[j] != (Object)null) { list[j].localScale = Vector3.one; } } num2++; } int num3 = 0; while (flag2 && num3 < armSegments.Count) { if (armSegments[num3].Collapsed) { List<Transform> list2 = armSegments[num3].Proxies; for (int k = 0; k < list2.Count; k++) { if ((Object)(object)list2[k] != (Object)null) { list2[k].localScale = Collapsed; } } } num3++; } bool value = VeConfig.ShowBody.Value; for (int l = 0; l < copies.Count; l++) { SkinnedMeshRenderer copy = copies[l].Copy; if (!((Object)(object)copy == (Object)null)) { bool flag4 = active && value; if (((Renderer)copy).enabled != flag4) { ((Renderer)copy).enabled = flag4; } bool flag5 = active && flag; if (((Renderer)copy).forceRenderingOff != flag5) { ((Renderer)copy).forceRenderingOff = flag5; } } } handHidden.Clear(); if (!active) { return; } float num4 = num * num; float num5 = Mathf.Min(num, rig.LastNearClip + 0.03f); float num6 = num5 * num5; bool shieldPlaced = hold.ShieldPlaced; for (int m = 0; m < handItems.Count; m++) { Renderer val3 = handItems[m]; if (!((Object)(object)val3 == (Object)null)) { float num7 = ((shieldPlaced && m < leftHandItems) ? num6 : num4); if (flag || ClosestPointDistanceSqr(val3, cameraWorldPosition) < num7) { handHidden.Add(GetHandEntry(val3)); } } } } private HiddenRenderer GetHandEntry(Renderer renderer) { if (!handEntries.TryGetValue(renderer, out var value)) { value = new HiddenRenderer { Renderer = renderer }; handEntries[renderer] = value; } return value; } private static float ClosestPointDistanceSqr(Renderer renderer, Vector3 point) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_005a: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) MeshFilter component = ((Component)renderer).GetComponent<MeshFilter>(); Bounds val; if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { val = component.sharedMesh.bounds; } else { if (!(renderer is SkinnedMeshRenderer)) { Bounds bounds = renderer.bounds; return ((Bounds)(ref bounds)).SqrDistance(point); } val = ((Renderer)(SkinnedMeshRenderer)renderer).localBounds; } Transform transform = ((Component)renderer).transform; Vector3 val2 = transform.InverseTransformPoint(point); Vector3 val3 = ((Bounds)(ref val)).ClosestPoint(val2); Vector3 val4 = transform.TransformPoint(val3) - point; return ((Vector3)(ref val4)).sqrMagnitude; } private static Vector3 Parent(Transform t) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)t.parent != (Object)null)) { return t.position - Vector3.up * 0.1f; } return t.parent.position; } private static float DistanceToSegment(Vector3 p, Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: 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) Vector3 val = b - a; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < 1E-08f) { return Vector3.Distance(p, a); } float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / sqrMagnitude); return Vector3.Distance(p, a + val * num); } private void ApplyBodyTweaks(CameraRig rig, Player player, float weight) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0.001f || rig.CalibrationViewActive) { lookInitialised = false; hold.Weight = 0f; return; } Vector3 val = (((Object)(object)((Character)player).m_eye != (Object)null) ? ((Character)player).m_eye.rotation : ((Component)player).transform.rotation) * Vector3.forward; float num = (0f - Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f))) * 57.29578f; float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; Vector3 val2 = Quaternion.Euler(0f, num2, 0f) * Vector3.right; float num3 = Mathf.Clamp(Time.deltaTime, 0f, 0.1f); float num4 = ((((Character)player).IsAttached() || ((Character)player).InBed() || ((Character)player).IsSitting() || ((Character)player).IsSwimming() || ((Character)player).InDodge() || ((Character)player).IsDead() || Compat.IsClimbing(player)) ? 0f : weight); float num5 = Mathf.Clamp(VeConfig.SpinePitchClamp.Value, 0f, 60f); float num6 = Mathf.Clamp(VeConfig.SpinePitchDownClamp.Value, 0f, 60f); float num7 = Mathf.Clamp(num * Mathf.Clamp(VeConfig.SpinePitchFollow.Value, 0f, 1f), 0f - num5, num6) * num4; Vector3 position = bones.Head.position; float num8 = 0f; if (VeConfig.BodyYawSplit.Value) { float y = ((Component)player).transform.eulerAngles.y; float num9 = Mathf.Clamp(VeConfig.UpperBodyTwistLimit.Value, 0f, 80f); num8 = Mathf.Clamp(Mathf.DeltaAngle(y, num2), 0f - num9, num9) * num4; } for (int i = 0; i < spineTweaks.Length; i++) { BoneTweak boneTweak = spineTweaks[i]; if (!((Object)(object)boneTweak.Bone == (Object)null)) { float num10 = SpineShares[i]; Quaternion worldDelta = Quaternion.AngleAxis(num7 * num10, val2) * Quaternion.AngleAxis(num8 * num10, Vector3.up); Write(boneTweak, worldDelta); } } Vector3 val3 = bones.Head.position - position; rig.ApplyEyeOffset(val3); if (!lookInitialised) { lastLookYaw = num2; lastLookPitch = num; swayYaw.Reset(0f); swayPitch.Reset(0f); lookInitialised = true; } float num11 = ((num3 > 0.0001f) ? (Mathf.DeltaAngle(lastLookYaw, num2) / num3) : 0f); float num12 = ((num3 > 0.0001f) ? ((num - lastLookPitch) / num3) : 0f); lastLookYaw = num2; lastLookPitch = num; float num13 = Mathf.Clamp(VeConfig.LookSway.Value, 0f, 3f) * Mathf.Max(0f, VeConfig.MasterIntensity.Value); swayYaw.Step(Mathf.Clamp((0f - num11) * 0.012f, -4f, 4f) * num13, 6f, 0.6f, num3); swayPitch.Step(Mathf.Clamp((0f - num12) * 0.01f, -3f, 3f) * num13, 6f, 0.6f, num3); if (holdBroken) { return; } try { ItemData rightItem = ((RightHandRef != null) ? RightHandRef.Invoke((Humanoid)(object)player) : null); ItemData leftItem = ((LeftHandRef != null) ? LeftHandRef.Invoke((Humanoid)(object)player) : null); GameObject rightInstance = ((RightItemRef != null && (Object)(object)vis != (Object)null) ? RightItemRef.Invoke(vis) : null); GameObject leftInstance = ((LeftItemRef != null && (Object)(object)vis != (Object)null) ? LeftItemRef.Invoke(vis) : null); hold.Apply(rig, player, rightItem, leftItem, rightInstance, leftInstance, val3, weight, num2, num, swayYaw.Value, swayPitch.Value, num3); } catch (Exception ex) { holdBroken = true; Plugin.LogOnce("weapon-hold", "Weapon hold threw (" + ex.GetType().Name + ": " + ex.Message + "); the arms stay with the animation.\n" + ex.StackTrace); } } private static void Write(BoneTweak tweak, Quaternion worldDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) tweak.Rotate(worldDelta); } private void RestoreBones() { for (int i = 0; i < guardedBones.Count; i++) { guardedBones[i].Restore(); } } public void FixedTick() { //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_0115: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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) Player localPlayer = Player.m_localPlayer; CameraRig instance = CameraRig.Instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer != (Object)(object)boundPlayer || instance == null || !VeConfig.Enabled.Value || !VeConfig.BodyYawSplit.Value || instance.FirstPersonWeight < 0.5f || MoveDirRef == null) { legsTurning = false; return; } Vector3 val = MoveDirRef.Invoke((Character)(object)localPlayer); bool num = ((Vector3)(ref val)).sqrMagnitude > 0.0001f || ((Character)localPlayer).InAttack() || ((Character)localPlayer).IsBlocking() || ((Character)localPlayer).IsDrawingBow(); bool flag = ((Character)localPlayer).IsAttached() || ((Character)localPlayer).IsSitting() || ((Character)localPlayer).InBed() || ((Character)localPlayer).IsSwimming() || ((Character)localPlayer).InDodge() || ((Character)localPlayer).IsDead() || ((Character)localPlayer).InEmote() || ((Character)localPlayer).IsStaggering() || ((Character)localPlayer).IsTeleporting() || ((Character)localPlayer).InPlaceMode() || !((Character)localPlayer).IsOnGround() || !((Character)localPlayer).CanMove() || InventoryGui.IsVisible() || Compat.IsClimbing(localPlayer); if (num || flag) { legsTurning = false; return; } float y = ((Component)localPlayer).transform.eulerAngles.y; Quaternion lookYaw = ((Character)localPlayer).GetLookYaw(); float num2 = Mathf.DeltaAngle(y, ((Quaternion)(ref lookYaw)).eulerAngles.y); float num3 = Mathf.Clamp(VeConfig.LegsTurnThreshold.Value, 0f, 90f); if (!legsTurning && Mathf.Abs(num2) > num3) { legsTurning = true; } if (legsTurning) { float fixedDeltaTime = Time.fixedDeltaTime; float num4 = 1f - Mathf.Exp((float)Math.PI * -2f * Mathf.Clamp(VeConfig.LegsFollowHz.Value, 0.5f, 12f) * fixedDeltaTime); float num5 = num2 * num4; float num6 = 90f * fixedDeltaTime; if (Mathf.Abs(num5) < num6) { num5 = Mathf.Sign(num2) * Mathf.Min(num6, Mathf.Abs(num2)); } ((Component)localPlayer).transform.rotation = Quaternion.Euler(0f, y + num5, 0f); if (Mathf.Abs(num2 - num5) < ((num3 < 1f) ? 0.5f : 2f)) { legsTurning = false; } } } public static bool ShouldFaceView(Player player) { if (!VeConfig.Enabled.Value || !VeConfig.FaceViewWhileMoving.Value || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } CameraRig instance = CameraRig.Instance; if (instance == null || instance.FirstPersonWeight < 0.5f || MoveDirRef == null) { return false; } if (((Vector3)(ref MoveDirRef.Invoke((Character)(object)player))).sqrMagnitude < 0.01f) { return false; } if (!((Character)player).IsCrouching() && !((Character)player).IsSwimming() && !((Character)player).IsAttached() && !((Character)player).IsRiding() && !((Character)player).InDodge() && !((Character)player).IsEncumbered()) { return !Compat.IsClimbing(player); } return false; } public static bool KeepVisible(Character character) { if (!VeConfig.Enabled.Value) { return false; } CameraRig instance = CameraRig.Instance; if (instance != null && (Object)(object)character != (Object)null && (Object)(object)character == (Object)(object)Player.m_localPlayer) { if (!(instance.FirstPersonWeight > 0f)) { return instance.CalibrationViewActive; } return true; } return false; } private static FieldRef<VisEquipment, T> VisRef<T>(string field) { try { return AccessTools.FieldRefAccess<VisEquipment, T>(field); } catch (Exception ex) { Plugin.LogOnce("vis-" + field, "VisEquipment." + field + " not found (" + ex.Message + "); that part of the body feature is off."); return null; } } private static FieldRef<Humanoid, T> HumanoidRef<T>(string field) { try { return AccessTools.FieldRefAccess<Humanoid, T>(field); } catch (Exception ex) { Plugin.LogOnce("hum-" + field, "Humanoid." + field + " not found (" + ex.Message + "); held-item sizing and the weapon hold for that hand are off."); return null; } } private static FieldRef<Character, T> CharRef<T>(string field) { try { return AccessTools.FieldRefAccess<Character, T>(field); } catch (Exception ex) { Plugin.LogOnce("char-" + field, "Character." + field + " not found (" + ex.Message + "); body yaw split is off."); return null; } } } internal static class SelfEffects { private sealed class Entry { public Renderer Renderer; public bool SavedForceOff; public bool Applied; } private static readonly List<Entry> Candidates = new List<Entry>(); private static readonly List<Renderer> Scratch = new List<Renderer>(); private static Player scannedPlayer; private static float nextScan; private static bool hooked; private static Vector3 eye; private static bool active; public static void Install(Harmony harmony) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown VePatches.TryPatch(harmony, "own-damage-numbers", AccessTools.Method(typeof(DamageText), "AddInworldText", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SelfEffects), "AddInworldTextPrefix", (Type[])null), null); if (!hooked) { Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnPostRender)); hooked = true; } } private static bool AddInworldTextPrefix(TextType type, Vector3 pos, bool mySelf) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) if (!VeConfig.Enabled.Value || !VeConfig.HideOwnDamageNumbers.Value) { return true; } CameraRig instance = CameraRig.Instance; if (instance == null || instance.FirstPersonWeight < 0.5f) { return true; } if (mySelf && (int)type != 7) { return false; } if (((int)type == 6 || (int)type == 5) && (Object)(object)Player.m_localPlayer != (Object)null) { Vector3 val = ((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.3f; Vector3 val2 = pos - val; if (((Vector3)(ref val2)).sqrMagnitude < 1.44f) { return false; } } return true; } public static void Tick(CameraRig rig, Player player) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) active = false; if (!((Object)(object)player == (Object)null) && rig != null && VeConfig.Enabled.Value && VeConfig.HideOwnEffectsNearEyes.Value && !(rig.FirstPersonWeight < 0.5f) && !rig.CalibrationViewActive) { eye = rig.CameraWorldPosition; active = true; if ((Object)(object)player != (Object)(object)scannedPlayer || Time.time >= nextScan) { Rescan(player); } } } private static void Rescan(Player player) { RestoreAll(); scannedPlayer = player; nextScan = Time.time + 0.5f; Candidates.Clear(); Transform transform = ((Component)player).transform; GameObject visual = ((Character)player).GetVisual(); Transform val = (((Object)(object)visual != (Object)null) ? visual.transform : null); for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if ((Object)(object)child == (Object)(object)val || (Object)(object)child == (Object)(object)((Character)player).m_eye) { continue; } Scratch.Clear(); ((Component)child).GetComponentsInChildren<Renderer>(false, Scratch); for (int j = 0; j < Scratch.Count; j++) { Renderer val2 = Scratch[j]; if (!((Object)(object)val2 == (Object)null)) { Candidates.Add(new Entry { Renderer = val2 }); } } } } private static bool IsMainCamera(Camera camera) { GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null && (Object)(object)camera != (Object)null) { return (Object)(object)((Component)camera).gameObject == (Object)(object)((Component)instance).gameObject; } return false; } private static void OnPreCull(Camera camera) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!active || !IsMainCamera(camera)) { return; } float num = Mathf.Clamp(VeConfig.OwnEffectHideRadius.Value, 0.1f, 3f); float num2 = num * num; for (int i = 0; i < Candidates.Count; i++) { Entry entry = Candidates[i]; Renderer renderer = entry.Renderer; if (!((Object)(object)renderer == (Object)null) && !entry.Applied) { Bounds bounds = renderer.bounds; if (!(((Bounds)(ref bounds)).SqrDistance(eye) > num2)) { entry.SavedForceOff = renderer.forceRenderingOff; renderer.forceRenderingOff = true; entry.Applied = true; } } } } private static void OnPostRender(Camera camera) { if (IsMainCamera(camera)) { RestoreAll(); } } private static void RestoreAll() { for (int i = 0; i < Candidates.Count; i++) { Entry entry = Candidates[i]; if (entry.Applied) { entry.Applied = false; if ((Object)(object)entry.Renderer != (Object)null) { entry.Renderer.forceRenderingOff = entry.SavedForceOff; } } } } public static void Uninstall() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown RestoreAll(); Candidates.Clear(); if (hooked) { Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnPostRender)); hooked = false; } } } internal sealed class WeaponHold { private enum Mode { Off, Aimed, PositionOnly, Follow } private enum Aim { None, Weapon, TwoHand, Tool, Torch } private sealed class ItemAxis { public GameObject Instance; public Transform Root; public bool Valid; public Vector3 InHand; public float Elongation; public Vector3 ReachLocal; public float Length; public void Reset() { Instance = null; Root = null; Valid = false; Elongation = 0f; Length = 0f; } } private sealed class ShieldShape { public GameObject Instance; public Transform Root; public bool Valid; public Vector3 Min; public Vector3 Max; public void Reset() { Instance = null; Root = null; Valid = false; } } private sealed class Arm { public float Side; public readonly BoneTweak Upper = new BoneTweak(); public readonly BoneTweak Lower = new BoneTweak(); public readonly BoneTweak Hand = new BoneTweak(); public Mode WantMode; public Aim WantAim; public string WantKind = "off"; public Mode Mode; public Aim Aim; public string Kind = "off"; public GameObject Instance; public bool ItemInLeft; public bool Leaving; public Spring1 Blend; public float SinceAdopt = 10f; public float Weight; public readonly ItemAxis Axis = new ItemAxis(); public readonly ShieldShape Shield = new ShieldShape(); public Vector3 ShieldShift; public bool HingeKnown; public Vector3 HingeInUpper; public Vector3 AnimHand; public Quaternion AnimHandRotation; public float AnimReach; public bool Valid { get { if ((Object)(object)Upper.Bone != (Object)null && (Object)(object)Lower.Bone != (Object)null) { return (Object)(object)Hand.Bone != (Object)null; } return false; } } public void Clear() { //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) WantMode = (Mode = Mode.Off); WantAim = (Aim = Aim.None); WantKind = (Kind = "off"); Instance = null; ItemInLeft = false; Leaving = false; Blend.Reset(0f); SinceAdopt = 10f; Weight = 0f; Axis.Reset(); Shield.Reset(); ShieldShift = Vector3.zero; HingeKnown = false; } } private const string KindOff = "off"; private const string KindRanged = "ranged"; private const string KindWeapon = "weapon"; private const string KindTwoHanded = "two-handed"; private const string KindTool = "tool"; private const string KindTorch = "torch"; private const string KindFist = "fist"; private const string KindShield = "shield"; private const string KindGrip = "grip"; private const string KindGuard = "guard"; private const float HingeMinSine = 0.02f; private const float CameraHandoverStart = 0.99f; private const float GripReleaseMargin = 0.1f; private const float ShieldPlacedWeight = 0.25f; public float Weight; public string RightKind = "off"; public string LeftKind = "off"; private readonly Arm right = new Arm { Side = 1f }; private readonly Arm left = new Arm { Side = -1f }; private bool planItemInLeft; private bool handsTogether; private Spring1 blend; private Spring1 guard; private float sinceBusy = 10f; private int shieldFrame = -1; public float ShieldDrop; public bool ShieldArmShort; private static readonly List<Renderer> ScratchRenderers = new List<Renderer>(); public bool ShieldPlaced => shieldFrame == Time.frameCount; public bool Active => Weight > 0.001f; public void AddTweaks(List<BoneTweak> into) { into.Add(right.Upper); into.Add(right.Lower); into.Add(right.Hand); into.Add(left.Upper); into.Add(left.Lower); into.Add(left.Hand); } public void Bind(PlayerBones bones) { right.Upper.Reset(bones?.RightUpperArm); right.Lower.Reset(bones?.RightLowerArm); right.Hand.Reset(bones?.RightHand); left.Upper.Reset(bones?.LeftUpperArm); left.Lower.Reset(bones?.LeftLowerArm); left.Hand.Reset(bones?.LeftHand); right.Clear(); left.Clear(); planItemInLeft = false; handsTogether = false; blend.Reset(0f); guard.Reset(0f); sinceBusy = 10f; shieldFrame = -1; ShieldDrop = 0f; ShieldArmShort = false; Weight = 0f; RightKind = (LeftKind = "off"); } public void Apply(CameraRig rig, Player player, ItemData rightItem, ItemData leftItem, GameObject rightInstance, GameObject leftInstance, Vector3 eyeCarry, float firstPersonWeight, float yaw, float pitch, float swayYaw, float swayPitch, float dt) { //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: 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_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: 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_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) Capture(right); Capture(left); UpdateHandsTogether(); Plan(rightItem, leftItem); bool flag = IsBusy(player); sinceBusy = (flag ? 0f : Mathf.Min(sinceBusy + dt, 10f)); float num = Mathf.Max(0f, WeaponHoldConfig.HoldReturnDelay.Value); float num2 = Mathf.Clamp(WeaponHoldConfig.HoldOutHz.Value, 1f, 60f); float num3 = Mathf.Clamp(WeaponHoldConfig.HoldInHz.Value, 0.5f, 30f); float target = ((!(sinceBusy >= num)) ? 0f : (((Character)player).IsRunning() ? Mathf.Clamp01(WeaponHoldConfig.HoldWhileRunning.Value) : 1f)); blend.Step(target, flag ? num2 : num3, 1f, dt); float shared = Mathf.Clamp01(blend.Value) * Mathf.Clamp01(VeConfig.ReadyPose.Value) * Mathf.Clamp01(firstPersonWeight); Transition(right, planItemInLeft ? leftInstance : rightInstance, planItemInLeft, shared, num, num2, num3, dt); Transition(left, leftInstance, itemInLeft: false, shared, num, num2, num3, dt); int num4; int num5; if (left.Mode == Mode.PositionOnly && left.Kind == "shield" && left.Valid) { num4 = ((!left.Leaving) ? 1 : 0); if (num4 != 0 && WeaponHoldConfig.BlockGuard.Value && ((Character)player).IsBlocking()) { num5 = ((!IsBusyBesidesBlocking(player)) ? 1 : 0); goto IL_01ae; } } else { num4 = 0; } num5 = 0; goto IL_01ae; IL_01ae: bool flag2 = (byte)num5 != 0; guard.Step(flag2 ? 1f : 0f, Mathf.Clamp(flag2 ? WeaponHoldConfig.GuardInHz.Value : WeaponHoldConfig.GuardOutHz.Value, 1f, 60f), 1f, dt); float num6 = ((num4 != 0) ? Mathf.Clamp01(guard.Value) : 0f); float num7 = num6 * Mathf.Clamp01(left.Blend.Value) * Mathf.Clamp01(VeConfig.ReadyPose.Value) * Mathf.Clamp01(firstPersonWeight); left.Weight = Mathf.Max(left.Weight, num7); RightKind = right.Kind; LeftKind = ((num6 > 0.5f) ? "guard" : left.Kind); Weight = Mathf.Max(right.Weight, left.Weight); if (Weight <= 0.001f) { return; } Vector3 eye = EyePosition(rig, player, eyeCarry); Quaternion frame = Quaternion.Euler(pitch * Mathf.Clamp01(WeaponHoldConfig.HoldPitchFollow.Value), yaw, 0f) * Quaternion.Euler(swayPitch, swayYaw, 0f); bool flag3 = right.Valid && left.Valid; Vector3 gripOffset = Vector3.zero; Quaternion val = Quaternion.identity; if (flag3) { Quaternion val2 = Quaternion.Inverse(right.AnimHandRotation); gripOffset = val2 * (left.AnimHand - right.AnimHand); val = val2 * left.AnimHandRotation; } float num8 = Mathf.Max(1f, WeaponHoldConfig.AimMinElongation.Value); if (right.Weight > 0.001f) { ItemAxis axis = right.Axis; if (!right.Leaving) { RefreshAxis(axis, right.ItemInLeft ? left.Hand.Bone : right.Hand.Bone, right.Instance); } bool aimable = axis.Valid && axis.Elongation >= num8 && (!right.ItemInLeft || flag3); Vector3 axisInHand = (right.ItemInLeft ? (val * axis.InHand) : axis.InHand); Vector3 local = ((right.Aim == Aim.Torch) ? TorchTarget(1f) : RightTarget()); SolveHand(right, eye, local, frame, axisInHand, aimable); } if (!(left.Weight > 0.001f)) { return; } if (left.Mode == Mode.Follow) { if (flag3) { FollowGrip(left, right, gripOffset, val, frame); } return; } ItemAxis axis2 = left.Axis; if (left.Mode == Mode.Aimed && !left.Leaving) { RefreshAxis(axis2, left.Hand.Bone, left.Instance); } bool aimable2 = axis2.Valid && axis2.Elongation >= num8; Vector3 val3 = ((left.Aim == Aim.Torch) ? TorchTarget(-1f) : LeftTarget()); if (num6 > 0f) { val3 = Vector3.Lerp(val3, GuardTarget(), num6); } if (left.Mode == Mode.PositionOnly && left.Kind == "shield") { val3 = ShieldTarget(left, eye, frame, val3, pitch, yaw, num6); } SolveHand(left, eye, val3, frame, axis2.InHand, aimable2); } private void UpdateHandsTogether() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!right.Valid || !left.Valid) { handsTogether = false; return; } float num = Mathf.Max(0.05f, WeaponHoldConfig.TwoHandGripSpread.Value) + (handsTogether ? 0.1f : 0f); Vector3 val = left.AnimHand - right.AnimHand; handsTogether = ((Vector3)(ref val)).sqrMagnitude < num * num; } private void Plan(ItemData rightItem, ItemData leftItem) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Invalid comparison between Unknown and I4 //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Invalid comparison between Unknown and I4 //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Invalid comparison between Unknown and I4 //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Invalid comparison between Unknown and I4 //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Invalid comparison between Unknown and I4 right.WantMode = (left.WantMode = Mode.Off); right.WantAim = (left.WantAim = Aim.None); right.WantKind = (left.WantKind = "off"); planItemInLeft = false; SharedData val = rightItem?.m_shared; SharedData val2 = leftItem?.m_shared; if (IsRanged(val) || IsRanged(val2)) { right.WantKind = (left.WantKind = "ranged"); return; } if (val2 != null && (int)val2.m_itemType == 22) { bool flag = IsTool(val2); if (IsStaff(val2) || !handsTogether) { SetLeft(Mode.Aimed, (!flag) ? Aim.Weapon : Aim.Tool, flag ? "tool" : "weapon"); return; } SetRight(Mode.Aimed, flag ? Aim.Tool : Aim.TwoHand, "two-handed"); SetLeft(Mode.Follow, Aim.None, "grip"); planItemInLeft = true; return; } bool flag2 = false; if (val == null || (int)val.m_skillType == 11) { flag2 = WeaponHoldConfig.HoldUnarmed.Value; if (flag2) { SetRight(Mode.PositionOnly, Aim.None, "fist"); } } else if ((int)val.m_itemType == 15) { SetRight(Mode.Aimed, Aim.Torch, "torch"); } else if (IsStaff(val)) { SetRight(Mode.Aimed, Aim.Weapon, "weapon"); } else { if (IsTwoHanded(val)) { SetRight(Mode.Aimed, IsTool(val) ? Aim.Tool : Aim.TwoHand, "two-handed"); if (handsTogether) { SetLeft(Mode.Follow, Aim.None, "grip"); } return; } if (IsTool(val)) { SetRight(Mode.Aimed, Aim.Tool, "tool"); } else { SetRight(Mode.Aimed, Aim.Weapon, "weapon"); } } if (val2 != null && (int)val2.m_itemType == 5) { SetLeft(Mode.PositionOnly, Aim.None, "shield"); } else if (val2 != null && (int)val2.m_itemType == 15) { SetLeft(Mode.Aimed, Aim.Torch, "torch"); } else if (val2 == null && flag2) { SetLeft(Mode.PositionOnly, Aim.None, "fist"); } } private void SetRight(Mode mode, Aim aim, string kind) { right.WantMode = mode; right.WantAim = aim; right.WantKind = kind; } private void SetLeft(Mode mode, Aim aim, string kind) { left.WantMode = mode; left.WantAim = aim; left.WantKind = kind; } private static void Transition(Arm arm, GameObject instance, bool itemInLeft, float shared, float delay, float outHz, float inHz, float dt) { bool flag = arm.WantMode != arm.Mode || arm.WantAim != arm.Aim || itemInLeft != arm.ItemInLeft || (arm.WantMode != Mode.Off && instance != arm.Instance); bool flag2 = arm.Mode != Mode.Off && arm.Valid && Mathf.Clamp01(arm.Blend.Value) * shared > 0.001f; if (flag && !flag2) { arm.Mode = arm.WantMode; arm.Aim = arm.WantAim; arm.Instance = instance; arm.ItemInLeft = itemInLeft; if (shared > 0.001f) { arm.Blend.Reset(0f); arm.SinceAdopt = 0f; } else { arm.Blend.Reset(1f); arm.SinceAdopt = 10f; } flag = false; } arm.Leaving = flag; if (flag) { arm.Blend.Step(0f, outHz, 1f, dt); } else { arm.Kind = arm.WantKind; arm.SinceAdopt = Mathf.Min(arm.SinceAdopt + dt, 10f); float num = ((arm.SinceAdopt >= delay) ? 1f : 0f); arm.Blend.Step(num, (num < arm.Blend.Value) ? outHz : inHz, 1f, dt); } arm.Weight = ((arm.Mode != Mode.Off && arm.Valid) ? (Mathf.Clamp01(arm.Blend.Value) * shared) : 0f); } private static bool IsRanged(SharedData shared) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 if (shared != null) { if ((int)shared.m_itemType != 4 && (int)shared.m_animationState != 3 && (int)shared.m_animationState != 10 && (int)shared.m_skillType != 8) { return (int)shared.m_skillType == 14; } return true; } return false; } private static bool IsStaff(SharedData shared) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if ((int)shared.m_animationState != 12 && (int)shared.m_skillType != 9) { return (int)shared.m_skillType == 10; } return true; } private static bool IsTwoHanded(SharedData shared) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0017: 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_001b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected I4, but got Unknown if ((int)shared.m_itemType == 14) { return true; } AnimationState animationState = shared.m_animationState; if ((int)animationState != 2 && animationState - 7 > 1) { switch (animationState - 13) { case 0: case 2: case 4: break; default: return false; } } return true; } private static bool IsTool(SharedData shared) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if ((int)shared.m_itemType != 19 && (int)shared.m_skillType != 12) { return (int)shared.m_animationState == 9; } return true; } private static bool IsBusy(Player player) { if (!((Character)player).IsBlocking()) { return IsBusyBesidesBlocking(player); } return true; } private static bool IsBusyBesidesBlocking(Player player) { if (!((Character)player).InAttack() && !((Character)player).IsDrawingBow() && !((Character)player).InPlaceMode() && !((Character)player).IsStaggering() && !((Character)player).InMinorAction() && !((Character)player).IsAttached() && !((Character)player).IsSitting() && !((Character)player).IsSwimming() && !((Character)player).InDodge() && !((Character)player).IsDead() && !((Character)player).InBed() && !((Character)player).InEmote()) { return Compat.IsClimbing(player); } return true; } private static Vector3 EyePosition(CameraRig rig, Player player, Vector3 eyeCarry) { //IL_0021: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: 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_00c9: 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_00c5: Unknown result type (might be due to invalid IL or missing references) Quaternion val = (((Object)(object)((Character)player).m_eye != (Object)null) ? ((Character)player).m_eye.rotation : ((Component)player).transform.rotation); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, Mathf.Clamp(VeConfig.NeckPivotBelow.Value, 0f, 0.3f), Mathf.Clamp(VeConfig.NeckPivotBehind.Value, 0f, 0.3f)); Vector3 val3 = rig.NeckPivotWorld + val * val2 + Vector3.up * rig.LiftApplied; if (FeelMath.IsFinite(eyeCarry)) { val3 += Vector3.ClampMagnitude(eyeCarry, 0.4f); } float num = FeelMath.SmoothStep01(0.99f, 1f, rig.FirstPersonWeight); if (!(num > 0f)) { return val3; } return Vector3.Lerp(val3, rig.CameraWorldPosition, num); } private static Vector3 RightTarget() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return new Vector3(WeaponHoldConfig.RightHandX.Value, WeaponHoldConfig.RightHandY.Value, WeaponHoldConfig.RightHandZ.Value); } private static Vector3 LeftTarget() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return new Vector3(WeaponHoldConfig.LeftHandX.Value, WeaponHoldConfig.LeftHandY.Value, WeaponHoldConfig.LeftHandZ.Value); } private static Vector3 GuardTarget() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return new Vector3(WeaponHoldConfig.GuardX.Value, WeaponHoldConfig.GuardY.Value, WeaponHoldConfig.GuardZ.Value); } private static Vector3 TorchTarget(float side) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) return new Vector3(side * WeaponHoldConfig.TorchX.Value, WeaponHoldConfig.TorchY.Value, WeaponHoldConfig.TorchZ.Value); } private static Vector3 AimDirection(Aim aim, float side, Vector3 hand, float length) { //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_00ac: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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) float value2; float value; switch (aim) { case Aim.TwoHand: value = WeaponHoldConfig.TwoHandAimUp.Value; value2 = WeaponHoldConfig.TwoHandAimInward.Value; break; case Aim.Tool: value = WeaponHoldConfig.ToolAimUp.Value; value2 = WeaponHoldConfig.ToolAimInward.Value; break; case Aim.Torch: value = WeaponHoldConfig.TorchAimUp.Value; value2 = WeaponHoldConfig.TorchAimInward.Value; break; default: value = WeaponHoldConfig.WeaponAimUp.Value; value2 = WeaponHoldConfig.WeaponAimInward.Value; break; } value = Mathf.Clamp(value, 0f, 90f); if (aim != Aim.Torch && length > 0.05f) { value = Mathf.Min(value, HighestRaise(hand, length, value2)); } Vector3 val = Quaternion.AngleAxis(0f - value, Vector3.right) * Vector3.forward; return Quaternion.AngleAxis(value2 * side, Vector3.forward) * val; } private static float HighestRaise(Vector3 hand, float length, float inward) { //IL_0047: 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) float num = Mathf.Tan(Mathf.Clamp(WeaponHoldConfig.AimTipBelowEyes.Value, -60f, 60f) * ((float)Math.PI / 180f)); float num2 = length * Mathf.Cos(Mathf.Clamp(inward, -89f, 89f) * ((float)Math.PI / 180f)); float num3 = num * length; float num4 = 0f - hand.y - num * hand.z; float num5 = Mathf.Sqrt(num2 * num2 + num3 * num3); if (num5 < 1E-05f) { return 90f; } float num6 = num4 / num5; if (num6 >= 1f) { return 90f; } if (num6 <= -1f) { return 0f; } return Mathf.Clamp((Mathf.Asin(num6) - Mathf.Atan2(num3, num2)) * 57.29578f, 0f, 90f); } private Vector3 ShieldTarget(Arm arm, Vector3 eye, Quaternion frame, Vector3 local, float pitch, float yaw, float guardMix) { //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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (!WeaponHoldConfig.ShieldClearance.Value) { arm.ShieldShift = Vector3.zero; return local; } if (!arm.Leaving) { arm.ShieldShift = Vector3.zero; RefreshShield(arm.Shield, arm.Hand.Bone, arm.Instance); if (arm.Shield.Valid && (Object)(object)arm.Shield.Root != (Object)null) { float num = Mathf.Lerp(WeaponHoldConfig.ShieldRestRimBelowEyes.Value, WeaponHoldConfig.ShieldRimBelowEyes.Value, guardMix); float num2 = Mathf.Clamp(WeaponHoldConfig.ShieldClearLookDown.Value, 0f, 89f); Quaternion sight = Quaternion.Euler(Mathf.Min(pitch, num2), yaw, 0f); float minForward = Mathf.Clamp(WeaponHoldConfig.ShieldGuardMinForward.Value, 0f, 0.6f) * guardMix; bool armShort; Vector3 val = ClearRim(arm, eye, frame, sight, local, Mathf.Clamp(num, -30f, 60f), minForward, out armShort); if (FeelMath.IsFinite(val)) { arm.ShieldShift = val - local; } ShieldDrop = ((Vector3)(ref arm.ShieldShift)).magnitude; ShieldArmShort = armShort; if (arm.Weight >= 0.25f) { shieldFrame = Time.frameCount; } } } return local + arm.ShieldShift; } private static Vector3 ClearRim(Arm arm, Vector3 eye, Quaternion frame, Quaternion sight, Vector3 local, float below, float minForward, out bool armShort) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Vector3 n; float c; Vector3 s; float reach; return KeepInFront(ClearRimUnbounded(arm, eye, frame, sight, local, below, out armShort, out n, out c, out s, out reach), local, s, reach, n, c, minForward, ref armShort); } private static Vector3 KeepInFront(Vector3 p, Vector3 local, Vector3 s, float reach, Vector3 n, float c, float minForward, ref bool armShort) { //IL_0013: 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_0017: 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_003e: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_00c8: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00f4: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0111: 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_0180: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_013a: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_0207: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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_022a: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown resul