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 AndrewFTW;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OpenScripts2;
using OtherLoader;
using UnityEngine;
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]
namespace MeatyScripts
{
public class CartridgeHolderAttachment : FVRFireArmAttachment
{
public FVRFireArmChamber[] Chambers;
private const string flagDicChamberRoundClassKey = "ChamberRoundClassConfig";
private const string flagDicChamberRotationKey = "ChamberRotationConfig";
public override GameObject DuplicateFromSpawnLock(FVRViveHand hand)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = ((FVRPhysicalObject)this).DuplicateFromSpawnLock(hand);
CartridgeHolderAttachment component = val.GetComponent<CartridgeHolderAttachment>();
for (int i = 0; i < Chambers.Length; i++)
{
component.Chambers[i].SetRound(Chambers[i].m_round, false);
((Component)component.Chambers[i]).transform.localRotation = ((Component)Chambers[i]).transform.localRotation;
}
return val;
}
public override Dictionary<string, string> GetFlagDic()
{
//IL_0032: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, string> flagDic = ((FVRFireArmAttachment)this).GetFlagDic();
string text = string.Empty;
for (int i = 0; i < Chambers.Length; i++)
{
FVRFireArmRound round = Chambers[i].GetRound();
text = ((!((Object)(object)round != (Object)null)) ? (text + "None") : (text + round.RoundClass));
if (i != Chambers.Length - 1)
{
text += ";";
}
}
flagDic.Add("ChamberRoundClassConfig", text);
text = string.Empty;
for (int j = 0; j < Chambers.Length; j++)
{
string text2 = text;
text = text2 + ((Component)Chambers[j]).transform.localRotation.x + "," + ((Component)Chambers[j]).transform.localRotation.y + "," + ((Component)Chambers[j]).transform.localRotation.z + "," + ((Component)Chambers[j]).transform.localRotation.w;
if (j != Chambers.Length - 1)
{
text += ";";
}
}
flagDic.Add("ChamberRotationConfig", text);
return flagDic;
}
public override void ConfigureFromFlagDic(Dictionary<string, string> f)
{
//IL_017f: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Invalid comparison between Unknown and I4
//IL_01b6: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
((FVRFireArmAttachment)this).ConfigureFromFlagDic(f);
if (f.TryGetValue("ChamberRoundClassConfig", out var value))
{
string[] array = value.Split(new char[1] { ';' });
List<FireArmRoundClass> list = new List<FireArmRoundClass>();
string[] array2 = array;
foreach (string text in array2)
{
if (text == "None")
{
list.Add((FireArmRoundClass)int.MinValue);
}
else
{
list.Add((FireArmRoundClass)Enum.Parse(typeof(FireArmRoundClass), text));
}
}
for (int j = 0; j < Chambers.Length; j++)
{
if ((int)list[j] != int.MinValue)
{
GameObject gameObject = ((AnvilAsset)AM.GetRoundSelfPrefab(Chambers[j].RoundType, list[j])).GetGameObject();
FVRFireArmRound component = gameObject.GetComponent<FVRFireArmRound>();
Chambers[j].SetRound(component, false);
}
}
}
if (f.TryGetValue("ChamberRotationConfig", out value))
{
string[] array3 = value.Split(new char[1] { ';' });
List<Quaternion> list2 = new List<Quaternion>();
string[] array4 = array3;
foreach (string text2 in array4)
{
string[] array5 = text2.Split(new char[1] { ',' });
list2.Add(new Quaternion(float.Parse(array5[0]), float.Parse(array5[1]), float.Parse(array5[2]), float.Parse(array5[3])));
}
for (int l = 0; l < Chambers.Length; l++)
{
((Component)Chambers[l]).transform.localRotation = list2[l];
}
}
}
[ContextMenu("Copy existing Attachment's values")]
public void CopyAttachment()
{
FVRFireArmAttachment[] components = ((Component)this).GetComponents<FVRFireArmAttachment>();
FVRFireArmAttachment val = components.Single((FVRFireArmAttachment c) => (Object)(object)c != (Object)(object)this);
val.AttachmentInterface.Attachment = (FVRFireArmAttachment)(object)this;
val.Sensor.Attachment = (FVRFireArmAttachment)(object)this;
this.CopyComponent<FVRFireArmAttachment>((Component)(object)this, val);
}
public T CopyComponent<T>(Component target, T reference) where T : Component
{
Type type = ((object)reference).GetType();
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
PropertyInfo[] properties = type.GetProperties(bindingAttr);
PropertyInfo[] array = properties;
foreach (PropertyInfo propertyInfo in array)
{
if (propertyInfo.CanWrite)
{
try
{
propertyInfo.SetValue(target, propertyInfo.GetValue(reference, null), null);
}
catch
{
}
}
}
FieldInfo[] fields = type.GetFields(bindingAttr);
FieldInfo[] array2 = fields;
foreach (FieldInfo fieldInfo in array2)
{
fieldInfo.SetValue(target, fieldInfo.GetValue(reference));
}
return (T)(object)((target is T) ? target : null);
}
}
public class DirectionalFireArmChamber : FVRFireArmChamber
{
private static List<FVRFireArmChamber> _exsitingDirectionalFireArmChambers;
static DirectionalFireArmChamber()
{
_exsitingDirectionalFireArmChambers = new List<FVRFireArmChamber>();
Harmony.CreateAndPatchAll(typeof(DirectionalFireArmChamber), (string)null);
}
public override void Awake()
{
((FVRFireArmChamber)this).Awake();
_exsitingDirectionalFireArmChambers.Add((FVRFireArmChamber)(object)this);
}
public override void OnDestroy()
{
_exsitingDirectionalFireArmChambers.Remove((FVRFireArmChamber)(object)this);
((FVRInteractiveObject)this).OnDestroy();
}
[HarmonyPatch(typeof(FVRFireArmRound), "Chamber")]
[HarmonyPrefix]
public static void SetRoundPatch(FVRFireArmRound __instance, FVRFireArmChamber c)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (_exsitingDirectionalFireArmChambers.Contains(c))
{
float num = Vector3.Angle(((Component)__instance).transform.forward, ((Component)c).transform.forward);
if (num > 90f)
{
((Component)c).transform.Rotate(180f, 0f, 0f);
}
}
}
[ContextMenu("Copy existing Chmaber's values")]
public void CopyChamber()
{
FVRFireArmChamber reference = ((Component)this).GetComponents<FVRFireArmChamber>().Single((FVRFireArmChamber c) => (Object)(object)c != (Object)(object)this);
this.CopyComponent<FVRFireArmChamber>((Component)(object)this, reference);
}
public T CopyComponent<T>(Component target, T reference) where T : Component
{
Type type = ((object)reference).GetType();
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
PropertyInfo[] properties = type.GetProperties(bindingAttr);
PropertyInfo[] array = properties;
foreach (PropertyInfo propertyInfo in array)
{
if (propertyInfo.CanWrite)
{
try
{
propertyInfo.SetValue(target, propertyInfo.GetValue(reference, null), null);
}
catch
{
}
}
}
FieldInfo[] fields = type.GetFields(bindingAttr);
FieldInfo[] array2 = fields;
foreach (FieldInfo fieldInfo in array2)
{
fieldInfo.SetValue(target, fieldInfo.GetValue(reference));
}
return (T)(object)((target is T) ? target : null);
}
}
}
[RequireComponent(typeof(AudioLowPassFilter))]
[RequireComponent(typeof(AudioSource))]
public class DistanceEqualizer : MonoBehaviour
{
public bool Cutoff = true;
public bool VolumeDecrease = true;
public bool Debugging = true;
public float StartCutoffFrom = 10f;
[Range(0f, 1f)]
public float WallCutoff = 0.5f;
[Range(0.01f, 1f)]
public float DistanceCutoff = 0.3f;
[Range(0f, 1f)]
public float VolDecPerWall = 0.05f;
private float distance;
private float distcut;
private float wallcut;
private AudioListener AudioListener;
private AudioSource AudioSource;
private RaycastHit[] hits;
private Ray ray;
private void Start()
{
AudioListener = Object.FindObjectOfType<AudioListener>();
AudioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
((Behaviour)((Component)this).gameObject.GetComponent<AudioLowPassFilter>()).enabled = true;
}
private void FixedUpdate()
{
//IL_0008: 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_0045: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
distance = Vector3.Distance(((Component)this).transform.position, ((Component)AudioListener).transform.position);
if (distance < AudioSource.maxDistance)
{
ray = new Ray(((Component)this).transform.position, ((Component)AudioListener).transform.position - ((Component)this).transform.position);
hits = Physics.RaycastAll(ray, distance);
if (VolumeDecrease)
{
((Component)this).gameObject.GetComponent<AudioSource>().volume = 1f - VolDecPerWall * (float)hits.Length;
}
if (Cutoff)
{
distcut = 22000f * Mathf.Pow(0.6f, (distance - StartCutoffFrom) * Mathf.Pow(DistanceCutoff * 10f, 3f) / 1000f);
wallcut = Mathf.Atan((float)hits.Length * (1f + 10f * WallCutoff)) * distcut * WallCutoff;
((Component)this).gameObject.GetComponent<AudioLowPassFilter>().cutoffFrequency = distcut - wallcut;
}
if (Debugging)
{
Debug.Log((object)("Gameobject '" + ((Object)((Component)this).gameObject).name + "' :: Walls: " + hits.Length + "; current volume: " + ((Component)this).gameObject.GetComponent<AudioSource>().volume + "; current cutoff: " + ((Component)this).gameObject.GetComponent<AudioLowPassFilter>().cutoffFrequency));
Debug.DrawLine(((Component)this).transform.position, ((Component)AudioListener).transform.position, Color.green);
}
}
}
}
public class Cam : MonoBehaviour
{
private GameObject AudioSource;
public float speed = 10f;
private void Start()
{
speed = 0f - speed;
AudioSource = GameObject.Find("Turret");
}
private void Update()
{
//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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_007b: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.LookAt(AudioSource.transform);
if (((Component)this).transform.position.z <= -100f || ((Component)this).transform.position.z >= 300f)
{
speed = 0f - speed;
}
((Component)this).transform.Translate(Vector3.forward * speed * Time.deltaTime, (Space)0);
}
}
public class Fire : MonoBehaviour
{
private float random;
private float curTime;
private AudioSource AudioSource;
private GameObject Flash1;
private GameObject Flash2;
private void Start()
{
AudioSource = ((Component)this).gameObject.GetComponent<AudioSource>();
Flash1 = GameObject.Find("Fire1");
Flash2 = GameObject.Find("Fire2");
}
private void FixedUpdate()
{
random = Random.Range(0, 100);
if (random > 95f && !AudioSource.isPlaying)
{
AudioSource.Play();
}
if (AudioSource.isPlaying)
{
curTime += Time.deltaTime;
if ((double)curTime > 0.1)
{
((Behaviour)Flash1.GetComponent<Light>()).enabled = !((Behaviour)Flash1.GetComponent<Light>()).enabled;
if (((Behaviour)Flash1.GetComponent<Light>()).enabled)
{
((Behaviour)Flash2.GetComponent<Light>()).enabled = false;
}
else
{
((Behaviour)Flash2.GetComponent<Light>()).enabled = true;
}
curTime = 0f;
}
}
else
{
((Behaviour)Flash1.GetComponent<Light>()).enabled = false;
((Behaviour)Flash2.GetComponent<Light>()).enabled = false;
}
}
}
public class Look : MonoBehaviour
{
private AudioListener AudioListener;
private void Start()
{
AudioListener = Object.FindObjectOfType<AudioListener>();
}
private void Update()
{
((Component)this).transform.LookAt(((Component)AudioListener).transform);
}
}
public class OrientationAxis : MonoBehaviour
{
public enum AxisEnum
{
None = -1,
X,
Y,
Z,
XY,
XZ,
YZ,
XYZ
}
public AxisEnum axis = AxisEnum.None;
public Transform directionObject;
public Vector3 worldDirection = Vector3.up;
private void Update()
{
//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_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0117: 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)
if (!((Object)(object)directionObject.parent == (Object)null))
{
Vector3 val = worldDirection;
Quaternion rotation = directionObject.parent.rotation;
Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
switch (axis)
{
case AxisEnum.X:
val.y = eulerAngles.y;
val.z = eulerAngles.z;
break;
case AxisEnum.Y:
val.x = eulerAngles.x;
val.z = eulerAngles.z;
break;
case AxisEnum.Z:
val.x = eulerAngles.x;
val.y = eulerAngles.y;
break;
case AxisEnum.XY:
val.z = eulerAngles.z;
break;
case AxisEnum.XZ:
val.y = eulerAngles.y;
break;
case AxisEnum.YZ:
val.x = eulerAngles.x;
break;
}
directionObject.rotation = Quaternion.Euler(val);
}
}
}
public class AutoRotate : MonoBehaviour
{
public float m_Speed = 30f;
private void Update()
{
float num = Time.deltaTime * m_Speed;
((Component)this).transform.Rotate(num, num, 0f);
}
}
public class Demo : MonoBehaviour
{
private void Start()
{
QualitySettings.antiAliasing = 8;
}
private void OnGUI()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
GUI.Box(new Rect(10f, 10f, 150f, 25f), "Heat Wave Demo");
}
}
[RequireComponent(typeof(Camera))]
public class FreeCamera : MonoBehaviour
{
public float m_MoveSpeed = 0f;
public float m_RotateSpeed = 0f;
public KeyCode m_ForwardButton = (KeyCode)119;
public KeyCode m_BackwardButton = (KeyCode)115;
public KeyCode m_RightButton = (KeyCode)100;
public KeyCode m_LeftButton = (KeyCode)97;
public KeyCode m_UpButton = (KeyCode)113;
public KeyCode m_DownButton = (KeyCode)101;
private void Update()
{
//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_000a: 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_0023: 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_0035: 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_004e: 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_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_0078: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
Vector3 moveTo = Vector3.zero;
Move(m_ForwardButton, ref moveTo, ((Component)this).transform.forward);
Move(m_BackwardButton, ref moveTo, -((Component)this).transform.forward);
Move(m_RightButton, ref moveTo, ((Component)this).transform.right);
Move(m_LeftButton, ref moveTo, -((Component)this).transform.right);
Move(m_UpButton, ref moveTo, ((Component)this).transform.up);
Move(m_DownButton, ref moveTo, -((Component)this).transform.up);
Transform transform = ((Component)this).transform;
transform.position += moveTo * m_MoveSpeed * Time.deltaTime;
if (Input.GetMouseButton(0))
{
Vector3 eulerAngles = ((Component)this).transform.eulerAngles;
eulerAngles.x += (0f - Input.GetAxis("Mouse Y")) * 359f * m_RotateSpeed;
eulerAngles.y += Input.GetAxis("Mouse X") * 359f * m_RotateSpeed;
((Component)this).transform.eulerAngles = eulerAngles;
}
}
private void Move(KeyCode key, ref Vector3 moveTo, Vector3 dir)
{
//IL_0001: 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 (Input.GetKey(key))
{
moveTo = dir;
}
}
}
[RequireComponent(typeof(Camera))]
public class HeatWave : MonoBehaviour
{
[Range(0.003f, 0.02f)]
public float m_Strength = 0.01f;
public Material m_MatHeatWave;
public bool m_ShowInternalMaps = false;
[Header("Internal")]
private LayerMask m_LmHeatWave;
public Shader m_SdrDepthOnly;
public RenderTexture m_RTMask;
public Camera m_RTCamera;
public GameObject m_RTCameraGo;
private void Start()
{
//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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
if (!SystemInfo.supportsImageEffects)
{
((Behaviour)this).enabled = false;
return;
}
m_LmHeatWave = LayerMask.op_Implicit(LayerMask.NameToLayer("TransparentFX"));
m_RTMask = new RenderTexture(Screen.width, Screen.height, 16);
((Object)m_RTMask).hideFlags = (HideFlags)52;
m_SdrDepthOnly = Shader.Find("Heat Wave/Depth Only");
}
private void Update()
{
//IL_008c: 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_00e9: 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_003c: Expected O, but got Unknown
Camera main = Camera.main;
if ((Object)(object)m_RTCamera == (Object)null)
{
m_RTCameraGo = new GameObject("Mask Camera", new Type[1] { typeof(Camera) });
((Object)m_RTCameraGo).hideFlags = (HideFlags)52;
m_RTCamera = m_RTCameraGo.GetComponent<Camera>();
}
m_RTCamera.CopyFrom(main);
((Behaviour)m_RTCamera).enabled = false;
m_RTCamera.targetTexture = m_RTMask;
m_RTCamera.cullingMask = ~(1 << LayerMask.op_Implicit(m_LmHeatWave));
m_RTCamera.clearFlags = (CameraClearFlags)2;
m_RTCamera.backgroundColor = new Color(0.5f, 0.5f, 1f);
m_RTCamera.RenderWithShader(m_SdrDepthOnly, "");
m_RTCamera.cullingMask = 1 << LayerMask.op_Implicit(m_LmHeatWave);
m_RTCamera.clearFlags = (CameraClearFlags)4;
m_RTCamera.Render();
}
private void OnDisable()
{
if (Object.op_Implicit((Object)(object)m_RTCamera))
{
Object.DestroyImmediate((Object)(object)m_RTCamera);
m_RTCamera = null;
}
if (Object.op_Implicit((Object)(object)m_RTCameraGo))
{
Object.DestroyImmediate((Object)(object)m_RTCameraGo);
m_RTCameraGo = null;
}
}
private void OnRenderImage(RenderTexture src, RenderTexture dst)
{
m_MatHeatWave.SetFloat("_Strength", m_Strength);
m_MatHeatWave.SetTexture("_DistortionTex", (Texture)(object)m_RTMask);
Graphics.Blit((Texture)(object)src, dst, m_MatHeatWave);
}
private void OnGUI()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
if (m_ShowInternalMaps)
{
GUI.DrawTextureWithTexCoords(new Rect(10f, 10f, 128f, 128f), (Texture)(object)m_RTMask, new Rect(0f, 0f, 1f, 1f));
}
}
}
namespace Meat_banono.Meats_ModulAR2_MuzzleDevices
{
[BepInPlugin("Meat_banono.Meats_ModulAR2_MuzzleDevices", "Meats_ModulAR2_MuzzleDevices", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class Meats_ModulAR2_MuzzleDevicesPlugin : 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(), "Meat_banono.Meats_ModulAR2_MuzzleDevices");
OtherLoader.RegisterDirectLoad(BasePath, "Meat_banono.Meats_ModulAR2_MuzzleDevices", "", "", "modular2muzzledevices", "");
}
}
}
namespace MeatyScripts
{
public class FlipSightRemastered : FlipSight
{
public float RotationSpeedOpening;
public float RotationSpeedClosing;
public AudioEvent FlipOpen;
public AudioEvent FlipClosed;
public override void Awake()
{
((FlipSight)this).Awake();
Harmony.CreateAndPatchAll(typeof(FlipSightRemastered), (string)null);
}
[HarmonyPatch(typeof(FlipSight), "FVRFixedUpdate")]
[HarmonyPrefix]
public static bool FlipSight_FVRFixedUpdate_Patch(FlipSight __instance)
{
//IL_0139: 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 (__instance is FlipSightRemastered)
{
FlipSightRemastered flipSightRemastered = __instance as FlipSightRemastered;
if ((Object)(object)((FVRFireArmAttachmentInterface)flipSightRemastered).Attachment.curMount != (Object)null)
{
if (((FlipSight)flipSightRemastered).IsUp)
{
((FlipSight)flipSightRemastered).m_tarFlipLerp = 1f;
((FlipSight)flipSightRemastered).m_curFlipLerp = Mathf.MoveTowards(((FlipSight)flipSightRemastered).m_curFlipLerp, ((FlipSight)flipSightRemastered).m_tarFlipLerp, Time.deltaTime * flipSightRemastered.RotationSpeedOpening);
if (Mathf.Abs(((FlipSight)flipSightRemastered).m_curFlipLerp - ((FlipSight)flipSightRemastered).m_lastFlipLerp) > 0.001f)
{
((FlipSight)flipSightRemastered).FlipPart.localEulerAngles = new Vector3(Mathf.Lerp(((FlipSight)flipSightRemastered).XRotDown, ((FlipSight)flipSightRemastered).XRotUp, ((FlipSight)flipSightRemastered).m_curFlipLerp), 0f, 0f);
}
((FlipSight)flipSightRemastered).m_lastFlipLerp = ((FlipSight)flipSightRemastered).m_curFlipLerp;
}
else
{
((FlipSight)flipSightRemastered).m_tarFlipLerp = 0f;
((FlipSight)flipSightRemastered).m_curFlipLerp = Mathf.MoveTowards(((FlipSight)flipSightRemastered).m_curFlipLerp, ((FlipSight)flipSightRemastered).m_tarFlipLerp, Time.deltaTime * flipSightRemastered.RotationSpeedClosing);
if (Mathf.Abs(((FlipSight)flipSightRemastered).m_curFlipLerp - ((FlipSight)flipSightRemastered).m_lastFlipLerp) > 0.001f)
{
((FlipSight)flipSightRemastered).FlipPart.localEulerAngles = new Vector3(Mathf.Lerp(((FlipSight)flipSightRemastered).XRotDown, ((FlipSight)flipSightRemastered).XRotUp, ((FlipSight)flipSightRemastered).m_curFlipLerp), 0f, 0f);
}
((FlipSight)flipSightRemastered).m_lastFlipLerp = ((FlipSight)flipSightRemastered).m_curFlipLerp;
}
}
if (((FVRInteractiveObject)flipSightRemastered).IsHeld)
{
((FVRInteractiveObject)flipSightRemastered).TestHandDistance();
}
return false;
}
return true;
}
[HarmonyPatch(typeof(FlipSight), "Flip")]
[HarmonyPostfix]
public static void FlipSight_Flip_Patch(FlipSight __instance)
{
//IL_0049: 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)
if (__instance is FlipSightRemastered)
{
FlipSightRemastered flipSightRemastered = __instance as FlipSightRemastered;
if (((FlipSight)flipSightRemastered).IsUp)
{
SM.PlayGenericSound(flipSightRemastered.FlipOpen, ((Component)flipSightRemastered).transform.position);
}
else
{
SM.PlayGenericSound(flipSightRemastered.FlipClosed, ((Component)flipSightRemastered).transform.position);
}
}
}
}
public class NGSW_FC : FVRInteractiveObject
{
[Header("NGSW FireControl Config")]
public Amplifier AmplifierComponent;
public Transform TargetAimer;
public Transform RaycastOrigin;
public LayerMask RangeFinderHitLayers;
public GameObject OneEcksReticle;
public GameObject PreZeroReticle;
public GameObject PostZeroReticle;
public Transform ReticleCenteredTextContainer;
public Text HeadingText;
private float _currentHeading;
public float RangeFinderRange = 5000f;
public Text ZeroRangeText;
public int BulletDropCalculationSingleFrameLimit = 0;
public float AsynchAbortEpsilon = 0.1f;
public int MaxAsynchIterationsPerFrame = 100;
public float ArtificialCalculationDelay = 0.1f;
public float IncompleteZeroBlinkInterval = 0.25f;
[Header("Zoom Ring")]
public LinearZoomRing ZoomRing;
public float OneEcksThreshold = 0.1f;
private AnimationCurve BulletDropCurve;
private AnimationCurve BulletWindCurve;
private bool _isOneEcks = false;
private bool _isZeroed = false;
private FVRFireArm _fireArm;
private RaycastHit _lastHit;
private bool _stillCalculatingDrop;
private float _consineAdjustedRange;
private float _calculatedDrop;
private bool _wasAttached = false;
private bool _compassEnabled = true;
public bool CompassEnabled => _compassEnabled;
public override void Start()
{
((FVRInteractiveObject)this).Start();
base.IsSimpleInteract = true;
CheckMagnificationLevel();
Zero(reset: true);
}
public override void FVRUpdate()
{
((FVRInteractiveObject)this).FVRUpdate();
UpdateHeading();
CheckMagnificationLevel();
UpdateReticle();
}
public void ToggleCompass()
{
_compassEnabled = !_compassEnabled;
}
private void CheckAttachmentStatus()
{
if (!_wasAttached && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount.Parent != (Object)null && ((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount.Parent is FVRFireArm)
{
_wasAttached = true;
ref FVRFireArm fireArm = ref _fireArm;
FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount.Parent;
fireArm = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
CalculateBulletDropCurve();
CalculateBulletDrop();
}
else if (!_wasAttached && (Object)(object)AmplifierComponent.BackupFireArm != (Object)null)
{
_wasAttached = true;
_fireArm = AmplifierComponent.BackupFireArm;
CalculateBulletDrop();
}
else if (_wasAttached && (Object)(object)AmplifierComponent.BackupFireArm == (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount == (Object)null)
{
_wasAttached = false;
_fireArm = null;
}
}
private void FindCurrentFirearm()
{
if ((Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount.Parent != (Object)null && ((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount.Parent is FVRFireArm)
{
ref FVRFireArm fireArm = ref _fireArm;
FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount.Parent;
fireArm = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
}
else if ((Object)(object)AmplifierComponent.BackupFireArm != (Object)null)
{
_fireArm = AmplifierComponent.BackupFireArm;
}
else if ((Object)(object)AmplifierComponent.BackupFireArm == (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)AmplifierComponent).Attachment.curMount == (Object)null)
{
_fireArm = null;
}
}
private void CheckMagnificationLevel()
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
float num = ((!((Object)(object)ZoomRing == (Object)null)) ? ZoomRing.GetCurrentlySelectedMagnification() : AmplifierComponent.ZoomSettings[AmplifierComponent.m_zoomSettingIndex].Magnification);
if ((_isOneEcks || !((Object)(object)ZoomRing == (Object)null)) ? (num < 1f + OneEcksThreshold) : Mathf.Approximately(num, 1f))
{
_isOneEcks = true;
Zero(reset: true);
}
else if (_isOneEcks && !Mathf.Approximately(num, 1f))
{
_isOneEcks = false;
Zero(reset: true);
}
ReticleCenteredTextContainer.localScale = Vector3.one / num;
}
private void UpdateReticle()
{
if (_isOneEcks)
{
OneEcksReticle.SetActive(true);
PreZeroReticle.SetActive(false);
PostZeroReticle.SetActive(false);
}
else if (!_stillCalculatingDrop)
{
OneEcksReticle.SetActive(false);
if (_isZeroed)
{
PreZeroReticle.SetActive(false);
PostZeroReticle.SetActive(true);
}
else
{
PreZeroReticle.SetActive(true);
PostZeroReticle.SetActive(false);
}
}
}
public override void SimpleInteraction(FVRViveHand hand)
{
//IL_001a: 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_0037: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).SimpleInteraction(hand);
if (_isOneEcks)
{
return;
}
if (Physics.Raycast(RaycastOrigin.position, RaycastOrigin.forward, ref _lastHit, RangeFinderRange, LayerMask.op_Implicit(RangeFinderHitLayers)))
{
FindCurrentFirearm();
if ((Object)(object)_fireArm != (Object)null)
{
CalculateBulletDrop();
}
if (_stillCalculatingDrop)
{
Zero(reset: true);
((MonoBehaviour)this).StopCoroutine("WaitForCalculation");
((MonoBehaviour)this).StartCoroutine("WaitForCalculation");
}
else
{
Zero();
}
}
else
{
Zero(reset: true);
}
}
public void TriggerRangeFinderZeroing()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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)
if (_isOneEcks)
{
return;
}
if (Physics.Raycast(RaycastOrigin.position, RaycastOrigin.forward, ref _lastHit, RangeFinderRange, LayerMask.op_Implicit(RangeFinderHitLayers)))
{
FindCurrentFirearm();
if ((Object)(object)_fireArm != (Object)null)
{
float num = 90f - Vector3.Angle(Vector3.up, _fireArm.GetMuzzle().forward);
_consineAdjustedRange = ((RaycastHit)(ref _lastHit)).distance * Mathf.Cos(num * ((float)Math.PI / 180f));
CalculateBulletDrop();
}
if (_stillCalculatingDrop)
{
Zero(reset: true);
((MonoBehaviour)this).StopCoroutine("WaitForCalculation");
((MonoBehaviour)this).StartCoroutine("WaitForCalculation");
}
else
{
Zero();
}
}
else
{
Zero(reset: true);
}
}
private IEnumerator WaitForCalculation()
{
((MonoBehaviour)this).StopCoroutine("DisplayBlinker");
((MonoBehaviour)this).StartCoroutine("DisplayBlinker");
while (_stillCalculatingDrop)
{
yield return null;
}
Zero();
}
private IEnumerator DisplayBlinker()
{
if ((Object)(object)ZeroRangeText != (Object)null)
{
ZeroRangeText.text = $"{Mathf.RoundToInt(((RaycastHit)(ref _lastHit)).distance)}m";
}
while (_stillCalculatingDrop)
{
if ((Object)(object)ZeroRangeText != (Object)null)
{
((Component)ZeroRangeText).gameObject.SetActive(false);
}
PreZeroReticle.SetActive(false);
yield return (object)new WaitForSeconds(IncompleteZeroBlinkInterval);
if ((Object)(object)ZeroRangeText != (Object)null)
{
((Component)ZeroRangeText).gameObject.SetActive(true);
}
PreZeroReticle.SetActive(true);
yield return (object)new WaitForSeconds(IncompleteZeroBlinkInterval);
}
}
private void UpdateHeading()
{
//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_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_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_0032: 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_0034: Unknown result type (might be due to invalid IL or missing references)
if (_compassEnabled)
{
Vector3 forward = ((Component)this).transform.forward;
forward.y = 0f;
Vector3 forward2 = Vector3.forward;
Vector3 up = Vector3.up;
float currentHeading = AngleSigned(forward2, forward, up);
_currentHeading = currentHeading;
if (_currentHeading < 0f)
{
_currentHeading += 360f;
}
if ((Object)(object)HeadingText != (Object)null)
{
HeadingText.text = FormatHeadingText();
}
}
else if ((Object)(object)HeadingText != (Object)null)
{
HeadingText.text = string.Empty;
}
}
private string FormatHeadingText()
{
string text = $"{Mathf.RoundToInt(_currentHeading)}°";
string empty = string.Empty;
empty = ((_currentHeading < 22.5f || _currentHeading > 337.5f) ? "N " : ((_currentHeading >= 22.5f && _currentHeading < 67.5f) ? "NE " : ((_currentHeading >= 67.5f && _currentHeading < 112.5f) ? "E " : ((_currentHeading >= 112.5f && _currentHeading < 157.5f) ? "SE " : ((_currentHeading >= 157.5f && _currentHeading < 202.5f) ? "S " : ((_currentHeading >= 202.5f && _currentHeading < 247.5f) ? "SW " : ((!(_currentHeading >= 247.5f) || !(_currentHeading < 292.5f)) ? "NW " : "W ")))))));
return empty + text;
}
private float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
return Mathf.Atan2(Vector3.Dot(n, Vector3.Cross(v1, v2)), Vector3.Dot(v1, v2)) * 57.29578f;
}
public void Zero(bool reset = false)
{
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_00da: 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_0048: 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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: 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)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: 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_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
if (!reset)
{
float distance = ((RaycastHit)(ref _lastHit)).distance;
if ((Object)(object)_fireArm == (Object)null)
{
if ((Object)(object)AmplifierComponent.BackupMuzzle != (Object)null)
{
Vector3 val = AmplifierComponent.BackupMuzzle.position + AmplifierComponent.BackupMuzzle.forward * distance;
TargetAimer.LookAt(val, Vector3.up);
_isZeroed = true;
}
else
{
TargetAimer.localRotation = Quaternion.identity;
_isZeroed = false;
}
return;
}
Transform muzzle = _fireArm.GetMuzzle();
Vector3 val2 = ((RaycastHit)(ref _lastHit)).point - muzzle.position;
float magnitude = ((Vector3)(ref val2)).magnitude;
Vector3 val3 = Vector3.ProjectOnPlane(val2, Vector3.up);
float magnitude2 = ((Vector3)(ref val3)).magnitude;
if ((Object)(object)_fireArm != (Object)null)
{
float calculatedDrop = _calculatedDrop;
if (calculatedDrop == float.MinValue)
{
TargetAimer.localRotation = Quaternion.identity;
if ((Object)(object)ZeroRangeText != (Object)null)
{
ZeroRangeText.text = "Out of range!";
}
_isZeroed = false;
return;
}
Vector3 val4 = Vector2.op_Implicit(_fireArm.GetCombinedFixedDrift(_fireArm.AccuracyClass) * 0.0166667f);
float num = _fireArm.GetCombinedFixedDrop(_fireArm.AccuracyClass) * 0.0166667f;
Quaternion val5 = muzzle.rotation * Quaternion.Euler(val4.y + num, val4.x, 0f);
Vector3 val6 = val5 * Vector3.forward;
Vector3 val7 = muzzle.position + val6 * magnitude + Vector3.up * calculatedDrop;
Vector3 val8 = val7 - TargetAimer.position;
val8 = Quaternion.AngleAxis(0.004166675f * (float)AmplifierComponent.ElevationStep, ((Component)this).transform.right) * val8;
val8 = Quaternion.AngleAxis(0.004166675f * (float)AmplifierComponent.WindageStep, ((Component)this).transform.up) * val8;
TargetAimer.rotation = Quaternion.LookRotation(val8, ((Component)this).transform.up);
}
if ((Object)(object)ZeroRangeText != (Object)null)
{
ZeroRangeText.text = $"{Mathf.RoundToInt(distance)}m";
}
_isZeroed = true;
}
else
{
TargetAimer.localRotation = Quaternion.identity;
if ((Object)(object)ZeroRangeText != (Object)null)
{
ZeroRangeText.text = string.Empty;
}
_isZeroed = false;
}
}
public void CalculateBulletDropCurve()
{
//IL_000e: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: 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_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Expected O, but got Unknown
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Expected O, but got Unknown
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: 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_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
FVRFireArmChamber currentChamber = OpenScripts2_BasePlugin.GetCurrentChamber(_fireArm);
float chamberVelMult = AM.GetChamberVelMult(currentChamber.RoundType, Vector3.Distance(((Component)currentChamber).transform.position, _fireArm.GetMuzzle().position));
FireArmRoundType roundType = _fireArm.RoundType;
FVRFireArmRoundDisplayData val = AM.SRoundDisplayDataDic[roundType];
float airDensity = 1.225f;
float num = 0.012f;
num = Time.fixedDeltaTime;
float num2 = val.ZeroingVel;
float num3 = val.ZeroingMass;
float num4 = val.ZeroingXDim;
BallisticProjectile val2 = null;
if (currentChamber.IsFull && !currentChamber.IsSpent)
{
FVRFireArmRound round = currentChamber.GetRound();
val2 = round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>();
num2 = val2.MuzzleVelocityBase;
num3 = val2.Mass;
num4 = val2.Dimensions.x;
}
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(0f, 0f, num2 * chamberVelMult);
float num5 = (float)Math.PI * Mathf.Pow(num4 * 0.5f, 2f);
Keyframe[] array = (Keyframe[])(object)new Keyframe[Mathf.CeilToInt(((RaycastHit)(ref _lastHit)).distance / 100f) + 1];
Keyframe[] array2 = (Keyframe[])(object)new Keyframe[Mathf.CeilToInt(((RaycastHit)(ref _lastHit)).distance / 100f) + 1];
Vector3 val4 = Vector3.zero;
float num6 = 0f;
bool flag = false;
int num7 = 0;
bool flag2 = false;
int i;
for (i = 0; i < BulletDropCalculationSingleFrameLimit; i++)
{
if (val4.z >= (float)num7 * 100f && num7 < array.Length)
{
((Keyframe)(ref array[num7])).time = val4.z / 100f;
((Keyframe)(ref array2[num7])).time = val4.z / 100f;
((Keyframe)(ref array[num7])).value = val4.y;
((Keyframe)(ref array2[num7])).value = val4.x;
num7++;
}
if (!flag2 && val4.y < 0f)
{
flag2 = true;
}
if (val4.z >= (float)(Mathf.CeilToInt(((RaycastHit)(ref _lastHit)).distance / 100f) * 100))
{
break;
}
if (!flag && ((Vector3)(ref val3)).magnitude < 430f)
{
flag = true;
}
val3 += Vector3.down * GetGravity(val2) * num;
val3 = ApplyDrag(val3, airDensity, num, num5, num3);
Vector3 val5 = val4 + val3 * num;
num6 += Vector3.Distance(val5, val4);
val4 = val5;
}
if (i == BulletDropCalculationSingleFrameLimit)
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(ContinueCalculationAfterBreak(num7, val4, val3, num3, num5, array, array2, val2));
}
else
{
_stillCalculatingDrop = false;
}
BulletDropCurve = new AnimationCurve(array);
BulletWindCurve = new AnimationCurve(array2);
for (int j = 0; j < array.Length; j++)
{
BulletDropCurve.SmoothTangents(j, 1f);
}
for (int k = 0; k < array2.Length; k++)
{
BulletDropCurve.SmoothTangents(k, 1f);
}
}
private IEnumerator ContinueCalculationAfterBreak(int currentKeyframe, Vector3 startingBulletPosition, Vector3 startingBulletVelocity, float ZeroingMass, float ZeroingCrossSectionArea, Keyframe[] bulletDropKeyframes, Keyframe[] bulletWindKeyframes, BallisticProjectile projectile)
{
//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)
_stillCalculatingDrop = true;
Vector3 bulletPosition = startingBulletPosition;
Vector3 velocityVector2 = startingBulletVelocity;
float physicsDeltaTime2 = 0.012f;
physicsDeltaTime2 = Time.fixedDeltaTime;
float airDensity = 1.225f;
Vector3 positionLastFrame;
do
{
positionLastFrame = bulletPosition;
for (int i = 0; i < MaxAsynchIterationsPerFrame; i++)
{
if (bulletPosition.z >= (float)currentKeyframe * 100f && currentKeyframe < bulletDropKeyframes.Length)
{
((Keyframe)(ref bulletDropKeyframes[currentKeyframe])).time = bulletPosition.z / 100f;
((Keyframe)(ref bulletWindKeyframes[currentKeyframe])).time = bulletPosition.z / 100f;
((Keyframe)(ref bulletDropKeyframes[currentKeyframe])).value = bulletPosition.y;
((Keyframe)(ref bulletWindKeyframes[currentKeyframe])).value = bulletPosition.x;
currentKeyframe++;
}
if (bulletPosition.z >= (float)(Mathf.CeilToInt(((RaycastHit)(ref _lastHit)).distance / 100f) * 100))
{
break;
}
velocityVector2 += Vector3.down * GetGravity(projectile) * physicsDeltaTime2;
velocityVector2 = ApplyDrag(velocityVector2, airDensity, physicsDeltaTime2, ZeroingCrossSectionArea, ZeroingMass);
Vector3 nextPosition = bulletPosition + velocityVector2 * physicsDeltaTime2;
if (Mathf.Abs(nextPosition.z - bulletPosition.z) < AsynchAbortEpsilon / (float)MaxAsynchIterationsPerFrame)
{
break;
}
bulletPosition = nextPosition;
}
if (bulletPosition.z >= (float)(Mathf.CeilToInt(((RaycastHit)(ref _lastHit)).distance / 100f) * 100))
{
break;
}
yield return (object)new WaitForSeconds(ArtificialCalculationDelay);
}
while (Mathf.Abs(bulletPosition.z - positionLastFrame.z) > AsynchAbortEpsilon);
if (bulletPosition.z < (float)(Mathf.CeilToInt(((RaycastHit)(ref _lastHit)).distance / 100f) * 100))
{
((Keyframe)(ref bulletDropKeyframes[currentKeyframe])).time = bulletPosition.z / 100f;
((Keyframe)(ref bulletWindKeyframes[currentKeyframe])).time = bulletPosition.z / 100f;
((Keyframe)(ref bulletDropKeyframes[currentKeyframe])).value = bulletPosition.y;
((Keyframe)(ref bulletWindKeyframes[currentKeyframe])).value = bulletPosition.x;
if (currentKeyframe >= 2)
{
float x2 = ((Keyframe)(ref bulletDropKeyframes[currentKeyframe - 2])).time;
float value = ((Keyframe)(ref bulletDropKeyframes[currentKeyframe - 2])).value;
float x3 = ((Keyframe)(ref bulletDropKeyframes[currentKeyframe - 1])).time;
float value2 = ((Keyframe)(ref bulletDropKeyframes[currentKeyframe - 1])).value;
float time = ((Keyframe)(ref bulletDropKeyframes[currentKeyframe])).time;
float value3 = ((Keyframe)(ref bulletDropKeyframes[currentKeyframe])).value;
float num = (value2 - value) / (x3 - x2);
float num2 = (value3 - value2) / (time - x3);
float c = value;
float b = num;
float a = (num2 - num) / (time - x2);
Func<float, float> func = (float x) => a * (x - x3) * (x - x2) + b * (x - x2) + c;
currentKeyframe++;
for (int j = currentKeyframe; j < bulletDropKeyframes.Length; j++)
{
((Keyframe)(ref bulletDropKeyframes[j])).time = j;
((Keyframe)(ref bulletWindKeyframes[j])).time = j;
((Keyframe)(ref bulletDropKeyframes[j])).value = func(j);
((Keyframe)(ref bulletWindKeyframes[j])).value = bulletPosition.x;
}
}
}
BulletDropCurve = new AnimationCurve(bulletDropKeyframes);
BulletWindCurve = new AnimationCurve(bulletWindKeyframes);
for (int k = 0; k < bulletDropKeyframes.Length; k++)
{
BulletDropCurve.SmoothTangents(k, 1f);
}
for (int l = 0; l < bulletWindKeyframes.Length; l++)
{
BulletDropCurve.SmoothTangents(l, 1f);
}
_stillCalculatingDrop = false;
}
public void CalculateBulletDrop()
{
//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_001e: 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_003e: 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_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
FVRFireArmChamber currentChamber = OpenScripts2_BasePlugin.GetCurrentChamber(_fireArm);
FireArmRoundType roundType = _fireArm.RoundType;
FVRFireArmRoundDisplayData val = AM.SRoundDisplayDataDic[roundType];
float num = ((!((Object)(object)currentChamber != (Object)null)) ? 1f : AM.GetChamberVelMult(currentChamber.RoundType, Vector3.Distance(((Component)currentChamber).transform.position, _fireArm.GetMuzzle().position)));
float airDensity = 1.225f;
float num2 = 0.012f;
num2 = Time.fixedDeltaTime;
float num3 = val.ZeroingVel;
float num4 = val.ZeroingMass;
float num5 = val.ZeroingXDim;
BallisticProjectile val2 = null;
if ((Object)(object)currentChamber != (Object)null && currentChamber.IsFull && !currentChamber.IsSpent)
{
FVRFireArmRound round = currentChamber.GetRound();
if ((Object)(object)round != (Object)null)
{
val2 = round.BallisticProjectilePrefab.GetComponent<BallisticProjectile>();
if ((Object)(object)val2 != (Object)null)
{
num3 = val2.MuzzleVelocityBase;
num4 = val2.Mass;
num5 = val2.Dimensions.x;
}
}
}
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(0f, 0f, num3 * num);
float num6 = (float)Math.PI * Mathf.Pow(num5 * 0.5f, 2f);
Vector3 val4 = Vector3.zero;
float num7 = 0f;
bool flag = false;
int currentKeyframe = 0;
bool flag2 = false;
int i;
for (i = 0; i < BulletDropCalculationSingleFrameLimit; i++)
{
if (val4.z >= _consineAdjustedRange)
{
break;
}
if (!flag && ((Vector3)(ref val3)).magnitude < 430f)
{
flag = true;
}
if (!flag2 && val4.y < 0f)
{
flag2 = true;
}
val3 += Vector3.down * GetGravity(val2) * num2;
val3 = ApplyDrag(val3, airDensity, num2, num6, num4);
Vector3 val5 = val4 + val3 * num2;
num7 += Vector3.Distance(val5, val4);
val4 = val5;
}
if (i == BulletDropCalculationSingleFrameLimit)
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(ContinueDropCalculationAfterBreak(currentKeyframe, val4, val3, num4, num6, val2));
}
else
{
_calculatedDrop = val4.y;
_stillCalculatingDrop = false;
}
}
private IEnumerator ContinueDropCalculationAfterBreak(int currentKeyframe, Vector3 startingBulletPosition, Vector3 startingBulletVelocity, float ZeroingMass, float ZeroingCrossSectionArea, BallisticProjectile projectile)
{
//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)
_stillCalculatingDrop = true;
Vector3 bulletPosition = startingBulletPosition;
Vector3 velocityVector2 = startingBulletVelocity;
float physicsDeltaTime2 = 0.012f;
physicsDeltaTime2 = Time.fixedDeltaTime;
float airDensity = 1.225f;
Vector3 positionLastFrame;
do
{
positionLastFrame = bulletPosition;
for (int i = 0; i < MaxAsynchIterationsPerFrame; i++)
{
if (bulletPosition.z >= _consineAdjustedRange)
{
break;
}
velocityVector2 += Vector3.down * GetGravity(projectile) * physicsDeltaTime2;
velocityVector2 = ApplyDrag(velocityVector2, airDensity, physicsDeltaTime2, ZeroingCrossSectionArea, ZeroingMass);
Vector3 nextPosition = bulletPosition + velocityVector2 * physicsDeltaTime2;
if (Mathf.Abs(nextPosition.z - bulletPosition.z) < AsynchAbortEpsilon / (float)MaxAsynchIterationsPerFrame)
{
break;
}
bulletPosition = nextPosition;
}
if (bulletPosition.z >= _consineAdjustedRange)
{
break;
}
yield return (object)new WaitForSeconds(ArtificialCalculationDelay);
}
while (Mathf.Abs(bulletPosition.z - positionLastFrame.z) > AsynchAbortEpsilon);
if (bulletPosition.z < _consineAdjustedRange)
{
_calculatedDrop = float.MinValue;
}
else
{
_calculatedDrop = bulletPosition.y;
}
_stillCalculatingDrop = false;
}
private Vector3 ApplyDrag(Vector3 velocityVector, float airDensity, float deltaTime, float frontArea, float Mass)
{
//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_0031: 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_0038: 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)
float magnitude = ((Vector3)(ref velocityVector)).magnitude;
Vector3 normalized = ((Vector3)(ref velocityVector)).normalized;
float currentDragCoefficient = GetCurrentDragCoefficient(((Vector3)(ref velocityVector)).magnitude);
Vector3 val = (0f - 0.5f * currentDragCoefficient * airDensity * (frontArea / Mass) * magnitude) * velocityVector;
return normalized * Mathf.Clamp(magnitude - ((Vector3)(ref val)).magnitude * deltaTime, 0f, magnitude);
}
private float GetCurrentDragCoefficient(float velocityInMS)
{
float num = velocityInMS * 0.00291545f;
return AM.BDCC.Evaluate(num);
}
private float GetGravity(BallisticProjectile projectile)
{
//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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected I4, but got Unknown
float num = 1f;
if ((Object)(object)projectile != (Object)null)
{
num = projectile.GravityMultiplier;
}
GravityMode ballisticGravityMode = GM.Options.SimulationOptions.BallisticGravityMode;
return (int)ballisticGravityMode switch
{
0 => 9.81f * num,
1 => 5f * num,
2 => 1.622f * num,
3 => 0f * num,
_ => 0f * num,
};
}
}
public class NGSW_FC_Button : FVRInteractiveObject
{
public enum EButtonType
{
Center,
Up,
Down,
Left,
Right
}
[Header("NGS-FC Button Config")]
public NGSW_FC_ScreenController NGSW_FC_ScreenController;
public EButtonType ButtonType;
public AudioEvent ButtonAudio;
public override void Awake()
{
((FVRInteractiveObject)this).Awake();
base.IsSimpleInteract = true;
}
public override void SimpleInteraction(FVRViveHand hand)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).SimpleInteraction(hand);
switch (ButtonType)
{
case EButtonType.Center:
NGSW_FC_ScreenController.ButtonCenter();
break;
case EButtonType.Up:
NGSW_FC_ScreenController.ButtonUp();
break;
case EButtonType.Down:
NGSW_FC_ScreenController.ButtonDown();
break;
case EButtonType.Left:
NGSW_FC_ScreenController.ButtonLeft();
break;
case EButtonType.Right:
NGSW_FC_ScreenController.ButtonRight();
break;
}
SM.PlayGenericSound(ButtonAudio, ((Component)this).transform.position);
}
}
public class NGSW_FC_PressurePad : FVRFireArmAttachmentInterface
{
[Header("NGSW-FC Pressure Pad Config")]
public float DoubleTapWaitTime = 0.333f;
private bool _isLightToggle = false;
private bool _isLaserToggle = false;
private FVRAlternateGrip _altGrip;
private bool _wasAltGripGrabbed = false;
private float _timeWaited = 0f;
private bool _waitingForDoubleTap = false;
private bool _irActive = false;
private bool _strobeActive = false;
private List<TacticalFlashlight> _flashlights = new List<TacticalFlashlight>();
private List<LaserPointer> _lasers = new List<LaserPointer>();
private List<AdvancedLaserController> _advancedLaserControllers = new List<AdvancedLaserController>();
private Dictionary<AdvancedLaserController, List<int>> _advancedLights = new Dictionary<AdvancedLaserController, List<int>>();
private Dictionary<AdvancedLaserController, List<int>> _advancedLasers = new Dictionary<AdvancedLaserController, List<int>>();
private Dictionary<AdvancedLaserController, List<int>> _advancedIRLights = new Dictionary<AdvancedLaserController, List<int>>();
private Dictionary<AdvancedLaserController, List<int>> _advancedIRLasers = new Dictionary<AdvancedLaserController, List<int>>();
private Dictionary<AdvancedLaserController, List<int>> _advancedStrobes = new Dictionary<AdvancedLaserController, List<int>>();
private List<NGSW_FC> _ngsw_fcs = new List<NGSW_FC>();
private static Dictionary<FVRAlternateGrip, NGSW_FC_PressurePad> _existingPressurePadAttachments;
private static IntPtr _baseUpdateInteractionPointer;
private static FieldInfo _advancedLasersCurrentEmmitterIndex;
static NGSW_FC_PressurePad()
{
_existingPressurePadAttachments = new Dictionary<FVRAlternateGrip, NGSW_FC_PressurePad>();
Harmony.CreateAndPatchAll(typeof(NGSW_FC_PressurePad), (string)null);
_baseUpdateInteractionPointer = typeof(FVRAlternateGrip).BaseType.GetMethod("UpdateInteraction").MethodHandle.GetFunctionPointer();
_advancedLasersCurrentEmmitterIndex = typeof(AdvancedLaserController).GetField("_currentEmitterIndex", BindingFlags.Instance | BindingFlags.NonPublic);
}
public override void OnDestroy()
{
((FVRInteractiveObject)this).OnDestroy();
if ((Object)(object)_altGrip != (Object)null)
{
_existingPressurePadAttachments.Remove(_altGrip);
}
}
public override void OnAttach()
{
((FVRFireArmAttachmentInterface)this).OnAttach();
if ((Object)(object)base.Attachment.curMount != (Object)null && base.Attachment.curMount.GetRootMount().MyObject is FVRFireArm)
{
FVRPhysicalObject myObject = base.Attachment.curMount.GetRootMount().MyObject;
if ((Object)(object)((FVRFireArm)((myObject is FVRFireArm) ? myObject : null)).Foregrip != (Object)null)
{
ref FVRAlternateGrip altGrip = ref _altGrip;
FVRPhysicalObject myObject2 = base.Attachment.curMount.GetRootMount().MyObject;
altGrip = ((FVRFireArm)((myObject2 is FVRFireArm) ? myObject2 : null)).Foregrip.GetComponent<FVRAlternateGrip>();
}
else
{
_altGrip = ((Component)base.Attachment.curMount.GetRootMount().MyObject).GetComponentInChildren<FVRAlternateGrip>(true);
}
}
}
public override void OnDetach()
{
if ((Object)(object)_altGrip != (Object)null)
{
_existingPressurePadAttachments.Remove(_altGrip);
_altGrip = null;
}
ToggleLights(on: false);
ToggleLasers(on: false);
((FVRFireArmAttachmentInterface)this).OnDetach();
}
public override void FVRUpdate()
{
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
if (!((Object)(object)_altGrip != (Object)null))
{
return;
}
if (!_existingPressurePadAttachments.ContainsKey(_altGrip))
{
_existingPressurePadAttachments.Add(_altGrip, this);
}
FVRViveHand hand = ((FVRInteractiveObject)_altGrip).m_hand;
if (!_wasAltGripGrabbed && (Object)(object)hand != (Object)null)
{
_wasAltGripGrabbed = true;
CreateDictionaries();
}
else if (_wasAltGripGrabbed && (Object)(object)hand == (Object)null)
{
_wasAltGripGrabbed = false;
}
if (!((Object)(object)hand != (Object)null))
{
return;
}
if (!hand.IsInStreamlinedMode)
{
if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
{
if (!_waitingForDoubleTap)
{
((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: true));
}
}
else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f && !_waitingForDoubleTap)
{
((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: false));
}
}
else if (hand.Input.BYButtonDown)
{
if (!_waitingForDoubleTap)
{
((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: true));
}
}
else if (hand.Input.AXButtonDown && !_waitingForDoubleTap)
{
((MonoBehaviour)this).StartCoroutine(WaitForDoubleTap(up: false));
}
if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.left) < 45f)
{
_irActive = !_irActive;
ToggleLights(on: false);
ToggleLasers(on: false);
_isLightToggle = false;
_isLaserToggle = false;
}
else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.right) < 45f)
{
ToggleStrobe();
}
if (!hand.IsInStreamlinedMode)
{
if (hand.Input.TouchpadPressed && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
{
ToggleLights(on: true);
}
else if (hand.Input.TouchpadUp && !_isLightToggle)
{
ToggleLights(on: false);
}
}
else if (hand.Input.BYButtonPressed)
{
ToggleLights(on: true);
}
else if (hand.Input.BYButtonUp && !_isLightToggle)
{
ToggleLights(on: false);
}
if (!hand.IsInStreamlinedMode)
{
if (hand.Input.TouchpadPressed && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f)
{
ToggleLasers(on: true);
}
else if (hand.Input.TouchpadUp && !_isLaserToggle)
{
ToggleLasers(on: false);
}
}
else if (hand.Input.AXButtonPressed)
{
ToggleLasers(on: true);
}
else if (hand.Input.AXButtonUp && !_isLaserToggle)
{
ToggleLasers(on: false);
}
if (!hand.IsInStreamlinedMode)
{
if (!hand.Input.TouchpadDown || !(Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f))
{
return;
}
{
foreach (NGSW_FC ngsw_fc in _ngsw_fcs)
{
ngsw_fc.TriggerRangeFinderZeroing();
}
return;
}
}
if (!hand.Input.AXButtonDown)
{
return;
}
foreach (NGSW_FC ngsw_fc2 in _ngsw_fcs)
{
ngsw_fc2.TriggerRangeFinderZeroing();
}
}
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_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
((FVRFireArmAttachmentInterface)this).UpdateInteraction(hand);
if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.left) < 45f)
{
_irActive = !_irActive;
ToggleLights(on: false);
ToggleLasers(on: false);
_isLightToggle = false;
_isLaserToggle = false;
}
else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.right) < 45f)
{
ToggleStrobe();
}
}
public void CreateDictionaries()
{
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Expected O, but got Unknown
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Expected O, but got Unknown
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Invalid comparison between Unknown and I4
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Invalid comparison between Unknown and I4
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_0374: Invalid comparison between Unknown and I4
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Invalid comparison between Unknown and I4
//IL_0436: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Invalid comparison between Unknown and I4
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_04a0: Invalid comparison between Unknown and I4
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLight in _advancedLights)
{
advancedLight.Value.Clear();
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLaser in _advancedLasers)
{
advancedLaser.Value.Clear();
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLight in _advancedIRLights)
{
advancedIRLight.Value.Clear();
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLaser in _advancedIRLasers)
{
advancedIRLaser.Value.Clear();
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedStrobe in _advancedStrobes)
{
advancedStrobe.Value.Clear();
}
_ngsw_fcs.Clear();
_flashlights.Clear();
_lasers.Clear();
_advancedLaserControllers.Clear();
_advancedLights.Clear();
_advancedLasers.Clear();
_advancedIRLights.Clear();
_advancedIRLasers.Clear();
_advancedStrobes.Clear();
foreach (FVRFireArmAttachment attachments in base.Attachment.curMount.GetRootMount().MyObject.AttachmentsList)
{
if (attachments.AttachmentInterface is TacticalFlashlight)
{
_flashlights.Add((TacticalFlashlight)attachments.AttachmentInterface);
continue;
}
if (attachments.AttachmentInterface is LaserPointer)
{
_lasers.Add((LaserPointer)attachments.AttachmentInterface);
continue;
}
AdvancedLaserController componentInChildren = ((Component)attachments).GetComponentInChildren<AdvancedLaserController>(true);
NGSW_FC componentInChildren2 = ((Component)attachments).GetComponentInChildren<NGSW_FC>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
_advancedLaserControllers.Add(componentInChildren);
}
else if ((Object)(object)componentInChildren2 != (Object)null)
{
_ngsw_fcs.Add(componentInChildren2);
}
}
foreach (AdvancedLaserController advancedLaserController in _advancedLaserControllers)
{
for (int i = 0; i < advancedLaserController.ListOfEmitterObjects.Count; i++)
{
List<int> value;
if ((int)advancedLaserController.ListOfEmitterTypes[i] == 1 || (int)advancedLaserController.ListOfEmitterTypes[i] == 6)
{
if (_advancedLasers.TryGetValue(advancedLaserController, out value))
{
value.Add(i);
continue;
}
List<int> list = new List<int>();
list.Add(i);
value = list;
_advancedLasers.Add(advancedLaserController, value);
}
else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 3)
{
if (_advancedLights.TryGetValue(advancedLaserController, out value))
{
value.Add(i);
continue;
}
List<int> list = new List<int>();
list.Add(i);
value = list;
_advancedLights.Add(advancedLaserController, value);
}
else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 2)
{
if (_advancedIRLasers.TryGetValue(advancedLaserController, out value))
{
value.Add(i);
continue;
}
List<int> list = new List<int>();
list.Add(i);
value = list;
_advancedIRLasers.Add(advancedLaserController, value);
}
else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 4)
{
if (_advancedIRLights.TryGetValue(advancedLaserController, out value))
{
value.Add(i);
continue;
}
List<int> list = new List<int>();
list.Add(i);
value = list;
_advancedIRLights.Add(advancedLaserController, value);
}
else if ((int)advancedLaserController.ListOfEmitterTypes[i] == 5)
{
if (_advancedStrobes.TryGetValue(advancedLaserController, out value))
{
value.Add(i);
continue;
}
List<int> list = new List<int>();
list.Add(i);
value = list;
_advancedStrobes.Add(advancedLaserController, value);
}
}
}
}
public void ToggleLights(bool on)
{
if (on)
{
if (!_irActive)
{
foreach (TacticalFlashlight flashlight in _flashlights)
{
if (!flashlight.IsOn)
{
flashlight.ToggleOn();
}
}
{
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLight in _advancedLights)
{
foreach (int item in advancedLight.Value)
{
int num = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedLight.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLight.Key, item);
advancedLight.Key.ToggleRight();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLight.Key, num);
}
}
return;
}
}
{
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLight in _advancedIRLights)
{
foreach (int item2 in advancedIRLight.Value)
{
int num2 = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedIRLight.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLight.Key, item2);
advancedIRLight.Key.ToggleRight();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLight.Key, num2);
}
}
return;
}
}
foreach (TacticalFlashlight flashlight2 in _flashlights)
{
if (flashlight2.IsOn)
{
flashlight2.ToggleOn();
}
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLight2 in _advancedLights)
{
foreach (int item3 in advancedLight2.Value)
{
int num3 = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedLight2.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLight2.Key, item3);
advancedLight2.Key.ToggleLeft();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLight2.Key, num3);
}
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLight2 in _advancedIRLights)
{
foreach (int item4 in advancedIRLight2.Value)
{
int num4 = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedIRLight2.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLight2.Key, item4);
advancedIRLight2.Key.ToggleLeft();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLight2.Key, num4);
}
}
}
public void ToggleLasers(bool on)
{
if (on)
{
if (!_irActive)
{
foreach (LaserPointer laser in _lasers)
{
if (!laser.IsOn)
{
laser.ToggleOn();
}
}
{
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLaser in _advancedLasers)
{
foreach (int item in advancedLaser.Value)
{
int num = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedLaser.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLaser.Key, item);
advancedLaser.Key.ToggleRight();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLaser.Key, num);
}
}
return;
}
}
{
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLaser in _advancedIRLasers)
{
foreach (int item2 in advancedIRLaser.Value)
{
int num2 = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedIRLaser.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLaser.Key, item2);
advancedIRLaser.Key.ToggleRight();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLaser.Key, num2);
}
}
return;
}
}
foreach (LaserPointer laser2 in _lasers)
{
if (laser2.IsOn)
{
laser2.ToggleOn();
}
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedLaser2 in _advancedLasers)
{
foreach (int item3 in advancedLaser2.Value)
{
int num3 = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedLaser2.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLaser2.Key, item3);
advancedLaser2.Key.ToggleLeft();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedLaser2.Key, num3);
}
}
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedIRLaser2 in _advancedIRLasers)
{
foreach (int item4 in advancedIRLaser2.Value)
{
int num4 = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedIRLaser2.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLaser2.Key, item4);
advancedIRLaser2.Key.ToggleLeft();
_advancedLasersCurrentEmmitterIndex.SetValue(advancedIRLaser2.Key, num4);
}
}
}
public void ToggleStrobe()
{
_strobeActive = !_strobeActive;
foreach (KeyValuePair<AdvancedLaserController, List<int>> advancedStrobe in _advancedStrobes)
{
foreach (int item in advancedStrobe.Value)
{
int num = (int)_advancedLasersCurrentEmmitterIndex.GetValue(advancedStrobe.Key);
_advancedLasersCurrentEmmitterIndex.SetValue(advancedStrobe.Key, item);
if (_strobeActive)
{
advancedStrobe.Key.ToggleRight();
}
else
{
advancedStrobe.Key.ToggleLeft();
}
_advancedLasersCurrentEmmitterIndex.SetValue(advancedStrobe.Key, num);
}
}
}
private IEnumerator WaitForDoubleTap(bool up)
{
yield return null;
_timeWaited = 0f;
_waitingForDoubleTap = true;
FVRViveHand hand = ((FVRInteractiveObject)_altGrip).m_hand;
while (_timeWaited < DoubleTapWaitTime)
{
_timeWaited += Time.deltaTime;
if (!hand.IsInStreamlinedMode)
{
if (up && hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
{
_isLightToggle = !_isLightToggle;
break;
}
if (!up && hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f)
{
_isLaserToggle = !_isLaserToggle;
break;
}
}
else
{
if (up && hand.Input.BYButtonDown)
{
_isLightToggle = !_isLightToggle;
break;
}
if (!up && hand.Input.AXButtonDown)
{
_isLaserToggle = !_isLaserToggle;
break;
}
}
yield return null;
}
_waitingForDoubleTap = false;
}
[HarmonyPatch(typeof(FVRAlternateGrip), "UpdateInteraction")]
[HarmonyPrefix]
public static bool AltGripUpdateInteractionPatch(FVRAlternateGrip __instance, FVRViveHand hand)
{
//IL_004b: 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_00e3: 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_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
if (_existingPressurePadAttachments.ContainsKey(__instance))
{
Action<FVRViveHand> action = (Action<FVRViveHand>)Activator.CreateInstance(typeof(Action<FVRViveHand>), __instance, _baseUpdateInteractionPointer);
action(hand);
Vector2 touchpadAxes = hand.Input.TouchpadAxes;
bool flag = true;
if (!__instance.DoesBracing)
{
flag = false;
}
if (__instance.m_wasGrabbedFromAttachableForegrip && !__instance.m_lastGrabbedInGrip.DoesBracing)
{
flag = false;
}
if (__instance.PrimaryObject.IsAltHeld)
{
flag = false;
}
if (flag && hand.Input.TriggerPressed)
{
if (!__instance.m_hasSavedPalmPoint)
{
__instance.AttemptToGenerateSavedPalmPoint();
if (__instance.m_hasSavedPalmPoint)
{
hand.Buzz(hand.Buzzer.Buzz_BeginInteraction);
}
}
else if (Vector3.Distance(__instance.m_savedRigPalmPos, ((FVRInteractiveObject)__instance).m_hand.PalmTransform.position) > 0.2f)
{
__instance.ClearSavedPalmPoint();
}
}
else if (__instance.m_hasSavedPalmPoint)
{
__instance.ClearSavedPalmPoint();
}
if (hand.Input.TriggerUp)
{
__instance.ClearSavedPalmPoint();
}
if (!__instance.m_wasGrabbedFromAttachableForegrip && __instance.HasQuickMagEject && __instance.PrimaryObject is FVRFireArm)
{
FVRPhysicalObject primaryObject = __instance.PrimaryObject;
FVRFireArm val = (FVRFireArm)(object)((primaryObject is FVRFireArm) ? primaryObject : null);
if (val.UsesMagazines && (Object)(object)val.Magazine != (Object)null && !val.Magazine.IsIntegrated)
{
if (hand.IsInStreamlinedMode)
{
if (hand.Input.AXButtonDown)
{
val.EjectMag(false);
}
}
else if (hand.Input.TouchpadDown && Vector2.Angle(Vector2.down, touchpadAxes) < 45f && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f)
{
val.EjectMag(false);
}
}
}
__instance.PassHandInput(hand, (FVRInteractiveObject)(object)__instance);
return false;
}
return true;
}
}
public class NGSW_FC_ScreenController : MonoBehaviour
{
public enum ESetting
{
Zero,
Compass,
Laser,
Reticle,
Color,
Brightness
}
[Header("NGS-FC Button Config")]
public NGSW_FC NGSW_FC;
public LaserPointer LaserPointer;
public float ScreenTimeout = 1f;
public ESetting[] Settings;
public int CurrentSettingIndex;
public GameObject Canvas;
public Image Frame;
public Text LeftArrow;
public Text RightArrow;
public Text ZeroingValueText;
public Text CompassValueText;
[Header("Text Fields")]
public Text ZeroingText;
public Text LaserText;
public Text CompassOptionText;
public Text ReticleText;
public Text ColorText;
public Text BrightnessText;
[Header("Reticle Stuff")]
public HolographicSight OneEcksReticle;
public HolographicSight PreZeroReticle;
public HolographicSight PostZeroReticle;
[ColorUsage(true, true, 0f, float.MaxValue, 0f, float.MaxValue)]
public Color[] ReticleColors;
public string[] ColorNames;
public int CurrentColor;
[ColorUsage(true, true, 0f, float.MaxValue, 0f, float.MaxValue)]
public Color[] ReticleBrightnesses;
public int CurrentBrightness;
public Texture2D[] OneEcksReticles;
public string[] ReticleNames;
public int CurrentReticle;
private ESetting _currentSetting = ESetting.Compass;
private string _laserStartText;
private string _compassStartText;
private string _reticleStartText;
private string _colorStartText;
private string _brightnessStartText;
private bool _screenIsOn = false;
private static readonly Dictionary<HolographicSight, NGSW_FC_ScreenController> _existingOneEcksReticles = new Dictionary<HolographicSight, NGSW_FC_ScreenController>();
private static readonly Dictionary<HolographicSight, NGSW_FC_ScreenController> _existingNGSWReticles = new Dictionary<HolographicSight, NGSW_FC_ScreenController>();
private const string c_h3vrHolograpicSightMainTex = "_MainTex";
private const string c_h3vrHolograpicSightMainColor = "_Color";
public void Awake()
{
_currentSetting = Settings[CurrentSettingIndex];
_laserStartText = LaserText.text;
_compassStartText = CompassOptionText.text;
_reticleStartText = ReticleText.text;
_colorStartText = ColorText.text;
_brightnessStartText = BrightnessText.text;
UpdateScreen();
UpdateColor();
if (!OpenScripts2_BasePlugin.IsInEditor)
{
Harmony.CreateAndPatchAll(typeof(NGSW_FC_ScreenController), (string)null);
_existingOneEcksReticles.Add(OneEcksReticle, this);
_existingNGSWReticles.Add(OneEcksReticle, this);
_existingNGSWReticles.Add(PreZeroReticle, this);
_existingNGSWReticles.Add(PostZeroReticle, this);
Canvas.SetActive(false);
}
}
public void OnDestroy()
{
_existingOneEcksReticles.Remove(OneEcksReticle);
_existingNGSWReticles.Remove(OneEcksReticle);
_existingNGSWReticles.Remove(PreZeroReticle);
_existingNGSWReticles.Remove(PostZeroReticle);
}
public void ButtonCenter()
{
NGSW_FC.TriggerRangeFinderZeroing();
}
public void ButtonUp()
{
if (_screenIsOn)
{
CurrentSettingIndex--;
if (CurrentSettingIndex < 0)
{
CurrentSettingIndex = Settings.Length - 1;
}
_currentSetting = Settings[CurrentSettingIndex];
}
UpdateScreen();
}
public void ButtonDown()
{
if (_screenIsOn)
{
CurrentSettingIndex++;
if (CurrentSettingIndex >= Settings.Length)
{
CurrentSettingIndex = 0;
}
_currentSetting = Settings[CurrentSettingIndex];
}
UpdateScreen();
}
public void ButtonLeft()
{
if (_screenIsOn)
{
switch (_currentSetting)
{
case ESetting.Zero:
NGSW_FC.TriggerRangeFinderZeroing();
break;
case ESetting.Compass:
if (NGSW_FC.CompassEnabled)
{
NGSW_FC.ToggleCompass();
}
break;
case ESetting.Laser:
if (LaserPointer.IsOn)
{
LaserPointer.ToggleOn();
}
break;
case ESetting.Reticle:
CurrentReticle--;
if (CurrentReticle < 0)
{
CurrentReticle = OneEcksReticles.Length - 1;
}
break;
case ESetting.Color:
CurrentColor--;
if (CurrentColor < 0)
{
CurrentColor = ReticleColors.Length - 1;
}
break;
case ESetting.Brightness:
CurrentBrightness--;
if (CurrentBrightness < 0)
{
CurrentBrightness = ReticleBrightnesses.Length - 1;
}
break;
}
}
UpdateColor();
UpdateScreen();
}
public void ButtonRight()
{
if (_screenIsOn)
{
switch (_currentSetting)
{
case ESetting.Zero:
NGSW_FC.TriggerRangeFinderZeroing();
break;
case ESetting.Compass:
if (!NGSW_FC.CompassEnabled)
{
NGSW_FC.ToggleCompass();
}
break;
case ESetting.Laser:
if (!LaserPointer.IsOn)
{
LaserPointer.ToggleOn();
}
break;
case ESetting.Reticle:
CurrentReticle++;
if (CurrentReticle >= OneEcksReticles.Length)
{
CurrentReticle = 0;
}
break;
case ESetting.Color:
CurrentColor++;
if (CurrentColor >= ReticleColors.Length)
{
CurrentColor = 0;
}
break;
case ESetting.Brightness:
CurrentBrightness++;
if (CurrentBrightness >= ReticleBrightnesses.Length)
{
CurrentBrightness = 0;
}
break;
}
}
UpdateScreen();
UpdateColor();
}
private void UpdateScreen()
{
//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_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_0060: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(AutomaticDisplayTimeout());
Vector3 localPosition = Vector3.zero;
switch (_currentSetting)
{
case ESetting.Zero:
localPosition = ((Component)ZeroingText).transform.localPosition;
((Component)Frame).transform.localPosition = localPosition;
((Component)LeftArrow).gameObject.SetActive(false);
((Component)RightArrow).gameObject.SetActive(false);
break;
case ESetting.Compass:
localPosition = ((Component)CompassOptionText).transform.localPosition;
((Component)Frame).transform.localPosition = localPosition;
((Component)LeftArrow).gameObject.SetActive(NGSW_FC.CompassEnabled);
((Component)RightArrow).gameObject.SetActive(!NGSW_FC.CompassEnabled);
break;
case ESetting.Laser:
localPosition = ((Component)LaserText).transform.localPosition;
((Component)Frame).transform.localPosition = localPosition;
((Component)LeftArrow).gameObject.SetActive(LaserPointer.IsOn);
((Component)RightArrow).gameObject.SetActive(!LaserPointer.IsOn);
break;
case ESetting.Reticle:
localPosition = ((Component)ReticleText).transform.localPosition;
((Component)Frame).transform.localPosition = localPosition;
((Component)LeftArrow).gameObject.SetActive(true);
((Component)RightArrow).gameObject.SetActive(true);
break;
case ESetting.Color:
localPosition = ((Component)ColorText).transform.localPosition;
((Component)Frame).transform.localPosition = localPosition;
((Component)LeftArrow).gameObject.SetActive(true);
((Component)RightArrow).gameObject.SetActive(true);
break;
case ESetting.Brightness:
localPosition = ((Component)BrightnessText).transform.localPosition;
((Component)Frame).transform.localPosition = localPosition;
((Component)LeftArrow).gameObject.SetActive(true);
((Component)RightArrow).gameObject.SetActive(true);
break;
}
if ((Object)(object)ZeroingText != (Object)null)
{
ZeroingText.text = "Zeroing";
}
CompassOptionText.text = _compassStartText + ((!NGSW_FC.CompassEnabled) ? "off" : "on");
LaserText.text = _laserStartText + ((!LaserPointer.IsOn) ? "off" : "on");
ReticleText.text = _reticleStartText + ReticleNames[CurrentReticle];
ColorText.text = _colorStartText + ColorNames[CurrentColor];
BrightnessText.text = _brightnessStartText + CurrentBrightness;
UnityEngineExtensions.ModifyLocalPositionAxisValue(((Component)LeftArrow).transform, (Axis)1, localPosition.y);
UnityEngineExtensions.ModifyLocalPositionAxisValue(((Component)RightArrow).transform, (Axis)1, localPosition.y);
}
private void UpdateColor()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0051: 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_0069: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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)
Color color = ReticleColors[CurrentColor] * ReticleBrightnesses[CurrentBrightness];
((Graphic)ZeroingValueText).color = color;
((Graphic)CompassValueText).color = color;
((Graphic)LeftArrow).color = color;
((Graphic)RightArrow).color = color;
((Graphic)ZeroingText).color = color;
((Graphic)LaserText).color = color;
((Graphic)CompassOptionText).color = color;
((Graphic)ReticleText).color = color;
((Graphic)ColorText).color = color;
((Graphic)BrightnessText).color = color;
((Graphic)Frame).color = color;
}
private IEnumerator AutomaticDisplayTimeout()
{
_screenIsOn = true;
Canvas.SetActive(true);
((Component)CompassValueText).gameObject.SetActive(false);
((Component)ZeroingValueText).gameObject.SetActive(false);
for (float displayTimeOn = 0f; displayTimeOn < ScreenTimeout; displayTimeOn += Time.deltaTime)
{
yield return null;
}
((Component)CompassValueText).gameObject.SetActive(true);
((Component)ZeroingValueText).gameObject.SetActive(true);
Canvas.SetActive(false);
_screenIsOn = false;
}
[HarmonyPatch(typeof(HolographicSight), "OnWillRenderObject")]
[HarmonyPrefix]
public static void OnWillRender_ReticleTexturePatch(HolographicSight __instance)
{
if (_existingOneEcksReticles.TryGetValue(__instance, out var value))
{
__instance.m_block.SetTexture("_MainTex", (Texture)(object)value.OneEcksReticles[value.CurrentReticle]);
}
}
[HarmonyPatch(typeof(HolographicSight), "OnWillRenderObject")]
[HarmonyPrefix]
public static void OnWillRender_ReticleColorPatch(Holograph