using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace FALCamo
{
public class FALCamoMagazine : FVRFireArmMagazine
{
public override void Awake()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0024: Expected I4, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
FireArmRoundClass[] array = (FireArmRoundClass[])(object)new FireArmRoundClass[base.m_capacity];
FireArmRoundClass defaultRoundClass = AM.GetDefaultRoundClass(base.RoundType);
for (int i = 0; i < array.Length; i++)
{
array[i] = (FireArmRoundClass)(int)defaultRoundClass;
}
FVRMagazineLoadingPattern val = new FVRMagazineLoadingPattern();
val.Classes = array;
base.DefaultLoadingPattern = val;
((FVRFireArmMagazine)this).Awake();
}
}
public class FALCamoReflex : MonoBehaviour
{
public Transform Muzzle;
public Transform Window;
public float ConvergenceDistance = 50f;
private MaterialPropertyBlock properties;
public void UpdateAim()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
if (!((Object)(object)Muzzle == (Object)null) && !((Object)(object)Window == (Object)null))
{
Vector3 val = Muzzle.position + Muzzle.forward * ConvergenceDistance;
Window.rotation = Quaternion.LookRotation(val - Window.position, ((Component)this).transform.up);
if (properties == null)
{
properties = new MaterialPropertyBlock();
}
properties.SetFloat("_ZeroDistance", Vector3.Distance(val, Window.position));
((Component)Window).GetComponent<Renderer>().SetPropertyBlock(properties);
}
}
private void LateUpdate()
{
UpdateAim();
}
}
public class FALNativeAudio : MonoBehaviour
{
public ClosedBoltWeapon Firearm;
private IEnumerator Start()
{
FVRObject entry = null;
for (int i = 0; i < 300; i++)
{
if (IM.OD != null && IM.OD.TryGetValue("Fal", out entry))
{
break;
}
yield return null;
}
if ((Object)(object)entry == (Object)null)
{
Debug.LogError((object)"FAL_AUDIO_DONOR_UNAVAILABLE");
yield break;
}
AnvilCallback<GameObject> request = ((AnvilAsset)entry).GetGameObjectAsync();
yield return request;
if ((Object)(object)request.Result == (Object)null)
{
yield break;
}
ClosedBoltWeapon donor = request.Result.GetComponent<ClosedBoltWeapon>();
if ((Object)(object)donor == (Object)null)
{
yield break;
}
foreach (FVRObject compatibleMagazine in ((FVRPhysicalObject)donor).ObjectWrapper.CompatibleMagazines)
{
if ((Object)(object)compatibleMagazine != (Object)null && !((FVRPhysicalObject)Firearm).ObjectWrapper.CompatibleMagazines.Contains(compatibleMagazine))
{
((FVRPhysicalObject)Firearm).ObjectWrapper.CompatibleMagazines.Add(compatibleMagazine);
}
}
FVRFirearmAudioSet set = Object.Instantiate<FVRFirearmAudioSet>(((FVRFireArm)Firearm).AudioClipSet);
((FVRFireArm)Firearm).AudioClipSet = set;
set.BoltSlideBackHeld = ((FVRFireArm)donor).AudioClipSet.BoltSlideBackHeld;
set.BoltSlideForwardHeld = ((FVRFireArm)donor).AudioClipSet.BoltSlideForwardHeld;
set.HandleBack = ((FVRFireArm)donor).AudioClipSet.HandleBack;
set.HandleForward = ((FVRFireArm)donor).AudioClipSet.HandleForward;
set.FireSelector = ((FVRFireArm)donor).AudioClipSet.FireSelector;
}
}
public class FALUnderbarrel : MonoBehaviour
{
public const string NativeID = "M203Picatinny";
public ClosedBoltWeapon Firearm;
public FVRFireArmAttachmentMount Mount;
public Transform BarrelArt;
public Transform AuthoredMuzzle;
public Transform AuthoredBreech;
public Transform AuthoredGrip;
public M203 Launcher;
public bool Ready;
private IEnumerator Start()
{
yield return null;
FVRObject entry = null;
for (int i = 0; i < 300; i++)
{
if (IM.OD != null && IM.OD.TryGetValue("M203Picatinny", out entry))
{
break;
}
yield return null;
}
if ((Object)(object)entry == (Object)null)
{
Debug.LogError((object)"FAL_M203_FAILED: native item unavailable");
yield break;
}
AnvilCallback<GameObject> request = ((AnvilAsset)entry).GetGameObjectAsync();
yield return request;
try
{
AttachableFirearmPhysicalObject val = null;
foreach (FVRFireArmAttachment attachments in Mount.AttachmentsList)
{
if ((Object)(object)((FVRPhysicalObject)attachments).ObjectWrapper != (Object)null && ((FVRPhysicalObject)attachments).ObjectWrapper.ItemID == "M203Picatinny")
{
val = (AttachableFirearmPhysicalObject)(object)((attachments is AttachableFirearmPhysicalObject) ? attachments : null);
break;
}
}
if ((Object)(object)val == (Object)null)
{
if ((Object)(object)request.Result == (Object)null)
{
throw new Exception("M203 prefab unavailable");
}
val = Object.Instantiate<GameObject>(request.Result).GetComponent<AttachableFirearmPhysicalObject>();
((Component)val).gameObject.SetActive(true);
((Component)val).transform.position = ((Component)Mount).transform.position;
((Component)val).transform.rotation = ((Component)Mount).transform.rotation;
((FVRFireArmAttachment)val).AttachToMount(Mount, false);
}
Configure(((Component)val).GetComponent<M203>());
}
catch (Exception ex)
{
Debug.LogError((object)("FAL_M203_FAILED: " + ex));
}
}
public void Configure(M203 native)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: 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_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0376: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)native == (Object)null || (Object)(object)native.Fore == (Object)null || (Object)(object)native.Chamber == (Object)null || (Object)(object)((AttachableFirearm)native).Interface == (Object)null)
{
throw new Exception("Incomplete native M203");
}
Launcher = native;
AttachableFirearmPhysicalObject attachment = ((AttachableFirearm)native).Attachment;
((Component)attachment).transform.SetParent(((Component)Mount).transform, false);
((Component)attachment).transform.localPosition = Vector3.zero;
((Component)attachment).transform.localRotation = Quaternion.identity;
((Component)attachment).transform.localScale = Vector3.one;
Vector3 val = ((Component)native.Fore).transform.position - native.Fore.Point_Rearward.position;
Transform transform = ((Component)attachment).transform;
transform.position += AuthoredMuzzle.position - (((AttachableFirearm)native).MuzzlePos.position - val);
((AttachableFirearm)native).OverrideFA = (FVRFireArm)(object)Firearm;
((AttachableForegrip)((AttachableFirearm)native).Interface).OverrideFirearm = (FVRFireArm)(object)Firearm;
((FVRFireArmAttachmentInterface)((AttachableFirearm)native).Interface).IsLocked = true;
((FVRFireArmAttachmentInterface)((AttachableFirearm)native).Interface).ForceInteractable = true;
((Component)native.Chamber).transform.position = AuthoredBreech.position + val + AuthoredBreech.forward * 0.0345112f;
native.Fore.EjectPos.position = AuthoredBreech.position - AuthoredBreech.forward * 0.01f + AuthoredBreech.up * 0.015f;
Renderer[] componentsInChildren = ((Component)native).GetComponentsInChildren<Renderer>(true);
foreach (Renderer val2 in componentsInChildren)
{
if (!((Object)(object)((Component)val2).transform == (Object)(object)BarrelArt) && !((Component)val2).transform.IsChildOf(BarrelArt))
{
val2.enabled = (Object)(object)val2 == (Object)(object)native.Chamber.ProxyRenderer;
}
}
Collider[] componentsInChildren2 = ((Component)native).GetComponentsInChildren<Collider>(true);
foreach (Collider val3 in componentsInChildren2)
{
if (!((Object)(object)((Component)val3).transform == (Object)(object)BarrelArt) && !((Component)val3).transform.IsChildOf(BarrelArt))
{
val3.enabled = val3.isTrigger && ((Object)(object)((Component)val3).GetComponent<M203_Fore>() != (Object)null || (Object)(object)((Component)val3).GetComponent<AttachableFirearmInterface>() != (Object)null || (Object)(object)((Component)val3).GetComponent<FVRFireArmChamber>() != (Object)null);
}
}
if ((Object)(object)BarrelArt.parent != (Object)(object)((Component)native.Fore).transform)
{
Transform barrelArt = BarrelArt;
barrelArt.position += val;
}
BarrelArt.SetParent(((Component)native.Fore).transform, true);
CapsuleCollider component = ((Component)native.Fore).GetComponent<CapsuleCollider>();
if ((Object)(object)component != (Object)null)
{
component.direction = 2;
component.radius = 0.029f;
component.height = 0.15f;
Transform transform2 = ((Component)native.Fore).transform;
Bounds bounds = ((Component)BarrelArt).GetComponent<Renderer>().bounds;
component.center = transform2.InverseTransformPoint(((Bounds)(ref bounds)).center);
}
((Component)((AttachableFirearm)native).Interface).transform.position = AuthoredGrip.position;
BoxCollider component2 = ((Component)((AttachableFirearm)native).Interface).GetComponent<BoxCollider>();
if ((Object)(object)component2 != (Object)null)
{
component2.center = Vector3.zero;
component2.size = new Vector3(0.05f, 0.055f, 0.05f);
}
if ((Object)(object)((AttachableForegrip)((AttachableFirearm)native).Interface).ForePosePoint != (Object)null)
{
((AttachableForegrip)((AttachableFirearm)native).Interface).ForePosePoint.position = AuthoredGrip.position;
((AttachableForegrip)((AttachableFirearm)native).Interface).ForePosePoint.rotation = ((FVRInteractiveObject)Firearm).PoseOverride.rotation;
}
native.Chamber.IsManuallyChamberable = true;
Ready = true;
Debug.Log((object)"FAL_M203_READY: native single-shot 40mm, source sliding barrel, separate firing grip");
}
private void OnDestroy()
{
if ((Object)(object)Mount == (Object)null)
{
return;
}
FVRFireArmAttachment[] array = Mount.AttachmentsList.ToArray();
foreach (FVRFireArmAttachment val in array)
{
if ((Object)(object)val != (Object)null && (Object)(object)((FVRPhysicalObject)val).ObjectWrapper != (Object)null && ((FVRPhysicalObject)val).ObjectWrapper.ItemID == "M203Picatinny")
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
}
}
namespace LocalTest.FALCamoPrototype
{
[BepInPlugin("LocalTest.FALCamoPrototype", "FALCamoPrototype", "0.1.2")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class FALCamoPrototypePlugin : 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(), "LocalTest.FALCamoPrototype");
OtherLoader.RegisterDirectLoad(BasePath, "LocalTest.FALCamoPrototype", "", "", "fal_camo", "");
}
}
}