using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using FistVR; using H3VRUtils; using HarmonyLib; using OtherLoader; using ShermanJumbo; using Sodalite.Api; using Sodalite.Utilities; using UnityEditor; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] public class FireAttachableFireSelector : MonoBehaviour { [Header("Selector Settings")] public Transform selectorTransform; public Vector3 onRotation = new Vector3(0f, 45f, 0f); private Quaternion startRot; private bool isOn; private FVRPhysicalObject rootFPO; private void Awake() { //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) if ((Object)(object)selectorTransform == (Object)null) { selectorTransform = ((Component)this).transform; } startRot = selectorTransform.localRotation; rootFPO = ((Component)this).GetComponentInParent(); if ((Object)(object)rootFPO == (Object)null) { Debug.LogError((object)"[FireSelector] No FVRPhysicalObject found in parents!"); } } private void Update() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rootFPO == (Object)null) && ((FVRInteractiveObject)rootFPO).IsHeld && !((Object)(object)((FVRInteractiveObject)rootFPO).m_hand == (Object)null)) { HandleInput(((FVRInteractiveObject)rootFPO).m_hand); selectorTransform.localRotation = ((!isOn) ? startRot : (startRot * Quaternion.Euler(onRotation))); } } private void HandleInput(FVRViveHand hand) { //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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) HandInput input = hand.Input; if (hand.IsInStreamlinedMode) { if (input.BYButtonDown) { isOn = !isOn; } } else if (input.TouchpadDown && ((Vector2)(ref input.TouchpadAxes)).magnitude > 0.2f && Vector2.Angle(input.TouchpadAxes, Vector2.left) <= 45f) { isOn = !isOn; } } } namespace MeatKit { public class HideInNormalInspectorAttribute : PropertyAttribute { } } namespace Volks.Type79_MiniLauncher { [BepInPlugin("Volks.Type79_MiniLauncher", "Type79_MiniLauncher", "1.0.0")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] public class Type79_MiniLauncherPlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.Type79_MiniLauncher"); OtherLoader.RegisterDirectLoad(BasePath, "Volks.Type79_MiniLauncher", "", "", "type79_minilauncher", ""); } } } namespace SimpleLightProbePlacer { [RequireComponent(typeof(LightProbeGroup))] [AddComponentMenu("Rendering/Light Probe Group Control")] public class LightProbeGroupControl : MonoBehaviour { [SerializeField] private float m_mergeDistance = 0.5f; [SerializeField] private bool m_usePointLights = true; [SerializeField] private float m_pointLightRange = 1f; private int m_mergedProbes; private LightProbeGroup m_lightProbeGroup; public float MergeDistance { get { return m_mergeDistance; } set { m_mergeDistance = value; } } public int MergedProbes => m_mergedProbes; public bool UsePointLights { get { return m_usePointLights; } set { m_usePointLights = value; } } public float PointLightRange { get { return m_pointLightRange; } set { m_pointLightRange = value; } } public LightProbeGroup LightProbeGroup { get { if ((Object)(object)m_lightProbeGroup != (Object)null) { return m_lightProbeGroup; } return m_lightProbeGroup = ((Component)this).GetComponent(); } } public void DeleteAll() { LightProbeGroup.probePositions = null; m_mergedProbes = 0; } public void Create() { DeleteAll(); List list = CreatePositions(); list.AddRange(CreateAroundPointLights(m_pointLightRange)); list = MergeClosestPositions(list, m_mergeDistance, out m_mergedProbes); ApplyPositions(list); } public void Merge() { if (LightProbeGroup.probePositions != null) { List source = MergeClosestPositions(LightProbeGroup.probePositions.ToList(), m_mergeDistance, out m_mergedProbes); source = source.Select((Vector3 x) => ((Component)this).transform.TransformPoint(x)).ToList(); ApplyPositions(source); } } private void ApplyPositions(List positions) { LightProbeGroup.probePositions = positions.Select((Vector3 x) => ((Component)this).transform.InverseTransformPoint(x)).ToArray(); } private static List CreatePositions() { LightProbeVolume[] array = Object.FindObjectsOfType(); if (array.Length == 0) { return new List(); } List list = new List(); for (int i = 0; i < array.Length; i++) { list.AddRange(array[i].CreatePositions()); } return list; } private static List CreateAroundPointLights(float range) { List list = (from x in Object.FindObjectsOfType() where (int)x.type == 2 select x).ToList(); if (list.Count == 0) { return new List(); } List list2 = new List(); for (int num = 0; num < list.Count; num++) { list2.AddRange(CreatePositionsAround(((Component)list[num]).transform, range)); } return list2; } private static List MergeClosestPositions(List positions, float distance, out int mergedCount) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_019d: Unknown result type (might be due to invalid IL or missing references) if (positions == null) { mergedCount = 0; return new List(); } int count = positions.Count; bool flag = false; while (!flag) { Dictionary> dictionary = new Dictionary>(); for (int i = 0; i < positions.Count; i++) { List list = positions.Where(delegate(Vector3 x) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = x - positions[i]; return ((Vector3)(ref val)).magnitude < distance; }).ToList(); if (list.Count > 0 && !dictionary.ContainsKey(positions[i])) { dictionary.Add(positions[i], list); } } positions.Clear(); List list2 = dictionary.Keys.ToList(); for (int num = 0; num < list2.Count; num++) { Vector3 center = dictionary[list2[num]].Aggregate(Vector3.zero, (Vector3 result, Vector3 target) => result + target) / (float)dictionary[list2[num]].Count; if (!positions.Exists((Vector3 x) => x == center)) { positions.Add(center); } } flag = positions.Select((Vector3 x) => positions.Where(delegate(Vector3 y) { //IL_0000: 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_0011: 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_0018: 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) int result; if (y != x) { Vector3 val = y - x; result = ((((Vector3)(ref val)).magnitude < distance) ? 1 : 0); } else { result = 0; } return (byte)result != 0; })).All((IEnumerable x) => !x.Any()); } mergedCount = count - positions.Count; return positions; } public static List CreatePositionsAround(Transform transform, float range) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) Vector3[] source = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f) }; return source.Select((Vector3 x) => transform.TransformPoint(x * range)).ToList(); } } public enum LightProbeVolumeType { Fixed, Float } [AddComponentMenu("Rendering/Light Probe Volume")] public class LightProbeVolume : TransformVolume { [SerializeField] private LightProbeVolumeType m_type = LightProbeVolumeType.Fixed; [SerializeField] private Vector3 m_densityFixed = Vector3.one; [SerializeField] private Vector3 m_densityFloat = Vector3.one; public LightProbeVolumeType Type { get { return m_type; } set { m_type = value; } } public Vector3 Density { get { //IL_0018: 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_001d: 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) return (m_type != LightProbeVolumeType.Fixed) ? m_densityFloat : m_densityFixed; } set { //IL_0019: 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_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) if (m_type == LightProbeVolumeType.Fixed) { m_densityFixed = value; } else { m_densityFloat = value; } } } public static Color EditorColor => new Color(1f, 0.9f, 0.25f); public List CreatePositions() { return CreatePositions(m_type); } public List CreatePositions(LightProbeVolumeType type) { //IL_0030: 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) //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_001a: Unknown result type (might be due to invalid IL or missing references) return (type != LightProbeVolumeType.Fixed) ? CreatePositionsFloat(((Component)this).transform, base.Origin, base.Size, Density) : CreatePositionsFixed(((Component)this).transform, base.Origin, base.Size, Density); } public static List CreatePositionsFixed(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density) { //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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) List list = new List(); Vector3 val = origin; float num = size.x / (float)Mathf.FloorToInt(density.x); float num2 = size.y / (float)Mathf.FloorToInt(density.y); float num3 = size.z / (float)Mathf.FloorToInt(density.z); val -= size * 0.5f; for (int i = 0; (float)i <= density.x; i++) { for (int j = 0; (float)j <= density.y; j++) { for (int k = 0; (float)k <= density.z; k++) { Vector3 val2 = val + new Vector3((float)i * num, (float)j * num2, (float)k * num3); val2 = volumeTransform.TransformPoint(val2); list.Add(val2); } } } return list; } public static List CreatePositionsFloat(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density) { //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_0049: 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_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_005a: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 val = origin; int num = Mathf.FloorToInt(size.x / density.x); int num2 = Mathf.FloorToInt(size.y / density.y); int num3 = Mathf.FloorToInt(size.z / density.z); val -= size * 0.5f; val.x += (size.x - (float)num * density.x) * 0.5f; val.y += (size.y - (float)num2 * density.y) * 0.5f; val.z += (size.z - (float)num3 * density.z) * 0.5f; for (int i = 0; i <= num; i++) { for (int j = 0; j <= num2; j++) { for (int k = 0; k <= num3; k++) { Vector3 val2 = val + new Vector3((float)i * density.x, (float)j * density.y, (float)k * density.z); val2 = volumeTransform.TransformPoint(val2); list.Add(val2); } } } return list; } } [AddComponentMenu("")] public class TransformVolume : MonoBehaviour { [SerializeField] private Volume m_volume = new Volume(Vector3.zero, Vector3.one); public Volume Volume { get { return m_volume; } set { m_volume = value; } } public Vector3 Origin => m_volume.Origin; public Vector3 Size => m_volume.Size; public bool IsInBounds(Vector3[] points) { //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_000c: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = GetBounds(); return ((Bounds)(ref bounds)).Intersects(GetBounds(points)); } public bool IsOnBorder(Vector3[] points) { if (points.All((Vector3 x) => !IsInVolume(x))) { return false; } return !points.All(IsInVolume); } public bool IsInVolume(Vector3[] points) { return points.All(IsInVolume); } public bool IsInVolume(Vector3 position) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Plane val = default(Plane); for (int i = 0; i < 6; i++) { ((Plane)(ref val))..ctor(GetSideDirection(i), GetSidePosition(i)); if (((Plane)(ref val)).GetSide(position)) { return false; } } return true; } public Vector3[] GetCorners() { //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_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_005d: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f) }; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference.x *= m_volume.Size.x; ref Vector3 reference2 = ref array[i]; reference2.y *= m_volume.Size.y; ref Vector3 reference3 = ref array[i]; reference3.z *= m_volume.Size.z; ref Vector3 reference4 = ref array[i]; reference4 = ((Component)this).transform.TransformPoint(m_volume.Origin + array[i]); } return array; } public Bounds GetBounds() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return GetBounds(GetCorners()); } public Bounds GetBounds(Vector3[] points) { //IL_0002: 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_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0070: Unknown result type (might be due to invalid IL or missing references) Vector3 val = points.Aggregate(Vector3.zero, (Vector3 val2, Vector3 point) => val2 + point) / (float)points.Length; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(val, Vector3.zero); for (int num = 0; num < points.Length; num++) { ((Bounds)(ref result)).Encapsulate(points[num]); } return result; } public GameObject[] GetGameObjectsInBounds(LayerMask layerMask) { //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_007f: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] array = Object.FindObjectsOfType(); List list = new List(); Bounds bounds = GetBounds(); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)((Component)array[i]).gameObject == (Object)(object)((Component)((Component)this).transform).gameObject) && !((Object)(object)((Component)array[i]).GetComponent() != (Object)null) && ((1 << ((Component)array[i]).gameObject.layer) & ((LayerMask)(ref layerMask)).value) != 0 && ((Bounds)(ref bounds)).Intersects(((Renderer)array[i]).bounds)) { list.Add(((Component)array[i]).gameObject); } } return list.ToArray(); } public Vector3 GetSideDirection(int side) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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_0014: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) Vector3[] array = (Vector3[])(object)new Vector3[6]; Vector3 right = Vector3.right; Vector3 up = Vector3.up; Vector3 forward = Vector3.forward; array[0] = right; ref Vector3 reference = ref array[1]; reference = -right; array[2] = up; ref Vector3 reference2 = ref array[3]; reference2 = -up; array[4] = forward; ref Vector3 reference3 = ref array[5]; reference3 = -forward; return ((Component)this).transform.TransformDirection(array[side]); } public Vector3 GetSidePosition(int side) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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_0014: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[6]; Vector3 right = Vector3.right; Vector3 up = Vector3.up; Vector3 forward = Vector3.forward; array[0] = right; ref Vector3 reference = ref array[1]; reference = -right; array[2] = up; ref Vector3 reference2 = ref array[3]; reference2 = -up; array[4] = forward; ref Vector3 reference3 = ref array[5]; reference3 = -forward; return ((Component)this).transform.TransformPoint(array[side] * GetSizeAxis(side) + m_volume.Origin); } public float GetSizeAxis(int side) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) switch (side) { case 0: case 1: return m_volume.Size.x * 0.5f; case 2: case 3: return m_volume.Size.y * 0.5f; default: return m_volume.Size.z * 0.5f; } } public static Volume EditorVolumeControl(TransformVolume transformVolume, float handleSize, Color color) { //IL_000f: 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_0052: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0102: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[6]; Transform transform = ((Component)transformVolume).transform; Handles.color = color; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference = transformVolume.GetSidePosition(i); } ref Vector3 reference2 = ref array[0]; reference2 = Handles.Slider(array[0], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference3 = ref array[1]; reference3 = Handles.Slider(array[1], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference4 = ref array[2]; reference4 = Handles.Slider(array[2], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference5 = ref array[3]; reference5 = Handles.Slider(array[3], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference6 = ref array[4]; reference6 = Handles.Slider(array[4], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f); ref Vector3 reference7 = ref array[5]; reference7 = Handles.Slider(array[5], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f); Vector3 origin = default(Vector3); origin.x = transform.InverseTransformPoint((array[0] + array[1]) * 0.5f).x; origin.y = transform.InverseTransformPoint((array[2] + array[3]) * 0.5f).y; origin.z = transform.InverseTransformPoint((array[4] + array[5]) * 0.5f).z; Vector3 size = default(Vector3); size.x = transform.InverseTransformPoint(array[0]).x - transform.InverseTransformPoint(array[1]).x; size.y = transform.InverseTransformPoint(array[2]).y - transform.InverseTransformPoint(array[3]).y; size.z = transform.InverseTransformPoint(array[4]).z - transform.InverseTransformPoint(array[5]).z; return new Volume(origin, size); } } [Serializable] public struct Volume { [SerializeField] private Vector3 m_origin; [SerializeField] private Vector3 m_size; public Vector3 Origin => m_origin; public Vector3 Size => m_size; public Volume(Vector3 origin, Vector3 size) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) m_origin = origin; m_size = size; } public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } public static bool operator !=(Volume left, Volume right) { return !left.Equals(right); } public bool Equals(Volume other) { //IL_0002: 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_0019: 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) return Origin == other.Origin && Size == other.Size; } public override bool Equals(object obj) { if (object.ReferenceEquals(null, obj)) { return false; } return obj is Volume && Equals((Volume)obj); } public override int GetHashCode() { //IL_0003: 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_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) return (((object)Origin/*cast due to .constrained prefix*/).GetHashCode() * 397) ^ ((object)Size/*cast due to .constrained prefix*/).GetHashCode(); } public override string ToString() { //IL_0007: 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) return $"Origin: {Origin}, Size: {Size}"; } } } namespace nrgill28.AtlasSampleScene { public class CTF_CaptureZone : MonoBehaviour { public CTF_Manager Manager; public CTF_Team Team; public void OnTriggerEnter(Collider other) { CTF_Flag component = ((Component)other).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.Team != Team) { Manager.FlagCaptured(component); } } } public class CTF_Flag : FVRPhysicalObject { [Header("Flag stuffs")] public CTF_Team Team; public float RespawnDelay = 10f; public Vector3 FloorOffset = new Vector3(0f, 0.25f, 0f); private Vector3 _resetPosition; private Quaternion _resetRotation; private Transform _followTransform; private bool _isHeld; private bool _isTaken; private float _timer; private CTF_Sosig _heldBy; public override void Awake() { //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) ((FVRPhysicalObject)this).Awake(); _resetPosition = ((Component)this).transform.position; _resetRotation = ((Component)this).transform.rotation; } private void Update() { if (_isTaken && !_isHeld) { _timer -= Time.deltaTime; if (_timer < 0f) { ReturnFlag(); } } } public void Take() { _isHeld = true; _isTaken = true; } public void Drop() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).IsHeld = false; _timer = RespawnDelay; NavMeshHit val = default(NavMeshHit); NavMesh.SamplePosition(((Component)this).transform.position, ref val, 100f, -1); ((Component)this).transform.position = ((NavMeshHit)(ref val)).position + FloorOffset; ((Component)this).transform.rotation = Quaternion.identity; } public void ReturnFlag() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (((FVRInteractiveObject)this).IsHeld) { ((FVRInteractiveObject)this).ForceBreakInteraction(); } if (Object.op_Implicit((Object)(object)_heldBy)) { _heldBy.HeldFlag = null; } ((Component)this).transform.SetPositionAndRotation(_resetPosition, _resetRotation); _isTaken = false; } private void OnTriggerEnter(Collider other) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_isHeld) { return; } CTF_Sosig componentInParent = ((Component)other).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.Sosig.BodyState == 0) { if (componentInParent.Team == Team) { ReturnFlag(); return; } _heldBy = componentInParent; componentInParent.HeldFlag = this; Take(); } } public override void BeginInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).BeginInteraction(hand); Take(); } public override void EndInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).EndInteraction(hand); Drop(); } } public class CTF_Manager : MonoBehaviour { [Header("References")] public Text[] ScoreTexts; public Transform[] AttackPoints; public Text StartButtonText; [Header("Red Team")] public CTF_Flag RedFlag; public int RedTeamSize; public Transform[] RedSpawns; public SosigEnemyID[] RedTeam; [Header("Blue Team")] public CTF_Flag BlueFlag; public int BlueTeamSize; public Transform[] BlueSpawns; public SosigEnemyID[] BlueTeam; private int _blueScore; private int _redScore; private bool _running; private readonly List _sosigs = new List(); private readonly SpawnOptions _spawnOptions; public CTF_Manager() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown SpawnOptions val = new SpawnOptions(); val.SpawnState = (SosigOrder)7; val.SpawnActivated = true; val.EquipmentMode = (EquipmentSlots)7; val.SpawnWithFullAmmo = true; _spawnOptions = val; ((MonoBehaviour)this)..ctor(); } private void Start() { UpdateScoreText(); } public void ToggleGame() { if (_running) { EndGame(); StartButtonText.text = "Start Game"; } else { StartGame(); StartButtonText.text = "Stop Game"; } } private void StartGame() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ResetGame(); _running = true; GM.CurrentSceneSettings.SosigKillEvent += new SosigKill(CurrentSceneSettingsOnSosigKillEvent); ((MonoBehaviour)this).StartCoroutine(DoInitialSpawns()); } private void EndGame() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown GM.CurrentSceneSettings.SosigKillEvent -= new SosigKill(CurrentSceneSettingsOnSosigKillEvent); foreach (CTF_Sosig sosig in _sosigs) { sosig.Sosig.ClearSosig(); } _running = false; } private void CurrentSceneSettingsOnSosigKillEvent(Sosig s) { CTF_Sosig cTF_Sosig = _sosigs.FirstOrDefault((CTF_Sosig x) => (Object)(object)x.Sosig == (Object)(object)s); if (Object.op_Implicit((Object)(object)cTF_Sosig)) { ((MonoBehaviour)this).StartCoroutine(RespawnSosig(cTF_Sosig)); } } private void SpawnSosig(CTF_Team team) { //IL_001e: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_008e: Unknown result type (might be due to invalid IL or missing references) _spawnOptions.IFF = (int)team; _spawnOptions.SosigTargetPosition = SodaliteUtils.GetRandom((IList)AttackPoints).position; Transform transform; SosigEnemyID random; if (team == CTF_Team.Red) { transform = ((Component)SodaliteUtils.GetRandom((IList)RedSpawns)).transform; random = SodaliteUtils.GetRandom((IList)RedTeam); } else { transform = ((Component)SodaliteUtils.GetRandom((IList)BlueSpawns)).transform; random = SodaliteUtils.GetRandom((IList)BlueTeam); } Sosig val = SosigAPI.Spawn(ManagerSingleton.Instance.odicSosigObjsByID[random], _spawnOptions, transform.position, transform.rotation); CTF_Sosig cTF_Sosig = ((Component)val).gameObject.AddComponent(); _sosigs.Add(cTF_Sosig); cTF_Sosig.Sosig = val; cTF_Sosig.Team = team; } private IEnumerator DoInitialSpawns() { int i = 0; while (i < Mathf.Max(RedTeamSize, BlueTeamSize)) { if (i < RedTeamSize) { SpawnSosig(CTF_Team.Red); } if (i < BlueTeamSize) { SpawnSosig(CTF_Team.Blue); } i++; yield return (object)new WaitForSeconds(2.5f); } } private IEnumerator RespawnSosig(CTF_Sosig sosig) { yield return (object)new WaitForSeconds(5f); sosig.Sosig.ClearSosig(); _sosigs.Remove(sosig); yield return (object)new WaitForSeconds(5f); if (_running) { int sosigsLeft = _sosigs.Count((CTF_Sosig x) => x.Team == sosig.Team); int teamSize = ((sosig.Team != CTF_Team.Red) ? BlueTeamSize : RedTeamSize); if (sosigsLeft < teamSize) { SpawnSosig(sosig.Team); } } } public void ResetGame() { _blueScore = 0; _redScore = 0; UpdateScoreText(); if (Object.op_Implicit((Object)(object)RedFlag)) { RedFlag.ReturnFlag(); } if (Object.op_Implicit((Object)(object)BlueFlag)) { BlueFlag.ReturnFlag(); } } public void FlagCaptured(CTF_Flag flag) { if (flag.Team == CTF_Team.Red) { _blueScore++; } else { _redScore++; } UpdateScoreText(); flag.ReturnFlag(); } public void UpdateScoreText() { Text[] scoreTexts = ScoreTexts; foreach (Text val in scoreTexts) { val.text = "" + _redScore + " - " + _blueScore + ""; } } private void OnDrawGizmos() { //IL_0001: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) Gizmos.color = Color.red; Transform[] redSpawns = RedSpawns; foreach (Transform val in redSpawns) { Gizmos.DrawSphere(val.position, 0.15f); } Gizmos.color = Color.blue; Transform[] blueSpawns = BlueSpawns; foreach (Transform val2 in blueSpawns) { Gizmos.DrawSphere(val2.position, 0.15f); } Gizmos.color = Color.green; Transform[] attackPoints = AttackPoints; foreach (Transform val3 in attackPoints) { Gizmos.DrawSphere(val3.position, 0.15f); } } } public class CTF_Sosig : MonoBehaviour { public CTF_Team Team; public CTF_Flag HeldFlag; public Sosig Sosig; private void Awake() { Sosig = ((Component)this).GetComponent(); } private void Update() { //IL_001d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)HeldFlag)) { Vector3 val = ((Component)Sosig).transform.position - ((Component)Sosig).transform.forward * 0.1f; ((Component)HeldFlag).transform.SetPositionAndRotation(val, ((Component)Sosig).transform.rotation); } } } public enum CTF_Team { Red, Blue } public class PopupTarget : MonoBehaviour, IFVRDamageable { [Flags] public enum TargetRange { Near = 1, Mid = 2, Far = 4, All = 7 } public PopupTargetManager Manager; public TargetRange Range; public Transform Pivot; public Vector3 SetRotation; private Quaternion _startRotation; private Quaternion _endRotation; private bool _set; public bool Set { get { return _set; } set { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (_set != value) { _set = value; ((MonoBehaviour)this).StartCoroutine((!_set) ? RotateTo(_endRotation, _startRotation) : RotateTo(_startRotation, _endRotation)); } } } private void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) _startRotation = Pivot.rotation; _endRotation = Quaternion.Euler(SetRotation + ((Quaternion)(ref _startRotation)).eulerAngles); } void IFVRDamageable.Damage(Damage dam) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (Set && (int)dam.Class == 1) { Set = false; Manager.TargetHit(this); } } private IEnumerator RotateTo(Quaternion from, Quaternion to) { //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) float elapsed = 0f; while (elapsed < 0.25f) { yield return null; elapsed += Time.deltaTime; Pivot.localRotation = Quaternion.Slerp(from, to, elapsed / 0.25f); } Pivot.rotation = to; } } public class PopupTargetManager : MonoBehaviour { public List Targets; private readonly List _setTargets = new List(); private void Awake() { ((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All)); } private IEnumerator StartSetAsync(float minDelay, float maxDelay, int numTargets, PopupTarget.TargetRange ranges) { yield return (object)new WaitForSeconds(Random.Range(minDelay, maxDelay)); IListExtensions.Shuffle((IList)Targets); _setTargets.Clear(); foreach (PopupTarget target in Targets) { if ((target.Range & ranges) != 0) { target.Set = true; _setTargets.Add(target); numTargets--; } if (numTargets == 0) { break; } } } public void TargetHit(PopupTarget target) { if (_setTargets.Contains(target)) { _setTargets.Remove(target); if (_setTargets.Count == 0) { ((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All)); } } } } } public class AltGrip_Rear : FVRAlternateGrip { [Header("Rear Grip Pose (world)")] public Transform RearPosePoint; public override void UpdateInteraction(FVRViveHand hand) { //IL_0037: 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) ((FVRAlternateGrip)this).UpdateInteraction(hand); if ((Object)(object)((FVRInteractiveObject)this).PoseOverride != (Object)null && (Object)(object)RearPosePoint != (Object)null) { ((FVRInteractiveObject)this).PoseOverride.SetPositionAndRotation(RearPosePoint.position, RearPosePoint.rotation); } } } public class BreakOpenFlareGun_NoHammerSafe : BreakOpenFlareGun { public enum LatchAxisType { X, Y, Z } private float m_triggerFloat; private bool m_hasTriggerReset = true; [Header("Safety (ClosedBolt-style)")] public bool HasSafety = true; public Transform SafetySelector; public Axis SafetyAxis = (Axis)0; public InterpStyle SafetyInterpStyle = (InterpStyle)1; public float SafetyOffPosition = 0f; public float SafetyOnPosition = 1f; public bool SafetyOn = false; [Header("Auto‑eject on latch open")] public FVRInteractiveObject LatchObject; public Transform LatchVisual; public LatchAxisType LatchAxis = LatchAxisType.Z; public float LatchEjectAngleThreshold = 30f; public ChamberShellInsertEject.EjectAxisType EjectAxis = ChamberShellInsertEject.EjectAxisType.LocalBack; public float EjectOffset = 0.06f; public Vector3 EjectVelocity = new Vector3(0f, 0f, 0.12f); public Vector3 EjectAngular = Vector3.zero; private bool m_prevLatchOpen = false; private float m_latchBaseAngle = 0f; private const float TriggerFiringThreshold = 0.8f; private const float TriggerResetThreshold = 0.4f; public override void Awake() { //IL_0045: 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) ((BreakOpenFlareGun)this).Awake(); base.CocksOnOpen = false; base.CanCockHammer = false; base.HasVisibleHammer = false; base.Hammer = null; base.CanUnlatch = false; if ((Object)(object)LatchVisual != (Object)null) { m_latchBaseAngle = NormalizeAngle(GetAxisAngle(LatchVisual.localEulerAngles, LatchAxis)); } else if ((Object)(object)LatchObject != (Object)null) { Transform val = FindLatchVisualFromObject(LatchObject); if ((Object)(object)val != (Object)null) { LatchVisual = val; m_latchBaseAngle = NormalizeAngle(GetAxisAngle(LatchVisual.localEulerAngles, LatchAxis)); } } } public override void UpdateInteraction(FVRViveHand hand) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f5: Unknown result type (might be due to invalid IL or missing references) if (((FVRPhysicalObject)this).IsAltHeld) { return; } if (hand.IsInStreamlinedMode) { if (hand.Input.BYButtonDown && HasSafety) { ToggleSafety(); } } else { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.left) <= 45f && HasSafety) { ToggleSafety(); } } m_triggerFloat = hand.Input.TriggerFloat; if ((Object)(object)base.Trigger != (Object)null) { float num = Mathf.Lerp(base.TriggerForwardBackRots.x, base.TriggerForwardBackRots.y, m_triggerFloat); base.Trigger.localEulerAngles = new Vector3(num, 0f, 0f); } if (!m_hasTriggerReset && m_triggerFloat <= 0.4f) { m_hasTriggerReset = true; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f); } if ((!HasSafety || !SafetyOn) && m_triggerFloat >= 0.8f && m_hasTriggerReset && !IsLatchOpen()) { m_hasTriggerReset = false; FireWithoutHammer(); } } public void ToggleSafety() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (HasSafety) { SafetyOn = !SafetyOn; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)15, 1f); if ((Object)(object)SafetySelector != (Object)null) { float num = ((!SafetyOn) ? SafetyOffPosition : SafetyOnPosition); ((FVRPhysicalObject)this).SetAnimatedComponent(SafetySelector, num, SafetyInterpStyle, SafetyAxis); } } } private void FireWithoutHammer() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.Chamber == (Object)null || !base.Chamber.Fire()) { return; } try { ((FVRFireArm)this).Fire(base.Chamber, ((FVRFireArm)this).GetMuzzle(), true, 1f, -1f); } catch (Exception) { try { ((BreakOpenFlareGun)this).Fire(); } catch { } } ((FVRFireArm)this).FireMuzzleSmoke(); try { if ((Object)(object)base.Chamber != (Object)null && (Object)(object)base.Chamber.GetRound() != (Object)null) { ((FVRFireArm)this).PlayAudioGunShot(base.Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); } } catch { } try { bool flag = ((FVRFireArm)this).IsTwoHandStabilized(); bool flag2 = (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null; bool flag3 = ((FVRFireArm)this).IsShoulderStabilized(); try { ((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f); } catch { } } catch { } try { if (GM.CurrentSceneSettings.IsAmmoInfinite || GM.CurrentPlayerBody.IsInfiniteAmmo) { base.Chamber.IsSpent = false; base.Chamber.UpdateProxyDisplay(); } else if ((Object)(object)base.Chamber.GetRound() != (Object)null && base.Chamber.GetRound().IsCaseless) { base.Chamber.SetRound((FVRFireArmRound)null, false); } if (base.DeletesCartridgeOnFire) { base.Chamber.SetRound((FVRFireArmRound)null, false); } } catch { } } public override void FVRUpdate() { //IL_0077: 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_0050: Unknown result type (might be due to invalid IL or missing references) ((BreakOpenFlareGun)this).FVRUpdate(); if (HasSafety && (Object)(object)SafetySelector != (Object)null) { float num = ((!SafetyOn) ? SafetyOffPosition : SafetyOnPosition); ((FVRPhysicalObject)this).SetAnimatedComponent(SafetySelector, num, SafetyInterpStyle, SafetyAxis); } bool flag = false; if ((Object)(object)LatchVisual != (Object)null) { float num2 = NormalizeAngle(GetAxisAngle(LatchVisual.localEulerAngles, LatchAxis)); float num3 = Mathf.Abs(NormalizeAngle(num2 - m_latchBaseAngle)); flag = num3 >= Mathf.Abs(LatchEjectAngleThreshold); } else if ((Object)(object)LatchObject != (Object)null) { Type type = ((object)LatchObject).GetType(); PropertyInfo property = type.GetProperty("IsOpen", BindingFlags.Instance | BindingFlags.Public); if ((object)property != null && (object)property.PropertyType == typeof(bool)) { try { flag = (bool)property.GetValue(LatchObject, null); } catch { flag = false; } } else { FieldInfo field = type.GetField("IsOpen", BindingFlags.Instance | BindingFlags.Public); if ((object)field != null && (object)field.FieldType == typeof(bool)) { try { flag = (bool)field.GetValue(LatchObject); } catch { flag = false; } } else { MethodInfo method = type.GetMethod("IsOpen", BindingFlags.Instance | BindingFlags.Public); if ((object)method != null && (object)method.ReturnType == typeof(bool) && method.GetParameters().Length == 0) { try { flag = (bool)method.Invoke(LatchObject, null); } catch { flag = false; } } } } } if (flag && !m_prevLatchOpen) { ((MonoBehaviour)this).StartCoroutine(DelayedEjectOneFrame()); } m_prevLatchOpen = flag; } private IEnumerator DelayedEjectOneFrame() { yield return null; TryAutoEjectSpent(); } private void TryAutoEjectSpent() { //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_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_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_0080: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)base.Chamber == (Object)null) && base.Chamber.IsFull && base.Chamber.IsSpent) { Vector3 ejectDirection = GetEjectDirection(((Component)base.Chamber).transform, EjectAxis); Vector3 val = ((Component)base.Chamber).transform.position + ejectDirection * Mathf.Abs(EjectOffset); Vector3 val2 = ejectDirection * Mathf.Abs(EjectVelocity.z) + ((Component)base.Chamber).transform.up * EjectVelocity.y + ((Component)base.Chamber).transform.right * EjectVelocity.x; FVRFireArmRound val3 = base.Chamber.EjectRound(val, val2, EjectAngular, false); } } catch (Exception) { } } private Vector3 GetEjectDirection(Transform t, ChamberShellInsertEject.EjectAxisType axis) { //IL_0021: 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_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_004a: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) return (Vector3)(axis switch { ChamberShellInsertEject.EjectAxisType.LocalForward => t.forward, ChamberShellInsertEject.EjectAxisType.LocalBack => -t.forward, ChamberShellInsertEject.EjectAxisType.LocalRight => t.right, ChamberShellInsertEject.EjectAxisType.LocalLeft => -t.right, ChamberShellInsertEject.EjectAxisType.LocalUp => t.up, _ => -t.up, }); } private float GetAxisAngle(Vector3 euler, LatchAxisType axis) { return axis switch { LatchAxisType.X => euler.x, LatchAxisType.Y => euler.y, _ => euler.z, }; } private float NormalizeAngle(float a) { while (a > 180f) { a -= 360f; } while (a < -180f) { a += 360f; } return a; } private Transform FindLatchVisualFromObject(FVRInteractiveObject obj) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown if ((Object)(object)obj == (Object)null) { return null; } Type type = ((object)obj).GetType(); string[] array = new string[5] { "LatchVisual", "LatchTransform", "DustCoverGeo", "DustCover", "Latch" }; string[] array2 = array; foreach (string name in array2) { FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public); if ((object)field != null && (object)field.FieldType == typeof(Transform)) { try { return (Transform)field.GetValue(obj); } catch { } } PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public); if ((object)property != null && (object)property.PropertyType == typeof(Transform)) { try { return (Transform)property.GetValue(obj, null); } catch { } } } MeshRenderer componentInChildren = ((Component)obj).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { return ((Component)componentInChildren).transform; } SkinnedMeshRenderer componentInChildren2 = ((Component)obj).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { return ((Component)componentInChildren2).transform; } return null; } private bool IsLatchOpen() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) bool result = false; if ((Object)(object)LatchVisual != (Object)null) { float num = NormalizeAngle(GetAxisAngle(LatchVisual.localEulerAngles, LatchAxis)); float num2 = Mathf.Abs(NormalizeAngle(num - m_latchBaseAngle)); result = num2 >= Mathf.Abs(LatchEjectAngleThreshold); } else if ((Object)(object)LatchObject != (Object)null) { Type type = ((object)LatchObject).GetType(); PropertyInfo property = type.GetProperty("IsOpen", BindingFlags.Instance | BindingFlags.Public); if ((object)property != null && (object)property.PropertyType == typeof(bool)) { try { result = (bool)property.GetValue(LatchObject, null); } catch { result = false; } } else { FieldInfo field = type.GetField("IsOpen", BindingFlags.Instance | BindingFlags.Public); if ((object)field != null && (object)field.FieldType == typeof(bool)) { try { result = (bool)field.GetValue(LatchObject); } catch { result = false; } } else { MethodInfo method = type.GetMethod("IsOpen", BindingFlags.Instance | BindingFlags.Public); if ((object)method != null && (object)method.ReturnType == typeof(bool) && method.GetParameters().Length == 0) { try { result = (bool)method.Invoke(LatchObject, null); } catch { result = false; } } } } } return result; } } namespace ShermanJumbo { public class ChamberShellInsertEject : FVRInteractiveObject { public enum ChamberSlideState { In, Middle, Out } public enum EjectAxisType { LocalForward, LocalBack, LocalRight, LocalLeft, LocalUp, LocalDown } public FVRFireArmChamber Chamber; public bool IsCaseless = false; public AudioEvent AudEvent_ShellInStart; public AudioEvent AudEvent_ShellIn; public AudioEvent AudEvent_ShellOutStart; public AudioEvent AudEvent_ShellOut; public Transform ChamberPoint_Back; public Transform ChamberPoint_Forward; public ChamberSlideState CSState = (ChamberSlideState)2; private float m_curZ; private float m_tarZ; public float ZThreshold = 0.02f; private float m_timeHeld; private BreakActionWeapon BOWeapon; private bool BOWeaponHingeOpen = false; public float PostEjectLock = 0.2f; private float m_lastEjectTime = -10f; public void OnDestroy() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown ((FVRInteractiveObject)this).OnDestroy(); GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(ShotFired); } private void ShotFired(FVRFireArm firearm) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: 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_00a2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)firearm == (Object)(object)Chamber.Firearm && IsCaseless) { ((Component)Chamber).transform.localPosition = new Vector3(((Component)Chamber).transform.localPosition.x, ((Component)Chamber).transform.localPosition.y, ChamberPoint_Back.localPosition.z); m_curZ = ChamberPoint_Back.localPosition.z; m_tarZ = m_curZ; CSState = (ChamberSlideState)2; } } public override void Awake() { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown ((FVRInteractiveObject)this).Awake(); m_curZ = ChamberPoint_Back.localPosition.z; m_tarZ = m_curZ; GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(ShotFired); ref BreakActionWeapon bOWeapon = ref BOWeapon; FVRFireArm firearm = Chamber.Firearm; bOWeapon = (BreakActionWeapon)(object)((firearm is BreakActionWeapon) ? firearm : null); } public override bool IsInteractable() { return Chamber.IsFull && (BOWeaponHingeOpen || (Object)(object)BOWeapon == (Object)null); } public override void UpdateInteraction(FVRViveHand hand) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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) ((FVRInteractiveObject)this).UpdateInteraction(hand); float tarZ = Mathf.Clamp(((Component)Chamber.Firearm).transform.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).z, ChamberPoint_Back.localPosition.z, ChamberPoint_Forward.localPosition.z); m_tarZ = tarZ; } public override void EndInteraction(FVRViveHand hand) { //IL_0014: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) ((FVRInteractiveObject)this).EndInteraction(hand); float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z); float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z); if (num < ZThreshold * 2f) { m_tarZ = ChamberPoint_Back.localPosition.z; } else if (num2 < ZThreshold * 2f) { m_tarZ = ChamberPoint_Forward.localPosition.z; } } public override void BeginInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).BeginInteraction(hand); m_timeHeld = 0f; } public override void FVRUpdate() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Invalid comparison between Unknown and I4 //IL_01ce: 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_013a: Invalid comparison between Unknown and I4 //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Invalid comparison between Unknown and I4 //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Invalid comparison between Unknown and I4 //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Invalid comparison between Unknown and I4 //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); m_timeHeld += Time.deltaTime; if (!(Mathf.Abs(m_curZ - m_tarZ) > 0.001f)) { return; } m_curZ = Mathf.MoveTowards(m_curZ, m_tarZ, Time.deltaTime * 1f); ((Component)Chamber).transform.localPosition = new Vector3(((Component)Chamber).transform.localPosition.x, ((Component)Chamber).transform.localPosition.y, m_curZ); float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z); float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z); ChamberSlideState cSState = CSState; if (num < ZThreshold) { CSState = (ChamberSlideState)2; } else if (num2 < ZThreshold) { CSState = (ChamberSlideState)0; } else { CSState = (ChamberSlideState)1; } if ((int)CSState == 2 && (int)cSState != 2) { SM.PlayGenericSound(AudEvent_ShellOut, ((Component)this).transform.position); if (m_timeHeld > 0.2f) { FVRFireArmRound val = Chamber.EjectRound(((Component)ChamberPoint_Back).transform.position, ChamberPoint_Back.forward * 0.1f, Vector3.zero, false); if (((FVRInteractiveObject)this).IsHeld) { FVRViveHand hand = base.m_hand; hand.ForceSetInteractable((FVRInteractiveObject)(object)val); ((FVRInteractiveObject)val).BeginInteraction(hand); } } } else if ((int)CSState == 0 && (int)cSState != 0) { SM.PlayGenericSound(AudEvent_ShellIn, ((Component)this).transform.position); try { Collider[] array = Physics.OverlapSphere(((Component)Chamber).transform.position, 0.12f); FVRFireArmRound val2 = null; float num3 = float.MaxValue; Collider[] array2 = array; foreach (Collider val3 in array2) { if ((Object)(object)val3 == (Object)null) { continue; } FVRFireArmRound componentInParent = ((Component)val3).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { float num4 = Vector3.Distance(((Component)componentInParent).transform.position, ((Component)Chamber).transform.position); if (num4 < num3) { num3 = num4; val2 = componentInParent; } } } if ((Object)(object)val2 != (Object)null) { if (((FVRInteractiveObject)val2).IsHeld) { try { ((FVRInteractiveObject)val2).ForceBreakInteraction(); } catch { } ((MonoBehaviour)this).StartCoroutine(SeatWhenReady(val2)); } else { ((MonoBehaviour)this).StartCoroutine(SeatWhenReady(val2)); } } } catch (Exception ex) { Debug.LogWarning((object)("[ChamberShellInsertEject] Seat attempt failed: " + ex.Message)); } } else if ((int)CSState == 1 && (int)cSState == 0) { SM.PlayGenericSound(AudEvent_ShellOutStart, ((Component)this).transform.position); } else if ((int)CSState == 1 && (int)cSState == 2) { SM.PlayGenericSound(AudEvent_ShellInStart, ((Component)this).transform.position); } if ((Object)(object)BOWeapon != (Object)null) { if (!BOWeapon.m_isLatched) { BOWeaponHingeOpen = true; } else { BOWeaponHingeOpen = false; } } } public void TryEjectSpentRound(EjectAxisType axis = EjectAxisType.LocalBack, float offset = 0.06f, Vector3 ejectVelocity = default(Vector3), Vector3 ejectAngular = default(Vector3)) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0070: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)Chamber == (Object)null) && Chamber.IsFull && Chamber.IsSpent) { if (ejectVelocity == default(Vector3)) { ((Vector3)(ref ejectVelocity))..ctor(0f, 0f, 0.12f); } if (ejectAngular == default(Vector3)) { ejectAngular = Vector3.zero; } Vector3 ejectDirection = GetEjectDirection(((Component)Chamber).transform, axis); Vector3 val = ((Component)Chamber).transform.position + ejectDirection * Mathf.Abs(offset); Vector3 val2 = ejectDirection * Mathf.Abs(ejectVelocity.z) + ((Component)Chamber).transform.up * ejectVelocity.y + ((Component)Chamber).transform.right * ejectVelocity.x; FVRFireArmRound val3 = Chamber.EjectRound(val, val2, ejectAngular, false); if ((Object)(object)val3 != (Object)null) { m_lastEjectTime = Time.time; Debug.Log((object)("[ChamberShellInsertEject] Ejected round. mark lastEjectTime=" + m_lastEjectTime)); } else { Debug.LogWarning((object)"[ChamberShellInsertEject] EjectRound returned null."); } } } catch (Exception ex) { Debug.LogWarning((object)("[ChamberShellInsertEject] TryEjectSpentRound failed: " + ex.Message)); } } private IEnumerator SeatWhenReady(FVRFireArmRound round) { if ((Object)(object)round == (Object)null || (Object)(object)Chamber == (Object)null) { yield break; } float wait = 0f; float earliest = m_lastEjectTime + PostEjectLock; if (Time.time < earliest) { wait = earliest - Time.time; Debug.Log((object)("[ChamberShellInsertEject] Delaying seat for " + wait + "s to avoid race with eject")); yield return (object)new WaitForSeconds(wait); } if (!((Object)(object)round == (Object)null)) { if (Chamber.IsFull && (Object)(object)Chamber.GetRound() != (Object)null) { Debug.Log((object)"[ChamberShellInsertEject] Seat aborted: Chamber already has round."); } else { SeatRoundAnimatedFromBack_Internal(round); } } } private void SeatRoundAnimatedFromBack_Internal(FVRFireArmRound round) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)round == (Object)null || (Object)(object)Chamber == (Object)null) { return; } try { Vector3 position = ChamberPoint_Back.position; Quaternion rotation = ChamberPoint_Back.rotation; Debug.Log((object)string.Concat("[ChamberShellInsertEject] SeatRoundAnimatedFromBack: calling Chamber.SetRound(startPos=", position, ")")); try { Chamber.SetRound(round, position, rotation); } catch { try { Chamber.SetRound(round, false); } catch { } } ((MonoBehaviour)this).StartCoroutine(DestroyPhysicalRoundAfterDelay(round, 0.15f)); } catch (Exception ex) { Debug.LogWarning((object)("[ChamberShellInsertEject] SeatRoundAnimatedFromBack_Internal failed: " + ex.Message)); } } private IEnumerator DestroyPhysicalRoundAfterDelay(FVRFireArmRound round, float delay) { if ((Object)(object)round == (Object)null) { yield break; } float t = 0f; while (t < delay) { if ((Object)(object)round == (Object)null) { yield break; } t += Time.deltaTime; yield return null; } try { if ((Object)(object)round != (Object)null && !((FVRInteractiveObject)round).IsHeld) { Object.Destroy((Object)(object)((Component)round).gameObject); } } catch { } } private Vector3 GetEjectDirection(Transform t, EjectAxisType axis) { //IL_0021: 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_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_004a: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) return (Vector3)(axis switch { EjectAxisType.LocalForward => t.forward, EjectAxisType.LocalBack => -t.forward, EjectAxisType.LocalRight => t.right, EjectAxisType.LocalLeft => -t.right, EjectAxisType.LocalUp => t.up, _ => -t.up, }); } } } namespace Volksscript { public class PG_Chamber : FVRInteractiveObject { public enum ChamberSlideState { In, Middle, Out } [Header("References")] public FVRFireArmChamber Chamber; public Transform ChamberPoint_Back; public Transform ChamberPoint_Forward; public Transform ChamberRoot; public PG_Launcher Launcher; [Header("Tuning")] public float ZThreshold = 0.02f; public float MoveSpeed = 1f; [Header("Audio")] public AudioEvent AudEvent_Insert; public AudioEvent AudEvent_Remove; private float m_curZ; private float m_tarZ; private float m_timeHeld; public ChamberSlideState CSState = ChamberSlideState.Out; protected void Awake() { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).Awake(); if ((Object)(object)ChamberPoint_Back != (Object)null) { m_curZ = ChamberPoint_Back.localPosition.z; } else { m_curZ = ((Component)this).transform.localPosition.z; } m_tarZ = m_curZ; Vector3 localPosition = ((Component)this).transform.localPosition; ((Component)this).transform.localPosition = new Vector3(localPosition.x, localPosition.y, m_curZ); } public override bool IsInteractable() { return ((FVRInteractiveObject)this).IsInteractable() && (Object)(object)Chamber != (Object)null && (Object)(object)ChamberPoint_Back != (Object)null && (Object)(object)ChamberPoint_Forward != (Object)null; } public override void BeginInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).BeginInteraction(hand); m_timeHeld = 0f; } public override void UpdateInteraction(FVRViveHand hand) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_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) ((FVRInteractiveObject)this).UpdateInteraction(hand); Transform val = (((Object)(object)ChamberRoot != (Object)null) ? ChamberRoot : ((!((Object)(object)((Component)this).transform.parent != (Object)null)) ? ((Component)this).transform : ((Component)this).transform.parent)); float tarZ = Mathf.Clamp(val.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).z, ChamberPoint_Back.localPosition.z, ChamberPoint_Forward.localPosition.z); m_tarZ = tarZ; } public override void EndInteraction(FVRViveHand hand) { //IL_0014: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).EndInteraction(hand); float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z); float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z); if (num < ZThreshold * 2f) { m_tarZ = ChamberPoint_Back.localPosition.z; } else if (num2 < ZThreshold * 2f) { m_tarZ = ChamberPoint_Forward.localPosition.z; } } protected void FVRUpdate() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); m_timeHeld += Time.deltaTime; if (Mathf.Abs(m_curZ - m_tarZ) > 0.0001f) { m_curZ = Mathf.MoveTowards(m_curZ, m_tarZ, MoveSpeed * Time.deltaTime); Vector3 localPosition = ((Component)this).transform.localPosition; ((Component)this).transform.localPosition = new Vector3(localPosition.x, localPosition.y, m_curZ); } float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z); float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z); ChamberSlideState cSState = CSState; if (num < ZThreshold) { CSState = ChamberSlideState.Out; } else if (num2 < ZThreshold) { CSState = ChamberSlideState.In; } else { CSState = ChamberSlideState.Middle; } if (CSState == ChamberSlideState.Out && cSState != ChamberSlideState.Out) { if (AudEvent_Remove != null && (Object)(object)Launcher != (Object)null) { ((FVRFireArm)Launcher).PlayAudioAsHandling(AudEvent_Remove, ((Component)this).transform.position); } if ((Object)(object)Chamber != (Object)null && Chamber.IsFull && Chamber.IsSpent) { try { Vector3 val = ((Component)Chamber).transform.position + ((Component)Chamber).transform.forward * 0.05f; Chamber.EjectRound(val, ((Component)Chamber).transform.forward * 0.1f, Vector3.zero, false); } catch { } } } else if (CSState == ChamberSlideState.In && cSState != ChamberSlideState.In && AudEvent_Insert != null && (Object)(object)Launcher != (Object)null) { ((FVRFireArm)Launcher).PlayAudioAsHandling(AudEvent_Insert, ((Component)this).transform.position); } } } public class PG_Latch : FVRInteractiveObject { [Header("References")] public PG_Launcher Launcher; public FVRFireArmChamber Chamber; public Transform LatchTransform; public Transform RearPiece; [Header("Latch Rotation (X axis)")] public float LatchClosedAngle = 0f; public float LatchOpenAngle = 15f; [Header("RearPiece Rotation (Z axis)")] public float RearClosedZ = 0f; public float RearOpenZ = 15f; [Header("Speed")] public float MoveSpeed = 300f; [Header("State")] public bool IsOpen = false; public bool DebugLatch; protected void Awake() { ((FVRInteractiveObject)this).Awake(); ApplyVisualsImmediate(IsOpen); } public override void UpdateInteraction(FVRViveHand hand) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) ((FVRInteractiveObject)this).UpdateInteraction(hand); bool flag = false; if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown) { flag = true; } } else { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.left) <= 45f) { flag = true; } } if (flag) { ToggleLatch(); } } public void ToggleLatch() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) IsOpen = !IsOpen; ApplyVisualsImmediate(IsOpen); if (DebugLatch) { Debug.Log((object)("[PG_Latch] ToggleLatch -> " + IsOpen)); } if (!IsOpen) { return; } FVRFireArmChamber val = (((Object)(object)Chamber != (Object)null) ? Chamber : ((!((Object)(object)Launcher != (Object)null)) ? null : Launcher.Chamber)); if ((Object)(object)val != (Object)null && val.IsFull && val.IsSpent) { try { Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 0.05f; val.EjectRound(val2, ((Component)val).transform.forward * 0.1f, Vector3.zero, false); } catch { } } } protected void FVRUpdate() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0116: 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) ((FVRInteractiveObject)this).FVRUpdate(); float num = ((!IsOpen) ? LatchClosedAngle : LatchOpenAngle); float num2 = ((!IsOpen) ? RearClosedZ : RearOpenZ); if ((Object)(object)LatchTransform != (Object)null) { float num3 = NormalizeAngle(LatchTransform.localEulerAngles.x); float num4 = Mathf.MoveTowardsAngle(num3, num, MoveSpeed * Time.deltaTime); Vector3 localEulerAngles = LatchTransform.localEulerAngles; localEulerAngles.x = num4; LatchTransform.localEulerAngles = localEulerAngles; if (DebugLatch) { Debug.Log((object)("[PG_Latch] Latch.x -> " + num4)); } } if ((Object)(object)RearPiece != (Object)null) { float num5 = NormalizeAngle(RearPiece.localEulerAngles.z); float num6 = Mathf.MoveTowardsAngle(num5, num2, MoveSpeed * Time.deltaTime); Vector3 localEulerAngles2 = RearPiece.localEulerAngles; localEulerAngles2.z = num6; RearPiece.localEulerAngles = localEulerAngles2; if (DebugLatch) { Debug.Log((object)("[PG_Latch] Rear.z -> " + num6)); } } } private void ApplyVisualsImmediate(bool open) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0043: 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) if ((Object)(object)LatchTransform != (Object)null) { Vector3 localEulerAngles = LatchTransform.localEulerAngles; localEulerAngles.x = ((!open) ? LatchClosedAngle : LatchOpenAngle); LatchTransform.localEulerAngles = localEulerAngles; } if ((Object)(object)RearPiece != (Object)null) { Vector3 localEulerAngles2 = RearPiece.localEulerAngles; localEulerAngles2.z = ((!open) ? RearClosedZ : RearOpenZ); RearPiece.localEulerAngles = localEulerAngles2; } } private float NormalizeAngle(float a) { while (a > 180f) { a -= 360f; } while (a < -180f) { a += 360f; } return a; } } public class PG_Launcher : FVRFireArm { public enum SafetyAxisType { X, Y, Z } [Header("Parts")] public FVRFireArmChamber Chamber; public Transform Trigger; public Transform SafetyLever; public Transform FireSelectorSwitch; [Header("Rotation")] public Vector2 TriggerRots = new Vector2(-8f, 8f); [Header("Safety Visual (angles)")] public Vector2 SafetyRots = new Vector2(30f, 0f); [Header("Safety Axis")] public SafetyAxisType SafetyAxis = SafetyAxisType.X; [Header("Fire selector")] public float[] FireSelectorAngles = new float[0]; [Header("Fire selector axis (switch rotation)")] public SafetyAxisType FireSelectorAxis = SafetyAxisType.Z; private int m_fireSelectorIndex = 0; [Header("State")] public bool SafetyOn = true; [Header("Tuning")] public float TriggerAnimSpeed = 10f; public bool DebugSafetyAnim; public bool DebugTriggerAnim; public bool DebugSelector; private float m_triggerFloat; private bool m_hasTriggerReset; protected void Awake() { ((FVRFireArm)this).Awake(); if ((Object)(object)Chamber != (Object)null) { base.FChambers.Add(Chamber); } ApplySelectorVisual(); UpdateSafetyVisual(); } public override int GetTutorialState() { if ((Object)(object)Chamber == (Object)null || !Chamber.IsFull) { return 0; } if ((Object)(object)((FVRPhysicalObject)this).AltGrip == (Object)null) { return 1; } return 2; } public override void UpdateInteraction(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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) ((FVRPhysicalObject)this).UpdateInteraction(hand); Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown) { ToggleSafety(); } if (hand.Input.BYButtonDown) { ToggleFireSelector(); } } else if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f) { if (Vector2.Angle(touchpadAxes, Vector2.left) <= 45f) { ToggleFireSelector(); } else if (Vector2.Angle(touchpadAxes, Vector2.right) <= 45f) { ToggleSafety(); } } m_triggerFloat = hand.Input.TriggerFloat; UpdateTriggerRot(m_triggerFloat); if (hand.Input.TriggerDown) { if (!SafetyOn) { Fire(); } else if (DebugSafetyAnim) { Debug.Log((object)"[PG_Launcher] Fire blocked by safety"); } } } private void ToggleSafety() { SafetyOn = !SafetyOn; UpdateSafetyVisual(); if (DebugSafetyAnim) { Debug.Log((object)("[PG_Launcher] Safety toggled -> " + SafetyOn)); } } private void ToggleFireSelector() { if (FireSelectorAngles == null || FireSelectorAngles.Length == 0) { if (DebugSelector) { Debug.LogWarning((object)"[PG_Launcher] No FireSelectorAngles configured."); } return; } m_fireSelectorIndex++; if (m_fireSelectorIndex >= FireSelectorAngles.Length) { m_fireSelectorIndex = 0; } try { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)15, 1f); } catch { } ApplySelectorVisual(); if (DebugSelector) { Debug.Log((object)("[PG_Launcher] FireSelector index -> " + m_fireSelectorIndex)); } } private void ApplySelectorVisual() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)FireSelectorSwitch == (Object)null) && FireSelectorAngles != null && FireSelectorAngles.Length != 0) { float num = FireSelectorAngles[Mathf.Clamp(m_fireSelectorIndex, 0, FireSelectorAngles.Length - 1)]; Vector3 v = FireSelectorSwitch.localEulerAngles; SetAxis(ref v, FireSelectorAxis, num); FireSelectorSwitch.localEulerAngles = v; if (DebugSelector) { Debug.Log((object)("[PG_Launcher] Applied selector angle=" + num)); } } } public void UpdateTriggerRot(float f) { //IL_003f: 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_005a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Trigger == (Object)null)) { float num = Mathf.Lerp(TriggerRots.x, TriggerRots.y, Mathf.Clamp01(f)); Vector3 localEulerAngles = Trigger.localEulerAngles; Trigger.localEulerAngles = new Vector3(num, localEulerAngles.y, localEulerAngles.z); if (DebugTriggerAnim) { Debug.Log((object)("[PG_Launcher] Trigger.euler.x=" + num)); } } } private void SetAxis(ref Vector3 v, SafetyAxisType axis, float value) { switch (axis) { case SafetyAxisType.X: v.x = value; break; case SafetyAxisType.Y: v.y = value; break; default: v.z = value; break; } } public void UpdateSafetyVisual() { //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_0070: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)SafetyLever == (Object)null)) { float num = ((!SafetyOn) ? 1f : 0f); float num2 = Mathf.Lerp(SafetyRots.x, SafetyRots.y, num); Vector3 v = SafetyLever.localEulerAngles; SetAxis(ref v, SafetyAxis, num2); SafetyLever.localEulerAngles = v; if (DebugSafetyAnim) { Debug.Log((object)string.Concat("[PG_Launcher] Safety.euler.", SafetyAxis, "=", num2, " (SafetyOn=", SafetyOn, ")")); } } } public void Fire() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (SafetyOn) { if (DebugSafetyAnim) { Debug.Log((object)"[PG_Launcher] Fire() blocked - SafetyOn"); } } else { if ((Object)(object)Chamber == (Object)null) { return; } if (!Chamber.IsFull || Chamber.IsSpent) { try { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); return; } catch { return; } } ((FVRFireArm)this).Fire(Chamber, GetMuzzle(), true, 1f, -1f); ((FVRFireArm)this).FireMuzzleSmoke(); bool flag = ((FVRFireArm)this).IsTwoHandStabilized(); bool flag2 = (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null; bool flag3 = ((FVRFireArm)this).IsShoulderStabilized(); try { ((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f); } catch { } try { ((FVRFireArm)this).PlayAudioGunShot(Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); } catch { } Chamber.SetRound((FVRFireArmRound)null, false); } } protected Transform GetMuzzle() { try { return ((FVRFireArm)this).GetMuzzle(); } catch { return ((Component)this).transform; } } } } public class Pansarvarnsgevar_Latch : FVRInteractiveObject { public enum LatchAxis { X, Y, Z } public enum State { Closed, Middle, Open } public enum PGLatchState { Closed, Middle, Open } public Transform LatchVisual; public Transform BreechPivot; public Vector3 BreechClosedLocalEuler; public Vector3 BreechOpenLocalEuler; public float RotMin = 0f; public float RotMax = 90f; public bool IsMinOpen = false; public float UnlockRotMin = 0f; public float UnlockRotMax = 15f; public float UnlockThreshold = 10f; public float RotateSpeed = 900f; public float UnlockSpeed = 900f; public AudioEvent AudEvent_Open; public AudioEvent AudEvent_Close; public bool DebugLatch; private float m_curRot; private float m_tarRot; private float m_curUnlockRot; private float m_tarUnlockRot; private bool m_isUnlocked; private Vector3 m_baseLocalEuler; public LatchAxis RotateAxis = LatchAxis.Y; public LatchAxis RotateReferenceAxis = LatchAxis.Z; public LatchAxis UnlockAxis = LatchAxis.X; public LatchAxis UnlockReferenceAxis = LatchAxis.Z; private State m_state = State.Closed; public PGLatchState LState { get { return (PGLatchState)m_state; } set { m_state = (State)value; } } protected void Awake() { //IL_005f: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).Awake(); m_curRot = GetClosedRot(); m_tarRot = m_curRot; m_curUnlockRot = UnlockRotMin; m_tarUnlockRot = m_curUnlockRot; m_baseLocalEuler = ((!((Object)(object)LatchVisual != (Object)null)) ? ((Component)this).transform.localEulerAngles : LatchVisual.localEulerAngles); if (DebugLatch) { Debug.Log((object)string.Concat("[Pansarvarnsgevar_Latch] Awake - baseLocalEuler=", m_baseLocalEuler, " LatchVisual=", (!Object.op_Implicit((Object)(object)LatchVisual)) ? "null" : ((Object)LatchVisual).name)); } } public override bool IsInteractable() { bool flag = ((FVRInteractiveObject)this).IsInteractable(); if (DebugLatch) { Debug.Log((object)("[Pansarvarnsgevar_Latch] IsInteractable -> " + flag)); } return flag; } public override void UpdateInteraction(FVRViveHand hand) { //IL_0015: 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_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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007e: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).UpdateInteraction(hand); Transform transform = ((Component)this).transform; Vector3 val = ((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position; float signedAngle = GetSignedAngle(val, GetAxisVector(UnlockReferenceAxis, transform), GetAxisVector(UnlockAxis, transform)); signedAngle = (m_tarUnlockRot = Mathf.Clamp(signedAngle, UnlockRotMin, UnlockRotMax)); float signedAngle2 = GetSignedAngle(val, GetAxisVector(RotateReferenceAxis, transform), GetAxisVector(RotateAxis, transform)); signedAngle2 = Mathf.Clamp(signedAngle2, RotMin, RotMax); if (DebugLatch) { Debug.Log((object)("[Pansarvarnsgevar_Latch] UpdateInteraction unlock=" + signedAngle + " rot=" + signedAngle2 + " isUnlocked=" + m_isUnlocked + " state=" + m_state)); } if (m_state == State.Closed && !m_isUnlocked) { if (!(m_tarUnlockRot >= UnlockThreshold)) { m_tarRot = GetClosedRot(); return; } m_isUnlocked = true; if (DebugLatch) { Debug.Log((object)"[Pansarvarnsgevar_Latch] Unlocked by push"); } } m_tarRot = signedAngle2; } public override void EndInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).EndInteraction(hand); float num = Mathf.Abs(m_curRot - RotMin); float num2 = Mathf.Abs(m_curRot - RotMax); m_tarRot = ((!(num < num2)) ? RotMax : RotMin); m_isUnlocked = false; m_tarUnlockRot = UnlockRotMin; if (DebugLatch) { Debug.Log((object)("[Pansarvarnsgevar_Latch] EndInteraction snapped to " + m_tarRot)); } } protected void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (m_state == State.Closed) { m_tarUnlockRot = UnlockRotMin; m_isUnlocked = false; } if (Mathf.Abs(m_curRot - m_tarRot) > 0.001f || Mathf.Abs(m_curUnlockRot - m_tarUnlockRot) > 0.001f) { m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * RotateSpeed); m_curUnlockRot = Mathf.MoveTowards(m_curUnlockRot, m_tarUnlockRot, Time.deltaTime * UnlockSpeed); ApplyLatchRotation(); float num = Mathf.Abs(m_curRot - RotMin); float num2 = Mathf.Abs(m_curRot - RotMax); State state = m_state; if (num < 1f) { m_state = (IsMinOpen ? State.Open : State.Closed); } else if (num2 < 1f) { m_state = ((!IsMinOpen) ? State.Open : State.Closed); } else { m_state = State.Middle; } if (m_state != state) { if (DebugLatch) { Debug.Log((object)string.Concat("[Pansarvarnsgevar_Latch] State changed ", state, " -> ", m_state)); } if (m_state == State.Open) { if (AudEvent_Open == null) { } } else if (m_state == State.Closed && AudEvent_Close == null) { } } } UpdateBreechPivot(); } private void ApplyLatchRotation() { //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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) Vector3 v = m_baseLocalEuler; if (RotateAxis == UnlockAxis) { SetAxisValue(ref v, RotateAxis, m_curRot + m_curUnlockRot); } else { SetAxisValue(ref v, RotateAxis, m_curRot); SetAxisValue(ref v, UnlockAxis, m_curUnlockRot); } Transform val = ((!((Object)(object)LatchVisual != (Object)null)) ? ((Component)this).transform : LatchVisual); val.localRotation = Quaternion.Euler(v); if (DebugLatch) { Debug.Log((object)string.Concat("[Pansarvarnsgevar_Latch] Applied: ", v, " -> ", (!Object.op_Implicit((Object)(object)val)) ? "null" : ((Object)val).name)); } } private void LateUpdate() { //IL_0018: 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_0081: 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) if (!((Object)(object)LatchVisual == (Object)null)) { Vector3 v = m_baseLocalEuler; if (RotateAxis == UnlockAxis) { SetAxisValue(ref v, RotateAxis, m_curRot + m_curUnlockRot); } else { SetAxisValue(ref v, RotateAxis, m_curRot); SetAxisValue(ref v, UnlockAxis, m_curUnlockRot); } LatchVisual.localRotation = Quaternion.Euler(v); } } private void UpdateBreechPivot() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)BreechPivot == (Object)null)) { float num = ((!IsMinOpen) ? RotMax : RotMin); float closedRot = GetClosedRot(); float num2 = Mathf.InverseLerp(closedRot, num, m_curRot); Vector3 localEulerAngles = Vector3.Lerp(BreechClosedLocalEuler, BreechOpenLocalEuler, num2); BreechPivot.localEulerAngles = localEulerAngles; } } private float GetClosedRot() { return (!IsMinOpen) ? RotMin : RotMax; } private Vector3 GetAxisVector(LatchAxis axis, Transform basis) { //IL_0014: 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_0037: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(axis switch { LatchAxis.X => basis.right, LatchAxis.Y => basis.up, _ => basis.forward, }); } private void SetAxisValue(ref Vector3 v, LatchAxis axis, float value) { switch (axis) { case LatchAxis.X: v.x = value; break; case LatchAxis.Y: v.y = value; break; default: v.z = value; break; } } public float GetSignedAngle(Vector3 from, Vector3 to, Vector3 axis) { //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_0008: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001a: 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_0027: 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) Vector3 val = Vector3.ProjectOnPlane(from, axis); from = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(axis, to); float num = Mathf.Sign(Vector3.Dot(from, val2)); float num2 = Vector3.Angle(from, to); return num2 * num; } public bool IsOpen() { return m_state == State.Open; } } public class Pansarvarnsgevar_Launcher : FVRFireArm { public enum Axis { X, Y, Z } public enum AnimateMode { Rotation, Translation } private List m_disabledAnimators = new List(); private List m_disabledAnimatorsPrevState = new List(); public FVRFireArmChamber Chamber; public Pansarvarnsgevar_ShellEject ShellInsertEject; public Pansarvarnsgevar_Latch TailLatch; public Transform Trigger; public AnimateMode TriggerAnimateMode = AnimateMode.Rotation; public Axis TriggerAxis = Axis.X; public float TriggerFiringThreshold = 0.8f; public float TriggerResetThreshold = 0.4f; public float Trigger_ForwardValue; public float Trigger_RearwardValue; public Transform SafetyLever; public bool SafetyOn; public AnimateMode SafetyAnimateMode = AnimateMode.Rotation; public Axis SafetyAxis = Axis.X; public float SafetyOnValue; public float SafetyOffValue; private float m_triggerFloat; private float m_lastTriggerFloat; private bool m_hasTriggerReset; private Vector3 m_triggerBaseLocalEuler; private Vector3 m_triggerBaseLocalPos; private Vector3 m_safetyBaseLocalEuler; private Vector3 m_safetyBaseLocalPos; public AudioEvent AudEvent_BackSound; public Transform COM; public bool DebugSafetyInput; public bool DebugSafetyAnim; public bool DebugTriggerInput; public bool DebugTriggerAnim; protected void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArm)this).Awake(); base.FChambers.Add(Chamber); ((FVRPhysicalObject)this).RootRigidbody.centerOfMass = COM.localPosition; ValidateAndAssignVisual(ref Trigger, ref m_triggerBaseLocalEuler, ref m_triggerBaseLocalPos, "trigger"); ValidateAndAssignVisual(ref SafetyLever, ref m_safetyBaseLocalEuler, ref m_safetyBaseLocalPos, "safety"); } private void ValidateAndAssignVisual(ref Transform t, ref Vector3 baseEuler, ref Vector3 basePos, string hint) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)t == (Object)null) { Transform val = FindChildByNameHint(((Component)this).transform, hint); if ((Object)(object)val != (Object)null) { t = val; Debug.Log((object)("[Pansarvarnsgevar_Launcher] Auto-assigned " + hint + " -> " + ((Object)val).name)); } } if (!((Object)(object)t != (Object)null)) { return; } if (!((Object)(object)((Component)t).GetComponent() != (Object)null) && !((Object)(object)((Component)t).GetComponent() != (Object)null)) { Transform val2 = FindFirstMeshChild(t); if ((Object)(object)val2 != (Object)null) { Debug.Log((object)("[Pansarvarnsgevar_Launcher] Repointing " + hint + " to mesh child: " + ((Object)val2).name)); t = val2; } } baseEuler = t.localEulerAngles; basePos = t.localPosition; Animator componentInParent = ((Component)t).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && ((Behaviour)componentInParent).enabled) { m_disabledAnimators.Add(componentInParent); m_disabledAnimatorsPrevState.Add(((Behaviour)componentInParent).enabled); ((Behaviour)componentInParent).enabled = false; Debug.LogWarning((object)("[Pansarvarnsgevar_Launcher] Disabled Animator on '" + ((Object)((Component)componentInParent).gameObject).name + "' to allow manual trigger/safety animation. It will be restored on destroy.")); } } private Transform FindChildByNameHint(Transform root, string hint) { hint = hint.ToLowerInvariant(); Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name.ToLowerInvariant().Contains(hint)) { return val; } } return null; } private Transform FindFirstMeshChild(Transform root) { MeshRenderer componentInChildren = ((Component)root).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { return ((Component)componentInChildren).transform; } SkinnedMeshRenderer componentInChildren2 = ((Component)root).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { return ((Component)componentInChildren2).transform; } return null; } protected void FVRUpdate() { //IL_0087: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArm)this).FVRUpdate(); Chamber.IsAccessible = (Object)(object)TailLatch != (Object)null && TailLatch.IsOpen(); float num = Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat); if (Mathf.Abs(m_triggerFloat - m_lastTriggerFloat) > 0.0001f) { m_lastTriggerFloat = m_triggerFloat; ApplyAnimatedAxis(Trigger, TriggerAnimateMode, TriggerAxis, num, m_triggerBaseLocalPos, m_triggerBaseLocalEuler); if (DebugTriggerAnim) { Debug.Log((object)("[Pansarvarnsgevar_Launcher] TriggerAnim applied - value=" + num + " m_triggerFloat=" + m_triggerFloat + " target=" + ((!((Object)(object)Trigger != (Object)null)) ? "null" : ((Object)Trigger).name))); } } float num2 = ((!SafetyOn) ? SafetyOffValue : SafetyOnValue); Transform val = ((!((Object)(object)SafetyLever != (Object)null)) ? ((Component)this).transform : SafetyLever); ApplyAnimatedAxis(val, SafetyAnimateMode, SafetyAxis, num2, m_safetyBaseLocalPos, m_safetyBaseLocalEuler); if (DebugSafetyAnim) { Debug.Log((object)("[Pansarvarnsgevar_Launcher] SafetyAnim applied - value=" + num2 + " SafetyOn=" + SafetyOn + " target=" + ((Object)val).name)); } } private void LateUpdate() { //IL_0014: 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_0047: 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_009d: 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_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_0119: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Trigger != (Object)null) { Vector3 v = m_triggerBaseLocalEuler; float num = Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat); SetAxisValue(ref v, TriggerAxis, num); Trigger.localEulerAngles = v; if (DebugTriggerAnim) { Debug.Log((object)string.Concat("[Pansarvarnsgevar_Launcher] LateUpdate applied Trigger.euler = ", v, " (value=", num, ")")); } ((MonoBehaviour)this).StartCoroutine(CheckOverwriteRotation(Trigger, Quaternion.Euler(v), "Launcher.Trigger")); } Transform val = ((!((Object)(object)SafetyLever != (Object)null)) ? ((Component)this).transform : SafetyLever); if ((Object)(object)val != (Object)null) { Vector3 v2 = m_safetyBaseLocalEuler; float num2 = ((!SafetyOn) ? SafetyOffValue : SafetyOnValue); SetAxisValue(ref v2, SafetyAxis, num2); val.localEulerAngles = v2; if (DebugSafetyAnim) { Debug.Log((object)string.Concat("[Pansarvarnsgevar_Launcher] LateUpdate applied Safety.euler = ", v2, " (value=", num2, ") target=", ((Object)val).name)); } ((MonoBehaviour)this).StartCoroutine(CheckOverwriteRotation(val, Quaternion.Euler(v2), "Launcher.Safety")); } } private IEnumerator CheckOverwriteRotation(Transform t, Quaternion expected, string name) { //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) yield return (object)new WaitForEndOfFrame(); if ((Object)(object)t == (Object)null || !(Quaternion.Angle(t.localRotation, expected) > 0.1f)) { yield break; } Debug.LogWarning((object)string.Concat("[Pansarvarnsgevar_Launcher] Transform overwritten next frame: ", name, " Expected=", ((Quaternion)(ref expected)).eulerAngles, " Actual=", t.localEulerAngles)); MeshRenderer componentInChildren = ((Component)t).GetComponentInChildren(); SkinnedMeshRenderer componentInChildren2 = ((Component)t).GetComponentInChildren(); Transform val = null; if ((Object)(object)componentInChildren != (Object)null) { val = ((Component)componentInChildren).transform; } else if ((Object)(object)componentInChildren2 != (Object)null) { val = ((Component)componentInChildren2).transform; } if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)t) { Debug.Log((object)("[Pansarvarnsgevar_Launcher] Found mesh child '" + ((Object)val).name + "'. Reassigning target to it and applying rotation.")); if (name.Contains("Trigger")) { Trigger = val; m_triggerBaseLocalEuler = val.localEulerAngles; m_triggerBaseLocalPos = val.localPosition; } else if (name.Contains("Safety")) { SafetyLever = val; m_safetyBaseLocalEuler = val.localEulerAngles; m_safetyBaseLocalPos = val.localPosition; } Vector3 v = ((!name.Contains("Trigger")) ? m_safetyBaseLocalEuler : m_triggerBaseLocalEuler); float value = (name.Contains("Trigger") ? Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat) : ((!SafetyOn) ? SafetyOffValue : SafetyOnValue)); SetAxisValue(ref v, (!name.Contains("Trigger")) ? SafetyAxis : TriggerAxis, value); ((!name.Contains("Trigger")) ? SafetyLever : Trigger).localEulerAngles = v; } } private void ApplyAnimatedAxis(Transform target, AnimateMode mode, Axis axis, float value, Vector3 basePos, Vector3 baseEuler) { //IL_0040: 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_004f: 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_0026: 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) if ((Object)(object)target == (Object)null) { Debug.LogWarning((object)"[Pansarvarnsgevar_Launcher] ApplyAnimatedAxis - target is null!"); } else if (mode == AnimateMode.Rotation) { Vector3 v = baseEuler; SetAxisValue(ref v, axis, value); target.localEulerAngles = v; } else { Vector3 v2 = basePos; SetAxisValue(ref v2, axis, value); target.localPosition = v2; } } private void SetAxisValue(ref Vector3 v, Axis axis, float value) { switch (axis) { case Axis.X: v.x = value; break; case Axis.Y: v.y = value; break; default: v.z = value; break; } } public void FixCOM() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)COM == (Object)null || (Object)(object)((FVRPhysicalObject)this).RootRigidbody == (Object)null) { Debug.LogWarning((object)"[Pansarvarnsgevar_Launcher] FixCOM skipped: COM or RootRigidbody null"); } else { ((FVRPhysicalObject)this).RootRigidbody.centerOfMass = COM.localPosition; } } } public class Pansarvarnsgevar_ShellEject : FVRInteractiveObject { public enum ChamberSlideState { In, Middle, Out } public Pansarvarnsgevar_Launcher PG; public AudioEvent AudEvent_ShellInStart; public AudioEvent AudEvent_ShellIn; public AudioEvent AudEvent_ShellOutStart; public AudioEvent AudEvent_ShellOut; public Transform ChamberPoint_Back; public Transform ChamberPoint_Forward; public Collider Col; public bool AllowEmptySlide = true; public ChamberSlideState CSState = ChamberSlideState.Out; private float m_curZ; private float m_tarZ; public float ZThreshold = 0.02f; private float m_timeHeld; protected void Awake() { //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) ((FVRInteractiveObject)this).Awake(); m_curZ = ChamberPoint_Back.localPosition.z; m_tarZ = m_curZ; } public override bool IsInteractable() { return PG.TailLatch.LState == Pansarvarnsgevar_Latch.PGLatchState.Open && (AllowEmptySlide || PG.Chamber.IsFull) && ((FVRInteractiveObject)this).IsInteractable(); } public void AutoEjectIfChambered() { //IL_0034: 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_0060: 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) if (PG.Chamber.IsFull) { SetSlideToBack(); ((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellOut, ((Component)this).transform.position); PG.Chamber.EjectRound(((Component)ChamberPoint_Back).transform.position, ChamberPoint_Back.forward * 0.1f, Vector3.zero, false); PG.FixCOM(); } } private void SetSlideToBack() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) m_curZ = ChamberPoint_Back.localPosition.z; m_tarZ = m_curZ; ((Component)PG.Chamber).transform.localPosition = new Vector3(((Component)PG.Chamber).transform.localPosition.x, ((Component)PG.Chamber).transform.localPosition.y, m_curZ); CSState = ChamberSlideState.Out; } public override void UpdateInteraction(FVRViveHand hand) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) ((FVRInteractiveObject)this).UpdateInteraction(hand); float tarZ = Mathf.Clamp(((Component)PG).transform.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).z, ChamberPoint_Back.localPosition.z, ChamberPoint_Forward.localPosition.z); m_tarZ = tarZ; } public override void EndInteraction(FVRViveHand hand) { //IL_0014: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) ((FVRInteractiveObject)this).EndInteraction(hand); float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z); float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z); if (num < ZThreshold * 2f) { m_tarZ = ChamberPoint_Back.localPosition.z; } else if (num2 < ZThreshold * 2f) { m_tarZ = ChamberPoint_Forward.localPosition.z; } } public override void BeginInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).BeginInteraction(hand); m_timeHeld = 0f; } protected void FVRUpdate() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); m_timeHeld += Time.deltaTime; if (!(Mathf.Abs(m_curZ - m_tarZ) > 0.001f)) { return; } m_curZ = Mathf.MoveTowards(m_curZ, m_tarZ, Time.deltaTime * 1f); ((Component)PG.Chamber).transform.localPosition = new Vector3(((Component)PG.Chamber).transform.localPosition.x, ((Component)PG.Chamber).transform.localPosition.y, m_curZ); float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z); float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z); ChamberSlideState cSState = CSState; if (num < ZThreshold) { CSState = ChamberSlideState.Out; } else if (num2 < ZThreshold) { CSState = ChamberSlideState.In; } else { CSState = ChamberSlideState.Middle; } if (CSState == ChamberSlideState.Out && cSState != ChamberSlideState.Out) { ((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellOut, ((Component)this).transform.position); if (m_timeHeld > 0.2f) { FVRFireArmRound val = PG.Chamber.EjectRound(((Component)ChamberPoint_Back).transform.position, ChamberPoint_Back.forward * 0.1f, Vector3.zero, false); if (((FVRInteractiveObject)this).IsHeld) { FVRViveHand hand = base.m_hand; hand.ForceSetInteractable((FVRInteractiveObject)(object)val); ((FVRInteractiveObject)val).BeginInteraction(hand); } PG.FixCOM(); } } else if (CSState == ChamberSlideState.In && cSState != ChamberSlideState.In) { ((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellIn, ((Component)this).transform.position); ((FVRInteractiveObject)this).ForceBreakInteraction(); PG.FixCOM(); } else if (CSState == ChamberSlideState.Middle && cSState == ChamberSlideState.In) { ((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellOutStart, ((Component)this).transform.position); } else if (CSState == ChamberSlideState.Middle && cSState == ChamberSlideState.Out) { ((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellInStart, ((Component)this).transform.position); } } } public class RearStabilizerGrip : FVRAlternateGrip { public override bool IsInteractable() { return (Object)(object)base.PrimaryObject != (Object)null && ((FVRInteractiveObject)base.PrimaryObject).IsInteractable(); } public override void BeginInteraction(FVRViveHand hand) { //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).PlayGrabSound(!((FVRInteractiveObject)this).IsHeld, hand); if (base.PrimaryObject is FVRFireArm) { FVRPhysicalObject primaryObject = base.PrimaryObject; FVRFireArm val = (FVRFireArm)(object)((primaryObject is FVRFireArm) ? primaryObject : null); if ((Object)(object)((FVRPhysicalObject)val).Bipod != (Object)null && ((FVRPhysicalObject)val).Bipod.IsBipodActive) { ((FVRPhysicalObject)val).Bipod.Deactivate(); } } base.m_wasGrabbedFromAttachableForegrip = false; base.m_lastGrabbedInGrip = null; if (((FVRInteractiveObject)base.PrimaryObject).IsHeld && !base.PrimaryObject.IsAltHeld) { ((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin = false; if (((FVRInteractiveObject)this).IsHeld && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)(object)hand && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.EndInteractionIfHeld((FVRInteractiveObject)(object)this); } ((FVRInteractiveObject)this).IsHeld = true; ((FVRInteractiveObject)this).m_hand = hand; ((FVRInteractiveObject)this).triggerCooldown = 0.5f; if ((Object)(object)((FVRInteractiveObject)this).m_grabPointTransform == (Object)null) { ((FVRInteractiveObject)this).m_grabPointTransform = new GameObject("interpRot").transform; } ((FVRInteractiveObject)this).m_grabPointTransform.SetParent(((FVRInteractiveObject)this).Transform); ((FVRInteractiveObject)this).m_grabPointTransform.position = ((FVRInteractiveObject)this).m_handPos; ((FVRInteractiveObject)this).m_grabPointTransform.rotation = ((FVRInteractiveObject)this).m_handRot; ((FVRInteractiveObject)this).m_pos_interp_tick = 0f; ((FVRInteractiveObject)this).m_rot_interp_tick = 0f; if (base.FunctionalityEnabled) { base.PrimaryObject.AltGrip = (FVRAlternateGrip)(object)this; } } else { ((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin = false; if (((FVRInteractiveObject)this).IsHeld && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)(object)hand && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.EndInteractionIfHeld((FVRInteractiveObject)(object)this); } ((FVRInteractiveObject)this).IsHeld = true; ((FVRInteractiveObject)this).m_hand = hand; ((FVRInteractiveObject)this).triggerCooldown = 0.5f; if ((Object)(object)((FVRInteractiveObject)this).m_grabPointTransform == (Object)null) { ((FVRInteractiveObject)this).m_grabPointTransform = new GameObject("interpRot").transform; } ((FVRInteractiveObject)this).m_grabPointTransform.SetParent(((FVRInteractiveObject)this).Transform); ((FVRInteractiveObject)this).m_grabPointTransform.position = ((FVRInteractiveObject)this).m_handPos; ((FVRInteractiveObject)this).m_grabPointTransform.rotation = ((FVRInteractiveObject)this).m_handRot; ((FVRInteractiveObject)this).m_pos_interp_tick = 0f; ((FVRInteractiveObject)this).m_rot_interp_tick = 0f; if (base.FunctionalityEnabled) { base.PrimaryObject.AltGrip = (FVRAlternateGrip)(object)this; } } } public override void UpdateInteraction(FVRViveHand hand) { ((FVRAlternateGrip)this).UpdateInteraction(hand); if ((Object)(object)base.PrimaryObject != (Object)null && !((FVRInteractiveObject)base.PrimaryObject).IsHeld && !base.PrimaryObject.IsAltHeld) { ((FVRInteractiveObject)this).ForceBreakInteraction(); } } } public class FireFromMainHand : MonoBehaviour { public enum SelectorPosition { Safe, UnderbarrelSingle, UnderbarrelFullAuto, MainSingle } [Serializable] public class TriggerAnim { public Transform Trigger; public AnimateMode Mode = AnimateMode.Rotation; public Axis Axis = Axis.X; public float ForwardValue; public float RearwardValue; [HideInInspector] public Vector3 BaseLocalPos; [HideInInspector] public Vector3 BaseLocalEuler; } public enum Axis { X, Y, Z } public enum AnimateMode { Rotation, Translation } public BoltActionRifle MainRifle; public AttachableClosedBoltWeapon Underbarrel; public AudioEvent SwitchSound; [Header("Underbarrel Attachment (optional override)")] public FVRFireArmAttachment UnderbarrelAttachment; [Header("Master Selector")] public Transform MasterSelector; public Vector3[] MasterSelectorRotations = (Vector3[])(object)new Vector3[4]; public int MasterSelectorAxis = 2; [Header("Trigger Animation")] public TriggerAnim MainTriggerAnim = new TriggerAnim(); public TriggerAnim UnderbarrelTriggerAnim = new TriggerAnim(); [Header("Mode Overrides (-1 = auto)")] public int[] MainModeOverrides = new int[4] { -1, -1, -1, -1 }; public int[] UnderbarrelModeOverrides = new int[4] { -1, -1, -1, -1 }; [Header("Underbarrel Control")] public bool ForceUnderbarrelHeld = false; public bool UseUpdateInteractionForUnderbarrel = true; public bool DebugInput; public bool DebugSelector; public bool DebugAnimation; private SelectorPosition selectorPos = SelectorPosition.Safe; private int mainSafeIdx = -1; private int mainSingleIdx = -1; private int ubSafeIdx = -1; private int ubSingleIdx = -1; private int ubFullIdx = -1; private FVRFireArmAttachment m_cachedUnderbarrelAttachment; private bool m_loggedMissingUnderbarrelAttachment; private float m_cachedTriggerFloat; private bool m_hasActiveHand; public void Awake() { if ((Object)(object)MainRifle == (Object)null) { Debug.LogError((object)"[FireFromMainHand] MainRifle reference is missing. Disabling script."); ((Behaviour)this).enabled = false; return; } if ((Object)(object)Underbarrel == (Object)null) { Debug.LogError((object)"[FireFromMainHand] Underbarrel reference is missing. Disabling script."); ((Behaviour)this).enabled = false; return; } MainRifle.HasFireSelectorButton = false; Underbarrel.HasFireSelectorButton = false; CacheTriggerAnim(ref MainTriggerAnim); CacheTriggerAnim(ref UnderbarrelTriggerAnim); CacheSelectorIndices(); ApplySelectorState(); if (DebugInput || DebugSelector || DebugAnimation) { Debug.Log((object)("[FireFromMainHand] Awake complete. MainRifle: " + ((Object)MainRifle).name + " Underbarrel: " + ((Object)Underbarrel).name)); } } private void Update() { if ((Object)(object)MainRifle == (Object)null || (Object)(object)Underbarrel == (Object)null) { if (DebugInput) { Debug.LogWarning((object)"[FireFromMainHand] MainRifle or Underbarrel is null in Update."); } return; } if (!((FVRInteractiveObject)MainRifle).IsHeld || (Object)(object)((FVRInteractiveObject)MainRifle).m_hand == (Object)null) { ClearUnderbarrelHeldState(); if (DebugInput) { Debug.Log((object)"[FireFromMainHand] Main rifle not held or hand missing."); } return; } FVRViveHand hand = ((FVRInteractiveObject)MainRifle).m_hand; m_cachedTriggerFloat = hand.Input.TriggerFloat; m_hasActiveHand = true; bool flag = selectorPos == SelectorPosition.UnderbarrelSingle || selectorPos == SelectorPosition.UnderbarrelFullAuto; SyncUnderbarrelHeldState(hand, flag); if (flag) { FVRFireArmAttachment underbarrelAttachment = GetUnderbarrelAttachment(); if ((Object)(object)underbarrelAttachment != (Object)null) { if (!((FVRInteractiveObject)underbarrelAttachment).IsHeld) { ((FVRInteractiveObject)underbarrelAttachment).BeginInteraction(hand); if (DebugInput) { Debug.Log((object)"[FireFromMainHand] Began interaction with underbarrel attachment."); } } ((FVRInteractiveObject)underbarrelAttachment).UpdateInteraction(hand); ((AttachableFirearm)Underbarrel).ProcessInput(hand, false, (FVRInteractiveObject)(object)underbarrelAttachment); if (DebugInput) { Debug.Log((object)("[FireFromMainHand] Processed input for underbarrel. TriggerFloat: " + m_cachedTriggerFloat)); } } else { LogMissingUnderbarrelAttachmentOnce(); } } else { FVRFireArmAttachment underbarrelAttachment2 = GetUnderbarrelAttachment(); if ((Object)(object)underbarrelAttachment2 != (Object)null && ((FVRInteractiveObject)underbarrelAttachment2).IsHeld) { ((FVRInteractiveObject)underbarrelAttachment2).EndInteraction(hand); if (DebugInput) { Debug.Log((object)"[FireFromMainHand] Ended interaction with underbarrel attachment."); } } } if (ShouldAdvanceSelector(hand)) { AdvanceSelector(); } } private void LateUpdate() { if (m_hasActiveHand) { ApplyTriggerAnim(MainTriggerAnim, m_cachedTriggerFloat); ApplyTriggerAnim(UnderbarrelTriggerAnim, m_cachedTriggerFloat); if (DebugInput || DebugAnimation) { Debug.Log((object)("[FireFromMainHand] LateUpdate - TriggerFloat=" + m_cachedTriggerFloat + " MainTrigger=" + (MainTriggerAnim != null && (Object)(object)MainTriggerAnim.Trigger != (Object)null) + " UnderbarrelTrigger=" + (UnderbarrelTriggerAnim != null && (Object)(object)UnderbarrelTriggerAnim.Trigger != (Object)null))); } m_hasActiveHand = false; } } private void OnDisable() { ClearUnderbarrelHeldState(); if (DebugInput) { Debug.Log((object)"[FireFromMainHand] OnDisable - Cleared underbarrel state."); } } private void OnDestroy() { ClearUnderbarrelHeldState(); if (DebugInput) { Debug.Log((object)"[FireFromMainHand] OnDestroy - Cleared underbarrel state."); } } private void ClearUnderbarrelHeldState() { if (ForceUnderbarrelHeld && !((Object)(object)Underbarrel == (Object)null)) { SetPrivateField(Underbarrel, "m_hand", null); SetPrivateField(Underbarrel, "m_isHeld", false); FVRFireArmAttachment underbarrelAttachment = GetUnderbarrelAttachment(); if ((Object)(object)underbarrelAttachment != (Object)null) { SetPrivateField(underbarrelAttachment, "m_hand", null); SetPrivateField(underbarrelAttachment, "m_isHeld", false); } if (DebugInput) { Debug.Log((object)"[FireFromMainHand] Cleared underbarrel held state."); } } } private void SyncUnderbarrelHeldState(FVRViveHand hand, bool isHeld) { if (ForceUnderbarrelHeld && !((Object)(object)Underbarrel == (Object)null)) { bool flag = isHeld && (Object)(object)hand != (Object)null; SetPrivateField(Underbarrel, "m_hand", (!flag) ? null : hand); SetPrivateField(Underbarrel, "m_isHeld", flag); FVRFireArmAttachment underbarrelAttachment = GetUnderbarrelAttachment(); if ((Object)(object)underbarrelAttachment != (Object)null) { SetPrivateField(underbarrelAttachment, "m_hand", (!flag) ? null : hand); SetPrivateField(underbarrelAttachment, "m_isHeld", flag); } if (DebugInput) { Debug.Log((object)("[FireFromMainHand] Synced underbarrel held state: " + flag)); } } } private void CacheTriggerAnim(ref TriggerAnim anim) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (anim == null || (Object)(object)anim.Trigger == (Object)null) { if (DebugAnimation) { Debug.LogWarning((object)"[FireFromMainHand] TriggerAnim or Trigger is null, skipping cache."); } return; } anim.BaseLocalEuler = anim.Trigger.localEulerAngles; anim.BaseLocalPos = anim.Trigger.localPosition; if (DebugAnimation) { Debug.Log((object)string.Concat("[FireFromMainHand] Cached trigger anim for ", ((Object)anim.Trigger).name, " - BaseEuler: ", anim.BaseLocalEuler, " BasePos: ", anim.BaseLocalPos)); } } private void ApplyTriggerAnim(TriggerAnim anim, float triggerFloat) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (anim == null || (Object)(object)anim.Trigger == (Object)null) { return; } float num = Mathf.Lerp(anim.ForwardValue, anim.RearwardValue, triggerFloat); if (anim.Mode == AnimateMode.Rotation) { Vector3 v = anim.BaseLocalEuler; SetAxisValue(ref v, anim.Axis, num); anim.Trigger.localEulerAngles = v; if (DebugAnimation) { Debug.Log((object)string.Concat("[FireFromMainHand] Applied trigger rotation to ", ((Object)anim.Trigger).name, " - Axis: ", anim.Axis, " Value: ", num, " Euler: ", v)); } } else { Vector3 v2 = anim.BaseLocalPos; SetAxisValue(ref v2, anim.Axis, num); anim.Trigger.localPosition = v2; if (DebugAnimation) { Debug.Log((object)string.Concat("[FireFromMainHand] Applied trigger translation to ", ((Object)anim.Trigger).name, " - Axis: ", anim.Axis, " Value: ", num, " Pos: ", v2)); } } } private void SetAxisValue(ref Vector3 v, Axis axis, float value) { switch (axis) { case Axis.X: v.x = value; break; case Axis.Y: v.y = value; break; default: v.z = value; break; } } private FVRFireArmAttachment GetUnderbarrelAttachment() { if ((Object)(object)Underbarrel == (Object)null) { return null; } if ((Object)(object)UnderbarrelAttachment != (Object)null) { return UnderbarrelAttachment; } if ((Object)(object)((AttachableFirearm)Underbarrel).Attachment != (Object)null) { return (FVRFireArmAttachment)(object)((AttachableFirearm)Underbarrel).Attachment; } if ((Object)(object)m_cachedUnderbarrelAttachment == (Object)null) { m_cachedUnderbarrelAttachment = ((Component)Underbarrel).GetComponentInParent(); if (DebugAnimation && (Object)(object)m_cachedUnderbarrelAttachment != (Object)null) { Debug.Log((object)("[FireFromMainHand] Cached underbarrel attachment: " + ((Object)m_cachedUnderbarrelAttachment).name)); } } return m_cachedUnderbarrelAttachment; } private void LogMissingUnderbarrelAttachmentOnce() { if (!m_loggedMissingUnderbarrelAttachment) { m_loggedMissingUnderbarrelAttachment = true; Debug.LogWarning((object)"[FireFromMainHand] Underbarrel attachment is null; selector/input routing will not work. Check UnderbarrelAttachment field or component hierarchy."); } } private bool ShouldAdvanceSelector(FVRViveHand hand) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!CanToggleSelector()) { return false; } if (hand.IsInStreamlinedMode) { return hand.Input.BYButtonDown; } Vector2 touchpadAxes = hand.Input.TouchpadAxes; return hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.1f && Vector2.Angle(touchpadAxes, Vector2.left) <= 45f; } private bool CanToggleSelector() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Invalid comparison between Unknown and I4 if ((Object)(object)MainRifle == (Object)null) { return false; } if (MainRifle.RequiresHammerUncockedToToggleFireSelector && MainRifle.IsHammerCocked) { if (DebugSelector) { Debug.Log((object)"[FireFromMainHand] Cannot toggle: hammer cocked."); } return false; } if ((Object)(object)MainRifle.BoltHandle != (Object)null) { if (((FVRInteractiveObject)MainRifle.BoltHandle).IsHeld) { if (DebugSelector) { Debug.Log((object)"[FireFromMainHand] Cannot toggle: bolt handle held."); } return false; } if ((int)MainRifle.CurBoltHandleState != 0) { if (DebugSelector) { Debug.Log((object)"[FireFromMainHand] Cannot toggle: bolt not forward."); } return false; } if ((int)MainRifle.BoltHandle.HandleRot != 2) { if (DebugSelector) { Debug.Log((object)"[FireFromMainHand] Cannot toggle: bolt not down."); } return false; } } return true; } private void AdvanceSelector() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) selectorPos = (SelectorPosition)((int)(selectorPos + 1) % 4); if (SwitchSound != null) { SM.PlayGenericSound(SwitchSound, ((Component)this).transform.position); } ApplySelectorState(); if (DebugSelector) { Debug.Log((object)("[FireFromMainHand] Advanced selector to: " + selectorPos)); } } private void CacheSelectorIndices() { if (MainRifle.FireSelector_Modes == null || MainRifle.FireSelector_Modes.Length == 0) { Debug.LogError((object)"[FireFromMainHand] Main rifle has no selector modes. Disabling script."); ((Behaviour)this).enabled = false; return; } if (Underbarrel.FireSelector_Modes == null || Underbarrel.FireSelector_Modes.Length == 0) { Debug.LogError((object)"[FireFromMainHand] Underbarrel has no selector modes. Disabling script."); ((Behaviour)this).enabled = false; return; } mainSafeIdx = FindMainIndex((FireSelectorModeType)0); mainSingleIdx = FindMainIndex((FireSelectorModeType)1); ubSafeIdx = FindUnderbarrelIndex((FireSelectorModeType)0); ubSingleIdx = FindUnderbarrelIndex((FireSelectorModeType)1); ubFullIdx = FindUnderbarrelIndex((FireSelectorModeType)3); if (DebugSelector) { Debug.Log((object)("[FireFromMainHand] Cached indices - MainSafe: " + mainSafeIdx + " MainSingle: " + mainSingleIdx + " UBSafe: " + ubSafeIdx + " UBSingle: " + ubSingleIdx + " UBFull: " + ubFullIdx)); } } private void ApplySelectorState() { int mainOverrideIndex = GetMainOverrideIndex(selectorPos); int underbarrelOverrideIndex = GetUnderbarrelOverrideIndex(selectorPos); if (mainOverrideIndex < 0) { switch (selectorPos) { case SelectorPosition.Safe: case SelectorPosition.UnderbarrelSingle: case SelectorPosition.UnderbarrelFullAuto: mainOverrideIndex = mainSafeIdx; break; case SelectorPosition.MainSingle: mainOverrideIndex = mainSingleIdx; break; } } if (underbarrelOverrideIndex < 0) { switch (selectorPos) { case SelectorPosition.Safe: case SelectorPosition.MainSingle: underbarrelOverrideIndex = ubSafeIdx; break; case SelectorPosition.UnderbarrelSingle: underbarrelOverrideIndex = ubSingleIdx; break; case SelectorPosition.UnderbarrelFullAuto: underbarrelOverrideIndex = ubFullIdx; break; } } if (DebugSelector) { Debug.Log((object)string.Concat("[FireFromMainHand] Applying selector state - Pos: ", selectorPos, " mainIdx=", mainOverrideIndex, " ubIdx=", underbarrelOverrideIndex)); } SetMainSelector(mainOverrideIndex); SetUnderbarrelSelector(underbarrelOverrideIndex); AnimateMasterSelector(); } private int GetMainOverrideIndex(SelectorPosition pos) { if (MainModeOverrides == null || MainModeOverrides.Length <= (int)pos) { return -1; } return MainModeOverrides[(int)pos]; } private int GetUnderbarrelOverrideIndex(SelectorPosition pos) { if (UnderbarrelModeOverrides == null || UnderbarrelModeOverrides.Length <= (int)pos) { return -1; } return UnderbarrelModeOverrides[(int)pos]; } private void AnimateMasterSelector() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MasterSelector == (Object)null || MasterSelectorRotations == null || MasterSelectorRotations.Length <= (int)selectorPos) { if (DebugSelector) { Debug.LogWarning((object)"[FireFromMainHand] MasterSelector or rotations not set up."); } return; } Vector3 val = MasterSelector.localEulerAngles; Vector3 val2 = MasterSelectorRotations[(int)selectorPos]; switch (MasterSelectorAxis) { case 0: val.x = val2.x; break; case 1: val.y = val2.y; break; case 2: val.z = val2.z; break; default: val = val2; break; } MasterSelector.localEulerAngles = val; if (DebugSelector) { Debug.Log((object)("[FireFromMainHand] Animated master selector to " + val)); } } private int FindMainIndex(FireSelectorModeType type) { //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_0051: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < MainRifle.FireSelector_Modes.Length; i++) { if (MainRifle.FireSelector_Modes[i].ModeType == type) { return i; } } Debug.LogWarning((object)string.Concat("[FireFromMainHand] Main rifle missing selector mode ", type, ". Available modes: ", MainRifle.FireSelector_Modes.Length)); return -1; } private int FindUnderbarrelIndex(FireSelectorModeType type) { //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_0051: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < Underbarrel.FireSelector_Modes.Length; i++) { if (Underbarrel.FireSelector_Modes[i].ModeType == type) { return i; } } Debug.LogWarning((object)string.Concat("[FireFromMainHand] Underbarrel missing selector mode ", type, ". Available modes: ", Underbarrel.FireSelector_Modes.Length)); return -1; } private void SetMainSelector(int idx) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) if (idx < 0 || idx >= MainRifle.FireSelector_Modes.Length) { if (DebugSelector) { Debug.LogWarning((object)("[FireFromMainHand] Invalid main selector index: " + idx)); } return; } SetPrivateInt(MainRifle, "m_fireSelectorMode", idx); if ((Object)(object)MainRifle.FireSelector_Display != (Object)null) { float selectorPosition = MainRifle.FireSelector_Modes[idx].SelectorPosition; ((FVRPhysicalObject)MainRifle).SetAnimatedComponent(MainRifle.FireSelector_Display, selectorPosition, MainRifle.FireSelector_InterpStyle, MainRifle.FireSelector_Axis); if (DebugAnimation) { Debug.Log((object)("[FireFromMainHand] Animated main selector display to pos " + selectorPosition + " on " + ((Object)MainRifle.FireSelector_Display).name)); } } else if (DebugAnimation) { Debug.LogWarning((object)"[FireFromMainHand] Main rifle FireSelector_Display is null, cannot animate."); } if (MainRifle.UsesSecondFireSelectorChange && (Object)(object)MainRifle.FireSelector_Display_Secondary != (Object)null && MainRifle.FireSelector_Modes_Secondary != null && idx < MainRifle.FireSelector_Modes_Secondary.Length) { float selectorPosition2 = MainRifle.FireSelector_Modes_Secondary[idx].SelectorPosition; ((FVRPhysicalObject)MainRifle).SetAnimatedComponent(MainRifle.FireSelector_Display_Secondary, selectorPosition2, MainRifle.FireSelector_InterpStyle_Secondary, MainRifle.FireSelector_Axis_Secondary); if (DebugAnimation) { Debug.Log((object)("[FireFromMainHand] Animated main selector secondary display to pos " + selectorPosition2)); } } if (DebugSelector) { Debug.Log((object)string.Concat("[FireFromMainHand] Set main selector to index ", idx, " (", MainRifle.FireSelector_Modes[idx].ModeType, ")")); } } private void SetUnderbarrelSelector(int idx) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (idx < 0 || idx >= Underbarrel.FireSelector_Modes.Length) { if (DebugSelector) { Debug.LogWarning((object)("[FireFromMainHand] Invalid underbarrel selector index: " + idx)); } return; } SetPrivateInt(Underbarrel, "m_fireSelectorMode", idx); FVRFireArmAttachment underbarrelAttachment = GetUnderbarrelAttachment(); if ((Object)(object)underbarrelAttachment == (Object)null) { LogMissingUnderbarrelAttachmentOnce(); return; } if ((Object)(object)Underbarrel.FireSelectorSwitch != (Object)null) { float selectorPosition = Underbarrel.FireSelector_Modes[idx].SelectorPosition; ((FVRPhysicalObject)underbarrelAttachment).SetAnimatedComponent(Underbarrel.FireSelectorSwitch, selectorPosition, Underbarrel.FireSelector_InterpStyle, Underbarrel.FireSelector_Axis); if (DebugAnimation) { Debug.Log((object)("[FireFromMainHand] Animated underbarrel selector switch to pos " + selectorPosition + " on " + ((Object)Underbarrel.FireSelectorSwitch).name)); } } else if (DebugAnimation) { Debug.LogWarning((object)"[FireFromMainHand] Underbarrel FireSelectorSwitch is null, cannot animate."); } if ((Object)(object)Underbarrel.FireSelectorSwitch2 != (Object)null && Underbarrel.FireSelector_Modes2 != null && idx < Underbarrel.FireSelector_Modes2.Length) { float selectorPosition2 = Underbarrel.FireSelector_Modes2[idx].SelectorPosition; ((FVRPhysicalObject)underbarrelAttachment).SetAnimatedComponent(Underbarrel.FireSelectorSwitch2, selectorPosition2, Underbarrel.FireSelector_InterpStyle2, Underbarrel.FireSelector_Axis2); if (DebugAnimation) { Debug.Log((object)("[FireFromMainHand] Animated underbarrel selector switch2 to pos " + selectorPosition2)); } } if (DebugSelector) { Debug.Log((object)string.Concat("[FireFromMainHand] Set underbarrel selector to index ", idx, " (", Underbarrel.FireSelector_Modes[idx].ModeType, ")")); } } private void SetPrivateInt(object obj, string fieldName, int value) { Type type = obj.GetType(); FieldInfo fieldInfo = null; while ((object)type != null && (object)fieldInfo == null) { fieldInfo = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); type = type.BaseType; } if ((object)fieldInfo != null) { fieldInfo.SetValue(obj, value); if (DebugSelector) { Debug.Log((object)("[FireFromMainHand] Set private int " + fieldName + " to " + value + " on " + obj.GetType())); } } else { Debug.LogWarning((object)string.Concat("[FireFromMainHand] Could not find field ", fieldName, " on ", obj.GetType(), ". Check field name or access.")); } } private void SetPrivateField(object obj, string fieldName, object value) { if (obj == null) { if (DebugInput) { Debug.LogWarning((object)("[FireFromMainHand] SetPrivateField: obj is null for field " + fieldName)); } return; } Type type = obj.GetType(); FieldInfo fieldInfo = null; while ((object)type != null && (object)fieldInfo == null) { fieldInfo = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); type = type.BaseType; } if ((object)fieldInfo != null) { fieldInfo.SetValue(obj, value); if (DebugInput) { Debug.Log((object)("[FireFromMainHand] Set private field " + fieldName + " on " + obj.GetType())); } } else { Debug.LogWarning((object)("[FireFromMainHand] Could not find field " + fieldName + " on " + obj.GetType())); } } } public class ForceVibrationTrigger : MonoBehaviour { [Header("Debugging")] public bool DebugLogging = false; private FVRFireArm m_firearm; private AttachableFirearm m_attachable; private void Start() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown m_firearm = ((Component)this).GetComponent(); if ((Object)(object)m_firearm == (Object)null) { m_firearm = ((Component)this).GetComponentInParent(); } m_attachable = ((Component)this).GetComponent(); if ((Object)(object)m_attachable == (Object)null) { m_attachable = ((Component)this).GetComponentInParent(); } if ((Object)(object)m_firearm == (Object)null && (Object)(object)m_attachable == (Object)null) { Debug.LogError((object)"ForceVibrationTrigger: No FVRFireArm or AttachableFirearm found in parent hierarchy!"); } else if ((Object)(object)GM.CurrentSceneSettings != (Object)null) { GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired); LogDebug("Subscribed to global ShotFiredEvent."); } } private void OnDestroy() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if ((Object)(object)GM.CurrentSceneSettings != (Object)null) { GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired); } } private void OnShotFired(FVRFireArm firearm) { if ((Object)(object)firearm == (Object)null) { return; } if ((Object)(object)m_firearm != (Object)null && (Object)(object)firearm == (Object)(object)m_firearm) { LogDebug("Standard gun fired! Triggering haptic vibrations on active hands."); TriggerVibration(firearm); } else if ((Object)(object)m_attachable != (Object)null) { FVRFireArm val = null; if ((Object)(object)m_attachable.OverrideFA != (Object)null) { val = m_attachable.OverrideFA; } else if ((Object)(object)m_attachable.Attachment != (Object)null && (Object)(object)((FVRFireArmAttachment)m_attachable.Attachment).curMount != (Object)null) { FVRFireArmAttachmentMount rootMount = ((FVRFireArmAttachment)m_attachable.Attachment).curMount.GetRootMount(); FVRPhysicalObject val2 = ((!((Object)(object)rootMount != (Object)null)) ? ((FVRFireArmAttachment)m_attachable.Attachment).curMount.Parent : rootMount.Parent); val = (FVRFireArm)(object)((val2 is FVRFireArm) ? val2 : null); } if ((Object)(object)val != (Object)null && (Object)(object)firearm == (Object)(object)val) { LogDebug("Underbarrel attachable weapon fired! Triggering haptic vibrations on parent weapon: " + ((Object)val).name); TriggerVibration(val); } } } private void TriggerVibration(FVRFireArm firearm) { if ((Object)(object)((FVRInteractiveObject)firearm).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)firearm).m_hand.Buzzer != (Object)null) { ((FVRInteractiveObject)firearm).m_hand.Buzz(((FVRInteractiveObject)firearm).m_hand.Buzzer.Buzz_GunShot); } if ((Object)(object)((FVRPhysicalObject)firearm).AltGrip != (Object)null && (Object)(object)((FVRInteractiveObject)((FVRPhysicalObject)firearm).AltGrip).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)((FVRPhysicalObject)firearm).AltGrip).m_hand.Buzzer != (Object)null) { ((FVRInteractiveObject)((FVRPhysicalObject)firearm).AltGrip).m_hand.Buzz(((FVRInteractiveObject)((FVRPhysicalObject)firearm).AltGrip).m_hand.Buzzer.Buzz_GunShot); } } private void LogDebug(string message) { if (DebugLogging) { Debug.Log((object)("ForceVibrationTrigger: " + message)); } } } public class QTS11_Rifle : BoltActionRifle { public enum SelectorPosition { Safe, UnderbarrelSingle, UnderbarrelFullAuto, MainSingle } [Header("QTS-11 Dual Weapon System")] public AttachableClosedBoltWeapon Underbarrel; public AudioEvent SwitchSound; [Header("Master Selector Visual")] public Transform MasterSelectorSwitch; public float[] MasterSelectorPositions = new float[4]; public InterpStyle MasterSelectorInterpStyle = (InterpStyle)1; public Axis MasterSelectorAxis = (Axis)2; [Header("Debug")] public bool DebugSelector; private SelectorPosition m_selectorPos = SelectorPosition.Safe; private int m_mainSafeIdx = -1; private int m_mainSingleIdx = -1; private int m_ubSafeIdx = -1; private int m_ubSingleIdx = -1; private int m_ubFullIdx = -1; private Vector3 m_masterSelectorRestEuler; public override void Awake() { //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) ((BoltActionRifle)this).Awake(); base.HasFireSelectorButton = false; base.FireSelector_Display = null; if ((Object)(object)MasterSelectorSwitch != (Object)null) { m_masterSelectorRestEuler = MasterSelectorSwitch.localEulerAngles; } if ((Object)(object)Underbarrel != (Object)null) { Underbarrel.HasFireSelectorButton = false; CacheSelectorIndices(); SetPrivateField(Underbarrel, "m_hasTriggerReset", true); } ApplySelectorState(); } public override void UpdateInteraction(FVRViveHand hand) { if (ShouldAdvanceSelector(hand)) { AdvanceSelector(); } if ((m_selectorPos == SelectorPosition.UnderbarrelSingle || m_selectorPos == SelectorPosition.UnderbarrelFullAuto) && (Object)(object)Underbarrel != (Object)null) { UpdateInteraction_BaseOnly(hand); ((AttachableFirearm)Underbarrel).ProcessInput(hand, true, (FVRInteractiveObject)(object)this); int num = ((m_selectorPos != SelectorPosition.UnderbarrelSingle) ? m_ubFullIdx : m_ubSingleIdx); if (num >= 0) { SetPrivateField(Underbarrel, "m_fireSelectorMode", num); } if (hand.Input.TriggerFloat < 0.15f) { SetPrivateField(Underbarrel, "m_hasTriggerReset", true); } } else { ((BoltActionRifle)this).UpdateInteraction(hand); } } private void UpdateInteraction_BaseOnly(FVRViveHand hand) { ((FVRInteractiveObject)this).IsHeld = true; ((FVRInteractiveObject)this).m_hand = hand; if (!((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && ((FVRInteractiveObject)this).m_hand.Input.TriggerFloat < 0.15f) { ((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin = true; } if (((FVRInteractiveObject)this).triggerCooldown > 0f) { ((FVRInteractiveObject)this).triggerCooldown = ((FVRInteractiveObject)this).triggerCooldown - Time.deltaTime; } } private bool ShouldAdvanceSelector(FVRViveHand hand) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (hand.IsInStreamlinedMode) { return hand.Input.BYButtonDown; } Vector2 touchpadAxes = hand.Input.TouchpadAxes; return hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.left) <= 45f; } private void AdvanceSelector() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) m_selectorPos = (SelectorPosition)((int)(m_selectorPos + 1) % 4); if (SwitchSound != null) { SM.PlayGenericSound(SwitchSound, ((Component)this).transform.position); } ApplySelectorState(); if ((m_selectorPos == SelectorPosition.UnderbarrelSingle || m_selectorPos == SelectorPosition.UnderbarrelFullAuto) && (Object)(object)Underbarrel != (Object)null) { SetPrivateField(Underbarrel, "m_hasTriggerReset", true); } if (DebugSelector) { Debug.Log((object)("[QTS11] Selector -> " + m_selectorPos)); } } private void ApplySelectorState() { int mainSelector; int underbarrelSelector; switch (m_selectorPos) { case SelectorPosition.Safe: mainSelector = m_mainSafeIdx; underbarrelSelector = m_ubSafeIdx; break; case SelectorPosition.UnderbarrelSingle: mainSelector = m_mainSafeIdx; underbarrelSelector = m_ubSingleIdx; break; case SelectorPosition.UnderbarrelFullAuto: mainSelector = m_mainSafeIdx; underbarrelSelector = m_ubFullIdx; break; case SelectorPosition.MainSingle: mainSelector = m_mainSingleIdx; underbarrelSelector = m_ubSafeIdx; break; default: mainSelector = m_mainSafeIdx; underbarrelSelector = m_ubSafeIdx; break; } SetMainSelector(mainSelector); SetUnderbarrelSelector(underbarrelSelector); AnimateMasterSelector(); } private void SetMainSelector(int idx) { //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) if (idx >= 0 && base.FireSelector_Modes != null && idx < base.FireSelector_Modes.Length) { SetPrivateField(this, "m_fireSelectorMode", idx); if ((Object)(object)base.FireSelector_Display != (Object)null) { float selectorPosition = base.FireSelector_Modes[idx].SelectorPosition; ((FVRPhysicalObject)this).SetAnimatedComponent(base.FireSelector_Display, selectorPosition, base.FireSelector_InterpStyle, base.FireSelector_Axis); } } } private void SetUnderbarrelSelector(int idx) { if (!((Object)(object)Underbarrel == (Object)null) && idx >= 0 && Underbarrel.FireSelector_Modes != null && idx < Underbarrel.FireSelector_Modes.Length) { SetPrivateField(Underbarrel, "m_fireSelectorMode", idx); } } private void AnimateMasterSelector() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)MasterSelectorSwitch == (Object)null) && MasterSelectorPositions != null && (int)m_selectorPos < MasterSelectorPositions.Length) { float num = MasterSelectorPositions[(int)m_selectorPos]; ((FVRPhysicalObject)this).SetAnimatedComponent(MasterSelectorSwitch, num, MasterSelectorInterpStyle, MasterSelectorAxis); if (DebugSelector) { Debug.Log((object)string.Concat("[QTS11] AnimateMasterSelector - pos=", m_selectorPos, " target=", num, " result=", MasterSelectorSwitch.localEulerAngles)); } } } private void CacheSelectorIndices() { //IL_001d: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Invalid comparison between Unknown and I4 //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Invalid comparison between Unknown and I4 if (base.FireSelector_Modes != null) { for (int i = 0; i < base.FireSelector_Modes.Length; i++) { if ((int)base.FireSelector_Modes[i].ModeType == 0) { m_mainSafeIdx = i; } if ((int)base.FireSelector_Modes[i].ModeType == 1) { m_mainSingleIdx = i; } } } if (Underbarrel.FireSelector_Modes != null) { for (int j = 0; j < Underbarrel.FireSelector_Modes.Length; j++) { if ((int)Underbarrel.FireSelector_Modes[j].ModeType == 0) { m_ubSafeIdx = j; } if ((int)Underbarrel.FireSelector_Modes[j].ModeType == 1) { m_ubSingleIdx = j; } if ((int)Underbarrel.FireSelector_Modes[j].ModeType == 3) { m_ubFullIdx = j; } } } if (DebugSelector) { Debug.Log((object)("[QTS11] Indices - MainSafe:" + m_mainSafeIdx + " MainSingle:" + m_mainSingleIdx + " UBSafe:" + m_ubSafeIdx + " UBSingle:" + m_ubSingleIdx + " UBFull:" + m_ubFullIdx)); } } private void SetPrivateField(object obj, string fieldName, object value) { if (obj != null) { Type type = obj.GetType(); FieldInfo fieldInfo = null; while ((object)type != null && (object)fieldInfo == null) { fieldInfo = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); type = type.BaseType; } if ((object)fieldInfo != null) { fieldInfo.SetValue(obj, value); } else if (DebugSelector) { Debug.LogWarning((object)("[QTS11] SetPrivateField: field '" + fieldName + "' not found on " + obj.GetType().Name)); } } } } public class DM34Destroy : MonoBehaviour { public FVRPhysicalObject triggerDestroy; public FVRFireArmChamber chamber; private bool isTimerStarted; public float timeBeforedestruction; private float timer = 1f; private void FixedUpdate() { if (!chamber.IsFull && !isTimerStarted) { isTimerStarted = true; timer = timeBeforedestruction; } if (((FVRInteractiveObject)triggerDestroy).IsHeld) { timer = timeBeforedestruction; } if (isTimerStarted) { timer -= Time.fixedDeltaTime; } if (timer <= 0f) { Object.Destroy((Object)(object)((Component)triggerDestroy).gameObject); } } } public class SpawnEffect : MonoBehaviour { public float spawnEffectTime = 2f; public float pause = 1f; public AnimationCurve fadeIn; private ParticleSystem ps; private float timer = 0f; private Renderer _renderer; private int shaderProperty; private void Start() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) shaderProperty = Shader.PropertyToID("_cutoff"); _renderer = ((Component)this).GetComponent(); ps = ((Component)this).GetComponentInChildren(); MainModule main = ps.main; ((MainModule)(ref main)).duration = spawnEffectTime; ps.Play(); } private void Update() { if (timer < spawnEffectTime + pause) { timer += Time.deltaTime; } else { ps.Play(); timer = 0f; } _renderer.material.SetFloat(shaderProperty, fadeIn.Evaluate(Mathf.InverseLerp(0f, spawnEffectTime, timer))); } } [CreateAssetMenu] public class RampAsset : ScriptableObject { public Gradient gradient = new Gradient(); public int size = 16; public bool up = false; public bool overwriteExisting = true; } public class AttachableClosedBoltEjectionSideChanger : FVRInteractiveObject { private enum EState { Primary, Changing, Secondary } [Header("Attachable Closed Bolt Weapon Config")] public AttachableClosedBoltWeapon FireArm; public Transform SecondaryRoundPos_Ejection; public Vector3 SecondaryEjectionSpeed; public Vector3 SecondaryEjectionSpin; [Header("Second Dust Cover Config")] public AttachableClosedBoltReceiverDustCoverTrigger DustCoverTrigger; public Transform SecondaryDustCoverGeo; public float SecondaryOpenRot; public float SecondaryClosedRot; [Header("Debug")] public bool DebugSideChanger; private Vector3 _origPos; private Vector3 _origTriggerPos; private Transform _origDustCoverGeo; private float _origOpenRot; private float _origClosedRot; private Transform _origEjectPos; private Vector3 _origEjectionSpeed; private Vector3 _origEjectionSpin; private EState _state; [ContextMenu("Copy and Mirror Ejection Pattern")] public void MirrorEjectionPattern() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if ((Object)(object)SecondaryRoundPos_Ejection == (Object)null) { GameObject val = new GameObject("Secondary_" + ((Object)FireArm.RoundPos_Ejection).name); SecondaryRoundPos_Ejection = val.transform; } SecondaryRoundPos_Ejection.parent = ((Component)FireArm.RoundPos_Ejection).transform.parent; SecondaryRoundPos_Ejection.localPosition = Vector3.Reflect(((Component)FireArm.RoundPos_Ejection).transform.localPosition, ((Component)FireArm).transform.right); SecondaryEjectionSpeed = Vector3.Reflect(FireArm.EjectionSpeed, ((Component)FireArm).transform.right); SecondaryEjectionSpin = Vector3.Reflect(FireArm.EjectionSpin, ((Component)FireArm).transform.right); } [ContextMenu("Copy and Mirror Dust Cover Rotation Values")] public void MirrorDustCoverRotations() { SecondaryOpenRot = 0f - DustCoverTrigger.OpenRot; SecondaryClosedRot = 0f - DustCoverTrigger.ClosedRot; } public override void Awake() { //IL_0015: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) base.IsSimpleInteract = true; ((FVRInteractiveObject)this).Awake(); _origPos = ((Component)this).transform.localPosition; _origTriggerPos = ((Component)DustCoverTrigger).transform.localPosition; _origDustCoverGeo = DustCoverTrigger.DustCoverGeo; _origOpenRot = DustCoverTrigger.OpenRot; _origClosedRot = DustCoverTrigger.ClosedRot; _origEjectPos = FireArm.RoundPos_Ejection; _origEjectionSpeed = FireArm.EjectionSpeed; _origEjectionSpin = FireArm.EjectionSpin; if (DebugSideChanger) { Debug.Log((object)string.Concat("[SideChanger] Awake - origPos=", _origPos, " origTriggerPos=", _origTriggerPos, " origOpenRot=", _origOpenRot, " origClosedRot=", _origClosedRot, " SecondaryOpenRot=", SecondaryOpenRot, " SecondaryClosedRot=", SecondaryClosedRot)); } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); SwitchSides(); } private void SwitchSides() { if (DebugSideChanger) { Debug.Log((object)string.Concat("[SideChanger] SwitchSides - state=", _state, " isOpen=", DustCoverTrigger.m_isOpen)); } switch (_state) { case EState.Primary: if (DustCoverTrigger.m_isOpen) { ((MonoBehaviour)this).StartCoroutine(ChangeToSecondary()); } else { ChangeToSecondaryInstant(); } break; case EState.Secondary: if (DustCoverTrigger.m_isOpen) { ((MonoBehaviour)this).StartCoroutine(ChangeToPrimary()); } else { ChangeToPrimaryInstant(); } break; } } private IEnumerator ChangeToPrimary() { if (DebugSideChanger) { Debug.Log((object)"[SideChanger] ChangeToPrimary coroutine start"); } DustCoverTrigger.Close(); ((Component)this).GetComponent().enabled = false; ((Component)DustCoverTrigger).GetComponent().enabled = false; _state = EState.Changing; bool gotOpened = false; while (!gotOpened && Mathf.Abs(DustCoverTrigger.m_tarRot - DustCoverTrigger.m_curRot) > 0.01f) { yield return (object)new WaitForEndOfFrame(); if (DustCoverTrigger.m_isOpen) { gotOpened = true; } } if (DebugSideChanger) { Debug.Log((object)("[SideChanger] ChangeToPrimary - gotOpened=" + gotOpened + " curRot=" + DustCoverTrigger.m_curRot + " tarRot=" + DustCoverTrigger.m_tarRot)); } if (!gotOpened) { ((Component)this).transform.localPosition = _origPos; ((Component)DustCoverTrigger).transform.localPosition = _origTriggerPos; FireArm.RoundPos_Ejection = _origEjectPos; FireArm.EjectionSpeed = _origEjectionSpeed; FireArm.EjectionSpin = _origEjectionSpin; DustCoverTrigger.SnapToClosedForNewSide(_origDustCoverGeo, _origClosedRot, _origOpenRot); DustCoverTrigger.Open(); _state = EState.Primary; } else { _state = EState.Secondary; } ((Component)this).GetComponent().enabled = true; ((Component)DustCoverTrigger).GetComponent().enabled = true; } private void ChangeToPrimaryInstant() { //IL_001d: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (DebugSideChanger) { Debug.Log((object)"[SideChanger] ChangeToPrimaryInstant"); } ((Component)this).transform.localPosition = _origPos; ((Component)DustCoverTrigger).transform.localPosition = _origTriggerPos; FireArm.RoundPos_Ejection = _origEjectPos; FireArm.EjectionSpeed = _origEjectionSpeed; FireArm.EjectionSpin = _origEjectionSpin; DustCoverTrigger.SnapToClosedForNewSide(_origDustCoverGeo, _origClosedRot, _origOpenRot); DustCoverTrigger.Open(); _state = EState.Primary; } private IEnumerator ChangeToSecondary() { if (DebugSideChanger) { Debug.Log((object)"[SideChanger] ChangeToSecondary coroutine start"); } DustCoverTrigger.Close(); ((Component)this).GetComponent().enabled = false; ((Component)DustCoverTrigger).GetComponent().enabled = false; _state = EState.Changing; bool gotOpened = false; while (!gotOpened && Mathf.Abs(DustCoverTrigger.m_tarRot - DustCoverTrigger.m_curRot) > 0.01f) { yield return (object)new WaitForEndOfFrame(); if (DustCoverTrigger.m_isOpen) { gotOpened = true; } } if (DebugSideChanger) { Debug.Log((object)("[SideChanger] ChangeToSecondary - gotOpened=" + gotOpened + " curRot=" + DustCoverTrigger.m_curRot + " tarRot=" + DustCoverTrigger.m_tarRot)); } if (!gotOpened) { ((Component)this).transform.localPosition = _origTriggerPos; ((Component)DustCoverTrigger).transform.localPosition = _origPos; FireArm.RoundPos_Ejection = SecondaryRoundPos_Ejection; FireArm.EjectionSpeed = SecondaryEjectionSpeed; FireArm.EjectionSpin = SecondaryEjectionSpin; DustCoverTrigger.SnapToClosedForNewSide(SecondaryDustCoverGeo, SecondaryClosedRot, SecondaryOpenRot); DustCoverTrigger.Open(); _state = EState.Secondary; } else { _state = EState.Primary; } ((Component)this).GetComponent().enabled = true; ((Component)DustCoverTrigger).GetComponent().enabled = true; } private void ChangeToSecondaryInstant() { //IL_001d: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (DebugSideChanger) { Debug.Log((object)"[SideChanger] ChangeToSecondaryInstant"); } ((Component)this).transform.localPosition = _origTriggerPos; ((Component)DustCoverTrigger).transform.localPosition = _origPos; FireArm.RoundPos_Ejection = SecondaryRoundPos_Ejection; FireArm.EjectionSpeed = SecondaryEjectionSpeed; FireArm.EjectionSpin = SecondaryEjectionSpin; DustCoverTrigger.SnapToClosedForNewSide(SecondaryDustCoverGeo, SecondaryClosedRot, SecondaryOpenRot); DustCoverTrigger.Open(); _state = EState.Secondary; } } public class AttachableClosedBoltReceiverDustCoverTrigger : FVRInteractiveObject { public AttachableClosedBolt Bolt; public Transform DustCoverGeo; public float OpenRot; public float ClosedRot; public float RotSpeed = 360f; public AudioEvent AudEvent_CoverOpen; public AudioEvent AudEvent_CoverClose; [Header("Debug")] public bool DebugDustCover; public bool m_isOpen; public float m_curRot; public float m_tarRot; public override void Awake() { ((FVRInteractiveObject)this).Awake(); m_curRot = ClosedRot; m_tarRot = ClosedRot; if (DebugDustCover) { Debug.Log((object)("[DustCoverTrigger] Awake - ClosedRot=" + ClosedRot + " OpenRot=" + OpenRot + " Geo=" + ((!((Object)(object)DustCoverGeo != (Object)null)) ? "NULL" : ((Object)DustCoverGeo).name))); } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); ToggleDustCoverState(); } private void ToggleDustCoverState() { if (m_isOpen) { Close(); } else { Open(); } } public override void FVRUpdate() { //IL_00bb: 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_004a: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); if (!m_isOpen && (Object)(object)Bolt != (Object)null && (int)Bolt.CurPos != 0) { if (DebugDustCover) { Debug.Log((object)("[DustCoverTrigger] Bolt not forward - forcing Open. BoltPos=" + Bolt.CurPos)); } Open(); } if (Mathf.Abs(m_tarRot - m_curRot) > 0.01f) { m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * RotSpeed); DustCoverGeo.localEulerAngles = new Vector3(0f, 0f, m_curRot); if (DebugDustCover) { Debug.Log((object)("[DustCoverTrigger] Animating - curRot=" + m_curRot + " tarRot=" + m_tarRot + " Geo=" + ((Object)DustCoverGeo).name)); } } } public void Open() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (!m_isOpen) { m_isOpen = true; m_tarRot = OpenRot; RotSpeed = 1900f; if (DebugDustCover) { Debug.Log((object)("[DustCoverTrigger] Open() - tarRot=" + m_tarRot + " curRot=" + m_curRot + " Geo=" + ((!((Object)(object)DustCoverGeo != (Object)null)) ? "NULL" : ((Object)DustCoverGeo).name))); } ((AttachableFirearm)Bolt.Weapon).PlayAudioAsHandling(AudEvent_CoverOpen, ((Component)this).transform.position); } } public void Close() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (m_isOpen) { m_isOpen = false; m_tarRot = ClosedRot; RotSpeed = 800f; if (DebugDustCover) { Debug.Log((object)("[DustCoverTrigger] Close() - tarRot=" + m_tarRot + " curRot=" + m_curRot + " Geo=" + ((!((Object)(object)DustCoverGeo != (Object)null)) ? "NULL" : ((Object)DustCoverGeo).name))); } ((AttachableFirearm)Bolt.Weapon).PlayAudioAsHandling(AudEvent_CoverClose, ((Component)this).transform.position); } } public void SnapToClosedForNewSide(Transform newGeo, float newClosedRot, float newOpenRot) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) DustCoverGeo = newGeo; ClosedRot = newClosedRot; OpenRot = newOpenRot; m_isOpen = false; m_curRot = newClosedRot; m_tarRot = newClosedRot; if ((Object)(object)DustCoverGeo != (Object)null) { DustCoverGeo.localEulerAngles = new Vector3(0f, 0f, newClosedRot); } if (DebugDustCover) { Debug.Log((object)("[DustCoverTrigger] SnapToClosedForNewSide - Geo=" + ((!((Object)(object)newGeo != (Object)null)) ? "NULL" : ((Object)newGeo).name) + " ClosedRot=" + newClosedRot + " OpenRot=" + newOpenRot)); } } } public class OICW : ClosedBoltWeapon { public enum SelectorPosition { Safe, Semi, Auto, GL } [Header("XM29 OICW Dual Weapon System")] public AttachableClosedBoltWeapon GL; public AudioEvent RifleSwitchSound; public AudioEvent GLSwitchSound; [Header("Rifle Fire Selector Visual")] public Transform RifleSelectorSwitch; public float[] RifleSelectorPositions = new float[3]; public InterpStyle RifleSelectorInterpStyle = (InterpStyle)1; public Axis RifleSelectorAxis = (Axis)2; [Header("GL Fire Selector Visual")] public Transform GLSelectorSwitch; public float[] GLSelectorPositions = new float[2]; public InterpStyle GLSelectorInterpStyle = (InterpStyle)1; public Axis GLSelectorAxis = (Axis)2; [Header("Debug")] public bool DebugSelector; private SelectorPosition m_selectorPos = SelectorPosition.Safe; private int m_mainSafeIdx = -1; private int m_mainSingleIdx = -1; private int m_mainFullAutoIdx = -1; private int m_glSafeIdx = -1; private int m_glSingleIdx = -1; public override void Awake() { ((ClosedBoltWeapon)this).Awake(); base.HasFireSelectorButton = false; base.FireSelectorSwitch = null; base.FireSelectorSwitch2 = null; if ((Object)(object)GL != (Object)null) { GL.HasFireSelectorButton = false; GL.FireSelectorSwitch = null; GL.FireSelectorSwitch2 = null; CacheSelectorIndices(); SetPrivateField(GL, "m_hasTriggerReset", true); } ApplySelectorState(); } public override void UpdateInteraction(FVRViveHand hand) { //IL_0090: 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_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (ShouldAdvanceSelector(hand)) { AdvanceSelector(); } if (m_selectorPos == SelectorPosition.GL && (Object)(object)GL != (Object)null) { UpdateInteraction_BaseOnly(hand); if (base.HasMagReleaseButton) { if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown) { ((ClosedBoltWeapon)this).ReleaseMag(); } if (hand.Input.AXButtonPressed) { base.IsMagReleaseButtonHeld = true; } } else { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.down) <= 45f) { ((ClosedBoltWeapon)this).ReleaseMag(); } if (hand.Input.TouchpadPressed && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.down) <= 45f) { base.IsMagReleaseButtonHeld = true; } } } ((AttachableFirearm)GL).ProcessInput(hand, true, (FVRInteractiveObject)(object)this); int glSingleIdx = m_glSingleIdx; if (glSingleIdx >= 0) { SetPrivateField(GL, "m_fireSelectorMode", glSingleIdx); } if (hand.Input.TriggerFloat < 0.15f) { SetPrivateField(GL, "m_hasTriggerReset", true); } } else { if ((Object)(object)GL != (Object)null) { SetPrivateField(GL, "m_fireSelectorMode", (m_glSafeIdx >= 0) ? m_glSafeIdx : 0); } int mainIdxForCurrentState = GetMainIdxForCurrentState(); if (mainIdxForCurrentState >= 0) { SetPrivateField(this, "m_fireSelectorMode", mainIdxForCurrentState); } ((ClosedBoltWeapon)this).UpdateInteraction(hand); if (base.HasTrigger && (Object)(object)base.Trigger != (Object)null) { float triggerFloat = hand.Input.TriggerFloat; ((FVRPhysicalObject)this).SetAnimatedComponent(base.Trigger, Mathf.Lerp(base.Trigger_ForwardValue, base.Trigger_RearwardValue, triggerFloat), base.TriggerInterpStyle, base.TriggerAxis); } } } private int GetMainIdxForCurrentState() { return m_selectorPos switch { SelectorPosition.Semi => m_mainSingleIdx, SelectorPosition.Auto => m_mainFullAutoIdx, _ => m_mainSafeIdx, }; } private void UpdateInteraction_BaseOnly(FVRViveHand hand) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).IsHeld = true; ((FVRInteractiveObject)this).m_hand = hand; if (!((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && ((FVRInteractiveObject)this).m_hand.Input.TriggerFloat < 0.15f) { ((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin = true; } if (((FVRInteractiveObject)this).triggerCooldown > 0f) { ((FVRInteractiveObject)this).triggerCooldown = ((FVRInteractiveObject)this).triggerCooldown - Time.deltaTime; } if (base.HasTrigger && (Object)(object)base.Trigger != (Object)null) { float triggerFloat = hand.Input.TriggerFloat; ((FVRPhysicalObject)this).SetAnimatedComponent(base.Trigger, Mathf.Lerp(base.Trigger_ForwardValue, base.Trigger_RearwardValue, triggerFloat), base.TriggerInterpStyle, base.TriggerAxis); } } private bool ShouldAdvanceSelector(FVRViveHand hand) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (hand.IsInStreamlinedMode) { return hand.Input.BYButtonDown; } Vector2 touchpadAxes = hand.Input.TouchpadAxes; return hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.left) <= 45f; } private void AdvanceSelector() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) SelectorPosition selectorPos = m_selectorPos; m_selectorPos = (SelectorPosition)((int)(m_selectorPos + 1) % 4); AudioEvent val = ((m_selectorPos != SelectorPosition.GL && selectorPos != SelectorPosition.GL) ? RifleSwitchSound : GLSwitchSound); if (val != null) { SM.PlayGenericSound(val, ((Component)this).transform.position); } ApplySelectorState(); if (m_selectorPos == SelectorPosition.GL && (Object)(object)GL != (Object)null) { SetPrivateField(GL, "m_hasTriggerReset", true); } if (DebugSelector) { Debug.Log((object)("[OICW] Selector -> " + m_selectorPos)); } } private void ApplySelectorState() { int mainSelector; int gLSelector; switch (m_selectorPos) { case SelectorPosition.Safe: mainSelector = m_mainSafeIdx; gLSelector = m_glSafeIdx; break; case SelectorPosition.Semi: mainSelector = m_mainSingleIdx; gLSelector = m_glSafeIdx; break; case SelectorPosition.Auto: mainSelector = m_mainFullAutoIdx; gLSelector = m_glSafeIdx; break; case SelectorPosition.GL: mainSelector = m_mainSafeIdx; gLSelector = m_glSingleIdx; break; default: mainSelector = m_mainSafeIdx; gLSelector = m_glSafeIdx; break; } SetMainSelector(mainSelector); SetGLSelector(gLSelector); AnimateRifleSelector(); AnimateGLSelector(); } private void SetMainSelector(int idx) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (idx >= 0 && base.FireSelector_Modes != null && idx < base.FireSelector_Modes.Length) { SetPrivateField(this, "m_fireSelectorMode", idx); if (DebugSelector) { Debug.Log((object)string.Concat("[OICW] Main selector -> idx=", idx, " (", base.FireSelector_Modes[idx].ModeType, ")")); } } } private void SetGLSelector(int idx) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GL == (Object)null) && idx >= 0 && GL.FireSelector_Modes != null && idx < GL.FireSelector_Modes.Length) { SetPrivateField(GL, "m_fireSelectorMode", idx); if (DebugSelector) { Debug.Log((object)string.Concat("[OICW] GL selector -> idx=", idx, " (", GL.FireSelector_Modes[idx].ModeType, ")")); } } } private void AnimateRifleSelector() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RifleSelectorSwitch == (Object)null || RifleSelectorPositions == null) { return; } int num = m_selectorPos switch { SelectorPosition.Semi => 1, SelectorPosition.Auto => 2, _ => 0, }; if (num < RifleSelectorPositions.Length) { ((FVRPhysicalObject)this).SetAnimatedComponent(RifleSelectorSwitch, RifleSelectorPositions[num], RifleSelectorInterpStyle, RifleSelectorAxis); if (DebugSelector) { Debug.Log((object)("[OICW] RifleSelector visual=" + num + " angle=" + RifleSelectorPositions[num])); } } } private void AnimateGLSelector() { //IL_0054: 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) if (!((Object)(object)GLSelectorSwitch == (Object)null) && GLSelectorPositions != null && GLSelectorPositions.Length >= 2) { int num = ((m_selectorPos == SelectorPosition.GL) ? 1 : 0); ((FVRPhysicalObject)this).SetAnimatedComponent(GLSelectorSwitch, GLSelectorPositions[num], GLSelectorInterpStyle, GLSelectorAxis); if (DebugSelector) { Debug.Log((object)("[OICW] GLSelector visual=" + num + " angle=" + GLSelectorPositions[num])); } } } private void CacheSelectorIndices() { //IL_001d: 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: Invalid comparison between Unknown and I4 //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Invalid comparison between Unknown and I4 if (base.FireSelector_Modes != null) { for (int i = 0; i < base.FireSelector_Modes.Length; i++) { if ((int)base.FireSelector_Modes[i].ModeType == 0) { m_mainSafeIdx = i; } if ((int)base.FireSelector_Modes[i].ModeType == 1) { m_mainSingleIdx = i; } if ((int)base.FireSelector_Modes[i].ModeType == 3) { m_mainFullAutoIdx = i; } } } if ((Object)(object)GL != (Object)null && GL.FireSelector_Modes != null) { for (int j = 0; j < GL.FireSelector_Modes.Length; j++) { if ((int)GL.FireSelector_Modes[j].ModeType == 0) { m_glSafeIdx = j; } if ((int)GL.FireSelector_Modes[j].ModeType == 1) { m_glSingleIdx = j; } } } if (DebugSelector) { Debug.Log((object)("[OICW] Indices - MainSafe:" + m_mainSafeIdx + " MainSingle:" + m_mainSingleIdx + " MainAuto:" + m_mainFullAutoIdx + " GLSafe:" + m_glSafeIdx + " GLSingle:" + m_glSingleIdx)); } } private void SetPrivateField(object obj, string fieldName, object value) { if (obj != null) { Type type = obj.GetType(); FieldInfo fieldInfo = null; while ((object)type != null && (object)fieldInfo == null) { fieldInfo = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); type = type.BaseType; } if ((object)fieldInfo != null) { fieldInfo.SetValue(obj, value); } else if (DebugSelector) { Debug.LogWarning((object)("[OICW] SetPrivateField: field '" + fieldName + "' not found on " + obj.GetType().Name)); } } } } public class PIPScopeVisionToggle : FVRInteractiveObject { public enum VisionMode { NightVision, Thermal } public enum Axis { X, Y, Z } public enum AnimMode { Rotation, Position } [Header("Required References")] public PIPScope PScope; public PIPScopeController PScopeController; [Header("Vision Mode")] public VisionMode Mode = VisionMode.NightVision; [Header("Button Animation")] public Transform ButtonGeo; public AnimMode ButtonAnimMode = AnimMode.Rotation; public Axis ButtonAxis = Axis.Z; public float ButtonOffValue = 0f; public float ButtonOnValue = 90f; public float AnimSpeed = 4f; [Header("Audio")] public AudioEvent AudEvent_TurnOn; public AudioEvent AudEvent_TurnOff; private bool _isOn = false; private float m_curLerp = 0f; private float m_tarLerp = 0f; private float m_lastLerp = -1f; public override void Awake() { base.IsSimpleInteract = true; ((FVRInteractiveObject)this).Awake(); } public override void Start() { if ((Object)(object)PScope != (Object)null) { PScope.enableNightvision = false; PScope.enableThermal = false; } if ((Object)(object)PScopeController != (Object)null) { PScopeController.UpdateScopeParams(); } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); Toggle(); } private void Toggle() { if (_isOn) { TurnOff(); } else { TurnOn(); } } private void TurnOn() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (_isOn) { return; } _isOn = true; m_tarLerp = 1f; if ((Object)(object)PScope == (Object)null || (Object)(object)PScopeController == (Object)null) { Debug.LogWarning((object)"[PIPScopeVisionToggle] PScope or PScopeController is not assigned."); return; } switch (Mode) { case VisionMode.NightVision: PScope.enableNightvision = true; PScope.enableThermal = false; break; case VisionMode.Thermal: PScope.enableNightvision = false; PScope.enableThermal = true; break; } PScopeController.UpdateScopeParams(); if (AudEvent_TurnOn != null) { SM.PlayGenericSound(AudEvent_TurnOn, ((Component)this).transform.position); } } private void TurnOff() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!_isOn) { return; } _isOn = false; m_tarLerp = 0f; if ((Object)(object)PScope == (Object)null || (Object)(object)PScopeController == (Object)null) { Debug.LogWarning((object)"[PIPScopeVisionToggle] PScope or PScopeController is not assigned."); return; } PScope.enableNightvision = false; PScope.enableThermal = false; PScopeController.UpdateScopeParams(); if (AudEvent_TurnOff != null) { SM.PlayGenericSound(AudEvent_TurnOff, ((Component)this).transform.position); } } public override void FVRUpdate() { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); m_curLerp = Mathf.MoveTowards(m_curLerp, m_tarLerp, Time.deltaTime * AnimSpeed); if ((Object)(object)ButtonGeo != (Object)null && Mathf.Abs(m_curLerp - m_lastLerp) > 0.001f) { float num = Mathf.Lerp(ButtonOffValue, ButtonOnValue, m_curLerp); if (ButtonAnimMode == AnimMode.Rotation) { switch (ButtonAxis) { case Axis.X: ButtonGeo.localEulerAngles = new Vector3(num, 0f, 0f); break; case Axis.Y: ButtonGeo.localEulerAngles = new Vector3(0f, num, 0f); break; case Axis.Z: ButtonGeo.localEulerAngles = new Vector3(0f, 0f, num); break; } } else { Vector3 localPosition = ButtonGeo.localPosition; switch (ButtonAxis) { case Axis.X: ButtonGeo.localPosition = new Vector3(num, localPosition.y, localPosition.z); break; case Axis.Y: ButtonGeo.localPosition = new Vector3(localPosition.x, num, localPosition.z); break; case Axis.Z: ButtonGeo.localPosition = new Vector3(localPosition.x, localPosition.y, num); break; } } } m_lastLerp = m_curLerp; } } public class RangeFinderChamber : MonoBehaviour { public Text rangedisplay; public LayerMask lm; public FVRInteractiveObject grip; public FVRFireArmChamber chamber; public float range; public bool ranging = false; public AudioEvent bip; public AudioEvent bip2; public Transform aperture; private void Start() { range = 1000f; rangedisplay.text = "999"; } private void FixedUpdate() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) if (!grip.IsHeld) { return; } if (grip.m_hand.Input.TriggerFloat >= 0.5f) { if (!ranging) { SM.PlayCoreSound((FVRPooledAudioType)41, bip, ((Component)this).transform.position); ranging = true; } Ray val = default(Ray); ((Ray)(ref val))..ctor(aperture.position, aperture.forward); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 1500f, LayerMask.op_Implicit(lm))) { if (((RaycastHit)(ref val2)).distance >= 1000f) { rangedisplay.text = "999"; range = 1000f; } else if (((RaycastHit)(ref val2)).distance < 1000f) { rangedisplay.text = ((int)((RaycastHit)(ref val2)).distance/*cast due to .constrained prefix*/).ToString(); range = ((RaycastHit)(ref val2)).distance + 1f; } } else if (!Physics.Raycast(val, ref val2)) { rangedisplay.text = "999"; range = 1000f; } } else if (grip.m_hand.Input.TriggerFloat < 0.5f && ranging) { ranging = false; if (chamber.IsFull && !chamber.IsSpent) { chamber.m_round.BallisticProjectilePrefab.GetComponent().MaxRange = range; } SM.PlayCoreSound((FVRPooledAudioType)41, bip2, ((Component)this).transform.position); } } }