using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using ModularWorkshop;
using OpenScripts2;
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 SuppressorAddSound : Suppressor
{
public bool PlaysTail = true;
public AudioEvent AudEvent_SoundToPlay;
public override void OnShot(FVRFireArm f, FVRTailSoundClass tailClass)
{
//IL_0072: 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_0080: Unknown result type (might be due to invalid IL or missing references)
FVRFirearmAudioSet audioClipSet = f.AudioClipSet;
if (PlaysTail)
{
f.PlayShotTail((FVRTailSoundClass)11, (FVRSoundEnvironment)12, 1f);
int playerIFF = GM.CurrentPlayerBody.GetPlayerIFF();
GM.CurrentSceneSettings.OnPerceiveableSound(200f, 80f, ((Component)this).transform.position, playerIFF, GM.CurrentPlayerBody.PlayerEntities[0]);
}
else
{
f.PlayAudioAsHandling(AudEvent_SoundToPlay, ((Component)this).transform.position);
}
((MuzzleDevice)this).OnShot(f, tailClass);
}
public override void OnShot(AttachableFirearm f, FVRTailSoundClass tailClass)
{
//IL_0072: 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_0080: Unknown result type (might be due to invalid IL or missing references)
FVRFirearmAudioSet audioClipSet = f.AudioClipSet;
if (PlaysTail)
{
f.PlayShotTail((FVRTailSoundClass)11, (FVRSoundEnvironment)12, 1f);
int playerIFF = GM.CurrentPlayerBody.GetPlayerIFF();
GM.CurrentSceneSettings.OnPerceiveableSound(200f, 80f, ((Component)this).transform.position, playerIFF, GM.CurrentPlayerBody.PlayerEntities[0]);
}
else
{
f.PlayAudioAsHandling(AudEvent_SoundToPlay, ((Component)this).transform.position);
}
((MuzzleDevice)this).OnShot(f, tailClass);
}
[ContextMenu("Copy Suppressor")]
public void CopySuppressor()
{
Suppressor[] components = ((Component)this).GetComponents<Suppressor>();
Suppressor val = components.Single((Suppressor c) => (Object)(object)c != (Object)(object)this);
foreach (FVRFireArmAttachmentMount attachmentMount in ((FVRPhysicalObject)val).AttachmentMounts)
{
attachmentMount.MyObject = (FVRPhysicalObject)(object)this;
attachmentMount.Parent = (FVRPhysicalObject)(object)this;
}
((FVRFireArmAttachment)val).AttachmentInterface.Attachment = (FVRFireArmAttachment)(object)this;
((FVRFireArmAttachment)val).Sensor.Attachment = (FVRFireArmAttachment)(object)this;
UniversalCopy.CopyComponent<Suppressor>((Component)(object)this, val);
}
}
[DefaultExecutionOrder(-200)]
[RequireComponent(typeof(ModularWeaponPart))]
public class FirearmMagazineAddons : MonoBehaviour, IPartFireArmRequirement
{
[Header("Debug Settings")]
[Tooltip("Enable detailed console logs to track component auto-detection and linking.")]
public bool EnableDebugLogging = true;
[Header("Detachable Magazine Settings")]
[Tooltip("Does this part alter the firearm's detachable magazine parameters?")]
public bool OverridesExternalMagazines = false;
[Tooltip("The detachable magazine type accepted by this well.")]
public FireArmMagazineType MagazineTypeOverride;
[Tooltip("Local transform where the detachable magazine mounts on this part.")]
public Transform MagazineMountPos;
[Tooltip("Local transform where the detachable magazine ejects on this part.")]
public Transform MagazineEjectPos;
[Tooltip("Optional: The FVRFireArmReloadTriggerWell component on this part prefab.")]
public FVRFireArmReloadTriggerWell MagazineWellTrigger;
[Tooltip("Optional: The UniversalMagGrabTrigger component on this part prefab.")]
public UniversalMagGrabTrigger MagGrabTrigger;
[Tooltip("Optional: The UniversalAdvancedMagazineGrabTrigger component on this part prefab.")]
public UniversalAdvancedMagazineGrabTrigger AdvancedMagGrabTrigger;
[Tooltip("Optional: Manual AudioEvent to play when a magazine is inserted.")]
public AudioEvent CustomMagazineInAudio;
[Tooltip("Optional: Manual AudioEvent to play when a magazine is ejected.")]
public AudioEvent CustomMagazineOutAudio;
[Header("Integrated/Internal Magazine Settings")]
[Tooltip("Does this part feature a built-in internal magazine (like a tube or fixed box)?")]
public bool EnablesInternalMagazine = false;
[Tooltip("The FVRFireArmMagazine component representing the internal feed system on this part.")]
public FVRFireArmMagazine InternalMagazine;
[Tooltip("Does this part override the base firearm's physical magazine release button behavior?")]
public bool OverridesMagReleaseButton = false;
[Tooltip("Should the physical magazine release button on the base receiver be enabled (true) or disabled (false)?")]
public bool NewMagReleaseButtonState = true;
[Header("Stripper Clip Settings")]
[Tooltip("Does this part alter the firearm's stripper clip parameters?")]
public bool OverridesStripperClips = false;
[Tooltip("The stripper clip type accepted by this clip guide.")]
public FireArmClipType ClipTypeOverride;
[Tooltip("Local transform where the clip mounts on this part.")]
public Transform ClipMountPos;
[Tooltip("Local transform where the clip ejects on this part.")]
public Transform ClipEjectPos;
[Tooltip("Optional: The FVRFireArmClipTriggerWell component on this part prefab.")]
public FVRFireArmClipTriggerWell ClipWellTrigger;
[Tooltip("Optional: The clip trigger GameObject on this part.")]
public GameObject ClipTrigger;
[Header("Top Cover Settings")]
[Tooltip("Does this part feature a functional top cover?")]
public bool OverridesTopCover = false;
[Tooltip("Should the top cover start in the open (up) state when equipped?")]
public bool StartTopCoverUp = false;
[Tooltip("Optional: The FVRFireArmTopCover component on this part prefab.")]
public FVRFireArmTopCover TopCoverScript;
[Header("Caliber Conversion Settings")]
[Tooltip("Does this part perform a caliber conversion?")]
public bool OverridesRoundType = false;
[Tooltip("The round type accepted by the weapon with this part equipped.")]
public FireArmRoundType RoundTypeOverride;
[Header("Belt-Fed (LMG) Settings")]
[Tooltip("Does this part convert the firearm to a belt-fed system?")]
public bool OverridesBeltFed = false;
[Tooltip("The Belt Display Data component on this part.")]
public FVRFirearmBeltDisplayData BeltDisplayData;
[Tooltip("Local transform where the belt box mounts on this part.")]
public Transform BeltBoxMountPos;
[Tooltip("Local transform where the belt box ejects on this part.")]
public Transform BeltBoxEjectPos;
[Tooltip("Does the belt system require the bolt to be back to seat the belt?")]
public bool RequiresBoltBackToSeatBelt = false;
[Tooltip("Optional: The FVRFireArmBeltRemovalTrigger component on this part prefab.")]
public FVRFireArmBeltRemovalTrigger BeltRemovalTrigger;
[Tooltip("Optional: The ParticleSystem that ejects links when firing.")]
public ParticleSystem DelinkerSystemOverride;
[Tooltip("Optional: The GameObject prefab containing your pre-combined bullet + link models.")]
public GameObject CustomProxyPrefab;
[Tooltip("Where the ammo belt physically exits your part (used if no magazine is loaded).")]
public Transform BeltExitPointOverride;
[Tooltip("Where the ammo belt physically enters the gun's feed tray.")]
public Transform FeedTrayEntPos;
[Tooltip("How far down (in meters) the ammo belt sags between the box and the gun.")]
public float BeltGravitySag = 0.15f;
[Tooltip("Rotate the bullet model in the Inspector if it is facing the wrong direction.")]
public Vector3 BulletRotationOffset = Vector3.zero;
private FVRFireArm _mainFireArm;
private bool _originalUsesMagazines;
private FireArmMagazineType _originalMagazineType;
private Transform _originalMagazineMountPos;
private Transform _originalMagazineEjectPos;
private bool _originalUsesClips;
private FireArmClipType _originalClipType;
private Transform _originalClipMountPos;
private Transform _originalClipEjectPos;
private GameObject _originalClipTrigger;
private bool _originalUsesTopCover;
private bool _originalIsTopCoverUp;
private FireArmRoundType _originalRoundType;
private bool _originalUsesBelts;
private FVRFirearmBeltDisplayData _originalBeltDD;
private Transform _originalBeltBoxMountPos;
private Transform _originalBeltBoxEjectPos;
private bool _originalRequiresBoltBack;
private bool _origUsesDelinker;
private ParticleSystem _origDelinkerSystem;
private bool _origMagReleaseState;
private AudioEvent _originalMagazineInAudio;
private AudioEvent _originalMagazineOutAudio;
private List<GameObject> _disabledReceiverGrabTriggers = new List<GameObject>();
private FVRFireArmMagazine _originalReceiverMagazine;
private FVRFireArmMagazine _lastMagazine;
private Transform _currentGrabPointBox;
private Transform _currentHiddenInBoxSpot;
private bool _needsInternalMagRestore = false;
private Vector3 _internalMagLocalPos;
private Quaternion _internalMagLocalRot;
private Transform _internalMagOriginalParent;
private AttachableFirearm _underbarrelFirearm;
private AttachableFirearmPhysicalObject _underbarrelPhysical;
private AttachableFirearmInterface _underbarrelInterface;
public FVRFireArm FireArm
{
get
{
return _mainFireArm;
}
set
{
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0655: Unknown result type (might be due to invalid IL or missing references)
//IL_065a: Unknown result type (might be due to invalid IL or missing references)
//IL_045a: Unknown result type (might be due to invalid IL or missing references)
//IL_045f: Unknown result type (might be due to invalid IL or missing references)
//IL_0470: Unknown result type (might be due to invalid IL or missing references)
//IL_0475: Unknown result type (might be due to invalid IL or missing references)
//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
//IL_074b: Unknown result type (might be due to invalid IL or missing references)
//IL_0750: Unknown result type (might be due to invalid IL or missing references)
//IL_0712: Unknown result type (might be due to invalid IL or missing references)
//IL_0717: Unknown result type (might be due to invalid IL or missing references)
//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
//IL_08da: Unknown result type (might be due to invalid IL or missing references)
//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
//IL_090c: Unknown result type (might be due to invalid IL or missing references)
//IL_090e: Unknown result type (might be due to invalid IL or missing references)
//IL_0924: Unknown result type (might be due to invalid IL or missing references)
//IL_0926: Unknown result type (might be due to invalid IL or missing references)
//IL_092b: Unknown result type (might be due to invalid IL or missing references)
//IL_0935: Unknown result type (might be due to invalid IL or missing references)
//IL_0937: Unknown result type (might be due to invalid IL or missing references)
//IL_093c: Unknown result type (might be due to invalid IL or missing references)
//IL_0941: Unknown result type (might be due to invalid IL or missing references)
//IL_0945: Unknown result type (might be due to invalid IL or missing references)
//IL_0947: Unknown result type (might be due to invalid IL or missing references)
//IL_0951: Unknown result type (might be due to invalid IL or missing references)
//IL_0953: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)value != (Object)null)
{
_mainFireArm = value;
if (EnableDebugLogging)
{
Debug.Log((object)$"[FirearmMagazineAddons] Equipping - Main Firearm assigned: {((Object)value).name}");
}
if ((Object)(object)value.Magazine != (Object)null)
{
if (value.Magazine.IsIntegrated)
{
if (EnableDebugLogging)
{
Debug.Log((object)$"[FirearmMagazineAddons] Equipping - Silently destroying internal magazine: {((Object)value.Magazine).name}");
}
FVRFireArmMagazine magazine = value.Magazine;
value.Magazine = null;
if ((Object)(object)magazine != (Object)null)
{
magazine.SetMagChild((FVRFireArmMagazine)null);
magazine.SetMagParent((FVRFireArmMagazine)null);
Object.Destroy((Object)(object)((Component)magazine).gameObject);
}
}
else
{
if (EnableDebugLogging)
{
Debug.Log((object)$"[FirearmMagazineAddons] Equipping - Ejecting and preserving currently loaded external magazine: {((Object)value.Magazine).name}");
}
value.EjectMag(true);
}
}
if ((Object)(object)value.Clip != (Object)null)
{
if (EnableDebugLogging)
{
Debug.Log((object)"[FirearmMagazineAddons] Equipping - Ejecting currently loaded stripper clip.");
}
value.EjectClip();
}
if (OverridesRoundType)
{
List<FVRFireArmChamber> chambers = value.GetChambers();
if (chambers != null)
{
for (int i = 0; i < chambers.Count; i++)
{
chambers[i].Unload();
}
}
}
if ((Object)(object)MagazineWellTrigger != (Object)null)
{
MagazineWellTrigger.FireArm = value;
((Component)MagazineWellTrigger).gameObject.SetActive(true);
((Behaviour)MagazineWellTrigger).enabled = true;
((Component)MagazineWellTrigger).gameObject.tag = "FVRFireArmReloadTriggerWell";
}
if ((Object)(object)ClipWellTrigger != (Object)null)
{
ClipWellTrigger.FireArm = value;
((Component)ClipWellTrigger).gameObject.SetActive(true);
((Behaviour)ClipWellTrigger).enabled = true;
((Component)ClipWellTrigger).gameObject.tag = "FVRFireArmClipReloadTriggerWell";
}
if ((Object)(object)TopCoverScript != (Object)null)
{
TopCoverScript.FireArm = value;
((Component)TopCoverScript).gameObject.SetActive(true);
((Behaviour)TopCoverScript).enabled = true;
}
if ((Object)(object)BeltRemovalTrigger != (Object)null)
{
BeltRemovalTrigger.FireArm = value;
((Component)BeltRemovalTrigger).gameObject.SetActive(true);
((Behaviour)BeltRemovalTrigger).enabled = true;
}
if ((Object)(object)MagGrabTrigger == (Object)null)
{
MagGrabTrigger = ((Component)this).GetComponentInChildren<UniversalMagGrabTrigger>(true);
}
if ((Object)(object)MagGrabTrigger != (Object)null)
{
MagGrabTrigger.FireArm = value;
((Component)MagGrabTrigger).gameObject.SetActive(true);
((Behaviour)MagGrabTrigger).enabled = true;
MagGrabTrigger.IsBeltBox = OverridesBeltFed;
}
if ((Object)(object)AdvancedMagGrabTrigger == (Object)null)
{
AdvancedMagGrabTrigger = ((Component)this).GetComponentInChildren<UniversalAdvancedMagazineGrabTrigger>(true);
}
if ((Object)(object)AdvancedMagGrabTrigger != (Object)null)
{
AdvancedMagGrabTrigger.FireArm = value;
((Component)AdvancedMagGrabTrigger).gameObject.SetActive(true);
((Behaviour)AdvancedMagGrabTrigger).enabled = true;
AdvancedMagGrabTrigger.IsBeltBoxGrabTrigger = OverridesBeltFed;
}
FirearmMagazineAddonStateTracker firearmMagazineAddonStateTracker = ((Component)value).GetComponent<FirearmMagazineAddonStateTracker>();
if ((Object)(object)firearmMagazineAddonStateTracker == (Object)null)
{
firearmMagazineAddonStateTracker = ((Component)value).gameObject.AddComponent<FirearmMagazineAddonStateTracker>();
firearmMagazineAddonStateTracker.CacheReceiverOriginalStates(value);
}
firearmMagazineAddonStateTracker.ActiveAddonCount++;
if (OverridesExternalMagazines)
{
value.UsesMagazines = true;
value.MagazineType = MagazineTypeOverride;
if ((Object)(object)MagazineMountPos != (Object)null)
{
value.MagazineMountPos = MagazineMountPos;
}
if ((Object)(object)MagazineEjectPos != (Object)null)
{
value.MagazineEjectPos = MagazineEjectPos;
}
}
if (EnablesInternalMagazine && (Object)(object)InternalMagazine != (Object)null)
{
value.UsesMagazines = true;
if ((Object)(object)value.MagazineMountPos == (Object)null)
{
value.MagazineMountPos = ((Component)InternalMagazine).transform;
}
if ((Object)(object)value.MagazineEjectPos == (Object)null)
{
value.MagazineEjectPos = ((Component)InternalMagazine).transform;
}
_internalMagLocalPos = ((Component)InternalMagazine).transform.localPosition;
_internalMagLocalRot = ((Component)InternalMagazine).transform.localRotation;
_internalMagOriginalParent = ((Component)InternalMagazine).transform.parent;
InternalMagazine.Load(value);
_needsInternalMagRestore = true;
FVRFireArmMagazineReloadTrigger[] componentsInChildren = ((Component)this).GetComponentsInChildren<FVRFireArmMagazineReloadTrigger>(true);
for (int j = 0; j < componentsInChildren.Length; j++)
{
componentsInChildren[j].Magazine = InternalMagazine;
((Component)componentsInChildren[j]).gameObject.SetActive(true);
((Behaviour)componentsInChildren[j]).enabled = true;
if (EnableDebugLogging)
{
Debug.Log((object)$"[FirearmMagazineAddons] Equipping - Linked internal reload trigger: {((Object)((Component)componentsInChildren[j]).gameObject).name}");
}
}
_disabledReceiverGrabTriggers.Clear();
UniversalMagGrabTrigger[] componentsInChildren2 = ((Component)value).GetComponentsInChildren<UniversalMagGrabTrigger>(true);
for (int k = 0; k < componentsInChildren2.Length; k++)
{
if ((Object)(object)((Component)componentsInChildren2[k]).transform.parent != (Object)(object)((Component)this).transform && ((Component)componentsInChildren2[k]).gameObject.activeSelf)
{
((Component)componentsInChildren2[k]).gameObject.SetActive(false);
firearmMagazineAddonStateTracker.DisabledReceiverGrabTriggers.Add(((Component)componentsInChildren2[k]).gameObject);
}
}
UniversalAdvancedMagazineGrabTrigger[] componentsInChildren3 = ((Component)value).GetComponentsInChildren<UniversalAdvancedMagazineGrabTrigger>(true);
for (int l = 0; l < componentsInChildren3.Length; l++)
{
if ((Object)(object)((Component)componentsInChildren3[l]).transform.parent != (Object)(object)((Component)this).transform && ((Component)componentsInChildren3[l]).gameObject.activeSelf)
{
((Component)componentsInChildren3[l]).gameObject.SetActive(false);
firearmMagazineAddonStateTracker.DisabledReceiverGrabTriggers.Add(((Component)componentsInChildren3[l]).gameObject);
}
}
}
if (OverridesMagReleaseButton)
{
ModifyMagReleaseButton(value, NewMagReleaseButtonState, firearmMagazineAddonStateTracker);
}
if (OverridesStripperClips)
{
value.UsesClips = true;
value.ClipType = ClipTypeOverride;
if ((Object)(object)ClipMountPos != (Object)null)
{
value.ClipMountPos = ClipMountPos;
}
if ((Object)(object)ClipEjectPos != (Object)null)
{
value.ClipEjectPos = ClipEjectPos;
}
if ((Object)(object)ClipTrigger != (Object)null)
{
value.ClipTrigger = ClipTrigger;
}
}
if (OverridesTopCover)
{
value.UsesTopCover = true;
value.IsTopCoverUp = StartTopCoverUp;
}
if (OverridesRoundType)
{
value.RoundType = RoundTypeOverride;
List<FVRFireArmChamber> chambers2 = value.GetChambers();
if (chambers2 != null)
{
for (int m = 0; m < chambers2.Count; m++)
{
chambers2[m].RoundType = RoundTypeOverride;
}
}
if ((Object)(object)((FVRPhysicalObject)value).ObjectWrapper != (Object)null)
{
((FVRPhysicalObject)value).ObjectWrapper.RoundType = RoundTypeOverride;
}
}
if ((Object)(object)value.AudioClipSet != (Object)null)
{
if (CustomMagazineInAudio != null)
{
value.AudioClipSet.MagazineIn = CustomMagazineInAudio;
}
if (CustomMagazineOutAudio != null)
{
value.AudioClipSet.MagazineOut = CustomMagazineOutAudio;
}
}
if (OverridesBeltFed)
{
value.UsesBelts = true;
value.RequiresBoltBackToSeatBelt = RequiresBoltBackToSeatBelt;
if ((Object)(object)BeltDisplayData != (Object)null)
{
value.BeltDD = BeltDisplayData;
BeltDisplayData.Firearm = value;
if (value.BeltDD.ProxyRounds == null)
{
value.BeltDD.ProxyRounds = new List<Transform>();
}
if (value.BeltDD.ProxyRounds.Count == 0 && (Object)(object)CustomProxyPrefab != (Object)null)
{
Transform val = ((!((Object)(object)BeltExitPointOverride != (Object)null)) ? value.BeltDD.GrabPoint_Box : BeltExitPointOverride);
Transform val2 = ((!((Object)(object)FeedTrayEntPos != (Object)null)) ? value.BeltDD.GrabPoint_Gun : FeedTrayEntPos);
if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
{
Vector3 position = val.position;
Vector3 position2 = val2.position;
Vector3 val3 = Vector3.Lerp(position, position2, 0.5f) + Vector3.down * BeltGravitySag;
float num = 0f;
Vector3 val4 = position;
for (int n = 1; n <= 10; n++)
{
float num2 = (float)n / 10f;
Vector3 val5 = (1f - num2) * (1f - num2) * position + 2f * (1f - num2) * num2 * val3 + num2 * num2 * position2;
num += Vector3.Distance(val4, val5);
val4 = val5;
}
float num3 = value.BeltDD.DistanceBetweenRounds;
if (num3 <= 0f)
{
num3 = 0.03f;
}
int num4 = Mathf.CeilToInt(num / num3);
value.BeltDD.BeltCapacity = num4;
for (int num5 = 0; num5 < num4; num5++)
{
GameObject val6 = Object.Instantiate<GameObject>(CustomProxyPrefab);
((Object)val6).name = "ProxyRound_Procedural_" + num5;
val6.transform.SetParent(((Component)value.BeltDD).transform, false);
value.BeltDD.ProxyRounds.Add(val6.transform);
}
Type type = ((object)value.BeltDD).GetType();
FieldInfo field = type.GetField("m_proxyRends", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = type.GetField("m_proxyMeshes", BindingFlags.Instance | BindingFlags.NonPublic);
if ((object)field != null && (object)field2 != null)
{
List<Renderer> list = (List<Renderer>)field.GetValue(value.BeltDD);
List<MeshFilter> list2 = (List<MeshFilter>)field2.GetValue(value.BeltDD);
list.Clear();
list2.Clear();
for (int num6 = 0; num6 < value.BeltDD.ProxyRounds.Count; num6++)
{
list.Add(((Component)value.BeltDD.ProxyRounds[num6]).gameObject.GetComponentInChildren<Renderer>());
list2.Add(((Component)value.BeltDD.ProxyRounds[num6]).gameObject.GetComponentInChildren<MeshFilter>());
}
}
}
}
}
if ((Object)(object)BeltBoxMountPos != (Object)null)
{
value.BeltBoxMountPos = BeltBoxMountPos;
}
if ((Object)(object)BeltBoxEjectPos != (Object)null)
{
value.BeltBoxEjectPos = BeltBoxEjectPos;
}
if ((Object)(object)DelinkerSystemOverride != (Object)null)
{
ModifyDelinker(value, enableDelinker: true, DelinkerSystemOverride, firearmMagazineAddonStateTracker);
}
}
((Behaviour)this).enabled = true;
}
else
{
CleanupAddon(_mainFireArm);
}
}
}
private void Awake()
{
_underbarrelFirearm = ((Component)this).GetComponentInChildren<AttachableFirearm>(true);
_underbarrelPhysical = ((Component)this).GetComponentInChildren<AttachableFirearmPhysicalObject>(true);
_underbarrelInterface = ((Component)this).GetComponentInChildren<AttachableFirearmInterface>(true);
if ((Object)(object)_underbarrelFirearm != (Object)null)
{
_underbarrelFirearm.Attachment = _underbarrelPhysical;
_underbarrelFirearm.Interface = _underbarrelInterface;
}
if ((Object)(object)_underbarrelPhysical != (Object)null)
{
((FVRFireArmAttachment)_underbarrelPhysical).AttachmentInterface = (FVRFireArmAttachmentInterface)(object)_underbarrelInterface;
}
if ((Object)(object)_underbarrelInterface != (Object)null)
{
_underbarrelInterface.FA = _underbarrelFirearm;
((FVRFireArmAttachmentInterface)_underbarrelInterface).Attachment = (FVRFireArmAttachment)(object)_underbarrelPhysical;
}
}
private void Update()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: 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_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: 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_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_0374: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0440: Unknown result type (might be due to invalid IL or missing references)
//IL_046c: Unknown result type (might be due to invalid IL or missing references)
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
//IL_04da: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_0507: Unknown result type (might be due to invalid IL or missing references)
//IL_0509: Unknown result type (might be due to invalid IL or missing references)
//IL_050b: Unknown result type (might be due to invalid IL or missing references)
//IL_0541: Unknown result type (might be due to invalid IL or missing references)
//IL_0546: Unknown result type (might be due to invalid IL or missing references)
//IL_0548: Unknown result type (might be due to invalid IL or missing references)
//IL_054a: Unknown result type (might be due to invalid IL or missing references)
//IL_052a: Unknown result type (might be due to invalid IL or missing references)
//IL_052f: Unknown result type (might be due to invalid IL or missing references)
//IL_0579: Unknown result type (might be due to invalid IL or missing references)
//IL_057b: Unknown result type (might be due to invalid IL or missing references)
//IL_057d: Unknown result type (might be due to invalid IL or missing references)
//IL_0583: Unknown result type (might be due to invalid IL or missing references)
//IL_0588: Unknown result type (might be due to invalid IL or missing references)
//IL_058d: Unknown result type (might be due to invalid IL or missing references)
//IL_0592: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0605: Unknown result type (might be due to invalid IL or missing references)
//IL_0623: Unknown result type (might be due to invalid IL or missing references)
//IL_0641: Unknown result type (might be due to invalid IL or missing references)
//IL_0648: Unknown result type (might be due to invalid IL or missing references)
//IL_064a: Unknown result type (might be due to invalid IL or missing references)
//IL_0571: Unknown result type (might be due to invalid IL or missing references)
//IL_0576: Unknown result type (might be due to invalid IL or missing references)
if (_needsInternalMagRestore && (Object)(object)_mainFireArm != (Object)null && (Object)(object)InternalMagazine != (Object)null)
{
_needsInternalMagRestore = false;
((Component)InternalMagazine).transform.SetParent(_internalMagOriginalParent, false);
((Component)InternalMagazine).transform.localPosition = _internalMagLocalPos;
((Component)InternalMagazine).transform.localRotation = _internalMagLocalRot;
if (EnableDebugLogging)
{
Debug.Log((object)"[FirearmMagazineAddons] Update - Deferred internal magazine position and parentage restoration executed.");
}
}
if ((Object)(object)_mainFireArm == (Object)null || !OverridesBeltFed || (Object)(object)_mainFireArm.BeltDD == (Object)null)
{
return;
}
if ((Object)(object)_mainFireArm.Magazine != (Object)(object)_lastMagazine)
{
_lastMagazine = _mainFireArm.Magazine;
if ((Object)(object)_lastMagazine != (Object)null)
{
_currentGrabPointBox = ((Component)_lastMagazine).transform.Find("GrabPoint_Box");
_currentHiddenInBoxSpot = ((Component)_lastMagazine).transform.Find("HiddenInBoxSpot");
if ((Object)(object)_currentGrabPointBox != (Object)null)
{
_mainFireArm.BeltDD.GrabPoint_Box = _currentGrabPointBox;
}
if ((Object)(object)_currentHiddenInBoxSpot != (Object)null)
{
_mainFireArm.BeltDD.HiddenInBoxSpot = _currentHiddenInBoxSpot;
}
if ((Object)(object)_mainFireArm.AudioClipSet != (Object)null && (Object)(object)_lastMagazine.Profile != (Object)null)
{
_mainFireArm.AudioClipSet.MagazineIn = _lastMagazine.Profile.MagazineIn;
_mainFireArm.AudioClipSet.MagazineOut = _lastMagazine.Profile.MagazineOut;
}
}
else
{
_currentGrabPointBox = null;
_currentHiddenInBoxSpot = null;
}
}
Transform val = ((!((Object)(object)_currentGrabPointBox != (Object)null)) ? BeltExitPointOverride : _currentGrabPointBox);
Transform val2 = ((!((Object)(object)FeedTrayEntPos != (Object)null)) ? _mainFireArm.BeltDD.GrabPoint_Gun : FeedTrayEntPos);
if (!((Object)(object)val != (Object)null) || !((Object)(object)val2 != (Object)null))
{
return;
}
Vector3 position = val.position;
Vector3 position2 = val2.position;
Vector3 val3 = Vector3.Lerp(position, position2, 0.5f) + Vector3.down * BeltGravitySag;
int count = _mainFireArm.BeltDD.ProxyRounds.Count;
if (count <= 0)
{
return;
}
int num = count + 1;
while (_mainFireArm.BeltDD.Chain_In.localPosList.Count < num)
{
_mainFireArm.BeltDD.Chain_In.localPosList.Add(Vector3.zero);
_mainFireArm.BeltDD.Chain_In.localRotList.Add(Quaternion.identity);
}
while (_mainFireArm.BeltDD.Chain_Out.localPosList.Count < num)
{
_mainFireArm.BeltDD.Chain_Out.localPosList.Add(Vector3.zero);
_mainFireArm.BeltDD.Chain_Out.localRotList.Add(Quaternion.identity);
}
while (_mainFireArm.BeltDD.ChainInterpolatedInOut.localPosList.Count < num)
{
_mainFireArm.BeltDD.ChainInterpolatedInOut.localPosList.Add(Vector3.zero);
_mainFireArm.BeltDD.ChainInterpolatedInOut.localRotList.Add(Quaternion.identity);
}
while (_mainFireArm.BeltDD.ChainInterpolated01.localPosList.Count < count)
{
_mainFireArm.BeltDD.ChainInterpolated01.localPosList.Add(Vector3.zero);
_mainFireArm.BeltDD.ChainInterpolated01.localRotList.Add(Quaternion.identity);
}
Vector3 val4 = position;
for (int i = 0; i < num; i++)
{
float num2 = (float)i / (float)(num - 1);
Vector3 val5 = (1f - num2) * (1f - num2) * position + 2f * (1f - num2) * num2 * val3 + num2 * num2 * position2;
Vector3 val6 = 2f * (1f - num2) * (val3 - position) + 2f * num2 * (position2 - val3);
Vector3 val7 = ((Vector3)(ref val6)).normalized;
if (val7 == Vector3.zero)
{
val7 = ((Component)_mainFireArm.BeltDD).transform.forward;
}
Vector3 val8 = ((Component)_mainFireArm.BeltDD).transform.up;
if (Mathf.Abs(Vector3.Dot(val7, val8)) > 0.95f)
{
val8 = ((Component)_mainFireArm.BeltDD).transform.forward;
}
Quaternion val9 = Quaternion.LookRotation(val7, val8) * Quaternion.Euler(BulletRotationOffset);
Vector3 value = ((Component)_mainFireArm.BeltDD).transform.InverseTransformPoint(val5);
Quaternion value2 = Quaternion.Inverse(((Component)_mainFireArm.BeltDD).transform.rotation) * val9;
_mainFireArm.BeltDD.Chain_In.localPosList[i] = value;
_mainFireArm.BeltDD.Chain_In.localRotList[i] = value2;
_mainFireArm.BeltDD.Chain_Out.localPosList[i] = value;
_mainFireArm.BeltDD.Chain_Out.localRotList[i] = value2;
val4 = val5;
}
}
private void OnDestroy()
{
CleanupAddon(_mainFireArm);
}
private void CleanupAddon(FVRFireArm firearm)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: 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_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)firearm == (Object)null)
{
return;
}
if (EnableDebugLogging)
{
Debug.Log((object)"[FirearmMagazineAddons] Swapping away - Starting decentralized cleanup.");
}
_needsInternalMagRestore = false;
FirearmMagazineAddonStateTracker component = ((Component)firearm).GetComponent<FirearmMagazineAddonStateTracker>();
if ((Object)(object)component != (Object)null)
{
if (OverridesExternalMagazines)
{
firearm.UsesMagazines = component.OriginalUsesMagazines;
firearm.MagazineType = component.OriginalMagazineType;
firearm.MagazineMountPos = component.OriginalMagazineMountPos;
firearm.MagazineEjectPos = component.OriginalMagazineEjectPos;
if ((Object)(object)MagazineWellTrigger != (Object)null)
{
MagazineWellTrigger.FireArm = null;
}
if ((Object)(object)MagGrabTrigger != (Object)null)
{
((Component)MagGrabTrigger).gameObject.SetActive(false);
MagGrabTrigger.FireArm = null;
}
if ((Object)(object)AdvancedMagGrabTrigger != (Object)null)
{
((Component)AdvancedMagGrabTrigger).gameObject.SetActive(false);
AdvancedMagGrabTrigger.FireArm = null;
}
if ((Object)(object)firearm.AudioClipSet != (Object)null)
{
firearm.AudioClipSet.MagazineIn = component.OriginalMagazineInAudio;
firearm.AudioClipSet.MagazineOut = component.OriginalMagazineOutAudio;
}
}
if (EnablesInternalMagazine && (Object)(object)InternalMagazine != (Object)null)
{
Object.Destroy((Object)(object)((Component)InternalMagazine).gameObject);
}
if (OverridesMagReleaseButton)
{
RestoreMagReleaseButton(firearm, component);
}
if (OverridesStripperClips)
{
firearm.UsesClips = component.OriginalUsesClips;
firearm.ClipType = component.OriginalClipType;
firearm.ClipMountPos = component.OriginalClipMountPos;
firearm.ClipEjectPos = component.OriginalClipEjectPos;
firearm.ClipTrigger = component.OriginalClipTrigger;
if ((Object)(object)ClipWellTrigger != (Object)null)
{
ClipWellTrigger.FireArm = null;
}
}
if (OverridesTopCover)
{
firearm.UsesTopCover = component.OriginalUsesTopCover;
firearm.IsTopCoverUp = component.OriginalIsTopCoverUp;
if ((Object)(object)TopCoverScript != (Object)null)
{
TopCoverScript.FireArm = null;
}
}
if (OverridesRoundType)
{
firearm.RoundType = component.OriginalRoundType;
List<FVRFireArmChamber> chambers = firearm.GetChambers();
if (chambers != null)
{
for (int i = 0; i < chambers.Count; i++)
{
if (OverridesRoundType)
{
chambers[i].Unload();
}
chambers[i].RoundType = component.OriginalRoundType;
}
}
if ((Object)(object)((FVRPhysicalObject)firearm).ObjectWrapper != (Object)null)
{
((FVRPhysicalObject)firearm).ObjectWrapper.RoundType = component.OriginalRoundType;
}
}
if (OverridesBeltFed)
{
if (firearm.UsesBelts && (Object)(object)firearm.BeltDD != (Object)null)
{
firearm.BeltDD.ForceRelease();
firearm.BeltDD.BeltRounds.Clear();
firearm.BeltDD.UpdateProxyRounds(0);
}
firearm.UsesBelts = component.OriginalUsesBelts;
firearm.BeltDD = component.OriginalBeltDD;
firearm.BeltBoxMountPos = component.OriginalBeltBoxMountPos;
firearm.BeltBoxEjectPos = component.OriginalBeltBoxEjectPos;
firearm.RequiresBoltBackToSeatBelt = component.OriginalRequiresBoltBack;
RestoreDelinker(firearm, component);
if ((Object)(object)BeltRemovalTrigger != (Object)null)
{
BeltRemovalTrigger.FireArm = null;
}
}
component.ActiveAddonCount--;
if (component.ActiveAddonCount <= 0)
{
for (int j = 0; j < component.DisabledReceiverGrabTriggers.Count; j++)
{
if ((Object)(object)component.DisabledReceiverGrabTriggers[j] != (Object)null)
{
component.DisabledReceiverGrabTriggers[j].SetActive(true);
}
}
component.DisabledReceiverGrabTriggers.Clear();
if ((Object)(object)component.OriginalReceiverMagazine != (Object)null)
{
((Component)component.OriginalReceiverMagazine).gameObject.SetActive(true);
firearm.Magazine = component.OriginalReceiverMagazine;
FVRFireArmMagazineReloadTrigger[] componentsInChildren = ((Component)firearm).GetComponentsInChildren<FVRFireArmMagazineReloadTrigger>(true);
for (int k = 0; k < componentsInChildren.Length; k++)
{
componentsInChildren[k].Magazine = component.OriginalReceiverMagazine;
((Component)componentsInChildren[k]).gameObject.SetActive(true);
((Behaviour)componentsInChildren[k]).enabled = true;
}
component.OriginalReceiverMagazine = null;
}
if (EnableDebugLogging)
{
Debug.Log((object)"[FirearmMagazineAddons] Cleanup - Restored all native receiver baselines. Destroying state tracker.");
}
Object.Destroy((Object)(object)component);
}
}
_mainFireArm = null;
_lastMagazine = null;
_currentGrabPointBox = null;
_currentHiddenInBoxSpot = null;
}
private void ModifyMagReleaseButton(FVRFireArm firearm, bool enableButton, FirearmMagazineAddonStateTracker tracker)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
if (firearm is ClosedBoltWeapon)
{
ClosedBoltWeapon val = (ClosedBoltWeapon)firearm;
tracker.OrigMagReleaseState = val.HasMagReleaseButton;
val.HasMagReleaseButton = enableButton;
}
else if (firearm is OpenBoltReceiver)
{
OpenBoltReceiver val2 = (OpenBoltReceiver)firearm;
tracker.OrigMagReleaseState = val2.HasMagReleaseButton;
val2.HasMagReleaseButton = enableButton;
}
else if (firearm is Handgun)
{
Handgun val3 = (Handgun)firearm;
tracker.OrigMagReleaseState = val3.HasMagReleaseButton;
val3.HasMagReleaseButton = enableButton;
}
else if (firearm is BoltActionRifle)
{
BoltActionRifle val4 = (BoltActionRifle)firearm;
tracker.OrigMagReleaseState = val4.HasMagEjectionButton;
val4.HasMagEjectionButton = enableButton;
}
}
private void RestoreMagReleaseButton(FVRFireArm firearm, FirearmMagazineAddonStateTracker tracker)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
if (firearm is ClosedBoltWeapon)
{
ClosedBoltWeapon val = (ClosedBoltWeapon)firearm;
val.HasMagReleaseButton = tracker.OrigMagReleaseState;
}
else if (firearm is OpenBoltReceiver)
{
OpenBoltReceiver val2 = (OpenBoltReceiver)firearm;
val2.HasMagReleaseButton = tracker.OrigMagReleaseState;
}
else if (firearm is Handgun)
{
Handgun val3 = (Handgun)firearm;
val3.HasMagReleaseButton = tracker.OrigMagReleaseState;
}
else if (firearm is BoltActionRifle)
{
BoltActionRifle val4 = (BoltActionRifle)firearm;
val4.HasMagEjectionButton = tracker.OrigMagReleaseState;
}
}
private void ModifyDelinker(FVRFireArm firearm, bool enableDelinker, ParticleSystem customSystem, FirearmMagazineAddonStateTracker tracker)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
if (firearm is ClosedBoltWeapon)
{
ClosedBoltWeapon val = (ClosedBoltWeapon)firearm;
tracker.OrigUsesDelinker = val.UsesDelinker;
tracker.OrigDelinkerSystem = val.DelinkerSystem;
val.UsesDelinker = enableDelinker;
if ((Object)(object)customSystem != (Object)null)
{
val.DelinkerSystem = customSystem;
}
}
else if (firearm is OpenBoltReceiver)
{
OpenBoltReceiver val2 = (OpenBoltReceiver)firearm;
tracker.OrigUsesDelinker = val2.UsesDelinker;
tracker.OrigDelinkerSystem = val2.DelinkerSystem;
val2.UsesDelinker = enableDelinker;
if ((Object)(object)customSystem != (Object)null)
{
val2.DelinkerSystem = customSystem;
}
}
}
private void RestoreDelinker(FVRFireArm firearm, FirearmMagazineAddonStateTracker tracker)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
if (firearm is ClosedBoltWeapon)
{
ClosedBoltWeapon val = (ClosedBoltWeapon)firearm;
val.UsesDelinker = tracker.OrigUsesDelinker;
val.DelinkerSystem = tracker.OrigDelinkerSystem;
}
else if (firearm is OpenBoltReceiver)
{
OpenBoltReceiver val2 = (OpenBoltReceiver)firearm;
val2.UsesDelinker = tracker.OrigUsesDelinker;
val2.DelinkerSystem = tracker.OrigDelinkerSystem;
}
}
private void OnDrawGizmos()
{
//IL_00f2: 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_00fe: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: 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)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: 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_0182: 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_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: 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_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: 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_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: 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_02cf: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: 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_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
if (!OverridesBeltFed || !((Object)(object)BeltExitPointOverride != (Object)null) || !((Object)(object)FeedTrayEntPos != (Object)null) || !((Object)(object)BeltDisplayData != (Object)null))
{
return;
}
Mesh val = null;
if ((Object)(object)CustomProxyPrefab != (Object)null)
{
MeshFilter componentInChildren = CustomProxyPrefab.GetComponentInChildren<MeshFilter>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
val = componentInChildren.sharedMesh;
}
}
else if (BeltDisplayData.ProxyRounds != null && BeltDisplayData.ProxyRounds.Count > 0 && (Object)(object)BeltDisplayData.ProxyRounds[0] != (Object)null)
{
MeshFilter[] componentsInChildren = ((Component)BeltDisplayData.ProxyRounds[0]).GetComponentsInChildren<MeshFilter>(true);
if (componentsInChildren.Length > 0)
{
val = componentsInChildren[0].sharedMesh;
}
}
Vector3 position = BeltExitPointOverride.position;
Vector3 position2 = FeedTrayEntPos.position;
Vector3 val2 = Vector3.Lerp(position, position2, 0.5f) + Vector3.down * BeltGravitySag;
float num = 0f;
Vector3 val3 = position;
for (int i = 1; i <= 10; i++)
{
float num2 = (float)i / 10f;
Vector3 val4 = (1f - num2) * (1f - num2) * position + 2f * (1f - num2) * num2 * val2 + num2 * num2 * position2;
num += Vector3.Distance(val3, val4);
val3 = val4;
}
float num3 = BeltDisplayData.DistanceBetweenRounds;
if (num3 <= 0f)
{
num3 = 0.03f;
}
int num4 = Mathf.CeilToInt(num / num3);
Vector3 val5 = position;
for (int j = 0; j < num4; j++)
{
float num5 = (float)j / (float)(num4 - 1);
Vector3 val6 = (1f - num5) * (1f - num5) * position + 2f * (1f - num5) * num5 * val2 + num5 * num5 * position2;
Vector3 val7 = 2f * (1f - num5) * (val2 - position) + 2f * num5 * (position2 - val2);
Vector3 val8 = ((Vector3)(ref val7)).normalized;
if (val8 == Vector3.zero)
{
val8 = ((Component)this).transform.forward;
}
Vector3 val9 = ((Component)this).transform.up;
if (Mathf.Abs(Vector3.Dot(val8, val9)) > 0.95f)
{
val9 = ((Component)this).transform.forward;
}
Quaternion val10 = Quaternion.LookRotation(val8, val9) * Quaternion.Euler(BulletRotationOffset);
if ((Object)(object)val != (Object)null)
{
Gizmos.color = Color.white;
Gizmos.DrawMesh(val, val6, val10, Vector3.one);
}
else
{
Gizmos.color = Color.green;
Gizmos.DrawSphere(val6, 0.012f);
}
val5 = val6;
}
}
}
public class FirearmMagazineAddonStateTracker : MonoBehaviour
{
public int ActiveAddonCount = 0;
public bool OriginalUsesMagazines;
public FireArmMagazineType OriginalMagazineType;
public Transform OriginalMagazineMountPos;
public Transform OriginalMagazineEjectPos;
public bool OriginalUsesClips;
public FireArmClipType OriginalClipType;
public Transform OriginalClipMountPos;
public Transform OriginalClipEjectPos;
public GameObject OriginalClipTrigger;
public bool OriginalUsesTopCover;
public bool OriginalIsTopCoverUp;
public FireArmRoundType OriginalRoundType;
public bool OriginalUsesBelts;
public FVRFirearmBeltDisplayData OriginalBeltDD;
public Transform OriginalMagazineMountPosFallback;
public Transform OriginalMagazineEjectPosFallback;
public Transform OriginalBeltBoxMountPos;
public Transform OriginalBeltBoxEjectPos;
public bool OriginalRequiresBoltBack;
public bool OrigUsesDelinker;
public ParticleSystem OrigDelinkerSystem;
public bool OrigMagReleaseState;
public AudioEvent OriginalMagazineInAudio;
public AudioEvent OriginalMagazineOutAudio;
public FVRFireArmMagazine OriginalReceiverMagazine;
public List<GameObject> DisabledReceiverGrabTriggers = new List<GameObject>();
public void CacheReceiverOriginalStates(FVRFireArm value)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
OriginalUsesMagazines = value.UsesMagazines;
OriginalMagazineType = value.MagazineType;
OriginalMagazineMountPos = value.MagazineMountPos;
OriginalMagazineEjectPos = value.MagazineEjectPos;
OriginalUsesClips = value.UsesClips;
OriginalClipType = value.ClipType;
OriginalClipMountPos = value.ClipMountPos;
OriginalClipEjectPos = value.ClipEjectPos;
OriginalClipTrigger = value.ClipTrigger;
OriginalUsesTopCover = value.UsesTopCover;
OriginalIsTopCoverUp = value.IsTopCoverUp;
OriginalRoundType = value.RoundType;
OriginalUsesBelts = value.UsesBelts;
OriginalBeltDD = value.BeltDD;
OriginalBeltBoxMountPos = value.BeltBoxMountPos;
OriginalBeltBoxEjectPos = value.BeltBoxEjectPos;
OriginalRequiresBoltBack = value.RequiresBoltBackToSeatBelt;
if ((Object)(object)value.AudioClipSet != (Object)null)
{
OriginalMagazineInAudio = value.AudioClipSet.MagazineIn;
OriginalMagazineOutAudio = value.AudioClipSet.MagazineOut;
}
OriginalReceiverMagazine = value.Magazine;
}
}
[RequireComponent(typeof(ModularWeaponPart))]
public class ModularMeshToggleAddon : MonoBehaviour, IPartFireArmRequirement
{
[Header("Debug Settings")]
[Tooltip("Enable detailed console logs to track component auto-detection and linking.")]
public bool EnableDebugLogging = true;
[Header("Mesh/GameObject Hiding Settings")]
[Tooltip("List of exact GameObject names in the parent firearm hierarchy to completely deactivate (hides visuals and disables physics).")]
public string[] GameObjectsToDeactivate;
[Tooltip("List of exact GameObject names in the parent firearm hierarchy to only hide (disables visual mesh but keeps physics grip colliders active).")]
public string[] MeshesToHideOnly;
private FVRFireArm _mainFireArm;
private List<GameObject> _deactivatedObjects = new List<GameObject>();
private List<Renderer> _hiddenRenderers = new List<Renderer>();
public FVRFireArm FireArm
{
get
{
return _mainFireArm;
}
set
{
if ((Object)(object)value != (Object)null)
{
_mainFireArm = value;
if (EnableDebugLogging)
{
Debug.Log((object)$"[ModularMeshToggleAddon] Equipping - Target Firearm: {((Object)value).name}");
}
if (GameObjectsToDeactivate != null)
{
for (int i = 0; i < GameObjectsToDeactivate.Length; i++)
{
string text = GameObjectsToDeactivate[i];
if (string.IsNullOrEmpty(text))
{
continue;
}
Transform val = FindChildRecursive(((Component)value).transform, text);
if ((Object)(object)val != (Object)null)
{
if (((Component)val).gameObject.activeSelf)
{
((Component)val).gameObject.SetActive(false);
_deactivatedObjects.Add(((Component)val).gameObject);
if (EnableDebugLogging)
{
Debug.Log((object)$"[ModularMeshToggleAddon] Equipping - Deactivated GameObject: {text}");
}
}
}
else if (EnableDebugLogging)
{
Debug.LogWarning((object)$"[ModularMeshToggleAddon] Equipping - Could not find GameObject target: {text}");
}
}
}
if (MeshesToHideOnly == null)
{
return;
}
for (int j = 0; j < MeshesToHideOnly.Length; j++)
{
string text2 = MeshesToHideOnly[j];
if (string.IsNullOrEmpty(text2))
{
continue;
}
Transform val2 = FindChildRecursive(((Component)value).transform, text2);
if ((Object)(object)val2 != (Object)null)
{
Renderer component = ((Component)val2).GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
if (component.enabled)
{
component.enabled = false;
_hiddenRenderers.Add(component);
if (EnableDebugLogging)
{
Debug.Log((object)$"[ModularMeshToggleAddon] Equipping - Hidden Renderer: {text2}");
}
}
}
else if (EnableDebugLogging)
{
Debug.LogWarning((object)$"[ModularMeshToggleAddon] Equipping - Target '{text2}' does not have a Renderer component.");
}
}
else if (EnableDebugLogging)
{
Debug.LogWarning((object)$"[ModularMeshToggleAddon] Equipping - Could not find Mesh target: {text2}");
}
}
return;
}
if (EnableDebugLogging)
{
Debug.Log((object)"[ModularMeshToggleAddon] Swapping away - Restoring cached meshes/GameObjects.");
}
if ((Object)(object)_mainFireArm != (Object)null)
{
for (int k = 0; k < _deactivatedObjects.Count; k++)
{
if ((Object)(object)_deactivatedObjects[k] != (Object)null)
{
_deactivatedObjects[k].SetActive(true);
}
}
_deactivatedObjects.Clear();
for (int l = 0; l < _hiddenRenderers.Count; l++)
{
if ((Object)(object)_hiddenRenderers[l] != (Object)null)
{
_hiddenRenderers[l].enabled = true;
}
}
_hiddenRenderers.Clear();
}
_mainFireArm = null;
}
}
private Transform FindChildRecursive(Transform parent, string name)
{
if (((Object)parent).name == name)
{
return parent;
}
for (int i = 0; i < parent.childCount; i++)
{
Transform val = FindChildRecursive(parent.GetChild(i), name);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
}
public class ModularReloadTriggerWellBinder : MonoBehaviour
{
[Header("Bind Settings")]
[Tooltip("If true, assigns AFireArm (Attachable Firearm). If false, assigns FireArm.")]
public bool UseAttachableFireArm = false;
[Header("Round Type")]
public bool ChangesFireArmRoundType = false;
public FireArmRoundType CustomRoundType;
[Header("Recoil Profile")]
public bool ChangesRecoilProfile = false;
public FVRFireArmRecoilProfile CustomRecoilProfile;
public FVRFireArmRecoilProfile CustomRecoilProfileStocked;
[Header("Magazine Mounting")]
public bool ChangesMagazineMountPoint = false;
public Transform CustomMagMountPoint;
public Transform CustomMagEjectPoint;
[Header("Magazine Type")]
public bool ChangesMagazineType = false;
public FireArmMagazineType CustomMagazineType;
[Header("Audio Set")]
public bool ChangesAudioSet = false;
public FVRFirearmAudioSet CustomAudioSet;
private FVRFireArmReloadTriggerWell _well;
private FVRFireArm _boundFireArm;
private bool _hasOriginals;
private FireArmRoundType _origRoundType;
private FVRFireArmRecoilProfile _origRecoilProfile;
private FVRFireArmRecoilProfile _origRecoilProfileStocked;
private bool _origUsesStockedRecoilProfile;
private Transform _origMagazineMountPos;
private Transform _origMagazineEjectPos;
private FireArmMagazineType _origMagazineType;
private FVRFirearmAudioSet _origAudioSet;
private void Awake()
{
_well = ((Component)this).GetComponent<FVRFireArmReloadTriggerWell>();
if ((Object)(object)_well == (Object)null)
{
ModularWorkshopManager.LogWarning((MonoBehaviour)(object)this, "No FVRFireArmReloadTriggerWell found!");
}
}
private void OnEnable()
{
BindToParentFirearm();
}
private void OnDisable()
{
Unbind();
}
private void BindToParentFirearm()
{
if ((Object)(object)_well == (Object)null)
{
return;
}
if (UseAttachableFireArm)
{
AttachableFirearm componentInParent = ((Component)this).GetComponentInParent<AttachableFirearm>();
if ((Object)(object)componentInParent == (Object)null)
{
ModularWorkshopManager.LogWarning((MonoBehaviour)(object)this, "Parent AttachableFirearm not found!");
}
else
{
_well.AFireArm = componentInParent;
}
return;
}
FVRFireArm componentInParent2 = ((Component)this).GetComponentInParent<FVRFireArm>();
if ((Object)(object)componentInParent2 == (Object)null)
{
ModularWorkshopManager.LogWarning((MonoBehaviour)(object)this, "Parent FVRFireArm not found!");
return;
}
_well.FireArm = componentInParent2;
ApplyOverrides(componentInParent2);
}
private void Unbind()
{
if (!((Object)(object)_well == (Object)null))
{
if ((Object)(object)_boundFireArm != (Object)null)
{
RestoreOverrides(_boundFireArm);
_boundFireArm = null;
}
_well.FireArm = null;
_well.AFireArm = null;
}
}
private void ApplyOverrides(FVRFireArm firearm)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)firearm == (Object)null)
{
return;
}
if (!_hasOriginals)
{
_origRoundType = firearm.RoundType;
_origRecoilProfile = firearm.RecoilProfile;
_origRecoilProfileStocked = firearm.RecoilProfileStocked;
_origUsesStockedRecoilProfile = firearm.UsesStockedRecoilProfile;
_origMagazineMountPos = firearm.MagazineMountPos;
_origMagazineEjectPos = firearm.MagazineEjectPos;
_origMagazineType = firearm.MagazineType;
_origAudioSet = firearm.AudioClipSet;
_hasOriginals = true;
}
_boundFireArm = firearm;
if (ChangesFireArmRoundType)
{
firearm.RoundType = CustomRoundType;
}
if (ChangesRecoilProfile)
{
firearm.RecoilProfile = CustomRecoilProfile;
if ((Object)(object)CustomRecoilProfileStocked != (Object)null)
{
firearm.UsesStockedRecoilProfile = true;
firearm.RecoilProfileStocked = CustomRecoilProfileStocked;
}
else
{
firearm.UsesStockedRecoilProfile = false;
}
}
if (ChangesMagazineMountPoint)
{
firearm.MagazineMountPos = CustomMagMountPoint;
firearm.MagazineEjectPos = CustomMagEjectPoint;
}
if (ChangesMagazineType)
{
firearm.MagazineType = CustomMagazineType;
}
if (ChangesAudioSet)
{
firearm.AudioClipSet = CustomAudioSet;
}
}
private void RestoreOverrides(FVRFireArm firearm)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)firearm == (Object)null) && _hasOriginals)
{
firearm.RoundType = _origRoundType;
firearm.RecoilProfile = _origRecoilProfile;
firearm.RecoilProfileStocked = _origRecoilProfileStocked;
firearm.UsesStockedRecoilProfile = _origUsesStockedRecoilProfile;
firearm.MagazineMountPos = _origMagazineMountPos;
firearm.MagazineEjectPos = _origMagazineEjectPos;
firearm.MagazineType = _origMagazineType;
firearm.AudioClipSet = _origAudioSet;
_hasOriginals = false;
}
}
}
public class AudioConsistencyEnforcer : MonoBehaviour
{
[Header("Audio Profiles")]
public FVRFirearmAudioSet BaseHandlingAudioProfile;
private FVRFireArm _firearm;
private FVRFirearmAudioSet _lastAudioClipSet;
private void Awake()
{
_firearm = ((Component)this).GetComponent<FVRFireArm>();
if ((Object)(object)_firearm != (Object)null && (Object)(object)_firearm.AudioClipSet != (Object)null)
{
_lastAudioClipSet = _firearm.AudioClipSet;
BaseHandlingAudioProfile = ScriptableObject.CreateInstance<FVRFirearmAudioSet>();
SaveBaseHandlingAudio(_lastAudioClipSet);
}
}
private void LateUpdate()
{
if ((Object)(object)_firearm == (Object)null)
{
return;
}
FVRFirearmAudioSet audioClipSet = _firearm.AudioClipSet;
if (!((Object)(object)audioClipSet == (Object)null))
{
if ((Object)(object)audioClipSet != (Object)(object)_lastAudioClipSet)
{
_lastAudioClipSet = audioClipSet;
}
EnforceHandlingSounds(audioClipSet);
}
}
private void SaveBaseHandlingAudio(FVRFirearmAudioSet source)
{
BaseHandlingAudioProfile.BoltRelease = source.BoltRelease;
BaseHandlingAudioProfile.BoltSlideBack = source.BoltSlideBack;
BaseHandlingAudioProfile.BoltSlideForward = source.BoltSlideForward;
BaseHandlingAudioProfile.BoltSlideBackHeld = source.BoltSlideBackHeld;
BaseHandlingAudioProfile.BoltSlideBackLocked = source.BoltSlideBackLocked;
BaseHandlingAudioProfile.BreachOpen = source.BreachOpen;
BaseHandlingAudioProfile.BreachClose = source.BreachClose;
BaseHandlingAudioProfile.CatchOnSear = source.CatchOnSear;
BaseHandlingAudioProfile.ChamberManual = source.ChamberManual;
BaseHandlingAudioProfile.FireSelector = source.FireSelector;
BaseHandlingAudioProfile.HammerHit = source.HammerHit;
BaseHandlingAudioProfile.HandleBack = source.HandleBack;
BaseHandlingAudioProfile.HandleBackEmpty = source.HandleBackEmpty;
BaseHandlingAudioProfile.HandleForward = source.HandleForward;
BaseHandlingAudioProfile.HandleForwardEmpty = source.HandleForwardEmpty;
BaseHandlingAudioProfile.HandleUp = source.HandleUp;
BaseHandlingAudioProfile.HandleDown = source.HandleDown;
BaseHandlingAudioProfile.HandleGrab = source.HandleGrab;
BaseHandlingAudioProfile.Prefire = source.Prefire;
BaseHandlingAudioProfile.Safety = source.Safety;
BaseHandlingAudioProfile.TriggerReset = source.TriggerReset;
BaseHandlingAudioProfile.TopCoverRelease = source.TopCoverRelease;
BaseHandlingAudioProfile.TopCoverUp = source.TopCoverUp;
BaseHandlingAudioProfile.TopCoverDown = source.TopCoverDown;
BaseHandlingAudioProfile.StockOpen = source.StockOpen;
BaseHandlingAudioProfile.StockClosed = source.StockClosed;
BaseHandlingAudioProfile.BipodOpen = source.BipodOpen;
BaseHandlingAudioProfile.BipodClosed = source.BipodClosed;
BaseHandlingAudioProfile.BeltGrab = source.BeltGrab;
BaseHandlingAudioProfile.BeltRelease = source.BeltRelease;
BaseHandlingAudioProfile.BeltSeat = source.BeltSeat;
BaseHandlingAudioProfile.BeltSettle = source.BeltSettle;
}
private void EnforceHandlingSounds(FVRFirearmAudioSet targetProfile)
{
targetProfile.BoltRelease = BaseHandlingAudioProfile.BoltRelease;
targetProfile.BoltSlideBack = BaseHandlingAudioProfile.BoltSlideBack;
targetProfile.BoltSlideForward = BaseHandlingAudioProfile.BoltSlideForward;
targetProfile.BoltSlideBackHeld = BaseHandlingAudioProfile.BoltSlideBackHeld;
targetProfile.BoltSlideBackLocked = BaseHandlingAudioProfile.BoltSlideBackLocked;
targetProfile.BreachOpen = BaseHandlingAudioProfile.BreachOpen;
targetProfile.BreachClose = BaseHandlingAudioProfile.BreachClose;
targetProfile.CatchOnSear = BaseHandlingAudioProfile.CatchOnSear;
targetProfile.ChamberManual = BaseHandlingAudioProfile.ChamberManual;
targetProfile.FireSelector = BaseHandlingAudioProfile.FireSelector;
targetProfile.HammerHit = BaseHandlingAudioProfile.HammerHit;
targetProfile.HandleBack = BaseHandlingAudioProfile.HandleBack;
targetProfile.HandleBackEmpty = BaseHandlingAudioProfile.HandleBackEmpty;
targetProfile.HandleForward = BaseHandlingAudioProfile.HandleForward;
targetProfile.HandleForwardEmpty = BaseHandlingAudioProfile.HandleForwardEmpty;
targetProfile.HandleUp = BaseHandlingAudioProfile.HandleUp;
targetProfile.HandleDown = BaseHandlingAudioProfile.HandleDown;
targetProfile.HandleGrab = BaseHandlingAudioProfile.HandleGrab;
targetProfile.Prefire = BaseHandlingAudioProfile.Prefire;
targetProfile.Safety = BaseHandlingAudioProfile.Safety;
targetProfile.TriggerReset = BaseHandlingAudioProfile.TriggerReset;
targetProfile.TopCoverRelease = BaseHandlingAudioProfile.TopCoverRelease;
targetProfile.TopCoverUp = BaseHandlingAudioProfile.TopCoverUp;
targetProfile.TopCoverDown = BaseHandlingAudioProfile.TopCoverDown;
targetProfile.StockOpen = BaseHandlingAudioProfile.StockOpen;
targetProfile.StockClosed = BaseHandlingAudioProfile.StockClosed;
targetProfile.BipodOpen = BaseHandlingAudioProfile.BipodOpen;
targetProfile.BipodClosed = BaseHandlingAudioProfile.BipodClosed;
targetProfile.BeltGrab = BaseHandlingAudioProfile.BeltGrab;
targetProfile.BeltRelease = BaseHandlingAudioProfile.BeltRelease;
targetProfile.BeltSeat = BaseHandlingAudioProfile.BeltSeat;
targetProfile.BeltSettle = BaseHandlingAudioProfile.BeltSettle;
}
}
public class MuzzleDeviceParentMonitor : MuzzleDevice
{
public bool DisableParentBehavior = true;
private FVRFireArmAttachmentMount monitoredAttachmentMount;
public override void Start()
{
((FVRInteractiveObject)this).Start();
FindAttachmentMount();
}
private void Update()
{
if (DisableParentBehavior)
{
if ((Object)(object)monitoredAttachmentMount == (Object)null)
{
FindAttachmentMount();
}
if ((Object)(object)monitoredAttachmentMount != (Object)null && monitoredAttachmentMount.ParentToThis)
{
KeepObjectInPlaceWhileParented();
}
}
}
private void FindAttachmentMount()
{
monitoredAttachmentMount = ((Component)this).GetComponentInParent<FVRFireArmAttachmentMount>();
}
private void KeepObjectInPlaceWhileParented()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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)
if ((Object)(object)monitoredAttachmentMount != (Object)null)
{
Vector3 position = ((Component)this).transform.position;
Quaternion rotation = ((Component)this).transform.rotation;
monitoredAttachmentMount.ParentToThis = false;
((Component)this).transform.position = position;
((Component)this).transform.rotation = rotation;
}
}
}
public class LeverActionDustCover : FVRInteractiveObject
{
public LeverActionFirearm LeverAction;
public Transform DustCoverGeo;
public float OpenRot;
public float ClosedRot;
public float RotSpeed = 360f;
public AudioEvent AudEvent_CoverOpen;
public AudioEvent AudEvent_CoverClose;
private bool m_isOpen;
private float m_curRot;
private float m_tarRot;
public override void Awake()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).Awake();
m_curRot = ClosedRot;
m_tarRot = ClosedRot;
m_isOpen = false;
if ((Object)(object)DustCoverGeo != (Object)null)
{
DustCoverGeo.localEulerAngles = new Vector3(0f, 0f, ClosedRot);
}
}
public override void SimpleInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).SimpleInteraction(hand);
ToggleDustCoverState();
}
private void ToggleDustCoverState()
{
if (m_isOpen)
{
Close();
}
else
{
Open();
}
}
public override void FVRUpdate()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
if (!m_isOpen && (Object)(object)LeverAction != (Object)null && (int)LeverAction.m_curLeverPos != 0)
{
Open();
}
if (Mathf.Abs(m_tarRot - m_curRot) > 0.01f)
{
m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * RotSpeed);
if ((Object)(object)DustCoverGeo != (Object)null)
{
DustCoverGeo.localEulerAngles = new Vector3(0f, 0f, m_curRot);
}
}
}
private void Open()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (!m_isOpen)
{
m_isOpen = true;
m_tarRot = OpenRot;
RotSpeed = 1900f;
if (AudEvent_CoverOpen != null && AudEvent_CoverOpen.Clips.Count > 0)
{
AudioSource.PlayClipAtPoint(AudEvent_CoverOpen.Clips[0], ((Component)this).transform.position, AudEvent_CoverOpen.VolumeRange.x);
}
}
}
private void Close()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (m_isOpen)
{
m_isOpen = false;
m_tarRot = ClosedRot;
RotSpeed = 800f;
if (AudEvent_CoverClose != null && AudEvent_CoverClose.Clips.Count > 0)
{
AudioSource.PlayClipAtPoint(AudEvent_CoverClose.Clips[0], ((Component)this).transform.position, AudEvent_CoverClose.VolumeRange.x);
}
}
}
}
public class LeverActionMagRelease : FVRInteractiveObject
{
public LeverActionFirearm LeverActionWeapon;
public Transform MagazineReleaseButton;
public Vector3 MagReleaseUnpressed = Vector3.zero;
public Vector3 MagReleasePressed = new Vector3(0f, -5f, 0f);
public InterpStyle MagReleaseInterp = (InterpStyle)0;
private bool isHeldDown = false;
public override void SimpleInteraction(FVRViveHand hand)
{
TryReleaseMag(hand);
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
bool flag = hand.Input.TriggerDown || hand.Input.TouchpadDown || hand.Input.AXButtonDown;
bool flag2 = hand.Input.TriggerPressed || hand.Input.TouchpadPressed || hand.Input.AXButtonPressed;
if (flag)
{
TryReleaseMag(hand);
}
if ((Object)(object)MagazineReleaseButton != (Object)null)
{
if (flag2 && !isHeldDown)
{
SetAnimatedComponent(MagazineReleaseButton, MagReleasePressed, MagReleaseInterp);
isHeldDown = true;
}
else if (!flag2 && isHeldDown)
{
SetAnimatedComponent(MagazineReleaseButton, MagReleaseUnpressed, MagReleaseInterp);
isHeldDown = false;
}
}
}
private void TryReleaseMag(FVRViveHand hand)
{
if ((Object)(object)LeverActionWeapon != (Object)null && (Object)(object)((FVRFireArm)LeverActionWeapon).Magazine != (Object)null)
{
FVRFireArmMagazine magazine = ((FVRFireArm)LeverActionWeapon).Magazine;
((FVRFireArm)LeverActionWeapon).EjectMag(false);
if ((Object)(object)hand != (Object)null)
{
hand.ForceSetInteractable((FVRInteractiveObject)(object)magazine);
((FVRInteractiveObject)magazine).BeginInteraction(hand);
}
}
}
private void SetAnimatedComponent(Transform t, Vector3 value, InterpStyle interp)
{
//IL_0001: 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_0015: Invalid comparison between Unknown and I4
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if ((int)interp == 0)
{
t.localPosition = value;
}
else if ((int)interp == 1)
{
t.localEulerAngles = value;
}
}
}
namespace Volks.DPMagMosinReceiver;
[BepInPlugin("Volks.DPMagMosinReceiver", "DPMagMosinReceiver", "2.0.0")]
[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 DPMagMosinReceiverPlugin : 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.DPMagMosinReceiver");
OtherLoader.RegisterDirectLoad(BasePath, "Volks.DPMagMosinReceiver", "", "", "dpmagmosin", "");
GameAPI.PreloadAllAssets(Path.Combine(BasePath, "mw_dpmagmosinreceiver"));
}
}
public class FVRTorch : FVRPhysicalObject
{
public GameObject FireGO;
public GameObject LinkedObject;
public AudioSource fireAud;
public float BurnDuration = 120f;
public float DestructionDelay = 5f;
private bool m_isBurning = false;
private bool m_hasBeenLit = false;
private bool m_canDestroy = false;
private float m_burnTimer;
private float m_unheldTimer;
public override void Awake()
{
((FVRPhysicalObject)this).Awake();
if ((Object)(object)FireGO != (Object)null)
{
fireAud = FireGO.GetComponent<AudioSource>();
FireGO.SetActive(false);
}
if ((Object)(object)LinkedObject != (Object)null)
{
LinkedObject.SetActive(false);
}
}
public override void FVRUpdate()
{
((FVRPhysicalObject)this).FVRUpdate();
if (m_isBurning)
{
m_burnTimer -= Time.deltaTime;
if ((Object)(object)fireAud != (Object)null)
{
fireAud.volume = Mathf.Lerp(fireAud.volume, 0f, Time.deltaTime / BurnDuration);
}
if (m_burnTimer <= 0f)
{
StopBurning();
}
}
if (m_canDestroy && !((FVRInteractiveObject)this).IsHeld)
{
m_unheldTimer -= Time.deltaTime;
if (m_unheldTimer <= 0f)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
else if (((FVRInteractiveObject)this).IsHeld)
{
m_unheldTimer = DestructionDelay;
}
}
public void Ignite()
{
if (!m_hasBeenLit)
{
m_hasBeenLit = true;
m_isBurning = true;
m_burnTimer = BurnDuration;
if ((Object)(object)FireGO != (Object)null)
{
FireGO.SetActive(true);
}
if ((Object)(object)fireAud != (Object)null)
{
fireAud.Play();
}
if ((Object)(object)LinkedObject != (Object)null)
{
LinkedObject.SetActive(true);
}
}
}
private void StopBurning()
{
m_isBurning = false;
m_canDestroy = true;
if ((Object)(object)FireGO != (Object)null)
{
FireGO.SetActive(false);
}
if ((Object)(object)fireAud != (Object)null)
{
fireAud.Stop();
}
Debug.Log((object)"Torch fire has died out.");
}
private void OnCollisionEnter(Collision col)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
if (m_hasBeenLit && m_isBurning && (Object)(object)col.collider.attachedRigidbody != (Object)null)
{
IFVRDamageable val = ((Component)col.collider).GetComponent<IFVRDamageable>() ?? ((Component)col.collider.attachedRigidbody).GetComponent<IFVRDamageable>();
if (val != null)
{
Damage val2 = new Damage();
val2.Dam_Thermal = 50f;
val2.Dam_TotalEnergetic = 50f;
val2.point = ((ContactPoint)(ref col.contacts[0])).point;
val2.hitNormal = ((ContactPoint)(ref col.contacts[0])).normal;
val2.strikeDir = ((Component)this).transform.forward;
val.Damage(val2);
}
}
}
}
public class TorchTrigger : MonoBehaviour
{
public FVRTorch Torch;
public Collider collider;
private void OnTriggerEnter(Collider col)
{
collider.enabled = false;
((Component)collider).gameObject.layer = LayerMask.NameToLayer("NoCol");
Torch.Ignite();
}
}