using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using Microsoft.CodeAnalysis;
using On.FistVR;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("BagOfScripts")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BagOfScripts")]
[assembly: AssemblyTitle("BagOfScripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace BagOfScripts
{
internal class ContinuousFiringSound : MonoBehaviour
{
[Header("Closed bolt, open bolt or pistol")]
[SerializeField]
private FVRFireArm firearm;
[SerializeField]
private AudioSource fireLoop;
[Header("Optional")]
[SerializeField]
private bool hasSingleShot;
[SerializeField]
private AudioEvent? singleShot;
[Space(5f)]
[SerializeField]
private bool hasFiringStart;
[SerializeField]
private AudioEvent? firingStart;
[SerializeField]
private bool hasFiringStop;
[SerializeField]
private AudioEvent? firingStop;
[Header("Fade Out")]
[SerializeField]
private bool fadesOut;
[SerializeField]
private AnimationCurve? fadeOutCurve;
private float _fadeOutDuration;
private float _origAudioVolume;
private float timeSinceFadeOutStart;
private IEnumerator _FadeOutCoroutine;
private bool _isFiringSoundPlaying;
private bool _isFiring;
private bool hasFiredSingleShot;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
if (fadesOut && fadeOutCurve != null)
{
_fadeOutDuration = ((Keyframe)(ref fadeOutCurve.keys[fadeOutCurve.length - 1])).time;
_origAudioVolume = fireLoop.volume;
_FadeOutCoroutine = FiringSoundFadeOut();
((MonoBehaviour)this).StartCoroutine(_FadeOutCoroutine);
}
if (firearm is ClosedBoltWeapon)
{
ClosedBoltWeapon.UpdateInputAndAnimate += new hook_UpdateInputAndAnimate(ClosedBoltWeapon_UpdateInputAndAnimate);
}
else if (firearm is OpenBoltReceiver)
{
OpenBoltReceiver.UpdateInteraction += new hook_UpdateInteraction(OpenBoltReceiver_UpdateInteraction);
}
else
{
Debug.LogError((object)"Unsupported firearm type!");
}
}
private void OnShotFired(FVRFireArm _firearm)
{
if ((Object)(object)_firearm == (Object)(object)firearm)
{
_isFiring = true;
if (fadesOut)
{
fireLoop.volume = _origAudioVolume;
timeSinceFadeOutStart = 0f;
}
}
}
private void TryPlayFiringAudio()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (!_isFiringSoundPlaying)
{
if (hasFiringStart)
{
SM.PlayCoreSound((FVRPooledAudioType)10, firingStart, firearm.GetMuzzle().position);
}
fireLoop.Play();
_isFiringSoundPlaying = true;
}
}
private void StopFiringAudio()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (!fadesOut)
{
fireLoop.Stop();
if (hasFiringStop)
{
SM.PlayCoreSound((FVRPooledAudioType)10, firingStop, firearm.GetMuzzle().position);
}
}
_isFiringSoundPlaying = false;
_isFiring = false;
hasFiredSingleShot = false;
}
private IEnumerator FiringSoundFadeOut()
{
while (true)
{
if (!_isFiring && fireLoop.isPlaying)
{
fireLoop.volume = _origAudioVolume * fadeOutCurve.Evaluate(timeSinceFadeOutStart);
timeSinceFadeOutStart += Time.deltaTime;
if (timeSinceFadeOutStart > _fadeOutDuration)
{
fireLoop.volume = 0f;
fireLoop.Stop();
}
}
yield return null;
}
}
private void ClosedBoltWeapon_UpdateInputAndAnimate(orig_UpdateInputAndAnimate orig, ClosedBoltWeapon self, FVRViveHand hand)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Invalid comparison between Unknown and I4
//IL_00e4: 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)
orig.Invoke(self, hand);
if (!((Object)(object)self == (Object)(object)firearm) || !_isFiring)
{
return;
}
FireSelectorModeType modeType = self.FireSelector_Modes[self.m_fireSelectorMode].ModeType;
if (self.m_triggerFloat < self.TriggerFiringThreshold || (Object)(object)((FVRFireArm)self).Magazine == (Object)null || ((Object)(object)((FVRFireArm)self).Magazine != (Object)null && ((FVRFireArm)self).Magazine.m_numRounds < 1 && !self.Chamber.IsFull && !self.m_proxy.IsFull) || ((int)modeType == 2 && self.m_CamBurst < 1))
{
StopFiringAudio();
}
else if ((int)modeType == 1)
{
if (!hasFiredSingleShot)
{
if (hasSingleShot)
{
hasFiredSingleShot = true;
SM.PlayCoreSound((FVRPooledAudioType)10, singleShot, firearm.GetMuzzle().position);
}
else
{
TryPlayFiringAudio();
StopFiringAudio();
}
}
}
else if ((int)modeType != 0)
{
TryPlayFiringAudio();
}
}
private void OpenBoltReceiver_UpdateInteraction(orig_UpdateInteraction orig, OpenBoltReceiver self, FVRViveHand hand)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Invalid comparison between Unknown and I4
//IL_00e7: 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_0112: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, hand);
if (!((Object)(object)self == (Object)(object)firearm) || !_isFiring)
{
return;
}
FireSelectorModeType modeType = self.FireSelector_Modes[self.m_fireSelectorMode].ModeType;
if (self.m_triggerFloat < self.TriggerFiringThreshold || (Object)(object)((FVRFireArm)self).Magazine == (Object)null || ((Object)(object)((FVRFireArm)self).Magazine != (Object)null && ((FVRFireArm)self).Magazine.m_numRounds < 1 && !self.Chamber.IsFull && !self.m_proxy.IsFull) || ((int)modeType == 3 && self.m_CamBurst < 1))
{
StopFiringAudio();
}
else if ((int)modeType == 1)
{
if (!hasFiredSingleShot)
{
if (hasSingleShot)
{
hasFiredSingleShot = true;
SM.PlayCoreSound((FVRPooledAudioType)10, singleShot, firearm.GetMuzzle().position);
}
else
{
TryPlayFiringAudio();
StopFiringAudio();
}
}
}
else
{
if ((int)modeType == 0)
{
return;
}
if (((FVRInteractiveObject)self.Bolt).IsHeld)
{
if (hasSingleShot)
{
SM.PlayCoreSound((FVRPooledAudioType)10, singleShot, firearm.GetMuzzle().position);
}
else
{
TryPlayFiringAudio();
StopFiringAudio();
}
}
TryPlayFiringAudio();
}
}
private void OnDestroy()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
ClosedBoltWeapon.UpdateInputAndAnimate -= new hook_UpdateInputAndAnimate(ClosedBoltWeapon_UpdateInputAndAnimate);
OpenBoltReceiver.UpdateInteraction -= new hook_UpdateInteraction(OpenBoltReceiver_UpdateInteraction);
((MonoBehaviour)this).StopCoroutine(_FadeOutCoroutine);
}
}
internal class CustomCenterOfMass : MonoBehaviour
{
[Header("Note: Will probably cause stuttering with break-action weapons!")]
[SerializeField]
private FVRPhysicalObject mainObject;
[SerializeField]
private Transform centerOfMassOverride;
[Tooltip("Set to true if you want attachments to change the weapon's center of mass. This will ignore the center of mass override, nothing I can do about that unfortunately.")]
public bool attachmentsChangeCenterOfMass;
private void Awake()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
if ((Object)(object)mainObject == (Object)null)
{
Debug.LogError((object)"mainObject is not assigned!");
}
else if ((Object)(object)centerOfMassOverride == (Object)null)
{
Debug.LogError((object)"centerOfMassOverride is not assigned!");
}
else
{
FVRPhysicalObject.ResetClampCOM += new hook_ResetClampCOM(FVRPhysicalObject_ResetClampCOM);
}
}
private void OnDestroy()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRPhysicalObject.ResetClampCOM -= new hook_ResetClampCOM(FVRPhysicalObject_ResetClampCOM);
}
private void Start()
{
//IL_0011: 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_002c: Unknown result type (might be due to invalid IL or missing references)
mainObject.RootRigidbody.centerOfMass = centerOfMassOverride.localPosition;
mainObject.m_storedCOMLocal = centerOfMassOverride.localPosition;
}
private void FVRPhysicalObject_ResetClampCOM(orig_ResetClampCOM orig, FVRPhysicalObject self)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (attachmentsChangeCenterOfMass)
{
orig.Invoke(self);
if (mainObject.AttachmentsList.Count == 0)
{
mainObject.RootRigidbody.centerOfMass = centerOfMassOverride.localPosition;
}
}
}
}
internal class DropSlideOnMagRelease : MonoBehaviour
{
[Header("Weapon type must have an external magazine and a bolt or slide!")]
public FVRFireArm firearm;
private void Awake()
{
Hook();
}
private void OnDestroy()
{
Unhook();
}
private void FVRFireArm_EjectMag(orig_EjectMag orig, FVRFireArm self, bool PhysicalRelease)
{
orig.Invoke(self, PhysicalRelease);
Handgun val = (Handgun)(object)((self is Handgun) ? self : null);
if (val != null && (Object)(object)val == (Object)(object)firearm && (Object)(object)val.Slide != (Object)null)
{
val.DropSlideRelease();
return;
}
ClosedBoltWeapon val2 = (ClosedBoltWeapon)(object)((self is ClosedBoltWeapon) ? self : null);
if (val2 != null && (Object)(object)val2 == (Object)(object)firearm && (Object)(object)val2.Bolt != (Object)null)
{
val2.Bolt.ReleaseBolt();
return;
}
FVRFireArm obj = firearm;
OpenBoltReceiver val3 = (OpenBoltReceiver)(object)((obj is OpenBoltReceiver) ? obj : null);
if (val3 != null && (Object)(object)val3 == (Object)(object)firearm && (Object)(object)val3.Bolt != (Object)null)
{
val3.ReleaseSeer();
}
}
private void Hook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRFireArm.EjectMag += new hook_EjectMag(FVRFireArm_EjectMag);
}
private void Unhook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRFireArm.EjectMag -= new hook_EjectMag(FVRFireArm_EjectMag);
}
}
public class Hooks
{
public void Hook()
{
}
public void Unhook()
{
}
}
internal class TogglePosBreakActionWeapon : BreakActionWeapon
{
private GameObject movingBreachObject;
private Vector3 oldPos;
private Vector3 oldRot;
private Vector3 oldScale;
[SerializeField]
private Vector3 newPos;
[SerializeField]
private Vector3 newRot;
[SerializeField]
private Vector3 newScale;
private bool isLatchedPrevFrame;
public override void Awake()
{
//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_0043: 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_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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
((BreakActionWeapon)this).Awake();
if ((Object)(object)movingBreachObject != (Object)null)
{
((MonoBehaviour)this).StartCoroutine(CheckBreachState());
oldPos = movingBreachObject.transform.localPosition;
Quaternion localRotation = movingBreachObject.transform.localRotation;
oldRot = ((Quaternion)(ref localRotation)).eulerAngles;
oldPos = movingBreachObject.transform.localScale;
}
else
{
Debug.LogWarning((object)"movingBreachObject is not assigned");
}
}
public override void OnDestroy()
{
((FVRInteractiveObject)this).OnDestroy();
((MonoBehaviour)this).StopCoroutine(CheckBreachState());
}
private IEnumerator CheckBreachState()
{
while (true)
{
if (isLatchedPrevFrame != base.m_isLatched)
{
if (!base.m_isLatched)
{
SetNewTransforms();
}
else
{
SetOldTransforms();
}
isLatchedPrevFrame = base.m_isLatched;
}
yield return null;
}
}
private void SetNewTransforms()
{
//IL_000c: 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_003d: Unknown result type (might be due to invalid IL or missing references)
movingBreachObject.transform.localPosition = newPos;
movingBreachObject.transform.localRotation = Quaternion.Euler(newRot);
movingBreachObject.transform.localScale = newScale;
}
private void SetOldTransforms()
{
//IL_000c: 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_003d: Unknown result type (might be due to invalid IL or missing references)
movingBreachObject.transform.localPosition = oldPos;
movingBreachObject.transform.localRotation = Quaternion.Euler(oldRot);
movingBreachObject.transform.localScale = oldScale;
}
}
[RequireComponent(typeof(Collider))]
internal class NambuSear : FVRInteractiveObject, IFVRDamageable
{
private enum SearType
{
trigger,
collision
}
[SerializeField]
private Handgun handgun;
[Tooltip("Remember to tick the \"is trigger\" checkbox if using trigger mode.")]
[SerializeField]
private SearType searType;
public override void Awake()
{
if ((Object)(object)handgun == (Object)null)
{
Debug.LogError((object)"handgun is not assigned!");
}
}
public override void SimpleInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).SimpleInteraction(hand);
if (searType == SearType.trigger)
{
handgun.ReleaseSeer();
}
}
public void Damage(Damage d)
{
if (searType == SearType.collision)
{
handgun.ReleaseSeer();
}
}
private void Update()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (!handgun.m_isSeerReady && !((FVRInteractiveObject)handgun).IsHeld && (int)handgun.Slide.CurPos == 0)
{
handgun.m_isSeerReady = true;
}
}
}
internal class PermanentlyAttachedWeapon : AttachableFirearmPhysicalObject
{
public override bool CanDetach()
{
return false;
}
}
public class PistolBrace : AttachableStock
{
public static FVRFireArm? bracedFirearm;
[HideInInspector]
public bool isInBraceMode;
public AudioEvent? audClipBraceMode;
public AudioEvent? audClipStockMode;
public ToggleAnimation braceToggleAnimation;
private bool FVRFireArm_IsTwoHandStabilized(orig_IsTwoHandStabilized orig, FVRFireArm self)
{
if ((Object)(object)bracedFirearm == (Object)(object)self && isInBraceMode)
{
return true;
}
return orig.Invoke(self);
}
private void Hook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRFireArm.IsTwoHandStabilized += new hook_IsTwoHandStabilized(FVRFireArm_IsTwoHandStabilized);
}
private void Unhook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRFireArm.IsTwoHandStabilized -= new hook_IsTwoHandStabilized(FVRFireArm_IsTwoHandStabilized);
}
public override void OnAttach()
{
((AttachableStock)this).OnAttach();
FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)this).Attachment.curMount.GetRootMount().Parent;
FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
if (val != null)
{
bracedFirearm = val;
if (isInBraceMode)
{
val.HasActiveShoulderStock = false;
}
val.UsesStockedRecoilProfile = false;
}
Hook();
}
public override void OnDetach()
{
((AttachableStock)this).OnDetach();
FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)this).Attachment.curMount.GetRootMount().Parent;
FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null);
if (val != null && (Object)(object)val == (Object)(object)bracedFirearm)
{
if ((Object)(object)val.RecoilProfileStocked != (Object)null)
{
val.UsesStockedRecoilProfile = true;
}
bracedFirearm = null;
}
Unhook();
}
public override void OnDestroy()
{
Unhook();
}
public void ToggleBrace()
{
//IL_0071: 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)
isInBraceMode = !isInBraceMode;
if ((Object)(object)bracedFirearm != (Object)null)
{
if (isInBraceMode)
{
bracedFirearm.HasActiveShoulderStock = false;
SM.PlayCoreSound((FVRPooledAudioType)0, audClipBraceMode, ((Component)this).transform.position);
braceToggleAnimation.Toggle(isInBraceMode);
}
else
{
bracedFirearm.HasActiveShoulderStock = true;
SM.PlayCoreSound((FVRPooledAudioType)0, audClipStockMode, ((Component)this).transform.position);
braceToggleAnimation.Toggle(isInBraceMode);
}
}
}
}
internal class PistolBraceToggle : FVRInteractiveObject
{
public PistolBrace pistolBraceInterface;
public override void Awake()
{
((FVRInteractiveObject)this).Awake();
if ((Object)(object)pistolBraceInterface != (Object)null)
{
pistolBraceInterface.isInBraceMode = false;
}
}
public override void SimpleInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).SimpleInteraction(hand);
if ((Object)(object)pistolBraceInterface != (Object)null)
{
pistolBraceInterface.ToggleBrace();
}
else
{
Debug.Log((object)"pistolBraceInterface is missing!");
}
}
}
internal class PlaySoundOnLoadState : MonoBehaviour
{
[Header("Only fill firearm or external magazine, not both!")]
[Header("If script is attached to firearm")]
[SerializeField]
private FVRFireArm? firearm;
[Tooltip("Do you want the sound to play on the final shot, even if the gun doesn't have a magazine loaded in it?")]
public bool finalShotRequiresMagazine;
[Header("If script is attached to external magazine")]
[SerializeField]
private FVRFireArmMagazine? magazine;
[Header("Clips")]
public bool playSoundOnMagazineFull;
[Tooltip("The sound the gun plays when the magazine is fully loaded.")]
[SerializeField]
private AudioEvent? onMagazineFull;
public bool playSoundOnFirearmEmpty;
[Tooltip("The sound the gun plays when it fires its final shot.")]
[SerializeField]
private AudioEvent? onFirearmEmpty;
private void Awake()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
if ((Object)(object)firearm != (Object)null && (Object)(object)magazine != (Object)null)
{
Debug.LogError((object)"Warning: Both firearm and external magazine fields are filled out!");
}
if ((Object)(object)firearm == (Object)null && (Object)(object)magazine == (Object)null)
{
Debug.LogError((object)"Warning: no FVRFireArm or FVRFireArmMagazine assigned!");
}
if (playSoundOnFirearmEmpty)
{
GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
}
if (playSoundOnMagazineFull)
{
Hook();
}
}
private void Hook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRFireArmMagazine.AddRound_FVRFireArmRound_bool_bool_bool += new hook_AddRound_FVRFireArmRound_bool_bool_bool(FVRFireArmMagazine_AddRound_FVRFireArmRound_bool_bool_bool);
}
private void Unhook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRFireArmMagazine.AddRound_FVRFireArmRound_bool_bool_bool -= new hook_AddRound_FVRFireArmRound_bool_bool_bool(FVRFireArmMagazine_AddRound_FVRFireArmRound_bool_bool_bool);
}
private void FVRFireArmMagazine_AddRound_FVRFireArmRound_bool_bool_bool(orig_AddRound_FVRFireArmRound_bool_bool_bool orig, FVRFireArmMagazine self, FVRFireArmRound round, bool makeSound, bool updateDisplay, bool animate)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, round, makeSound, updateDisplay, animate);
if ((Object)(object)firearm != (Object)null && (Object)(object)magazine == (Object)null && (Object)(object)self != (Object)null && (Object)(object)self == (Object)(object)firearm.Magazine && self.m_numRounds == self.m_capacity)
{
SM.PlayCoreSound((FVRPooledAudioType)0, onMagazineFull, ((Component)firearm.Magazine).transform.position);
}
if ((Object)(object)firearm == (Object)null && (Object)(object)magazine != (Object)null && (Object)(object)self != (Object)null && (Object)(object)self == (Object)(object)magazine && self.m_numRounds == self.m_capacity)
{
SM.PlayCoreSound((FVRPooledAudioType)0, onMagazineFull, ((Component)magazine).transform.position);
}
}
private void OnShotFired(FVRFireArm _firearm)
{
//IL_00ff: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)firearm != (Object)null && (Object)(object)magazine == (Object)null && (Object)(object)_firearm == (Object)(object)firearm)
{
if (!finalShotRequiresMagazine && (Object)(object)firearm.Magazine == (Object)null)
{
SM.PlayCoreSound((FVRPooledAudioType)0, onFirearmEmpty, ((Component)firearm).transform.position);
}
if ((Object)(object)firearm.Magazine != (Object)null && firearm.Magazine.m_numRounds < 1)
{
SM.PlayCoreSound((FVRPooledAudioType)0, onFirearmEmpty, ((Component)firearm).transform.position);
}
}
if ((Object)(object)firearm == (Object)null && (Object)(object)magazine != (Object)null && (Object)(object)magazine.FireArm == (Object)(object)_firearm && magazine.m_numRounds < 1)
{
SM.PlayCoreSound((FVRPooledAudioType)0, onFirearmEmpty, ((Component)magazine.FireArm).transform.position);
}
}
private void OnDestroy()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
Unhook();
}
}
[BepInPlugin("okkim.bagofscripts", "Bag Of Scripts", "1.6.0")]
[BepInProcess("h3vr.exe")]
public class Plugin : BaseUnityPlugin
{
private readonly Hooks _hooks;
public Plugin()
{
_hooks = new Hooks();
_hooks.Hook();
}
private void Awake()
{
}
private void Update()
{
}
private void OnDestroy()
{
_hooks.Unhook();
}
}
internal static class PluginInfo
{
internal const string NAME = "Bag Of Scripts";
internal const string GUID = "okkim.bagofscripts";
internal const string VERSION = "1.6.0";
}
public class ToggleAnimation : MonoBehaviour
{
private enum ToggleType
{
Animation,
Visibility
}
private float animLength;
private float animProgress;
private bool isForward;
[SerializeField]
private ToggleType toggleType;
[Header("Only used with ToggleType of Animation")]
public GameObject objectToAnimate;
public string? forwardAnimationName;
public string? rewindAnimationName;
private Animator? animator;
[Header("Only used with ToggleType of Visibility")]
public GameObject? forwardObject;
public GameObject? rewindObject;
private void Awake()
{
switch (toggleType)
{
case ToggleType.Animation:
if ((Object)(object)objectToAnimate != (Object)null)
{
animator = objectToAnimate.GetComponent<Animator>();
if ((Object)(object)animator != (Object)null && animator.runtimeAnimatorController.animationClips.Length == 2)
{
animLength = animator.runtimeAnimatorController.animationClips[0].length;
if (animator.runtimeAnimatorController.animationClips[0].length != animator.runtimeAnimatorController.animationClips[0].length)
{
Debug.LogWarning((object)("The two animations in " + ((object)objectToAnimate)?.ToString() + "are of differing lengths. This will cause jittery movement."));
}
}
else
{
Debug.LogError((object)"animator is missing or it doesn't have only two animations!");
}
}
else
{
Debug.LogError((object)"objectToAnimate is missing!");
}
break;
case ToggleType.Visibility:
if ((Object)(object)forwardObject == (Object)null && (Object)(object)rewindObject == (Object)null)
{
Debug.LogError((object)"forward and rewind objects are both missing, or ToggleType is accidentally on Visibility!");
}
break;
}
}
private void Update()
{
if (isForward)
{
animProgress += Time.deltaTime;
}
else if (!isForward)
{
animProgress -= Time.deltaTime;
}
animProgress = Mathf.Clamp(animProgress, 0f, animLength);
}
public void Toggle(bool _isForward)
{
if (_isForward)
{
if (toggleType == ToggleType.Animation)
{
animator.Play(forwardAnimationName, 0, animProgress / animLength);
return;
}
if ((Object)(object)forwardObject != (Object)null)
{
forwardObject.SetActive(true);
}
if ((Object)(object)rewindObject != (Object)null)
{
rewindObject.SetActive(false);
}
}
else if (toggleType == ToggleType.Animation)
{
animator.Play(rewindAnimationName, 0, 1f - animProgress / animLength);
}
else
{
if ((Object)(object)forwardObject != (Object)null)
{
forwardObject.SetActive(false);
}
if ((Object)(object)rewindObject != (Object)null)
{
rewindObject.SetActive(true);
}
}
}
}
public class ToggleLerp : FVRInteractiveObject
{
public enum LerpState
{
A,
AtoB,
B,
BtoA
}
[Tooltip("The root FVRPhysicalObject this is parented to")]
[SerializeField]
private FVRPhysicalObject mainObject;
[SerializeField]
private GameObject objectToMove;
[SerializeField]
private Vector2 endPointValues;
[Tooltip("How long (in seconds) it takes to move the object between positions")]
[SerializeField]
private float lerpDuration = 0.5f;
[SerializeField]
private Axis interpAxis;
[Tooltip("Rotations will not work beyond 180 degrees because of quaternion fuckery")]
[SerializeField]
private InterpStyle interpStyle;
[SerializeField]
private AudioEvent audioEvent_AToB;
[SerializeField]
private AudioEvent audioEvent_BToA;
[Tooltip("Does the object need to reach the end point before it can be reactivated?")]
[SerializeField]
private bool requireReachingEndToReactivate;
[SerializeField]
private UnityEvent OnStartAToB;
[SerializeField]
private UnityEvent OnStartBToA;
[SerializeField]
private UnityEvent OnReachB;
[SerializeField]
private UnityEvent OnReachA;
[HideInInspector]
public LerpState lerpState;
private float lerpProgress;
public override void Awake()
{
((FVRInteractiveObject)this).Awake();
if ((Object)(object)objectToMove == (Object)null)
{
Debug.LogError((object)"objectToMove is not assigned!");
}
}
public override void FVRUpdate()
{
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
if (lerpState == LerpState.AtoB || lerpState == LerpState.BtoA)
{
float num = Time.deltaTime / lerpDuration;
if (lerpState == LerpState.BtoA)
{
num *= -1f;
}
lerpProgress += num;
if (lerpProgress >= 1f)
{
lerpProgress = 1f;
lerpState = LerpState.B;
OnReachB.Invoke();
}
else if (lerpProgress <= 0f)
{
lerpProgress = 0f;
lerpState = LerpState.A;
OnReachA.Invoke();
}
mainObject.SetAnimatedComponent(objectToMove.transform, Mathf.Lerp(endPointValues.x, endPointValues.y, lerpProgress), interpStyle, interpAxis);
}
}
public void ToggleLerpState()
{
if (lerpState == LerpState.A || (!requireReachingEndToReactivate && lerpState == LerpState.BtoA))
{
LerpAtoB();
}
else if (lerpState == LerpState.B || (!requireReachingEndToReactivate && lerpState == LerpState.AtoB))
{
LerpBtoA();
}
}
private void LerpAtoB()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
lerpState = LerpState.AtoB;
if (audioEvent_AToB != null)
{
SM.PlayCoreSound((FVRPooledAudioType)0, audioEvent_AToB, ((Component)this).transform.position);
}
OnStartAToB.Invoke();
}
private void LerpBtoA()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
lerpState = LerpState.BtoA;
if (audioEvent_AToB != null)
{
SM.PlayCoreSound((FVRPooledAudioType)0, audioEvent_BToA, ((Component)this).transform.position);
}
OnStartBToA.Invoke();
}
public override void SimpleInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).SimpleInteraction(hand);
ToggleLerpState();
}
}
}