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 Sodalite.Api;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class BoltCatchHandle : ClosedBoltHandle
{
public bool HasBoltCatchReleaseButton;
private bool m_isBoltCatchHeldOnHandle;
private bool m_isReleaseCatchHeldOnHandle;
public GameObject[] BoltLockPositions;
private float m_boltLockPosZ;
public override void Start()
{
//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)
((FVRInteractiveObject)this).Start();
if (BoltLockPositions.Length > 0)
{
m_boltLockPosZ = BoltLockPositions[0].transform.localPosition.z;
Debug.Log((object)("BoltCatchHandle initialized. Bolt lock position Z: " + m_boltLockPosZ));
}
else
{
Debug.LogWarning((object)"No BoltLockPositions assigned!");
}
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0078: 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_01d9: 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_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
((ClosedBoltHandle)this).UpdateInteraction(hand);
if (base.HasRotatingPart)
{
Vector3 val = ((Component)this).transform.position - ((FVRInteractiveObject)this).m_hand.PalmTransform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
if (Vector3.Dot(normalized, ((Component)this).transform.right) > 0f)
{
base.RotatingPart.localEulerAngles = base.RotatingPartLeftEulers;
}
else
{
base.RotatingPart.localEulerAngles = base.RotatingPartRightEulers;
}
}
float z = ((Component)this).transform.localPosition.z;
bool flag = Mathf.Abs(z - m_boltLockPosZ) < 0.01f;
Debug.Log((object)("Handle position Z: " + z + " | At Bolt Lock: " + flag));
if (hand.Input.AXButtonDown)
{
Debug.Log((object)"AXButtonDown detected");
}
if (hand.Input.BYButtonDown)
{
Debug.Log((object)"BYButtonDown detected");
}
if (hand.Input.TouchpadDown)
{
Debug.Log((object)"TouchpadDown detected");
}
if (hand.IsInStreamlinedMode)
{
if (hand.Input.AXButtonDown && HasBoltCatchReleaseButton && flag)
{
m_isBoltCatchHeldOnHandle = true;
Debug.Log((object)"Bolt Catch Held on Handle");
((FVRInteractiveObject)this).ForceBreakInteraction();
}
else if (hand.Input.BYButtonDown && HasBoltCatchReleaseButton && flag)
{
m_isReleaseCatchHeldOnHandle = true;
Debug.Log((object)"Release Catch Held on Handle");
((FVRInteractiveObject)this).ForceBreakInteraction();
}
}
else if (hand.Input.TouchpadDown)
{
if (Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f && HasBoltCatchReleaseButton && flag)
{
m_isBoltCatchHeldOnHandle = true;
Debug.Log((object)"Bolt Catch Held on Handle (Touchpad)");
((FVRInteractiveObject)this).ForceBreakInteraction();
}
else if (Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f && HasBoltCatchReleaseButton && flag)
{
m_isReleaseCatchHeldOnHandle = true;
Debug.Log((object)"Release Catch Held on Handle (Touchpad)");
((FVRInteractiveObject)this).ForceBreakInteraction();
}
}
}
}
public class DM34Destroy : MonoBehaviour
{
public FVRPhysicalObject triggerDestroy;
public FVRFireArmChamber chamber;
private bool isTimerStarted;
public float timeBeforedestruction;
private float timer = 1f;
private void FixedUpdate()
{
if (!chamber.IsFull && !isTimerStarted)
{
isTimerStarted = true;
timer = timeBeforedestruction;
}
if (((FVRInteractiveObject)triggerDestroy).IsHeld)
{
timer = timeBeforedestruction;
}
if (isTimerStarted)
{
timer -= Time.fixedDeltaTime;
}
if (timer <= 0f)
{
Object.Destroy((Object)(object)((Component)triggerDestroy).gameObject);
}
}
}
public class UnhideObjectOnRotation : MonoBehaviour
{
public GameObject objectToUnhide;
public Transform targetObject;
public float targetAngle = 90f;
public string rotationAxis = "Z";
public float tolerance = 1f;
private bool goalAchieved = false;
private void Update()
{
float rotationOnAxis = GetRotationOnAxis(targetObject, rotationAxis);
if (!goalAchieved && Mathf.Abs(Mathf.DeltaAngle(rotationOnAxis, targetAngle)) <= tolerance)
{
if ((Object)(object)objectToUnhide != (Object)null && !objectToUnhide.activeInHierarchy)
{
objectToUnhide.SetActive(true);
}
goalAchieved = true;
Debug.Log((object)"Rotation goal achieved! Object unhidden.");
}
else if (goalAchieved && Mathf.Abs(Mathf.DeltaAngle(rotationOnAxis, targetAngle)) > tolerance)
{
goalAchieved = false;
Debug.Log((object)"Rotation has deviated from the goal.");
}
}
private float GetRotationOnAxis(Transform obj, string axis)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
switch (axis.ToUpper())
{
case "X":
return obj.eulerAngles.x;
case "Y":
return obj.eulerAngles.y;
case "Z":
return obj.eulerAngles.z;
default:
Debug.LogError((object)"Invalid rotation axis specified.");
return 0f;
}
}
}
public class UnhideScriptOnRotation : MonoBehaviour
{
public MonoBehaviour scriptToEnable;
public Transform targetObject;
public float targetAngle = 90f;
public string rotationAxis = "Z";
public float tolerance = 1f;
private bool goalAchieved = false;
private void Update()
{
float rotationOnAxis = GetRotationOnAxis(targetObject, rotationAxis);
if (!goalAchieved && Mathf.Abs(Mathf.DeltaAngle(rotationOnAxis, targetAngle)) <= tolerance)
{
if ((Object)(object)scriptToEnable != (Object)null && !((Behaviour)scriptToEnable).enabled)
{
((Behaviour)scriptToEnable).enabled = true;
}
goalAchieved = true;
Debug.Log((object)"Rotation goal achieved! Script enabled.");
}
else if (goalAchieved && Mathf.Abs(Mathf.DeltaAngle(rotationOnAxis, targetAngle)) > tolerance)
{
goalAchieved = false;
Debug.Log((object)"Rotation has deviated from the goal.");
}
}
private float GetRotationOnAxis(Transform obj, string axis)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
switch (axis.ToUpper())
{
case "X":
return obj.eulerAngles.x;
case "Y":
return obj.eulerAngles.y;
case "Z":
return obj.eulerAngles.z;
default:
Debug.LogError((object)"Invalid rotation axis specified.");
return 0f;
}
}
}
namespace Volks.ModulWieger940Series;
[BepInPlugin("Volks.ModulWieger940Series", "ModulWieger940Series", "1.0.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
[BepInDependency("h3vr.cityrobo.ModularWorkshopManager", "1.0.0")]
[BepInDependency("nrgill28.Sodalite", "1.4.2")]
public class ModulWieger940SeriesPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.ModulWieger940Series");
OtherLoader.RegisterDirectLoad(BasePath, "Volks.ModulWieger940Series", "", "", "modulwieger940", "");
GameAPI.PreloadAllAssets(Path.Combine(BasePath, "mw_modulwieger940series"));
}
}
public class SAR21_Laser : FVRAlternateGrip
{
private bool isLaserActive = false;
public GameObject BeamEffect;
public GameObject BeamHitPoint;
public Transform Aperture;
public LayerMask LM;
private RaycastHit m_hit;
public AudioEvent AudEvent_LaserOnClip;
public AudioEvent AudEvent_LaserOffClip;
public override void Awake()
{
((FVRAlternateGrip)this).Awake();
if ((Object)(object)BeamHitPoint == (Object)null)
{
Debug.LogError((object)"BeamHitPoint is not assigned in the Inspector. Please assign it in Unity.");
}
if ((Object)(object)BeamEffect == (Object)null)
{
Debug.LogError((object)"BeamEffect is not assigned in the Inspector. Please assign it in Unity.");
}
if ((Object)(object)BeamHitPoint != (Object)null)
{
BeamHitPoint.transform.SetParent((Transform)null);
}
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
((FVRAlternateGrip)this).UpdateInteraction(hand);
Vector2 touchpadAxes = hand.Input.TouchpadAxes;
if (hand.IsInStreamlinedMode)
{
if (hand.Input.BYButtonDown)
{
ToggleLaser();
}
}
else if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.25f && Vector2.Angle(touchpadAxes, Vector2.up) <= 45f)
{
ToggleLaser();
}
}
public override void FVRUpdate()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_00c6: 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)
((FVRInteractiveObject)this).FVRUpdate();
if (isLaserActive)
{
Vector3 position = Aperture.position + Aperture.forward * 1000f;
float num = 1000f;
if (Physics.Raycast(Aperture.position, Aperture.forward, ref m_hit, 1000f, LayerMask.op_Implicit(LM), (QueryTriggerInteraction)1))
{
position = ((RaycastHit)(ref m_hit)).point;
num = ((RaycastHit)(ref m_hit)).distance;
}
float num2 = num * 0.01f;
float num3 = Mathf.Lerp(0.01f, 0.2f, num2);
if ((Object)(object)BeamHitPoint != (Object)null)
{
BeamHitPoint.transform.position = position;
BeamHitPoint.transform.localScale = new Vector3(num3, num3, num3);
}
}
}
public override void OnDestroy()
{
((FVRInteractiveObject)this).OnDestroy();
if ((Object)(object)BeamHitPoint != (Object)null)
{
Object.Destroy((Object)(object)BeamHitPoint);
}
}
private void ToggleLaser()
{
//IL_0056: 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)
isLaserActive = !isLaserActive;
SetLaserState(isLaserActive);
if (isLaserActive)
{
SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_LaserOnClip, ((Component)this).transform.position);
}
else
{
SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_LaserOffClip, ((Component)this).transform.position);
}
}
private void SetLaserState(bool state)
{
if ((Object)(object)BeamHitPoint != (Object)null)
{
BeamHitPoint.SetActive(state);
}
if ((Object)(object)BeamEffect != (Object)null)
{
BeamEffect.SetActive(state);
}
}
}