using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
[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 FireAttachableFireSelector : MonoBehaviour
{
[Header("Selector Settings")]
public Transform selectorTransform;
public Vector3 onRotation = new Vector3(0f, 45f, 0f);
private Quaternion startRot;
private bool isOn;
private FVRPhysicalObject rootFPO;
private void Awake()
{
//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)
if ((Object)(object)selectorTransform == (Object)null)
{
selectorTransform = ((Component)this).transform;
}
startRot = selectorTransform.localRotation;
rootFPO = ((Component)this).GetComponentInParent<FVRPhysicalObject>();
if ((Object)(object)rootFPO == (Object)null)
{
Debug.LogError((object)"[FireSelector] No FVRPhysicalObject found in parents!");
}
}
private void Update()
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rootFPO == (Object)null) && ((FVRInteractiveObject)rootFPO).IsHeld && !((Object)(object)((FVRInteractiveObject)rootFPO).m_hand == (Object)null))
{
HandleInput(((FVRInteractiveObject)rootFPO).m_hand);
selectorTransform.localRotation = ((!isOn) ? startRot : (startRot * Quaternion.Euler(onRotation)));
}
}
private void HandleInput(FVRViveHand hand)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
HandInput input = hand.Input;
if (hand.IsInStreamlinedMode)
{
if (input.BYButtonDown)
{
isOn = !isOn;
}
}
else if (input.TouchpadDown && ((Vector2)(ref input.TouchpadAxes)).magnitude > 0.2f && Vector2.Angle(input.TouchpadAxes, Vector2.left) <= 45f)
{
isOn = !isOn;
}
}
}
namespace Volks.AICW;
[BepInPlugin("Volks.AICW", "AICW", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class AICWPlugin : 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.AICW");
OtherLoader.RegisterDirectLoad(BasePath, "Volks.AICW", "", "", "aicw_gun", "");
}
}
public class Pansarvarnsgevar_Latch : FVRInteractiveObject
{
public enum PGLatchType
{
Main,
Lock
}
public enum PGLatchState
{
Closed,
Middle,
Open
}
public Pansarvarnsgevar_Launcher PG;
public PGLatchType LType;
public PGLatchState LState;
public float RotMin;
public float RotMax;
public bool IsMinOpen;
public AudioEvent AudEvent_Open;
public AudioEvent AudEvent_Close;
public Transform BaseZeroDir;
private float m_curRot;
private float m_tarRot;
public bool DisablesUseWhenNotInGivenState = true;
public Pansarvarnsgevar_Latch RestrictingLatch;
public PGLatchState RequiredState = PGLatchState.Open;
public bool DoesPartialChamberingBlock;
public bool IsOpen()
{
return LState == PGLatchState.Open;
}
public override bool IsInteractable()
{
return (!DoesPartialChamberingBlock || !PG.Chamber.IsFull || PG.ShellInsertEject.CSState == Pansarvarnsgevar_ShellEject.ChamberSlideState.In) && (!DisablesUseWhenNotInGivenState || RestrictingLatch.LState == RequiredState) && ((FVRInteractiveObject)this).IsInteractable();
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//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_0023: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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)
((FVRInteractiveObject)this).UpdateInteraction(hand);
Vector3 val = ((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position;
val = Vector3.ProjectOnPlane(val, BaseZeroDir.up);
float signedAngle = GetSignedAngle(val, BaseZeroDir.forward, BaseZeroDir.up);
signedAngle = Mathf.Clamp(signedAngle, RotMin, RotMax);
m_tarRot = signedAngle;
}
public override void EndInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).EndInteraction(hand);
float num = Mathf.Abs(m_curRot - RotMin);
float num2 = Mathf.Abs(m_curRot - RotMax);
if (num < num2)
{
m_tarRot = RotMin;
}
else
{
m_tarRot = RotMax;
}
}
protected void FVRUpdate()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
if (!(Mathf.Abs(m_curRot - m_tarRot) > 0.001f))
{
return;
}
m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * 900f);
((Component)this).transform.localEulerAngles = new Vector3(0f, m_curRot, 0f);
float num = Mathf.Abs(m_curRot - RotMin);
float num2 = Mathf.Abs(m_curRot - RotMax);
PGLatchState lState = LState;
if (num < 1f)
{
if (IsMinOpen)
{
LState = PGLatchState.Open;
}
else
{
LState = PGLatchState.Closed;
}
}
else if (num2 < 1f)
{
if (IsMinOpen)
{
LState = PGLatchState.Closed;
}
else
{
LState = PGLatchState.Open;
}
}
else
{
LState = PGLatchState.Middle;
}
if (LState == PGLatchState.Closed && lState != 0)
{
((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_Close, ((Component)this).transform.position);
}
else if (LState == PGLatchState.Open && lState != PGLatchState.Open)
{
((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_Open, ((Component)this).transform.position);
}
}
public float GetSignedAngle(Vector3 from, Vector3 to, Vector3 axis)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = Vector3.ProjectOnPlane(from, axis);
from = ((Vector3)(ref val)).normalized;
Vector3 val2 = Vector3.Cross(axis, to);
float num = Mathf.Sign(Vector3.Dot(from, val2));
float num2 = Vector3.Angle(from, to);
return num2 * num;
}
}
public class Pansarvarnsgevar_Launcher : FVRFireArm
{
public FVRFireArmChamber Chamber;
public Pansarvarnsgevar_ShellEject ShellInsertEject;
public Pansarvarnsgevar_Latch TailLatch;
public Transform Trigger;
public float TriggerFiringThreshold = 0.8f;
public float TriggerResetThreshold = 0.4f;
public float Trigger_ForwardValue;
public float Trigger_RearwardValue;
private float m_triggerFloat;
private float m_lastTriggerFloat;
private bool m_hasTriggerReset;
public AudioEvent AudEvent_BackSound;
public Transform COM;
protected void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
((FVRFireArm)this).Awake();
base.FChambers.Add(Chamber);
((FVRPhysicalObject)this).RootRigidbody.centerOfMass = COM.localPosition;
}
public void FixCOM()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
((FVRPhysicalObject)this).RootRigidbody.centerOfMass = COM.localPosition;
}
protected void FVRUpdate()
{
((FVRFireArm)this).FVRUpdate();
if (TailLatch.LState == Pansarvarnsgevar_Latch.PGLatchState.Open)
{
Chamber.IsAccessible = true;
}
else
{
Chamber.IsAccessible = false;
}
if (Mathf.Abs(m_triggerFloat - m_lastTriggerFloat) > 0.0001f)
{
m_lastTriggerFloat = m_triggerFloat;
((FVRPhysicalObject)this).SetAnimatedComponent(Trigger, Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat), (InterpStyle)1, (Axis)0);
}
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
((FVRPhysicalObject)this).UpdateInteraction(hand);
if (((FVRPhysicalObject)this).IsAltHeld)
{
m_triggerFloat = 0f;
return;
}
if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && m_triggerFloat < TriggerResetThreshold)
{
if (hand.IsInStreamlinedMode)
{
if (hand.Input.AXButtonDown)
{
ReleaseHammer();
}
}
else
{
Vector2 touchpadAxes = hand.Input.TouchpadAxes;
if (hand.Input.TouchpadDown && Vector2.Angle(touchpadAxes, Vector2.down) <= 45f)
{
ReleaseHammer();
}
}
}
if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin)
{
m_triggerFloat = hand.Input.TriggerFloat;
}
else
{
m_triggerFloat = 0f;
}
if (!m_hasTriggerReset && m_triggerFloat <= TriggerResetThreshold)
{
m_hasTriggerReset = true;
((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f);
}
if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && m_triggerFloat >= TriggerFiringThreshold && TailLatch.LState == Pansarvarnsgevar_Latch.PGLatchState.Closed && m_hasTriggerReset)
{
ReleaseHammer();
m_hasTriggerReset = false;
}
}
private void ReleaseHammer()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f);
if (Chamber.Fire())
{
((FVRFireArm)this).PlayAudioGunShot(Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f);
((FVRFireArm)this).Fire(Chamber, ((FVRFireArm)this).GetMuzzle(), true, 1f, -1f);
((FVRFireArm)this).FireMuzzleSmoke();
SM.PlayCoreSound((FVRPooledAudioType)5, AudEvent_BackSound, ((Component)TailLatch).transform.position);
bool flag = ((FVRFireArm)this).IsTwoHandStabilized();
bool flag2 = (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null;
bool flag3 = ((FVRFireArm)this).IsShoulderStabilized();
((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f);
}
}
}
public class Pansarvarnsgevar_ShellEject : FVRInteractiveObject
{
public enum ChamberSlideState
{
In,
Middle,
Out
}
public Pansarvarnsgevar_Launcher PG;
public AudioEvent AudEvent_ShellInStart;
public AudioEvent AudEvent_ShellIn;
public AudioEvent AudEvent_ShellOutStart;
public AudioEvent AudEvent_ShellOut;
public Transform ChamberPoint_Back;
public Transform ChamberPoint_Forward;
public Collider Col;
public ChamberSlideState CSState = ChamberSlideState.Out;
private float m_curZ;
private float m_tarZ;
public float ZThreshold = 0.02f;
private float m_timeHeld;
protected 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)
((FVRInteractiveObject)this).Awake();
m_curZ = ChamberPoint_Back.localPosition.z;
m_tarZ = m_curZ;
}
public override bool IsInteractable()
{
return PG.Chamber.IsFull && PG.TailLatch.LState == Pansarvarnsgevar_Latch.PGLatchState.Open;
}
public override void UpdateInteraction(FVRViveHand hand)
{
//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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
((FVRInteractiveObject)this).UpdateInteraction(hand);
float tarZ = Mathf.Clamp(((Component)PG).transform.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).z, ChamberPoint_Back.localPosition.z, ChamberPoint_Forward.localPosition.z);
m_tarZ = tarZ;
}
public override void EndInteraction(FVRViveHand hand)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).EndInteraction(hand);
float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z);
float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z);
if (num < ZThreshold * 2f)
{
m_tarZ = ChamberPoint_Back.localPosition.z;
}
else if (num2 < ZThreshold * 2f)
{
m_tarZ = ChamberPoint_Forward.localPosition.z;
}
}
public override void BeginInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).BeginInteraction(hand);
m_timeHeld = 0f;
}
protected void FVRUpdate()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: 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_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: 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_01a8: 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_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
m_timeHeld += Time.deltaTime;
if (!(Mathf.Abs(m_curZ - m_tarZ) > 0.001f))
{
return;
}
m_curZ = Mathf.MoveTowards(m_curZ, m_tarZ, Time.deltaTime * 1f);
((Component)PG.Chamber).transform.localPosition = new Vector3(((Component)PG.Chamber).transform.localPosition.x, ((Component)PG.Chamber).transform.localPosition.y, m_curZ);
float num = Mathf.Abs(m_curZ - ChamberPoint_Back.localPosition.z);
float num2 = Mathf.Abs(m_curZ - ChamberPoint_Forward.localPosition.z);
ChamberSlideState cSState = CSState;
if (num < ZThreshold)
{
CSState = ChamberSlideState.Out;
}
else if (num2 < ZThreshold)
{
CSState = ChamberSlideState.In;
}
else
{
CSState = ChamberSlideState.Middle;
}
if (CSState == ChamberSlideState.Out && cSState != ChamberSlideState.Out)
{
((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellOut, ((Component)this).transform.position);
if (m_timeHeld > 0.2f)
{
FVRFireArmRound val = PG.Chamber.EjectRound(((Component)ChamberPoint_Back).transform.position, ChamberPoint_Back.forward * 0.1f, Vector3.zero, false);
if (((FVRInteractiveObject)this).IsHeld)
{
FVRViveHand hand = base.m_hand;
hand.ForceSetInteractable((FVRInteractiveObject)(object)val);
((FVRInteractiveObject)val).BeginInteraction(hand);
}
PG.FixCOM();
}
}
else if (CSState == ChamberSlideState.In && cSState != 0)
{
((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellIn, ((Component)this).transform.position);
((FVRInteractiveObject)this).ForceBreakInteraction();
PG.FixCOM();
}
else if (CSState == ChamberSlideState.Middle && cSState == ChamberSlideState.In)
{
((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellOutStart, ((Component)this).transform.position);
}
else if (CSState == ChamberSlideState.Middle && cSState == ChamberSlideState.Out)
{
((FVRFireArm)PG).PlayAudioAsHandling(AudEvent_ShellInStart, ((Component)this).transform.position);
}
}
}
public class FireFromMainHand : MonoBehaviour
{
public enum FireSelectorModeType
{
Safe,
Single,
FullAuto
}
public enum firearmActionMode
{
ClosedBolt,
BoltActionRifle,
OpenBolt
}
public FVRFireArm FireArm;
public AttachableFirearm AttachableFirearm;
public firearmActionMode FirearmActionMode = firearmActionMode.ClosedBolt;
public FireSelectorModeType MainWeaponFireMode = FireSelectorModeType.Single;
public AudioEvent SwitchSound;
private float triggerFW;
private float triggerRW;
private bool selectorOnMain = true;
private static Dictionary<FVRPhysicalObject, FireFromMainHand> fireAttachables = new Dictionary<FVRPhysicalObject, FireFromMainHand>();
}
public class SpawnEffect : MonoBehaviour
{
public float spawnEffectTime = 2f;
public float pause = 1f;
public AnimationCurve fadeIn;
private ParticleSystem ps;
private float timer = 0f;
private Renderer _renderer;
private int shaderProperty;
private void Start()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
shaderProperty = Shader.PropertyToID("_cutoff");
_renderer = ((Component)this).GetComponent<Renderer>();
ps = ((Component)this).GetComponentInChildren<ParticleSystem>();
MainModule main = ps.main;
((MainModule)(ref main)).duration = spawnEffectTime;
ps.Play();
}
private void Update()
{
if (timer < spawnEffectTime + pause)
{
timer += Time.deltaTime;
}
else
{
ps.Play();
timer = 0f;
}
_renderer.material.SetFloat(shaderProperty, fadeIn.Evaluate(Mathf.InverseLerp(0f, spawnEffectTime, timer)));
}
}
[CreateAssetMenu]
public class RampAsset : ScriptableObject
{
public Gradient gradient = new Gradient();
public int size = 16;
public bool up = false;
public bool overwriteExisting = true;
}