Decompiled source of OpenScripts2 v2.10.0
plugins/OpenScripts2.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FistVR; using HarmonyLib; using IL; using IL.FistVR; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On; using On.FistVR; using OpenScripts2; using Popcron; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Serialization; using UnityEngine.UI; using Valve.VR; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("OpenScripts2")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OpenScripts2")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("db04f669-7223-4552-9745-c06832a51db2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace System.Collections.Generic { public static class CSharpExtensions { public static string ToCSV<T>(this IEnumerable<T> enumerable) { if (enumerable == null || !enumerable.Any()) { return string.Empty; } return string.Join(",", enumerable.Select((T item) => item.ToString()).ToArray()); } public static void AddOrReplace<T, U>(this Dictionary<T, U> dic, T key, U value) { if (!dic.ContainsKey(key)) { dic.Add(key, value); } else { dic[key] = value; } } } } namespace UnityEngine { public static class UnityEngineExtensions { public static T GetComponentInDirectChildren<T>(this Component parent) where T : Component { return parent.GetComponentInDirectChildren<T>(includeInactive: false); } public static T GetComponentInDirectChildren<T>(this Component parent, bool includeInactive) where T : Component { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown foreach (Transform item in parent.transform) { Transform val = item; if (includeInactive || ((Component)val).gameObject.activeInHierarchy) { T component = ((Component)val).GetComponent<T>(); if ((Object)(object)component != (Object)null) { return component; } } } return default(T); } public static T[] GetComponentsInDirectChildren<T>(this Component parent) where T : Component { return parent.GetComponentsInDirectChildren<T>(includeInactive: false); } public static T[] GetComponentsInDirectChildren<T>(this Component parent, bool includeInactive) where T : Component { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown List<T> list = new List<T>(); foreach (Transform item in parent.transform) { Transform val = item; if (includeInactive || ((Component)val).gameObject.activeInHierarchy) { list.AddRange(((Component)val).GetComponents<T>()); } } return list.ToArray(); } public static T GetComponentInSiblings<T>(this Component sibling) where T : Component { return sibling.GetComponentInSiblings<T>(includeInactive: false); } public static T GetComponentInSiblings<T>(this Component sibling, bool includeInactive) where T : Component { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Transform parent = sibling.transform.parent; if ((Object)(object)parent == (Object)null) { return default(T); } foreach (Transform item in parent) { Transform val = item; if ((includeInactive || ((Component)val).gameObject.activeInHierarchy) && (Object)(object)val != (Object)(object)sibling) { T component = ((Component)val).GetComponent<T>(); if ((Object)(object)component != (Object)null) { return component; } } } return default(T); } public static T[] GetComponentsInSiblings<T>(this Component sibling) where T : Component { return sibling.GetComponentsInSiblings<T>(includeInactive: false); } public static T[] GetComponentsInSiblings<T>(this Component sibling, bool includeInactive) where T : Component { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown Transform parent = sibling.transform.parent; if ((Object)(object)parent == (Object)null) { return null; } List<T> list = new List<T>(); foreach (Transform item in parent) { Transform val = item; if ((includeInactive || ((Component)val).gameObject.activeInHierarchy) && (Object)(object)val != (Object)(object)sibling) { list.AddRange(((Component)val).GetComponents<T>()); } } return list.ToArray(); } public static T GetComponentInDirectParent<T>(this Component child) where T : Component { Transform parent = child.transform.parent; if ((Object)(object)parent == (Object)null) { return default(T); } return ((Component)parent).GetComponent<T>(); } public static T[] GetComponentsInDirectParent<T>(this Component child) where T : Component { Transform parent = child.transform.parent; if ((Object)(object)parent == (Object)null) { return null; } return ((Component)parent).GetComponents<T>(); } public static bool TryGetComponent<T>(this Component mainComponent, out T foundComponent) where T : Component { foundComponent = mainComponent.GetComponent<T>(); return (Object)(object)foundComponent != (Object)null; } public static bool TryGetComponentInChildren<T>(this Component mainComponent, out T foundComponent) where T : Component { foundComponent = mainComponent.GetComponentInChildren<T>(); return (Object)(object)foundComponent != (Object)null; } public static bool TryGetComponentInParent<T>(this Component mainComponent, out T foundComponent) where T : Component { foundComponent = mainComponent.GetComponentInParent<T>(); return (Object)(object)foundComponent != (Object)null; } public static bool TryGetComponents<T>(this Component mainComponent, out T[] foundComponent) where T : Component { foundComponent = mainComponent.GetComponents<T>(); return foundComponent != null; } public static bool TryGetComponentsInChildren<T>(this Component mainComponent, out T[] foundComponent) where T : Component { foundComponent = mainComponent.GetComponentsInChildren<T>(); return foundComponent != null; } public static bool TryGetComponentsInParent<T>(this Component mainComponent, out T[] foundComponent) where T : Component { foundComponent = mainComponent.GetComponentsInParent<T>(); return foundComponent != null; } public static bool TryGetComponent<T>(this GameObject mainComponent, out T foundComponent) where T : Component { foundComponent = mainComponent.GetComponent<T>(); return (Object)(object)foundComponent != (Object)null; } public static bool TryGetComponentInChildren<T>(this GameObject mainComponent, out T foundComponent) where T : Component { foundComponent = mainComponent.GetComponentInChildren<T>(); return (Object)(object)foundComponent != (Object)null; } public static bool TryGetComponentInParent<T>(this GameObject mainComponent, out T foundComponent) where T : Component { foundComponent = mainComponent.GetComponentInParent<T>(); return (Object)(object)foundComponent != (Object)null; } public static bool TryGetComponents<T>(this GameObject mainComponent, out T[] foundComponent) where T : Component { foundComponent = mainComponent.GetComponents<T>(); return foundComponent != null; } public static bool TryGetComponentsInChildren<T>(this GameObject mainComponent, out T[] foundComponent) where T : Component { foundComponent = mainComponent.GetComponentsInChildren<T>(); return foundComponent != null; } public static bool TryGetComponentsInParent<T>(this GameObject mainComponent, out T[] foundComponent) where T : Component { foundComponent = mainComponent.GetComponentsInParent<T>(); return foundComponent != null; } public static bool IsGreaterThan(this Vector3 local, Vector3 other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (local.x > other.x && local.y > other.y && local.z > other.z) { return true; } return false; } public static bool IsGreaterThanOrEqual(this Vector3 local, Vector3 other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (local.x >= other.x && local.y >= other.y && local.z >= other.z) { return true; } return false; } public static bool IsLessThan(this Vector3 local, Vector3 other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (local.x < other.x && local.y < other.y && local.z < other.z) { return true; } return false; } public static bool IsLessThanOrEqual(this Vector3 local, Vector3 other) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (local.x <= other.x && local.y <= other.y && local.z <= other.z) { return true; } return false; } public static Vector3 Clamp(this Vector3 vector, Vector3 vA, Vector3 vB) { //IL_0002: 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_000e: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) vector.x = Mathf.Clamp(vector.x, vA.x, vB.x); vector.y = Mathf.Clamp(vector.y, vA.y, vB.y); vector.z = Mathf.Clamp(vector.z, vA.z, vB.z); return vector; } public static Vector3 ProjectOnPlaneThroughPoint(this Vector3 vector, Vector3 point, Vector3 planeNormal) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return Vector3.ProjectOnPlane(vector, planeNormal) + Vector3.Dot(point, planeNormal) * planeNormal; } public static Vector3 GetLocalDirAxis(this Transform transform, OpenScripts2_BasePlugin.Axis axis) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) return (Vector3)(axis switch { OpenScripts2_BasePlugin.Axis.X => transform.right, OpenScripts2_BasePlugin.Axis.Y => transform.up, OpenScripts2_BasePlugin.Axis.Z => transform.forward, _ => Vector3.zero, }); } public static float GetLocalPositionAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis) { //IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references) return axis switch { OpenScripts2_BasePlugin.Axis.X => transform.localPosition.x, OpenScripts2_BasePlugin.Axis.Y => transform.localPosition.y, OpenScripts2_BasePlugin.Axis.Z => transform.localPosition.z, _ => 0f, }; } public static float GetLocalScaleAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis) { //IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references) return axis switch { OpenScripts2_BasePlugin.Axis.X => transform.localScale.x, OpenScripts2_BasePlugin.Axis.Y => transform.localScale.y, OpenScripts2_BasePlugin.Axis.Z => transform.localScale.z, _ => 0f, }; } public static float GetAxisValue(this Vector3 vector, OpenScripts2_BasePlugin.Axis axis) { return ((Vector3)(ref vector))[(int)axis]; } public static Vector3 GetAxisVector(this Vector3 vector, OpenScripts2_BasePlugin.Axis axis) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0045: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; switch (axis) { case OpenScripts2_BasePlugin.Axis.X: zero.x = vector.x; break; case OpenScripts2_BasePlugin.Axis.Y: zero.y = vector.y; break; case OpenScripts2_BasePlugin.Axis.Z: zero.z = vector.z; break; } return zero; } public static Vector3 GetCombinedAxisVector(this Vector3 vector, OpenScripts2_BasePlugin.Axis axis, Vector3 other) { //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_0018: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Vector3 result = other; switch (axis) { case OpenScripts2_BasePlugin.Axis.X: result.x = vector.x; break; case OpenScripts2_BasePlugin.Axis.Y: result.y = vector.y; break; case OpenScripts2_BasePlugin.Axis.Z: result.z = vector.z; break; } return result; } public static float GetAxisValue(this Quaternion quaternion, OpenScripts2_BasePlugin.Axis axis) { //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) Vector3 eulerAngles = ((Quaternion)(ref quaternion)).eulerAngles; return ((Vector3)(ref eulerAngles))[(int)axis]; } public static Vector3 ModifyAxisValue(this Vector3 vector, OpenScripts2_BasePlugin.Axis axis, float value) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref vector))[(int)axis] = value; return vector; } public static Vector3 RemoveAxisValue(this Vector3 vector, OpenScripts2_BasePlugin.Axis axis) { //IL_0000: 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) return vector.ModifyAxisValue(axis, 0f); } public static void ModifyLocalTransform(this Transform transform, OpenScripts2_BasePlugin.TransformType type, OpenScripts2_BasePlugin.Axis axis, float value) { switch (type) { case OpenScripts2_BasePlugin.TransformType.Movement: transform.ModifyLocalPositionAxisValue(axis, value); break; case OpenScripts2_BasePlugin.TransformType.Rotation: transform.ModifyLocalRotationAxisValue(axis, value); break; case OpenScripts2_BasePlugin.TransformType.Scale: transform.ModifyLocalScaleAxisValue(axis, value); break; } } public static void ModifyPositionAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = transform.position; ((Vector3)(ref position))[(int)axis] = value; if (VectorsNotEqual(transform.position, position)) { transform.position = position; } } public static void ModifyLocalPositionAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 localPosition = transform.localPosition; ((Vector3)(ref localPosition))[(int)axis] = value; if (VectorsNotEqual(transform.localPosition, localPosition)) { transform.localPosition = localPosition; } } public static void ModifyRotationAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0028: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; ((Vector3)(ref eulerAngles))[(int)axis] = value; if (axis == OpenScripts2_BasePlugin.Axis.X && eulerAngles.y >= 179f && eulerAngles.z >= 179f) { eulerAngles.y -= 180f; eulerAngles.z -= 180f; } if (QuaternionsNotEqual(transform.rotation, Quaternion.Euler(eulerAngles))) { transform.rotation = Quaternion.Euler(eulerAngles); } } public static void ModifyLocalRotationAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0028: Unknown result type (might be due to invalid IL or missing references) Quaternion localRotation = transform.localRotation; Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles; ((Vector3)(ref eulerAngles))[(int)axis] = value; if (axis == OpenScripts2_BasePlugin.Axis.X && eulerAngles.y >= 179f && eulerAngles.z >= 179f) { eulerAngles.y -= 180f; eulerAngles.z -= 180f; } if (QuaternionsNotEqual(transform.localRotation, Quaternion.Euler(eulerAngles))) { transform.localRotation = Quaternion.Euler(eulerAngles); } } public static void ModifyLocalScaleAxisValue(this Transform transform, OpenScripts2_BasePlugin.Axis axis, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = transform.localScale; ((Vector3)(ref localScale))[(int)axis] = value; if (VectorsNotEqual(transform.localScale, localScale)) { transform.localScale = localScale; } } public static void GoToTransformProxy(this Transform transform, TransformProxy proxy) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) transform.position = proxy.position; transform.rotation = proxy.rotation; transform.localScale = proxy.localScale; } public static Quaternion TransformRotation(this Transform transform, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return transform.rotation * rot; } public static Quaternion InverseTransformRotation(this Transform transform, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Inverse(transform.rotation) * rot; } public static Vector3 MultiplyComponentWise(this Vector3 v1, Vector3 v2) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) float num = v1.x * v2.x; float num2 = v1.y * v2.y; float num3 = v1.z * v2.z; return new Vector3(num, num2, num3); } public static Vector3 ApproximateInfiniteComponent(this Vector3 v1, float infinityApproximation) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = v1; if (float.IsInfinity(val.x)) { val.x = (float.IsPositiveInfinity(val.x) ? infinityApproximation : (0f - infinityApproximation)); } if (float.IsInfinity(val.y)) { val.y = (float.IsPositiveInfinity(val.y) ? infinityApproximation : (0f - infinityApproximation)); } if (float.IsInfinity(val.z)) { val.z = (float.IsPositiveInfinity(val.z) ? infinityApproximation : (0f - infinityApproximation)); } return val; } public static Quaternion Subtract(this Quaternion a, Quaternion 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) return a * Quaternion.Inverse(b); } public static bool VectorsNotEqual(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) bool flag = a.x != b.x; bool flag2 = a.y != b.y; bool flag3 = a.z != b.z; return flag || flag2 || flag3; } public static bool QuaternionsNotEqual(Quaternion a, Quaternion b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) bool flag = a.x != b.x; bool flag2 = a.y != b.y; bool flag3 = a.z != b.z; bool flag4 = a.w != b.w; return flag || flag2 || flag3 || flag4; } } } namespace FistVR { public class ClosedBoltRotatingChargingHandle : FVRInteractiveObject { public enum Placement { Forward, Middle, Rearward } [Header("Closed Bolt Rotating Charging Handle")] public Transform Handle; public Transform ReferenceVector; public float RotLimit; public ClosedBolt Bolt; public float ForwardSpeed = 360f; private float m_currentHandleZ; private Placement m_curPos; private Placement m_lastPos; public override void Awake() { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).Awake(); m_currentHandleZ = RotLimit; Vector3 val = Quaternion.AngleAxis(m_currentHandleZ, ReferenceVector.up) * ReferenceVector.forward; Handle.rotation = Quaternion.LookRotation(val, ReferenceVector.up); } public override void UpdateInteraction(FVRViveHand hand) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0091: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).UpdateInteraction(hand); Vector3 val = Vector3.ProjectOnPlane(((HandInput)(ref hand.Input)).Pos - ((Component)Handle).transform.position, ReferenceVector.up); Vector3 v = Vector3.RotateTowards(ReferenceVector.forward, val, (float)Math.PI / 180f * RotLimit, 1f); float num = (m_currentHandleZ = AngleSigned(ReferenceVector.forward, v, ReferenceVector.up)); Vector3 val2 = Quaternion.AngleAxis(m_currentHandleZ, ReferenceVector.up) * ReferenceVector.forward; Handle.rotation = Quaternion.LookRotation(val2, ReferenceVector.up); float num2 = Mathf.InverseLerp(RotLimit, 0f - RotLimit, num); Bolt.UpdateHandleHeldState(true, num2); } public override void EndInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).EndInteraction(hand); Bolt.UpdateHandleHeldState(false, 0f); } public override void FVRUpdate() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) ((FVRInteractiveObject)this).FVRUpdate(); float num = Mathf.InverseLerp(RotLimit, 0f - RotLimit, m_currentHandleZ); if (num < 0.01f) { m_curPos = Placement.Forward; } else if (num > 0.99f) { m_curPos = Placement.Rearward; } else { m_curPos = Placement.Middle; } if (!((FVRInteractiveObject)this).IsHeld && Mathf.Abs(m_currentHandleZ - RotLimit) >= 0.01f) { m_currentHandleZ = Mathf.MoveTowards(m_currentHandleZ, RotLimit, Time.deltaTime * ForwardSpeed); Vector3 val = Quaternion.AngleAxis(m_currentHandleZ, ReferenceVector.up) * ReferenceVector.forward; Handle.rotation = Quaternion.LookRotation(val, ReferenceVector.up); } if (m_curPos == Placement.Forward && m_lastPos != 0) { ((FVRFireArm)Bolt.Weapon).PlayAudioEvent((FirearmAudioEventType)11, 1f); } else if (m_lastPos == Placement.Rearward && m_lastPos != Placement.Rearward) { ((FVRFireArm)Bolt.Weapon).PlayAudioEvent((FirearmAudioEventType)10, 1f); } m_lastPos = m_curPos; } public float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return Mathf.Atan2(Vector3.Dot(n, Vector3.Cross(v1, v2)), Vector3.Dot(v1, v2)) * 57.29578f; } } } namespace OpenScripts2 { public class AdvancedMovingFireArmAttachmentInterface : FVRFireArmAttachmentInterface { public enum EDegreesOfFreedom { Linear, Planar, Spacial } [Serializable] public class MovementMode { public string ModeText; public EDegreesOfFreedom DegreesOfFreedom; public OpenScripts2_BasePlugin.Axis LimitingAxis; } [Header("Advanced Moving FireArm Attachment Interface Config")] [Tooltip("One degree means linear movement, two degrees means movement on a plane, three degrees free spacial movement.")] public EDegreesOfFreedom DegreesOfFreedom; public float[] RotationStepOptions = new float[5] { 90f, 45f, 22.5f, 11.25f, 5.625f }; public OpenScripts2_BasePlugin.Axis LimitingAxis; public Vector2 XLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public Vector2 YLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public Vector2 ZLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public bool OverridesDisableOnHoverOfMount; [Tooltip("Something placed on this mount will disable the hover on disable piece again.")] public FVRFireArmAttachmentMount OverrideDisableOverrideMount; [Tooltip("This transforms position will be vaulted as well")] public Transform SecondaryPiece; public bool CanRotate; public float RotationStep = 45f; public bool CanSwitchModes; public Text ModeDisplay; public MovementMode[] MovementModes = new MovementMode[4] { new MovementMode { ModeText = "All", DegreesOfFreedom = EDegreesOfFreedom.Spacial, LimitingAxis = OpenScripts2_BasePlugin.Axis.X }, new MovementMode { ModeText = "X Limited", DegreesOfFreedom = EDegreesOfFreedom.Planar, LimitingAxis = OpenScripts2_BasePlugin.Axis.X }, new MovementMode { ModeText = "Y Limited", DegreesOfFreedom = EDegreesOfFreedom.Planar, LimitingAxis = OpenScripts2_BasePlugin.Axis.Y }, new MovementMode { ModeText = "Z Limited", DegreesOfFreedom = EDegreesOfFreedom.Planar, LimitingAxis = OpenScripts2_BasePlugin.Axis.Z } }; private int _currentMode; private Vector3 _lastPos; private Vector3 _lastHandPos; private Vector3 _startPos; private Vector3 _lowerLimit; private Vector3 _upperLimit; [HideInInspector] public GameObject DisableOnHover; [HideInInspector] public GameObject EnableOnHover; public const string POSITION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Position"; public const string ROTATION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Rotation"; public const string SECONDARY_POSITION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Secondary Position"; public override void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmAttachmentInterface)this).Awake(); _lowerLimit = new Vector3(XLimits.x, YLimits.x, ZLimits.x); _upperLimit = new Vector3(XLimits.y, YLimits.y, ZLimits.y); _startPos = ((Component)((AnvilAsset)((FVRPhysicalObject)base.Attachment).ObjectWrapper).GetGameObject().GetComponent<FVRFireArmAttachment>().AttachmentInterface).transform.localPosition; if ((Object)(object)ModeDisplay != (Object)null) { ModeDisplay.text = MovementModes[_currentMode].ModeText; } } public override void OnAttach() { ((FVRFireArmAttachmentInterface)this).OnAttach(); if (OverridesDisableOnHoverOfMount && base.Attachment.curMount.HasHoverDisablePiece) { if (base.Attachment.curMount.MyObject is CustomOpenScripts2Attachment customOpenScripts2Attachment && ((FVRFireArmAttachment)customOpenScripts2Attachment).AttachmentInterface is MovingFireArmAttachmentInterface movingFireArmAttachmentInterface) { DisableOnHover = movingFireArmAttachmentInterface.DisableOnHover; movingFireArmAttachmentInterface.DisableOnHover = null; GameObject disableOnHover = DisableOnHover; if (disableOnHover != null) { disableOnHover.SetActive(true); } } else { DisableOnHover = base.Attachment.curMount.DisableOnHover; base.Attachment.curMount.DisableOnHover = null; GameObject disableOnHover2 = DisableOnHover; if (disableOnHover2 != null) { disableOnHover2.SetActive(true); } } } if (!OverridesDisableOnHoverOfMount || !base.Attachment.curMount.HasHoverEnablePiece) { return; } if (base.Attachment.curMount.MyObject is CustomOpenScripts2Attachment customOpenScripts2Attachment2 && ((FVRFireArmAttachment)customOpenScripts2Attachment2).AttachmentInterface is MovingFireArmAttachmentInterface movingFireArmAttachmentInterface2) { EnableOnHover = movingFireArmAttachmentInterface2.EnableOnHover; movingFireArmAttachmentInterface2.EnableOnHover = null; GameObject enableOnHover = EnableOnHover; if (enableOnHover != null) { enableOnHover.SetActive(false); } } else { EnableOnHover = base.Attachment.curMount.EnableOnHover; base.Attachment.curMount.EnableOnHover = null; GameObject enableOnHover2 = EnableOnHover; if (enableOnHover2 != null) { enableOnHover2.SetActive(false); } } } public override void OnDetach() { if (base.Attachment.curMount.MyObject is CustomOpenScripts2Attachment customOpenScripts2Attachment && ((FVRFireArmAttachment)customOpenScripts2Attachment).AttachmentInterface is MovingFireArmAttachmentInterface movingFireArmAttachmentInterface) { movingFireArmAttachmentInterface.DisableOnHover = DisableOnHover; movingFireArmAttachmentInterface.EnableOnHover = EnableOnHover; } else { base.Attachment.curMount.DisableOnHover = DisableOnHover; base.Attachment.curMount.EnableOnHover = EnableOnHover; } DisableOnHover = null; EnableOnHover = null; ((FVRFireArmAttachmentInterface)this).OnDetach(); } public override void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (!OverridesDisableOnHoverOfMount || !((Object)(object)OverrideDisableOverrideMount != (Object)null)) { return; } if (OverrideDisableOverrideMount.HasAttachmentsOnIt()) { GameObject disableOnHover = DisableOnHover; if (disableOnHover != null) { disableOnHover.SetActive(false); } } else { GameObject disableOnHover2 = DisableOnHover; if (disableOnHover2 != null) { disableOnHover2.SetActive(true); } } if (OverrideDisableOverrideMount.HasAttachmentsOnIt()) { GameObject enableOnHover = EnableOnHover; if (enableOnHover != null) { enableOnHover.SetActive(true); } } else { GameObject enableOnHover2 = EnableOnHover; if (enableOnHover2 != null) { enableOnHover2.SetActive(false); } } } public override void BeginInteraction(FVRViveHand hand) { //IL_000e: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).BeginInteraction(hand); _lastPos = ((Component)this).transform.position; _lastHandPos = hand.Input.FilteredPos; } public override void UpdateInteraction(FVRViveHand hand) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) ((FVRFireArmAttachmentInterface)this).UpdateInteraction(hand); if (hand.Input.TriggerFloat > 0f) { Vector3 val = (hand.Input.FilteredPos - _lastHandPos) * hand.Input.TriggerFloat; Vector3 val2 = (((Component)this).transform.position - _lastPos) * hand.Input.TriggerFloat; Vector3 newPosRaw = ((Component)this).transform.position + val - val2; switch (DegreesOfFreedom) { case EDegreesOfFreedom.Linear: OneDegreeOfFreedom(newPosRaw); break; case EDegreesOfFreedom.Planar: TwoDegreesOfFreedom(newPosRaw); break; case EDegreesOfFreedom.Spacial: ThreeDegreesOfFreedom(newPosRaw); break; } } else if (OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.up)) { ((Component)this).transform.localPosition = _startPos; } else if (CanRotate && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.left)) { ((Component)this).transform.Rotate(0f, 0f, RotationStep); } else if (CanRotate && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.right)) { ((Component)this).transform.Rotate(0f, 0f, 0f - RotationStep); } else if (CanSwitchModes && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.down)) { SwitchMode(); } _lastPos = ((Component)this).transform.position; _lastHandPos = hand.Input.FilteredPos; } private void OneDegreeOfFreedom(Vector3 newPosRaw) { //IL_007d: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) Vector3 localPosition; if (CanSwitchModes) { Vector3 val = _lowerLimit.GetCombinedAxisVector(LimitingAxis, ((Component)this).transform.localPosition).ApproximateInfiniteComponent(100f); Vector3 val2 = _upperLimit.GetCombinedAxisVector(LimitingAxis, ((Component)this).transform.localPosition).ApproximateInfiniteComponent(100f); localPosition = ((FVRInteractiveObject)this).GetClosestValidPoint(val, val2, ((Component)this).transform.parent.InverseTransformPoint(newPosRaw)); } else { localPosition = ((Component)this).transform.parent.InverseTransformPoint(newPosRaw).GetAxisVector(LimitingAxis).Clamp(_lowerLimit, _upperLimit); } ((Component)this).transform.localPosition = localPosition; } private void TwoDegreesOfFreedom(Vector3 newPosRaw) { //IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((!CanSwitchModes) ? ((Component)this).transform.parent.InverseTransformPoint(newPosRaw).RemoveAxisValue(LimitingAxis) : newPosRaw.ProjectOnPlaneThroughPoint(((Component)this).transform.position, ((Component)this).transform.parent.GetLocalDirAxis(LimitingAxis))); Vector3 vector = ((Component)this).transform.parent.InverseTransformPoint(val).Clamp(_lowerLimit, _upperLimit); ((Component)this).transform.localPosition = vector.ModifyAxisValue(LimitingAxis, _startPos.GetAxisValue(LimitingAxis)); } private void ThreeDegreesOfFreedom(Vector3 newPosRaw) { //IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localPosition = ((Component)this).transform.parent.InverseTransformPoint(newPosRaw).Clamp(_lowerLimit, _upperLimit); } [ContextMenu("Copy existing Interface's values")] public void CopyAttachment() { FVRFireArmAttachmentInterface[] components = ((Component)this).GetComponents<FVRFireArmAttachmentInterface>(); FVRFireArmAttachmentInterface val = components.Single((FVRFireArmAttachmentInterface c) => (Object)(object)c != (Object)(object)this); val.Attachment.AttachmentInterface = (FVRFireArmAttachmentInterface)(object)this; ((Component)(object)this).CopyComponent<FVRFireArmAttachmentInterface>(val); } private void SwitchMode() { _currentMode = (_currentMode + 1) % MovementModes.Length; if ((Object)(object)ModeDisplay != (Object)null) { ModeDisplay.text = MovementModes[_currentMode].ModeText; } DegreesOfFreedom = MovementModes[_currentMode].DegreesOfFreedom; LimitingAxis = MovementModes[_currentMode].LimitingAxis; } } public class InvertingMount : FVRFireArmAttachmentMount { private static bool _wasPatched; public void Start() { if (!_wasPatched) { Harmony.CreateAndPatchAll(typeof(InvertingMount), (string)null); _wasPatched = true; } } [HarmonyPatch(typeof(FVRFireArmAttachment), "AttachToMount")] [HarmonyPostfix] public static void FVRFireArmAttachment_AttachToMount_Postfix(FVRFireArmAttachment __instance, FVRFireArmAttachmentMount m) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020e: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) if (!(m is InvertingMount)) { return; } Vector3 localPosition = ((Component)__instance).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)__instance).transform.localPosition = localPosition; MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { Vector3 localScale = ((Component)val).transform.localScale; localScale.x = 0f - localScale.x; ((Component)val).transform.localScale = localScale; localPosition = ((Component)val).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)val).transform.localPosition = localPosition; } foreach (Collider item in ((FVRInteractiveObject)__instance).m_colliders.Where((Collider c) => !c.isTrigger)) { Vector3 localScale = ((Component)item).transform.localScale; localScale.x = 0f - localScale.x; ((Component)item).transform.localScale = localScale; localPosition = ((Component)item).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)item).transform.localPosition = localPosition; } foreach (FVRFireArmAttachmentMount attachmentMount in ((FVRPhysicalObject)__instance).AttachmentMounts) { if (!((Object)(object)attachmentMount == (Object)null)) { localPosition = ((Component)attachmentMount).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)attachmentMount).transform.localPosition = localPosition; Vector3 localEulerAngles = ((Component)attachmentMount).transform.localEulerAngles; localEulerAngles.z = 0f - localEulerAngles.z; ((Component)attachmentMount).transform.localEulerAngles = localEulerAngles; if ((Object)(object)attachmentMount.Point_Front.parent != (Object)(object)((Component)attachmentMount).transform) { localEulerAngles = attachmentMount.Point_Front.localEulerAngles; localEulerAngles.z = 0f - localEulerAngles.z; attachmentMount.Point_Front.localEulerAngles = localEulerAngles; } localPosition = attachmentMount.Point_Front.localPosition; localPosition.x = 0f - localPosition.x; attachmentMount.Point_Front.localPosition = localPosition; if ((Object)(object)attachmentMount.Point_Rear.parent != (Object)(object)((Component)attachmentMount).transform) { localEulerAngles = attachmentMount.Point_Rear.localEulerAngles; localEulerAngles.z = 0f - localEulerAngles.z; attachmentMount.Point_Rear.localEulerAngles = localEulerAngles; } localPosition = attachmentMount.Point_Rear.localPosition; localPosition.x = 0f - localPosition.x; attachmentMount.Point_Rear.localPosition = localPosition; } } } [HarmonyPatch(typeof(FVRFireArmAttachment), "DetachFromMount")] [HarmonyPrefix] public static void FVRFireArmAttachment_DetachFromMount_Prefix(FVRFireArmAttachment __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //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_0056: 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_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) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0293: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.curMount is InvertingMount)) { return; } Vector3 localPosition = ((Component)__instance).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)__instance).transform.localPosition = localPosition; MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { Vector3 localScale = ((Component)val).transform.localScale; localScale.x = 0f - localScale.x; ((Component)val).transform.localScale = localScale; localPosition = ((Component)val).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)val).transform.localPosition = localPosition; } foreach (Collider item in ((FVRInteractiveObject)__instance).m_colliders.Where((Collider c) => !c.isTrigger)) { Vector3 localScale = ((Component)item).transform.localScale; localScale.x = 0f - localScale.x; ((Component)item).transform.localScale = localScale; localPosition = ((Component)item).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)item).transform.localPosition = localPosition; } foreach (FVRFireArmAttachmentMount attachmentMount in ((FVRPhysicalObject)__instance).AttachmentMounts) { if (!((Object)(object)attachmentMount == (Object)null)) { Vector3 localEulerAngles = ((Component)attachmentMount).transform.localEulerAngles; localEulerAngles.z = 0f - localEulerAngles.z; ((Component)attachmentMount).transform.localEulerAngles = localEulerAngles; localPosition = ((Component)attachmentMount).transform.localPosition; localPosition.x = 0f - localPosition.x; ((Component)attachmentMount).transform.localPosition = localPosition; if ((Object)(object)attachmentMount.Point_Front.parent != (Object)(object)((Component)attachmentMount).transform) { localEulerAngles = attachmentMount.Point_Front.localEulerAngles; localEulerAngles.z = 0f - localEulerAngles.z; attachmentMount.Point_Front.localEulerAngles = localEulerAngles; } localPosition = attachmentMount.Point_Front.localPosition; localPosition.x = 0f - localPosition.x; attachmentMount.Point_Front.localPosition = localPosition; if ((Object)(object)attachmentMount.Point_Rear.parent != (Object)(object)((Component)attachmentMount).transform) { localEulerAngles = attachmentMount.Point_Rear.localEulerAngles; localEulerAngles.z = 0f - localEulerAngles.z; attachmentMount.Point_Rear.localEulerAngles = localEulerAngles; } localPosition = attachmentMount.Point_Rear.localPosition; localPosition.x = 0f - localPosition.x; attachmentMount.Point_Rear.localPosition = localPosition; } } } } public class MovingAttachmentInterfaceLimiterAddon : OpenScripts2_BasePlugin { public FVRFireArmAttachment Attachment; public Vector2 NewXLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public Vector2 NewYLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public Vector2 NewZLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); private Vector2 _oldLowerLimit; private Vector2 _oldUpperLimit; private MovingFireArmAttachmentInterface _interface; public void Update() { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_013c: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_interface == (Object)null && (Object)(object)Attachment.curMount != (Object)null) { FVRPhysicalObject myObject = Attachment.curMount.MyObject; FVRFireArmAttachment val = (FVRFireArmAttachment)(object)((myObject is FVRFireArmAttachment) ? myObject : null); if (val != null) { _interface = val.AttachmentInterface as MovingFireArmAttachmentInterface; if ((Object)(object)_interface != (Object)null) { _oldLowerLimit = Vector2.op_Implicit(_interface.LowerLimit); _oldUpperLimit = Vector2.op_Implicit(_interface.UpperLimit); _interface.LowerLimit = new Vector3(NewXLimits.x, NewYLimits.x, NewZLimits.x); _interface.UpperLimit = new Vector3(NewXLimits.y, NewYLimits.y, NewZLimits.y); } return; } } if ((Object)(object)_interface != (Object)null && (Object)(object)Attachment.curMount == (Object)null) { _interface.LowerLimit = Vector2.op_Implicit(_oldLowerLimit); _interface.UpperLimit = Vector2.op_Implicit(_oldUpperLimit); _interface = null; } } } public class ScopeBaseOptic : OpenScripts2_BasePlugin { public FVRFireArmAttachment Optic; public Transform FrontAreaFront; public Transform FrontAreaRear; public Transform RearAreaFront; public Transform RearAreaRear; private TransformProxy _frontAreaFrontProxy; private TransformProxy _frontAreaRearProxy; private TransformProxy _rearAreaFrontProxy; private TransformProxy _rearAreaRearProxy; private Vector2 _oldLowerLimit; private Vector2 _oldUpperLimit; private MovingFireArmAttachmentInterface _interface; public void Awake() { _frontAreaFrontProxy = new TransformProxy(FrontAreaFront, deleteReferenceGameObject: true); _frontAreaRearProxy = new TransformProxy(FrontAreaRear, deleteReferenceGameObject: true); _rearAreaFrontProxy = new TransformProxy(RearAreaFront, deleteReferenceGameObject: true); _rearAreaRearProxy = new TransformProxy(RearAreaRear, deleteReferenceGameObject: true); } public void Update() { //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_interface == (Object)null && (Object)(object)Optic.curMount != (Object)null && Optic.curMount is ScopeBaseMount scopeBaseMount) { FVRPhysicalObject myObject = Optic.curMount.MyObject; FVRFireArmAttachment val = (FVRFireArmAttachment)(object)((myObject is FVRFireArmAttachment) ? myObject : null); if (val != null) { _interface = val.AttachmentInterface as MovingFireArmAttachmentInterface; if ((Object)(object)_interface != (Object)null) { _oldLowerLimit = Vector2.op_Implicit(_interface.LowerLimit); _oldUpperLimit = Vector2.op_Implicit(_interface.UpperLimit); Vector2 zero = Vector2.zero; Vector2 zero2 = Vector2.zero; Vector2 zero3 = Vector2.zero; float z = ((Component)_interface).transform.parent.InverseTransformPoint(scopeBaseMount.FrontRingFrontProxy.position).z; float z2 = ((Component)_interface).transform.parent.InverseTransformPoint(scopeBaseMount.FrontRingRearProxy.position).z; float z3 = ((Component)_interface).transform.parent.InverseTransformPoint(scopeBaseMount.RearRingFrontProxy.position).z; float z4 = ((Component)_interface).transform.parent.InverseTransformPoint(scopeBaseMount.RearRingRearProxy.position).z; float z5 = ((Component)_interface).transform.parent.InverseTransformPoint(_frontAreaFrontProxy.position).z; float z6 = ((Component)_interface).transform.parent.InverseTransformPoint(_frontAreaRearProxy.position).z; float z7 = ((Component)_interface).transform.parent.InverseTransformPoint(_rearAreaFrontProxy.position).z; float z8 = ((Component)_interface).transform.parent.InverseTransformPoint(_rearAreaRearProxy.position).z; float x; float y; if (Vector3.Distance(scopeBaseMount.FrontRingFrontProxy.position, _frontAreaFrontProxy.position) < Vector3.Distance(scopeBaseMount.RearRingRearProxy.position, _frontAreaFrontProxy.position)) { float num = z - z5; float num2 = z3 - z7; x = Mathf.Max(num, num2); float num3 = z2 - z6; float num4 = z4 - z8; y = Mathf.Min(num3, num4); } else { float num5 = z - z8; float num6 = z3 - z6; x = Mathf.Max(num5, num6); float num7 = z2 - z7; float num8 = z4 - z5; y = Mathf.Min(num7, num8); } zero3.x = x; zero3.y = y; _interface.LowerLimit = new Vector3(zero.x, zero2.x, zero3.x); _interface.UpperLimit = new Vector3(zero.y, zero2.y, zero3.y); ((Component)_interface).transform.ModifyLocalPositionAxisValue(Axis.Z, Mathf.Abs(zero3.y - zero3.x) / 2f); } return; } } if ((Object)(object)_interface != (Object)null && (Object)(object)Optic.curMount == (Object)null) { _interface.LowerLimit = Vector2.op_Implicit(_oldLowerLimit); _interface.UpperLimit = Vector2.op_Implicit(_oldUpperLimit); _interface = null; } } } public class ScopeBaseMount : FVRFireArmAttachmentMount { [Header("ScopeBaseMount Config")] public MovingFireArmAttachmentInterface MovingInterface; [Header("Points will get deleted and replaced with TransformProxies")] public Transform FrontRingFront; public Transform FrontRingRear; public Transform RearRingFront; public Transform RearRingRear; [HideInInspector] public TransformProxy FrontRingFrontProxy; [HideInInspector] public TransformProxy FrontRingRearProxy; [HideInInspector] public TransformProxy RearRingFrontProxy; [HideInInspector] public TransformProxy RearRingRearProxy; private bool _wasConverted; public void Start() { if (!_wasConverted) { _wasConverted = true; FrontRingFrontProxy = new TransformProxy(FrontRingFront, deleteReferenceGameObject: true); FrontRingRearProxy = new TransformProxy(FrontRingRear, deleteReferenceGameObject: true); RearRingFrontProxy = new TransformProxy(RearRingFront, deleteReferenceGameObject: true); RearRingRearProxy = new TransformProxy(RearRingRear, deleteReferenceGameObject: true); } } [ContextMenu("Copy existing mounts's values")] public void CopyExistingMount() { FVRFireArmAttachmentMount[] components = ((Component)this).GetComponents<FVRFireArmAttachmentMount>(); FVRFireArmAttachmentMount val = components.Single((FVRFireArmAttachmentMount c) => (Object)(object)c != (Object)(object)this); val.MyObject.AttachmentMounts.Remove(val); val.MyObject.AttachmentMounts.Add((FVRFireArmAttachmentMount)(object)this); FVRPhysicalObject myObject = val.MyObject; FVRFireArmAttachment val2 = (FVRFireArmAttachment)(object)((myObject is FVRFireArmAttachment) ? myObject : null); if (val2 != null) { List<FVRFireArmAttachmentMount> list = val2.AttachmentInterface.SubMounts.ToList(); list.Remove(val); list.Add((FVRFireArmAttachmentMount)(object)this); val2.AttachmentInterface.SubMounts = list.ToArray(); } ((Component)(object)this).CopyComponent<FVRFireArmAttachmentMount>(val); } } public class SupressableMuzzleNoiseMaker : MuzzleNoiseMaker { public override void OnShot(FVRFireArm f, FVRTailSoundClass tailClass) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!f.IsSuppressed()) { ((MuzzleNoiseMaker)this).OnShot(f, tailClass); } } public override void OnShot(AttachableFirearm f, FVRTailSoundClass tailClass) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!f.IsSuppressed()) { ((MuzzleNoiseMaker)this).OnShot(f, tailClass); } } [ContextMenu("Copy Noise Maker")] public void CopyNoiseMaker() { MuzzleNoiseMaker[] components = ((Component)this).GetComponents<MuzzleNoiseMaker>(); MuzzleNoiseMaker val = components.Single((MuzzleNoiseMaker c) => (Object)(object)c != (Object)(object)this); foreach (FVRFireArmAttachmentMount attachmentMount in ((FVRPhysicalObject)val).AttachmentMounts) { attachmentMount.MyObject = (FVRPhysicalObject)(object)this; attachmentMount.Parent = (FVRPhysicalObject)(object)this; } ((FVRFireArmAttachment)val).AttachmentInterface.Attachment = (FVRFireArmAttachment)(object)this; ((FVRFireArmAttachment)val).Sensor.Attachment = (FVRFireArmAttachment)(object)this; ((Component)(object)this).CopyComponent<MuzzleNoiseMaker>(val); } } public class CustomMuzzleEffectsForMuzzleDevice : MonoBehaviour { public MuzzleDevice MuzzleDevice; public CustomMuzzleEffect[] CustomMuzzleEffects; public float MuzzleDeviceEffectSizeMultiplier = 1f; private static readonly List<FVRFireArmAttachment> _existingCustomMuzzleEffectsForMuzzleDevices; public void Awake() { _existingCustomMuzzleEffectsForMuzzleDevices.Add((FVRFireArmAttachment)(object)MuzzleDevice); } public void OnDestroy() { _existingCustomMuzzleEffectsForMuzzleDevices.Remove((FVRFireArmAttachment)(object)MuzzleDevice); } static CustomMuzzleEffectsForMuzzleDevice() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown _existingCustomMuzzleEffectsForMuzzleDevices = new List<FVRFireArmAttachment>(); FVRFireArmAttachment.AttachToMount += new hook_AttachToMount(FVRFireArmAttachment_AttachToMount); } private static void FVRFireArmAttachment_AttachToMount(orig_AttachToMount orig, FVRFireArmAttachment self, FVRFireArmAttachmentMount m, bool playSound) { if (_existingCustomMuzzleEffectsForMuzzleDevices.Contains(self)) { FVRPhysicalObject myObject = m.GetRootMount().MyObject; FVRFireArm val = (FVRFireArm)(object)((myObject is FVRFireArm) ? myObject : null); if ((Object)(object)val != (Object)null && !((Component)(object)val).TryGetComponentInChildren<CustomMuzzleEffectsController>(out CustomMuzzleEffectsController _)) { ((Component)val).gameObject.AddComponent<CustomMuzzleEffectsController>(); } } orig.Invoke(self, m, playSound); } } public class MovingFireArmAttachmentInterface : FVRFireArmAttachmentInterface { public enum EDegreesOfFreedom { Linear, Planar, Spacial } [Serializable] public class MovementMode { public string ModeText; public EDegreesOfFreedom DegreesOfFreedom; public OpenScripts2_BasePlugin.Axis LimitingAxis; } [Header("Moving FireArm Attachment Interface Config")] [Tooltip("One degree means linear movement, two degrees means movement on a plane, three degrees free spacial movement.")] public EDegreesOfFreedom DegreesOfFreedom; public OpenScripts2_BasePlugin.Axis LimitingAxis; public Vector2 XLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public Vector2 YLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public Vector2 ZLimits = new Vector2(float.NegativeInfinity, float.PositiveInfinity); public bool OverridesDisableOnHoverOfMount; [Tooltip("Something placed on this mount will disabled the hover on disable piece again.")] public FVRFireArmAttachmentMount OverrideDisableOverrideMount; [Tooltip("This transforms position will be vaulted as well")] public Transform SecondaryPiece; public bool CanRotate; public float RotationStep = 45f; public bool CanSwitchModes; public Text ModeDisplay; public MovementMode[] MovementModes = new MovementMode[4] { new MovementMode { ModeText = "All", DegreesOfFreedom = EDegreesOfFreedom.Spacial, LimitingAxis = OpenScripts2_BasePlugin.Axis.X }, new MovementMode { ModeText = "X Limited", DegreesOfFreedom = EDegreesOfFreedom.Planar, LimitingAxis = OpenScripts2_BasePlugin.Axis.X }, new MovementMode { ModeText = "Y Limited", DegreesOfFreedom = EDegreesOfFreedom.Planar, LimitingAxis = OpenScripts2_BasePlugin.Axis.Y }, new MovementMode { ModeText = "Z Limited", DegreesOfFreedom = EDegreesOfFreedom.Planar, LimitingAxis = OpenScripts2_BasePlugin.Axis.Z } }; private int _currentMode; private Vector3 _lastPos; private Vector3 _lastHandPos; private Vector3 _startPos; [HideInInspector] public Vector3 LowerLimit; [HideInInspector] public Vector3 UpperLimit; [HideInInspector] public GameObject DisableOnHover; [HideInInspector] public GameObject EnableOnHover; public const string POSITION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Position"; public const string ROTATION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Rotation"; public const string SECONDARY_POSITION_FLAGDIC_KEY = "MovingFireArmAttachmentInterface Secondary Position"; public override void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmAttachmentInterface)this).Awake(); LowerLimit = new Vector3(XLimits.x, YLimits.x, ZLimits.x); UpperLimit = new Vector3(XLimits.y, YLimits.y, ZLimits.y); _startPos = ((Component)((AnvilAsset)((FVRPhysicalObject)base.Attachment).ObjectWrapper).GetGameObject().GetComponent<FVRFireArmAttachment>().AttachmentInterface).transform.localPosition; if ((Object)(object)ModeDisplay != (Object)null) { ModeDisplay.text = MovementModes[_currentMode].ModeText; } } public override void OnAttach() { ((FVRFireArmAttachmentInterface)this).OnAttach(); if (OverridesDisableOnHoverOfMount && base.Attachment.curMount.HasHoverDisablePiece) { if (base.Attachment.curMount.MyObject is CustomOpenScripts2Attachment customOpenScripts2Attachment && ((FVRFireArmAttachment)customOpenScripts2Attachment).AttachmentInterface is MovingFireArmAttachmentInterface movingFireArmAttachmentInterface) { DisableOnHover = movingFireArmAttachmentInterface.DisableOnHover; movingFireArmAttachmentInterface.DisableOnHover = null; GameObject disableOnHover = DisableOnHover; if (disableOnHover != null) { disableOnHover.SetActive(true); } } else { DisableOnHover = base.Attachment.curMount.DisableOnHover; base.Attachment.curMount.DisableOnHover = null; GameObject disableOnHover2 = DisableOnHover; if (disableOnHover2 != null) { disableOnHover2.SetActive(true); } } } if (!OverridesDisableOnHoverOfMount || !base.Attachment.curMount.HasHoverEnablePiece) { return; } if (base.Attachment.curMount.MyObject is CustomOpenScripts2Attachment customOpenScripts2Attachment2 && ((FVRFireArmAttachment)customOpenScripts2Attachment2).AttachmentInterface is MovingFireArmAttachmentInterface movingFireArmAttachmentInterface2) { EnableOnHover = movingFireArmAttachmentInterface2.EnableOnHover; movingFireArmAttachmentInterface2.EnableOnHover = null; GameObject enableOnHover = EnableOnHover; if (enableOnHover != null) { enableOnHover.SetActive(false); } } else { EnableOnHover = base.Attachment.curMount.EnableOnHover; base.Attachment.curMount.EnableOnHover = null; GameObject enableOnHover2 = EnableOnHover; if (enableOnHover2 != null) { enableOnHover2.SetActive(false); } } } public override void OnDetach() { if (base.Attachment.curMount.MyObject is CustomOpenScripts2Attachment customOpenScripts2Attachment && ((FVRFireArmAttachment)customOpenScripts2Attachment).AttachmentInterface is MovingFireArmAttachmentInterface movingFireArmAttachmentInterface) { movingFireArmAttachmentInterface.DisableOnHover = DisableOnHover; movingFireArmAttachmentInterface.EnableOnHover = EnableOnHover; } else { base.Attachment.curMount.DisableOnHover = DisableOnHover; base.Attachment.curMount.EnableOnHover = EnableOnHover; } DisableOnHover = null; EnableOnHover = null; ((FVRFireArmAttachmentInterface)this).OnDetach(); } public override void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (!OverridesDisableOnHoverOfMount || !((Object)(object)OverrideDisableOverrideMount != (Object)null)) { return; } if (OverrideDisableOverrideMount.HasAttachmentsOnIt()) { GameObject disableOnHover = DisableOnHover; if (disableOnHover != null) { disableOnHover.SetActive(false); } } else { GameObject disableOnHover2 = DisableOnHover; if (disableOnHover2 != null) { disableOnHover2.SetActive(true); } } if (OverrideDisableOverrideMount.HasAttachmentsOnIt()) { GameObject enableOnHover = EnableOnHover; if (enableOnHover != null) { enableOnHover.SetActive(true); } } else { GameObject enableOnHover2 = EnableOnHover; if (enableOnHover2 != null) { enableOnHover2.SetActive(false); } } } public override void BeginInteraction(FVRViveHand hand) { //IL_000e: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).BeginInteraction(hand); _lastPos = ((Component)this).transform.position; _lastHandPos = hand.Input.FilteredPos; } public override void UpdateInteraction(FVRViveHand hand) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) ((FVRFireArmAttachmentInterface)this).UpdateInteraction(hand); if (hand.Input.TriggerFloat > 0f) { Vector3 val = (hand.Input.FilteredPos - _lastHandPos) * hand.Input.TriggerFloat; Vector3 val2 = (((Component)this).transform.position - _lastPos) * hand.Input.TriggerFloat; Vector3 newPosRaw = ((Component)this).transform.position + val - val2; switch (DegreesOfFreedom) { case EDegreesOfFreedom.Linear: OneDegreeOfFreedom(newPosRaw); break; case EDegreesOfFreedom.Planar: TwoDegreesOfFreedom(newPosRaw); break; case EDegreesOfFreedom.Spacial: ThreeDegreesOfFreedom(newPosRaw); break; } } else if (OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.up)) { ((Component)this).transform.localPosition = _startPos; } else if (CanRotate && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.left)) { ((Component)this).transform.Rotate(0f, 0f, RotationStep); } else if (CanRotate && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.right)) { ((Component)this).transform.Rotate(0f, 0f, 0f - RotationStep); } else if (CanSwitchModes && OpenScripts2_BasePlugin.TouchpadDirDown(hand, Vector2.down)) { SwitchMode(); } _lastPos = ((Component)this).transform.position; _lastHandPos = hand.Input.FilteredPos; } private void OneDegreeOfFreedom(Vector3 newPosRaw) { //IL_007d: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) Vector3 localPosition; if (CanSwitchModes) { Vector3 val = LowerLimit.GetCombinedAxisVector(LimitingAxis, ((Component)this).transform.localPosition).ApproximateInfiniteComponent(100f); Vector3 val2 = UpperLimit.GetCombinedAxisVector(LimitingAxis, ((Component)this).transform.localPosition).ApproximateInfiniteComponent(100f); localPosition = ((FVRInteractiveObject)this).GetClosestValidPoint(val, val2, ((Component)this).transform.parent.InverseTransformPoint(newPosRaw)); } else { localPosition = ((Component)this).transform.parent.InverseTransformPoint(newPosRaw).GetAxisVector(LimitingAxis).Clamp(LowerLimit, UpperLimit); } ((Component)this).transform.localPosition = localPosition; } private void TwoDegreesOfFreedom(Vector3 newPosRaw) { //IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((!CanSwitchModes) ? ((Component)this).transform.parent.InverseTransformPoint(newPosRaw).RemoveAxisValue(LimitingAxis) : newPosRaw.ProjectOnPlaneThroughPoint(((Component)this).transform.position, ((Component)this).transform.parent.GetLocalDirAxis(LimitingAxis))); Vector3 vector = ((Component)this).transform.parent.InverseTransformPoint(val).Clamp(LowerLimit, UpperLimit); ((Component)this).transform.localPosition = vector.ModifyAxisValue(LimitingAxis, _startPos.GetAxisValue(LimitingAxis)); } private void ThreeDegreesOfFreedom(Vector3 newPosRaw) { //IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localPosition = ((Component)this).transform.parent.InverseTransformPoint(newPosRaw).Clamp(LowerLimit, UpperLimit); } [ContextMenu("Copy existing Interface's values")] public void CopyInterface() { FVRFireArmAttachmentInterface[] components = ((Component)this).GetComponents<FVRFireArmAttachmentInterface>(); FVRFireArmAttachmentInterface val = components.Single((FVRFireArmAttachmentInterface c) => (Object)(object)c != (Object)(object)this); val.Attachment.AttachmentInterface = (FVRFireArmAttachmentInterface)(object)thi