using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
using UnityEngine.Events;
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 KamikazeF0X.PIVOT_Rifle_Scope
{
[BepInPlugin("KamikazeF0X.PIVOT_Rifle_Scope", "PIVOT_Rifle_Scope", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class PIVOT_Rifle_ScopePlugin : 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(), "KamikazeF0X.PIVOT_Rifle_Scope");
OtherLoader.RegisterDirectLoad(BasePath, "KamikazeF0X.PIVOT_Rifle_Scope", "", "", "pivot", "");
}
}
}
public class PIPScopeAngleAttach : MonoBehaviour
{
[Header("References")]
public PIPScope PScope;
public PIPScopeController PScopeController;
[Header("Angle Child")]
public Transform AngleChild;
[Tooltip("Used to determine whether the scope is being viewed through the front/objective lens.")]
public Transform ReferenceForwardTransform;
[Header("Stable Optical Reference")]
[Tooltip("Capture the PIP scope optical transform once and never use the live scopeCamTransform for angle calculations.")]
public bool UseStableOpticalReference = true;
[Tooltip("If enabled, the optical reference is recaptured when recalculating the zero angle.")]
public bool RecaptureReferenceOnRecalculate = false;
[Header("Debug Angle Multiplier")]
[Tooltip("Multiplies the final calculated AngleChild X rotation. 1 = normal, 0 = disabled, 2 = double.")]
public float AngleMultiplier = 1f;
[Tooltip("Print detailed angle calculation information to the Unity console.")]
public bool DebugAngleCalculation = true;
[Tooltip("Print the frozen optical transform used by the calculation.")]
public bool DebugStableReference = false;
[Header("Recalculation")]
[Tooltip("Recalculate when the controller's selected zero distance changes.")]
public bool RecalculateWhenZeroDistanceChanges = true;
[Tooltip("Also force a recalculation when the component starts.")]
public bool RecalculateOnStart = true;
[Tooltip("Optional smoothing for AngleChild. 0 = instant.")]
public float RotationSmoothSpeed = 0f;
[Header("Canvas Auto Create")]
public bool AutoCreateCanvas = true;
public Canvas WorldCanvas;
[Header("Text Outputs")]
public Text RangeText;
public Text AngleText;
public Text LaserRangeText;
[Header("Laser / Raycast")]
public Transform LaserPoint;
public LayerMask LM_LaserPoint = LayerMask.op_Implicit(-1);
private List<float> m_distances = new List<float>();
private int m_curDistToReplace;
private bool m_initialized;
private bool m_hasCachedAngle;
private float m_lastZeroDistance = float.NaN;
private Vector2 m_cachedZeroToWorld = Vector2.zero;
private Vector2 m_cachedRotatedZero = Vector2.zero;
private float m_cachedAngleX = 0f;
private bool m_cachedUseFrontLens = false;
private float m_cachedDrop = 0f;
private Quaternion m_lastAppliedRotation = Quaternion.identity;
private Transform m_stableReferenceParent;
private Vector3 m_stableScopeCamLocalPosition;
private Quaternion m_stableScopeCamLocalRotation;
private Vector3 m_stableScopeCamWorldPosition;
private Quaternion m_stableScopeCamWorldRotation;
private void Awake()
{
if ((Object)(object)PScope == (Object)null)
{
PScope = ((Component)this).GetComponentInParent<PIPScope>();
}
if (AutoCreateCanvas && (Object)(object)WorldCanvas == (Object)null)
{
CreateWorldCanvas();
}
CaptureStableOpticalReference();
}
private void Start()
{
FindController();
if ((Object)(object)ReferenceForwardTransform == (Object)null && (Object)(object)PScopeController != (Object)null)
{
ReferenceForwardTransform = ((!((Object)(object)PScopeController.OverrideMuzzle != (Object)null)) ? ((Component)PScopeController).transform : PScopeController.OverrideMuzzle);
}
if ((Object)(object)PScopeController != (Object)null && PScopeController.ZeroDistanceValues != null)
{
if (PScopeController.ZeroDistanceValues.Count > 0)
{
PScopeController.ZeroDistanceIndex = Mathf.Clamp(PScopeController.ZeroDistanceIndex, 0, PScopeController.ZeroDistanceValues.Count - 1);
}
else
{
PScopeController.ZeroDistanceIndex = 0;
}
}
m_initialized = true;
if (RecalculateOnStart)
{
ForceRecalculateAngle();
}
}
private void Update()
{
if ((Object)(object)PScope == (Object)null || !m_initialized)
{
return;
}
if ((Object)(object)PScopeController != (Object)null && PScopeController.ZeroDistanceValues != null && PScopeController.ZeroDistanceValues.Count > 0)
{
int index = Mathf.Clamp(PScopeController.ZeroDistanceIndex, 0, PScopeController.ZeroDistanceValues.Count - 1);
float num = PScopeController.ZeroDistanceValues[index];
if ((!m_hasCachedAngle || !Mathf.Approximately(num, m_lastZeroDistance)) && (RecalculateWhenZeroDistanceChanges || !m_hasCachedAngle))
{
RecalculateAngle(num);
}
}
else if (!m_hasCachedAngle)
{
m_cachedAngleX = 0f;
m_hasCachedAngle = true;
}
ApplyAngle();
UpdateRangeAndLaserUI();
}
private void FindController()
{
if ((Object)(object)PScope == (Object)null)
{
return;
}
PIPScopeController[] array = Object.FindObjectsOfType<PIPScopeController>();
PIPScopeController[] array2 = array;
foreach (PIPScopeController val in array2)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.PScope == (Object)(object)PScope)
{
PScopeController = val;
break;
}
}
}
private void CaptureStableOpticalReference()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)PScope == (Object)null) && !((Object)(object)PScope.scopeCamTransform == (Object)null))
{
Transform scopeCamTransform = PScope.scopeCamTransform;
m_stableReferenceParent = scopeCamTransform.parent;
if ((Object)(object)m_stableReferenceParent != (Object)null)
{
m_stableScopeCamLocalPosition = scopeCamTransform.localPosition;
m_stableScopeCamLocalRotation = scopeCamTransform.localRotation;
}
else
{
m_stableScopeCamWorldPosition = scopeCamTransform.position;
m_stableScopeCamWorldRotation = scopeCamTransform.rotation;
}
if (DebugStableReference)
{
string[] obj = new string[8]
{
"[PIPScopeAngleAttach] Stable optical reference captured.\nLocal Position=",
((Vector3)(ref m_stableScopeCamLocalPosition)).ToString("F5"),
"\nLocal Rotation=",
null,
null,
null,
null,
null
};
Vector3 eulerAngles = ((Quaternion)(ref m_stableScopeCamLocalRotation)).eulerAngles;
obj[3] = ((Vector3)(ref eulerAngles)).ToString("F5");
obj[4] = "\nWorld Position=";
obj[5] = ((Vector3)(ref m_stableScopeCamWorldPosition)).ToString("F5");
obj[6] = "\nWorld Rotation=";
Vector3 eulerAngles2 = ((Quaternion)(ref m_stableScopeCamWorldRotation)).eulerAngles;
obj[7] = ((Vector3)(ref eulerAngles2)).ToString("F5");
Debug.Log((object)string.Concat(obj));
}
}
}
private void GetStableOpticalTransform(out Vector3 position, out Quaternion rotation)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (!UseStableOpticalReference || (Object)(object)PScope == (Object)null || (Object)(object)PScope.scopeCamTransform == (Object)null)
{
position = PScope.scopeCamTransform.position;
rotation = PScope.scopeCamTransform.rotation;
}
else if ((Object)(object)m_stableReferenceParent != (Object)null)
{
position = m_stableReferenceParent.TransformPoint(m_stableScopeCamLocalPosition);
rotation = m_stableReferenceParent.rotation * m_stableScopeCamLocalRotation;
}
else
{
position = m_stableScopeCamWorldPosition;
rotation = m_stableScopeCamWorldRotation;
}
}
private void RecalculateAngle(float selectedDistance)
{
//IL_01f2: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Invalid comparison between Unknown and I4
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)PScope == (Object)null)
{
return;
}
if (RecaptureReferenceOnRecalculate)
{
CaptureStableOpticalReference();
}
FVRFireArm val = null;
Transform val2 = null;
if ((Object)(object)PScopeController != (Object)null)
{
if ((Object)(object)PScopeController.OverrideFireArm != (Object)null)
{
val = PScopeController.OverrideFireArm;
}
else if ((Object)(object)((FVRFireArmAttachmentInterface)PScopeController).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)PScopeController).Attachment.curMount != (Object)null && ((FVRFireArmAttachmentInterface)PScopeController).Attachment.curMount.Parent is FVRFireArm)
{
FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)PScopeController).Attachment.curMount.Parent;
val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
}
if ((Object)(object)PScopeController.OverrideMuzzle != (Object)null)
{
val2 = PScopeController.OverrideMuzzle;
}
else if ((Object)(object)val != (Object)null)
{
val2 = val.GetMuzzle();
}
}
float num = 0f;
if ((Object)(object)val != (Object)null)
{
try
{
FireArmRoundType roundType = val.RoundType;
if (AM.SRoundDisplayDataDic.ContainsKey(roundType))
{
FVRFireArmRoundDisplayData val3 = AM.SRoundDisplayDataDic[roundType];
if ((Object)(object)val3 != (Object)null && val3.BulletDropCurve != null)
{
num = val3.BulletDropCurve.Evaluate(selectedDistance * 0.001f);
}
}
}
catch
{
}
}
if ((Object)(object)val2 == (Object)null)
{
m_cachedZeroToWorld = Vector2.zero;
m_cachedRotatedZero = Vector2.zero;
m_cachedDrop = num;
m_cachedAngleX = 0f;
m_cachedUseFrontLens = false;
m_lastZeroDistance = selectedDistance;
m_hasCachedAngle = true;
if (DebugAngleCalculation)
{
Debug.Log((object)"[PIPScopeAngleAttach] No muzzle found. Angle forced to 0.");
}
return;
}
Vector3 targetWorldPos = val2.position + val2.forward * selectedDistance + val2.up * num;
Transform val4 = ((!((Object)(object)ReferenceForwardTransform != (Object)null)) ? val2 : ReferenceForwardTransform);
bool flag = false;
if ((Object)(object)val4 != (Object)null && (Object)(object)PScope.scopeCamTransform != (Object)null)
{
flag = Vector3.Dot(val4.forward, PScope.scopeCamTransform.forward) < 0f;
}
Vector2 val5 = StableZeroToWorldPoint(targetWorldPos, flag);
bool flag2 = (Object)(object)PScopeController != (Object)null && (int)PScopeController.ZeroingMode == 1;
if (flag2)
{
val5 -= PScope.scopeAdjustmentDegrees;
}
float zeroRotation = PScope.zeroRotation;
float num2 = (0f - zeroRotation) * ((float)Math.PI / 180f);
float num3 = Mathf.Cos(num2);
float num4 = Mathf.Sin(num2);
Vector2 cachedRotatedZero = default(Vector2);
((Vector2)(ref cachedRotatedZero))..ctor(val5.x * num3 - val5.y * num4, val5.x * num4 + val5.y * num3);
float num5 = (0f - cachedRotatedZero.y) * ((!flag) ? 1f : (-1f));
float cachedAngleX = num5 * AngleMultiplier;
m_cachedZeroToWorld = val5;
m_cachedRotatedZero = cachedRotatedZero;
m_cachedDrop = num;
m_cachedUseFrontLens = flag;
m_cachedAngleX = cachedAngleX;
m_lastZeroDistance = selectedDistance;
m_hasCachedAngle = true;
if (DebugAngleCalculation)
{
Debug.Log((object)("[PIPScopeAngleAttach] ZeroDistance=" + selectedDistance.ToString("F3") + "m | Drop=" + num.ToString("F6") + " | ZeroToWorld=" + ((Vector2)(ref val5)).ToString("F5") + " | Rotated=" + ((Vector2)(ref cachedRotatedZero)).ToString("F5") + " | RawAngleX=" + num5.ToString("F5") + " | Multiplier=" + AngleMultiplier.ToString("F4") + " | AngleX=" + cachedAngleX.ToString("F5") + " | FrontLens=" + flag + " | Mode=" + ((!flag2) ? "Scope" : "Reticle")));
}
}
private Vector2 StableZeroToWorldPoint(Vector3 targetWorldPos, bool useFrontLens)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: 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_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)PScope == (Object)null || (Object)(object)PScope.scopeCamTransform == (Object)null)
{
return Vector2.zero;
}
Vector3 val7;
if (!useFrontLens)
{
GetStableOpticalTransform(out var position, out var rotation);
Vector3 position2 = ((Component)PScope).transform.position;
Quaternion rotation2 = ((Component)PScope).transform.rotation;
Vector3 val = rotation2 * Vector3.forward;
Vector3 val2 = rotation2 * Vector3.up;
Vector3 val3 = rotation * Vector3.forward;
float num = Vector3.Angle(val, val3);
Vector3 val4;
if (num < 1f)
{
val4 = position;
}
else
{
float y = (Quaternion.Inverse(rotation2) * (position - position2)).y;
float num2 = y * Mathf.Tan((90f - num) * ((float)Math.PI / 180f));
float num3 = Mathf.Sqrt(y * y + num2 * num2);
val4 = position + val3 * num3;
}
float num4 = ((!(num < 1f)) ? Mathf.Max(0f, Mathf.Min(PScope.cameraOffsetRearLens, PScope.frontLensOffset)) : Mathf.Max(0f, Mathf.Min(PScope.cameraOffsetRearLens, PScope.frontLensOffset)));
Vector3 val5 = val4 + val3 * num4;
Matrix4x4 val6 = Matrix4x4.TRS(val5, rotation, Vector3.one);
Matrix4x4 inverse = ((Matrix4x4)(ref val6)).inverse;
val7 = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(targetWorldPos);
}
else
{
Transform transform = ((Component)PScope).transform;
Vector3 position3 = transform.position;
Quaternion rotation3 = transform.rotation;
Vector3 forward = transform.forward;
float num5 = Vector3.Angle(transform.forward, GetStableOpticalForward());
Vector3 val8;
if (num5 < 1f)
{
val8 = position3;
}
else
{
float y2 = (GetStableOpticalInverseRotation() * (position3 - GetStableOpticalPosition())).y;
float num6 = y2 * Mathf.Tan((90f - num5) * ((float)Math.PI / 180f));
float num7 = Mathf.Sqrt(y2 * y2 + num6 * num6);
val8 = position3 + forward * num7;
}
float num8;
if (num5 < 1f)
{
num8 = Mathf.Max(0f, Mathf.Min(PScope.cameraOffsetFrontLens, PScope.frontLensOffset));
}
else
{
Vector3 val9 = transform.InverseTransformPoint(val8);
num8 = 0f - Mathf.Max(0f, Mathf.Min(PScope.cameraOffsetFrontLens, val9.z));
}
Vector3 val10 = val8 + forward * num8;
Quaternion val11 = Quaternion.AngleAxis(180f, transform.up) * rotation3;
Matrix4x4 val12 = Matrix4x4.TRS(val10, val11, Vector3.one);
Matrix4x4 inverse2 = ((Matrix4x4)(ref val12)).inverse;
val7 = ((Matrix4x4)(ref inverse2)).MultiplyPoint3x4(targetWorldPos);
}
if (((Vector3)(ref val7)).sqrMagnitude < 1E-07f)
{
return Vector2.zero;
}
Quaternion val13 = Quaternion.LookRotation(val7);
Vector3 eulerAngles = ((Quaternion)(ref val13)).eulerAngles;
while (eulerAngles.x > 180f)
{
eulerAngles.x -= 360f;
}
while (eulerAngles.y > 180f)
{
eulerAngles.y -= 360f;
}
Vector2 result = default(Vector2);
((Vector2)(ref result))..ctor(eulerAngles.y, (0f - eulerAngles.x) * ((!useFrontLens) ? 1f : (-1f)));
return result;
}
private Vector3 GetStableOpticalPosition()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
GetStableOpticalTransform(out var position, out var _);
return position;
}
private Quaternion GetStableOpticalRotation()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
GetStableOpticalTransform(out var _, out var rotation);
return rotation;
}
private Vector3 GetStableOpticalForward()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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)
return GetStableOpticalRotation() * Vector3.forward;
}
private Quaternion GetStableOpticalInverseRotation()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
return Quaternion.Inverse(GetStableOpticalRotation());
}
private void ApplyAngle()
{
//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_0090: 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)
if (!((Object)(object)AngleChild == (Object)null))
{
Vector3 localEulerAngles = AngleChild.localEulerAngles;
float cachedAngleX = m_cachedAngleX;
if (RotationSmoothSpeed > 0f)
{
float num = Mathf.MoveTowardsAngle(localEulerAngles.x, cachedAngleX, RotationSmoothSpeed * Time.deltaTime);
AngleChild.localEulerAngles = new Vector3(num, localEulerAngles.y, localEulerAngles.z);
}
else
{
AngleChild.localEulerAngles = new Vector3(cachedAngleX, localEulerAngles.y, localEulerAngles.z);
}
}
}
[ContextMenu("Force Recalculate Angle")]
public void ForceRecalculateAngle()
{
if ((Object)(object)PScopeController == (Object)null || PScopeController.ZeroDistanceValues == null || PScopeController.ZeroDistanceValues.Count == 0)
{
Debug.LogWarning((object)"[PIPScopeAngleAttach] Cannot recalculate: no zero distance values.");
return;
}
int index = Mathf.Clamp(PScopeController.ZeroDistanceIndex, 0, PScopeController.ZeroDistanceValues.Count - 1);
float selectedDistance = PScopeController.ZeroDistanceValues[index];
RecalculateAngle(selectedDistance);
}
private void CreateWorldCanvas()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_0094: Expected O, but got Unknown
//IL_00d4: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0193: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: 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_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Expected O, but got Unknown
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("PIPScope_WorldCanvas");
val.transform.SetParent(((Component)this).transform, false);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)2;
RectTransform component = ((Component)val2).GetComponent<RectTransform>();
component.sizeDelta = new Vector2(0.2f, 0.08f);
CanvasScaler val3 = val.AddComponent<CanvasScaler>();
val3.dynamicPixelsPerUnit = 100f;
val.AddComponent<GraphicRaycaster>();
WorldCanvas = val2;
GameObject val4 = new GameObject("AngleText");
val4.transform.SetParent(val.transform, false);
Text val5 = val4.AddComponent<Text>();
val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
val5.alignment = (TextAnchor)3;
val5.fontSize = 14;
((Graphic)val5).color = Color.white;
RectTransform component2 = ((Component)val5).GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0f, 0.66f);
component2.anchorMax = new Vector2(1f, 1f);
component2.offsetMin = new Vector2(4f, -4f);
component2.offsetMax = new Vector2(-4f, 4f);
AngleText = val5;
GameObject val6 = new GameObject("LaserRangeText");
val6.transform.SetParent(val.transform, false);
Text val7 = val6.AddComponent<Text>();
val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
val7.alignment = (TextAnchor)3;
val7.fontSize = 14;
((Graphic)val7).color = Color.cyan;
RectTransform component3 = ((Component)val7).GetComponent<RectTransform>();
component3.anchorMin = new Vector2(0f, 0.33f);
component3.anchorMax = new Vector2(1f, 0.66f);
component3.offsetMin = new Vector2(4f, -2f);
component3.offsetMax = new Vector2(-4f, 2f);
LaserRangeText = val7;
GameObject val8 = new GameObject("RangeText");
val8.transform.SetParent(val.transform, false);
Text val9 = val8.AddComponent<Text>();
val9.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
val9.alignment = (TextAnchor)6;
val9.fontSize = 14;
((Graphic)val9).color = Color.white;
RectTransform component4 = ((Component)val9).GetComponent<RectTransform>();
component4.anchorMin = new Vector2(0f, 0f);
component4.anchorMax = new Vector2(1f, 0.33f);
component4.offsetMin = new Vector2(4f, 4f);
component4.offsetMax = new Vector2(-4f, 24f);
RangeText = val9;
}
private void UpdateRangeAndLaserUI()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0570: Unknown result type (might be due to invalid IL or missing references)
//IL_0576: Invalid comparison between Unknown and I4
float renderDistance = PIPScope.renderDistance;
renderDistance = Mathf.Min(renderDistance, 9999f);
Transform val = ((!((Object)(object)LaserPoint != (Object)null)) ? ((Component)this).transform : LaserPoint);
RaycastHit val2 = default(RaycastHit);
float num = (Physics.Raycast(val.position, val.forward, ref val2, renderDistance, LayerMask.op_Implicit(LM_LaserPoint)) ? ((RaycastHit)(ref val2)).distance : renderDistance);
float num2 = 0f;
if ((Object)(object)PScopeController != (Object)null && PScopeController.ZeroDistanceValues != null && PScopeController.ZeroDistanceValues.Count > 0)
{
int index = Mathf.Clamp(PScopeController.ZeroDistanceIndex, 0, PScopeController.ZeroDistanceValues.Count - 1);
num2 = PScopeController.ZeroDistanceValues[index];
}
else
{
RaycastHit val3 = default(RaycastHit);
float num3 = (Physics.Raycast(val.position, val.forward, ref val3, renderDistance, LayerMask.op_Implicit(LM_LaserPoint)) ? ((RaycastHit)(ref val3)).distance : renderDistance);
if (m_distances.Count < 10)
{
m_distances.Add(num3);
}
else
{
m_distances[m_curDistToReplace] = num3;
m_curDistToReplace++;
if (m_curDistToReplace >= m_distances.Count)
{
m_curDistToReplace = 0;
}
}
if (m_distances.Count > 0)
{
float num4 = 0f;
for (int i = 0; i < m_distances.Count; i++)
{
num4 += m_distances[i];
}
num4 /= (float)m_distances.Count;
num2 = num4;
}
}
if ((Object)(object)RangeText != (Object)null)
{
if (num2 < 100f)
{
string text = num2.ToString("f1");
string text2 = string.Empty;
for (int j = 0; j < text.Length; j++)
{
text2 += text[j];
if (j + 1 < text.Length && text[j] != '.' && text[j + 1] != '.')
{
text2 += " ";
}
}
RangeText.text = text2 + " m";
}
else
{
string text3 = num2.ToString("f0");
string text4 = string.Empty;
for (int k = 0; k < text3.Length; k++)
{
text4 += text3[k];
if (k + 1 < text3.Length)
{
text4 += " ";
}
}
RangeText.text = text4 + " m";
}
((Component)RangeText).gameObject.SetActive(true);
}
if ((Object)(object)LaserRangeText != (Object)null)
{
if (num < 100f)
{
string text5 = num.ToString("f1");
string text6 = string.Empty;
for (int l = 0; l < text5.Length; l++)
{
text6 += text5[l];
if (l + 1 < text5.Length && text5[l] != '.' && text5[l + 1] != '.')
{
text6 += " ";
}
}
LaserRangeText.text = text6 + " m";
}
else
{
string text7 = num.ToString("f0");
string text8 = string.Empty;
for (int m = 0; m < text7.Length; m++)
{
text8 += text7[m];
if (m + 1 < text7.Length)
{
text8 += " ";
}
}
LaserRangeText.text = text8 + " m";
}
((Component)LaserRangeText).gameObject.SetActive(true);
}
if (!((Object)(object)AngleText != (Object)null))
{
return;
}
float y = m_cachedRotatedZero.y;
float num5 = (0f - m_cachedRotatedZero.y) * ((!m_cachedUseFrontLens) ? 1f : (-1f));
string text9 = y.ToString("f1");
string text10 = string.Empty;
for (int n = 0; n < text9.Length; n++)
{
text10 += text9[n];
if (n + 1 < text9.Length)
{
text10 += " ";
}
}
AngleText.text = ((!((Object)(object)PScopeController != (Object)null) || (int)PScopeController.ZeroingMode != 1) ? "Mode: Scope\n" : "Mode: Reticle\n") + text10 + "° (raw: " + num5.ToString("f2") + "°, applied: " + m_cachedAngleX.ToString("f2") + "°)";
((Component)AngleText).gameObject.SetActive(true);
}
}
namespace KamikazeF0X
{
public class PIPScopeRangeHelper : MonoBehaviour
{
[Header("Scope Reference (parent PIPScope)")]
[Tooltip("The PIPScopeController this helper reads Zero Distance / Reticle / Color settings from.")]
public PIPScopeController ScopeController;
[Header("Laser Rangefinder")]
[Tooltip("Origin/direction the ranging laser is cast from, usually the scope's forward-facing transform.")]
public Transform LaserOrigin;
[Tooltip("Layers the laser can hit. Defaults to Everything - narrow this down in the Inspector if needed.")]
public LayerMask LM_LaserHit = LayerMask.op_Implicit(-1);
[Tooltip("Hard cap on ranging distance; also clamped by the scene's ScopeMaxDrawRange.")]
public float MaxRange = 3500f;
[Header("Canvas Display")]
public Text RangeText;
[Tooltip("Text shown in RangeText when the laser doesn't hit anything within MaxRange.")]
public string OverRangeText = "OVER";
[Tooltip("Shows the PIPScope's current target (zero) range in meters.")]
public Text TargetRangeText;
[Tooltip("Canvas whose Text children will all be tinted with the scope's reticle color.")]
public Canvas DisplayCanvas;
[Tooltip("Tint every Text under DisplayCanvas using the scope's current reticle illumination color.")]
public bool MatchReticleColor = true;
[Header("Drop Pointer")]
[Tooltip("Child transform whose local X angle is set to aim at the estimated drop for the scope's Zero Distance.")]
public Transform DropPointer;
public bool FlipDropAngle;
[Tooltip("Max simulated physics steps for the drop estimate. 90 ~= 1s of flight.")]
public int CalcFrames = 900;
[Tooltip("Seconds between re-reading the chambered round's ballistic data.")]
public float BallisticsRefreshInterval = 0.5f;
[Header("Angle Displays")]
[Tooltip("Shows the elevation angle (degrees) the scope is currently compensating for at its Zero Distance.")]
public Text TargetAngleText;
[Tooltip("Shows the DropPointer's current local X angle in MRAD.")]
public Text IndicatorAngleMradText;
private RaycastHit m_hit;
private FVRFireArm m_firearm;
private Transform m_muzzle;
private PIPScopeBallisticsHelper.ProjectileBallisticData m_ballisticData;
private bool m_ballisticsAvailable;
private float m_ballisticsTimer;
private List<float> m_rangeSamples = new List<float>();
private int m_rangeSampleToReplace;
private Text[] m_canvasTexts;
public float ZeroDistance
{
get
{
if ((Object)(object)ScopeController == (Object)null)
{
return 0f;
}
if (ScopeController.ZeroDistanceValues != null && ScopeController.ZeroDistanceValues.Count > 0)
{
int index = Mathf.Clamp(ScopeController.ZeroDistanceIndex, 0, ScopeController.ZeroDistanceValues.Count - 1);
return ScopeController.ZeroDistanceValues[index];
}
return ScopeController.FixedBaseZero;
}
}
public Color ReticleColor => (!((Object)(object)ScopeController != (Object)null) || !((Object)(object)ScopeController.PScope != (Object)null)) ? Color.white : ScopeController.PScope.reticleIllumination;
public Reticle CurrentReticle
{
get
{
if ((Object)(object)ScopeController == (Object)null || ScopeController.Reticles == null || ScopeController.Reticles.Count == 0)
{
return null;
}
int index = Mathf.Clamp(ScopeController.ReticleIndex, 0, ScopeController.Reticles.Count - 1);
return ScopeController.Reticles[index];
}
}
private void Awake()
{
//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)
if (((LayerMask)(ref LM_LaserHit)).value == 0)
{
Debug.LogWarning((object)"PIPScopeRangeHelper: LM_LaserHit was set to Nothing, defaulting to AM.PLM. Assign it in the Inspector to override.");
LM_LaserHit = AM.PLM;
}
if ((Object)(object)DisplayCanvas != (Object)null)
{
m_canvasTexts = ((Component)DisplayCanvas).GetComponentsInChildren<Text>(true);
}
}
private void Update()
{
UpdateRangeDisplay();
UpdateBallisticsData();
UpdateDropPointer();
UpdateCanvasColor();
}
private void UpdateCanvasColor()
{
//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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (!MatchReticleColor || m_canvasTexts == null)
{
return;
}
Color reticleColor = ReticleColor;
for (int i = 0; i < m_canvasTexts.Length; i++)
{
if ((Object)(object)m_canvasTexts[i] != (Object)null)
{
Color color = ((Graphic)m_canvasTexts[i]).color;
((Graphic)m_canvasTexts[i]).color = new Color(reticleColor.r, reticleColor.g, reticleColor.b, color.a);
}
}
}
private void UpdateRangeDisplay()
{
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)TargetRangeText != (Object)null)
{
((Component)TargetRangeText).gameObject.SetActive(true);
TargetRangeText.text = $"{ZeroDistance:F0}";
}
if ((Object)(object)RangeText == (Object)null)
{
return;
}
if ((Object)(object)ScopeController == (Object)null || (Object)(object)ScopeController.PScope == (Object)null || !((Behaviour)ScopeController.PScope).enabled)
{
((Component)RangeText).gameObject.SetActive(false);
return;
}
float num = MaxRange;
if ((Object)(object)GM.CurrentSceneSettings != (Object)null)
{
num = Mathf.Min(num, GM.CurrentSceneSettings.ScopeMaxDrawRange);
}
Transform val = ((!((Object)(object)LaserOrigin != (Object)null)) ? ((Component)this).transform : LaserOrigin);
bool flag = Physics.Raycast(val.position, val.forward, ref m_hit, num, LayerMask.op_Implicit(LM_LaserHit), (QueryTriggerInteraction)1);
float num2 = AddRangeSample((!flag) ? num : ((RaycastHit)(ref m_hit)).distance);
((Component)RangeText).gameObject.SetActive(true);
RangeText.text = ((!flag) ? OverRangeText : $"{num2:F0}");
}
private float AddRangeSample(float sample)
{
if (m_rangeSamples.Count < 10)
{
m_rangeSamples.Add(sample);
}
else
{
m_rangeSamples[m_rangeSampleToReplace] = sample;
m_rangeSampleToReplace = (m_rangeSampleToReplace + 1) % m_rangeSamples.Count;
}
float num = 0f;
for (int i = 0; i < m_rangeSamples.Count; i++)
{
num += m_rangeSamples[i];
}
return num / (float)m_rangeSamples.Count;
}
private void UpdateBallisticsData()
{
m_ballisticsTimer -= Time.deltaTime;
if (!m_ballisticsAvailable || !(m_ballisticsTimer > 0f))
{
m_ballisticsTimer = BallisticsRefreshInterval;
m_firearm = ResolveFirearm();
m_muzzle = ResolveMuzzle(m_firearm);
m_ballisticsAvailable = (Object)(object)m_muzzle != (Object)null && PIPScopeBallisticsHelper.TryGetProjectileData(m_firearm, m_muzzle, out m_ballisticData);
}
}
private FVRFireArm ResolveFirearm()
{
if ((Object)(object)ScopeController == (Object)null)
{
return null;
}
if ((Object)(object)ScopeController.OverrideFireArm != (Object)null)
{
return ScopeController.OverrideFireArm;
}
if ((Object)(object)((FVRFireArmAttachmentInterface)ScopeController).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)ScopeController).Attachment.curMount != (Object)null && ((FVRFireArmAttachmentInterface)ScopeController).Attachment.curMount.Parent is FVRFireArm)
{
FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)ScopeController).Attachment.curMount.Parent;
return (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
}
return null;
}
private Transform ResolveMuzzle(FVRFireArm firearm)
{
if ((Object)(object)ScopeController != (Object)null && (Object)(object)ScopeController.OverrideMuzzle != (Object)null)
{
return ScopeController.OverrideMuzzle;
}
if ((Object)(object)firearm != (Object)null)
{
return firearm.GetMuzzle();
}
return null;
}
private void UpdateDropPointer()
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)DropPointer == (Object)null || !m_ballisticsAvailable || (Object)(object)m_firearm == (Object)null)
{
if ((Object)(object)TargetAngleText != (Object)null)
{
((Component)TargetAngleText).gameObject.SetActive(false);
}
if ((Object)(object)IndicatorAngleMradText != (Object)null)
{
((Component)IndicatorAngleMradText).gameObject.SetActive(false);
}
return;
}
float zeroDistance = ZeroDistance;
if (!(zeroDistance <= 0f))
{
float num = 0f;
if (PIPScopeBallisticsHelper.TrySimulateDropAtDistance(m_ballisticData, Vector3.forward, zeroDistance, CalcFrames, out var dropMeters))
{
num = PIPScopeBallisticsHelper.DropToElevationAngleDegrees(dropMeters, zeroDistance);
}
if (FlipDropAngle)
{
num = 0f - num;
}
Vector3 localEulerAngles = DropPointer.localEulerAngles;
localEulerAngles.x = num;
DropPointer.localEulerAngles = localEulerAngles;
if ((Object)(object)TargetAngleText != (Object)null)
{
((Component)TargetAngleText).gameObject.SetActive(true);
TargetAngleText.text = $"{num:F2}";
}
if ((Object)(object)IndicatorAngleMradText != (Object)null)
{
((Component)IndicatorAngleMradText).gameObject.SetActive(true);
float num2 = NormalizeAngle(DropPointer.localEulerAngles.x);
float num3 = num2 / 0.05729578f;
IndicatorAngleMradText.text = $"{num3:F2}";
}
}
}
private static float NormalizeAngle(float angleDegrees)
{
angleDegrees %= 360f;
if (angleDegrees > 180f)
{
angleDegrees -= 360f;
}
else if (angleDegrees < -180f)
{
angleDegrees += 360f;
}
return angleDegrees;
}
}
public static class PIPScopeBallisticsHelper
{
public struct ProjectileBallisticData
{
public float MuzzleVelocity;
public float Mass;
public Vector3 Dimensions;
public float Density;
public float VelocityMultiplier;
public float GravityMultiplier;
public float Gravity;
}
public static bool TryGetProjectileData(FVRFireArm firearm, Transform muzzle, out ProjectileBallisticData data)
{
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: 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_01da: Unknown result type (might be due to invalid IL or missing references)
data = default(ProjectileBallisticData);
if ((Object)(object)firearm == (Object)null || (Object)(object)muzzle == (Object)null)
{
return false;
}
List<FVRFireArmChamber> chambers = firearm.GetChambers();
if (chambers == null || chambers.Count == 0)
{
return false;
}
FVRFireArmChamber val = chambers[0];
FVRFireArmMagazine magazine = firearm.Magazine;
FVRFireArmRound val2 = null;
if ((Object)(object)val != (Object)null && (Object)(object)val.GetRound() == (Object)null)
{
if ((Object)(object)magazine == (Object)null || magazine.m_numRounds <= 0 || magazine.LoadedRounds[magazine.m_numRounds - 1] == null)
{
return false;
}
val2 = ((AnvilAsset)magazine.LoadedRounds[magazine.m_numRounds - 1].LR_ObjectWrapper).GetGameObject().GetComponent<FVRFireArmRound>();
}
else if ((Object)(object)val != (Object)null)
{
val2 = val.GetRound();
}
if ((Object)(object)val2 == (Object)null || (Object)(object)val2.BallisticProjectilePrefab == (Object)null)
{
return false;
}
BallisticProjectile component = val2.BallisticProjectilePrefab.GetComponent<BallisticProjectile>();
if ((Object)(object)component == (Object)null)
{
return false;
}
float num = ((!((Object)(object)val != (Object)null)) ? 1f : val.ChamberVelocityMultiplier);
float num2 = ((!((Object)(object)val != (Object)null)) ? 0f : Vector3.Distance(((Component)val).transform.position, muzzle.position));
float num3 = ((!((Object)(object)val != (Object)null)) ? 1f : AM.GetChamberVelMult(val.RoundType, num2));
data.MuzzleVelocity = component.MuzzleVelocityBase * num * num3;
data.Mass = component.Mass;
data.Dimensions = component.Dimensions;
data.Density = 1.225f * component.AirDragMultiplier;
data.VelocityMultiplier = component.FlightVelocityMultiplier;
data.GravityMultiplier = component.GravityMultiplier;
data.Gravity = GetGravityFromOptions();
return true;
}
private static float GetGravityFromOptions()
{
//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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected I4, but got Unknown
GravityMode ballisticGravityMode = GM.Options.SimulationOptions.BallisticGravityMode;
return (int)ballisticGravityMode switch
{
0 => 9.81f,
1 => 5f,
2 => 1.622f,
_ => 0f,
};
}
private static float GetDragCoefficient(float velocityMS)
{
return AM.BDCC.Evaluate(velocityMS * 0.00291545f);
}
private static Vector3 ApplyDrag(Vector3 velocity, float materialDensity, float mass, Vector3 dimensions, float deltaTime)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
float num = (float)Math.PI * Mathf.Pow(dimensions.x * 0.5f, 2f);
float magnitude = ((Vector3)(ref velocity)).magnitude;
Vector3 normalized = ((Vector3)(ref velocity)).normalized;
float dragCoefficient = GetDragCoefficient(magnitude);
Vector3 val = -velocity * (materialDensity * 0.5f * dragCoefficient * num / mass * magnitude);
float num2 = ((Vector3)(ref val)).magnitude * deltaTime;
return normalized * Mathf.Clamp(magnitude - num2, 0f, magnitude);
}
public static bool TrySimulateDropAtDistance(ProjectileBallisticData data, Vector3 muzzleForward, float targetDistanceMeters, int maxFrames, out float dropMeters)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
dropMeters = 0f;
if (targetDistanceMeters <= 0f)
{
return true;
}
Vector3 val = Vector3.ProjectOnPlane(muzzleForward, Vector3.up);
bool flag = ((Vector3)(ref val)).sqrMagnitude > 0.0001f;
if (flag)
{
((Vector3)(ref val)).Normalize();
}
Vector3 val2 = muzzleForward * data.MuzzleVelocity;
Vector3 val3 = Vector3.zero;
float fixedDeltaTime = Time.fixedDeltaTime;
for (int i = 0; i < maxFrames; i++)
{
val2 += Vector3.down * (data.Gravity * fixedDeltaTime * data.GravityMultiplier);
val2 = ApplyDrag(val2, data.Density, data.Mass, data.Dimensions, fixedDeltaTime);
val3 += val2 * (fixedDeltaTime * data.VelocityMultiplier);
float num = ((!flag) ? ((Vector3)(ref val3)).magnitude : Vector3.Dot(val3, val));
if (num >= targetDistanceMeters)
{
dropMeters = 0f - val3.y;
return true;
}
}
dropMeters = 0f - val3.y;
return false;
}
public static float DropToElevationAngleDegrees(float dropMeters, float distanceMeters)
{
if (distanceMeters <= 0f)
{
return 0f;
}
return Mathf.Atan2(dropMeters, distanceMeters) * 57.29578f;
}
}
public class RangefinderAttach : FVRPhysicalObject
{
public Transform MountPoint;
public Transform LaserPoint;
public LayerMask LM_LaserPoint;
public Text RangeText;
public Text AngleText;
public TextMesh RangeTextMesh;
public TextMesh AngleTextMesh;
public float MaxRange = 9999f;
public Transform AngleChild;
public Transform Knob;
public float ManualAngle = 0f;
public bool AutoAngleFromBallistics = true;
public float ZeroDistance = 100f;
public FVRFireArm OverrideFireArm;
public Transform OverrideMuzzle;
public float KnobDegreesPerUnit = 1f;
public float KnobSpeed = 0.6f;
private RaycastHit m_hit;
private List<float> m_distances;
private int m_curDistToReplace;
private void Start()
{
//IL_0035: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
m_distances = new List<float>();
if ((Object)(object)MountPoint != (Object)null)
{
((Component)this).transform.parent = MountPoint;
((Component)this).transform.localPosition = Vector3.zero;
((Component)this).transform.localRotation = Quaternion.identity;
((Component)this).transform.localScale = Vector3.one;
}
if ((Object)(object)LaserPoint == (Object)null)
{
GameObject val = new GameObject("Rangefinder_LaserPoint");
val.transform.parent = ((Component)this).transform;
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
LaserPoint = val.transform;
}
if ((Object)(object)Knob != (Object)null)
{
if ((Object)(object)((Component)Knob).GetComponent<Collider>() == (Object)null)
{
SphereCollider val2 = ((Component)Knob).gameObject.AddComponent<SphereCollider>();
val2.radius = 0.02f;
((Collider)val2).isTrigger = false;
}
KnobHandler knobHandler = ((Component)Knob).gameObject.GetComponent<KnobHandler>();
if ((Object)(object)knobHandler == (Object)null)
{
knobHandler = ((Component)Knob).gameObject.AddComponent<KnobHandler>();
}
knobHandler.Parent = this;
}
}
private void Update()
{
//IL_001f: 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_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
float num = MaxRange;
if (num > 9999f)
{
num = 9999f;
}
float num2 = ((!Physics.Raycast(LaserPoint.position, LaserPoint.forward, ref m_hit, num, ((LayerMask)(ref LM_LaserPoint)).value)) ? num : ((RaycastHit)(ref m_hit)).distance);
if (m_distances.Count < 10)
{
m_distances.Add(num2);
}
else
{
m_distances[m_curDistToReplace] = num2;
m_curDistToReplace++;
if (m_curDistToReplace >= m_distances.Count)
{
m_curDistToReplace = 0;
}
}
if (m_distances.Count > 0)
{
float num3 = 0f;
for (int i = 0; i < m_distances.Count; i++)
{
num3 += m_distances[i];
}
float num4 = num3 / (float)m_distances.Count;
if (num4 < 100f)
{
string text = num4.ToString("f1");
string text2 = string.Empty;
for (int j = 0; j < text.Length; j++)
{
text2 += text[j];
if (j + 1 < text.Length && text[j] != '.' && text[j + 1] != '.')
{
text2 += " ";
}
}
SetRangeText(text2);
}
else
{
string text3 = num4.ToString("f0");
string text4 = string.Empty;
for (int k = 0; k < text3.Length; k++)
{
text4 += text3[k];
if (k + 1 < text3.Length)
{
text4 += " ";
}
}
SetRangeText(text4);
}
Vector3 forward = ((Component)this).transform.forward;
float num5 = Vector3.Angle(Vector3.ProjectOnPlane(forward, Vector3.up), forward);
if (forward.y < 0f)
{
num5 = 0f - num5;
}
string text5 = num5.ToString("f0");
string text6 = string.Empty;
for (int l = 0; l < text5.Length; l++)
{
text6 += text5[l];
if (l + 1 < text5.Length)
{
text6 += " ";
}
}
SetAngleText(text6);
SetDisplaysActive(active: true);
ApplyAngleToChild();
}
else
{
SetDisplaysActive(active: false);
}
if ((Object)(object)Knob != (Object)null && !AutoAngleFromBallistics)
{
Vector3 localEulerAngles = Knob.localEulerAngles;
localEulerAngles.x = ManualAngle;
Knob.localEulerAngles = localEulerAngles;
}
}
public void RotateKnob(float deltaUnits)
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
ManualAngle += deltaUnits * KnobDegreesPerUnit;
if (ManualAngle > 180f)
{
ManualAngle -= 360f;
}
if (ManualAngle < -180f)
{
ManualAngle += 360f;
}
if ((Object)(object)AngleChild != (Object)null && !AutoAngleFromBallistics)
{
Vector3 localEulerAngles = AngleChild.localEulerAngles;
localEulerAngles.x = ManualAngle;
AngleChild.localEulerAngles = localEulerAngles;
}
if ((Object)(object)Knob != (Object)null)
{
Vector3 localEulerAngles2 = Knob.localEulerAngles;
localEulerAngles2.x = ManualAngle;
Knob.localEulerAngles = localEulerAngles2;
}
}
public void StartKnobGrab()
{
}
public void UpdateKnobGrab(float deltaUnits)
{
RotateKnob(deltaUnits);
}
public void EndKnobGrab()
{
}
public void OpenZeroingUI()
{
PIPScopeController componentInParent = ((Component)this).GetComponentInParent<PIPScopeController>();
if ((Object)(object)componentInParent != (Object)null)
{
componentInParent.OpenUI();
}
}
private void ApplyAngleToChild()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: 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_0146: 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_0150: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)AngleChild == (Object)null)
{
return;
}
if (!AutoAngleFromBallistics)
{
Vector3 localEulerAngles = AngleChild.localEulerAngles;
localEulerAngles.x = ManualAngle;
AngleChild.localEulerAngles = localEulerAngles;
return;
}
Transform val = OverrideMuzzle;
FVRFireArm val2 = OverrideFireArm;
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
FVRFireArm componentInParent = ((Component)this).GetComponentInParent<FVRFireArm>();
if ((Object)(object)val2 == (Object)null)
{
val2 = componentInParent;
}
if ((Object)(object)val == (Object)null && (Object)(object)val2 != (Object)null)
{
val = val2.GetMuzzle();
}
}
if ((Object)(object)val == (Object)null)
{
val = ((Component)this).transform;
}
float zeroDistance = ZeroDistance;
float num = 0f;
if ((Object)(object)val2 != (Object)null)
{
FireArmRoundType roundType = val2.RoundType;
if (AM.SRoundDisplayDataDic.ContainsKey(roundType))
{
FVRFireArmRoundDisplayData val3 = AM.SRoundDisplayDataDic[roundType];
num = val3.BulletDropCurve.Evaluate(zeroDistance * 0.001f);
}
}
Vector3 val4 = val.position + val.forward * zeroDistance + val.up * num;
Vector3 val5 = val4 - AngleChild.position;
if (!(((Vector3)(ref val5)).sqrMagnitude < 0.0001f))
{
Quaternion val6 = Quaternion.LookRotation(val5);
Quaternion val7 = Quaternion.identity;
if ((Object)(object)AngleChild.parent != (Object)null)
{
val7 = Quaternion.Inverse(AngleChild.parent.rotation) * val6;
}
float num2 = ((Quaternion)(ref val7)).eulerAngles.x;
if (num2 > 180f)
{
num2 -= 360f;
}
Vector3 localEulerAngles2 = AngleChild.localEulerAngles;
localEulerAngles2.x = num2;
AngleChild.localEulerAngles = localEulerAngles2;
}
}
private void SetRangeText(string t)
{
if ((Object)(object)RangeText != (Object)null)
{
RangeText.text = t;
}
if ((Object)(object)RangeTextMesh != (Object)null)
{
RangeTextMesh.text = t;
}
}
private void SetAngleText(string t)
{
if ((Object)(object)AngleText != (Object)null)
{
AngleText.text = t;
}
if ((Object)(object)AngleTextMesh != (Object)null)
{
AngleTextMesh.text = t;
}
}
private void SetDisplaysActive(bool active)
{
if ((Object)(object)RangeText != (Object)null)
{
((Component)RangeText).gameObject.SetActive(active);
}
if ((Object)(object)AngleText != (Object)null)
{
((Component)AngleText).gameObject.SetActive(active);
}
if ((Object)(object)RangeTextMesh != (Object)null)
{
((Component)RangeTextMesh).gameObject.SetActive(active);
}
if ((Object)(object)AngleTextMesh != (Object)null)
{
((Component)AngleTextMesh).gameObject.SetActive(active);
}
}
}
public class KnobHandler : MonoBehaviour
{
public RangefinderAttach Parent;
private float m_lastMouseY;
private bool m_dragging;
private void OnMouseDown()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
m_dragging = true;
m_lastMouseY = Input.mousePosition.y;
if ((Object)(object)Parent != (Object)null)
{
Parent.StartKnobGrab();
}
}
private void OnMouseDrag()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (m_dragging && !((Object)(object)Parent == (Object)null))
{
float y = Input.mousePosition.y;
float num = y - m_lastMouseY;
m_lastMouseY = y;
float deltaUnits = num * Parent.KnobSpeed * 0.01f;
Parent.UpdateKnobGrab(deltaUnits);
}
}
private void OnMouseUp()
{
m_dragging = false;
if ((Object)(object)Parent != (Object)null)
{
Parent.EndKnobGrab();
}
}
}
}
public class PrefabLoader : MonoBehaviour
{
private AssetBundle LoadedPrefabAssetBundle;
public string PrefabPath;
public string Prefab_to_Load;
private void Start()
{
LoadPrefab(PrefabPath);
ActivatePrefab(Prefab_to_Load);
}
private void LoadPrefab(string bundleURL)
{
LoadedPrefabAssetBundle = AssetBundle.LoadFromFile(bundleURL);
Debug.Log((object)((!((Object)(object)LoadedPrefabAssetBundle == (Object)null)) ? ("Loaded AssetBundle " + PrefabPath) : "AssetBundle Failed to load"));
}
private void ActivatePrefab(string Prefab_to_Load)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
Object val = LoadedPrefabAssetBundle.LoadAsset(Prefab_to_Load);
Object.Instantiate(val, ((Component)this).transform.position, ((Component)this).transform.rotation);
}
}
internal class Target : MonoBehaviour
{
[Tooltip("Clip to be played when shot.")]
public List<AudioClip> clips;
[Tooltip("Range of volume for clip, chosen from randomly each time the target is shot.")]
public Vector2 volumeRange = new Vector2(0.9f, 1.1f);
[Tooltip("Range of pitch for clip, chosen from randomly each time the target is shot.")]
public Vector2 pitchRange = new Vector2(0.97f, 1.03f);
[Tooltip("Range of speed for clip, chosen from randomly each time the target is shot.")]
public Vector2 speedRange = new Vector2(1f, 1f);
[Tooltip("A Unity event, useful for triggering events that exist in base Unity code.")]
public UnityEvent shotEvent;
public void InitializeComponent()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0097: Expected O, but got Unknown
ReactiveSteelTarget val = ((Component)this).gameObject.AddComponent<ReactiveSteelTarget>();
val.HitEvent = new AudioEvent();
val.HitEvent.Clips = clips;
val.HitEvent.VolumeRange = volumeRange;
val.HitEvent.PitchRange = pitchRange;
val.HitEvent.ClipLengthRange = speedRange;
if (val.HitEvent.Clips.Count == 0)
{
val.HitEvent.Clips = new List<AudioClip>();
val.HitEvent.Clips.Add(new AudioClip());
}
val.BulletHolePrefabs = (GameObject[])(object)new GameObject[0];
}
}