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 BitWizrd.HuntNagantM1895OfficerCarbine
{
[BepInPlugin("BitWizrd.HuntNagantM1895OfficerCarbine", "HuntNagantM1895OfficerCarbine", "1.0.2")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class HuntNagantM1895OfficerCarbinePlugin : 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(), "BitWizrd.HuntNagantM1895OfficerCarbine");
OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.HuntNagantM1895OfficerCarbine", "", "m1895nagant_oc", "", "");
}
}
}
namespace BitWizrd.RevolverMod
{
public class DoubleActionEjectorRod : FVRInteractiveObject
{
public DoubleActionLoadingGateRevolver revolver;
}
public class DoubleActionLoadingGateRevolver : SingleActionRevolver
{
[SerializeField]
private bool disableFanning = false;
private bool singleActionMode = false;
private bool m_hasTriggerCycled = false;
private float da_targetTriggerFloat = 0f;
private float da_currentTriggerFloat = 0f;
private bool da_isHammerCocking = false;
private float da_triggerRotation = 0f;
private float da_hammerRotation = 0f;
private float da_cylinderLerp = 0f;
private bool da_hasFired = false;
[SerializeField]
public bool doesCylinderSealForward = false;
private bool isCylinderSealedForward = false;
private bool m_hasTriggeredUpSinceBeginWeapon = false;
private void Update()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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)
if (disableFanning && (Object)(object)base.HammerFanDir != (Object)null)
{
base.HammerFanDir.localPosition = new Vector3(base.HammerFanDir.localPosition.x, base.HammerFanDir.localPosition.y, base.HammerFanDir.localPosition.z - 1f);
}
}
public override void BeginInteraction(FVRViveHand hand)
{
((SingleActionRevolver)this).BeginInteraction(hand);
if (hand.Input.TriggerPressed)
{
m_hasTriggeredUpSinceBeginWeapon = false;
}
else
{
m_hasTriggeredUpSinceBeginWeapon = true;
}
}
public override void EndInteraction(FVRViveHand hand)
{
((SingleActionRevolver)this).EndInteraction(hand);
m_hasTriggeredUpSinceBeginWeapon = false;
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_0090: 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)
float triggerFloat = hand.Input.TriggerFloat;
if (!m_hasTriggeredUpSinceBeginWeapon)
{
if (!hand.Input.TriggerPressed)
{
m_hasTriggeredUpSinceBeginWeapon = true;
da_currentTriggerFloat = 0f;
da_targetTriggerFloat = 0f;
}
}
else
{
if (!base.m_isStateToggled && m_hasTriggerCycled && triggerFloat > 0.1f && ((!hand.IsInStreamlinedMode && hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f) || (hand.IsInStreamlinedMode && hand.Input.AXButtonDown)))
{
return;
}
((SingleActionRevolver)this).UpdateInteraction(hand);
if (base.m_isHammerCocked)
{
singleActionMode = true;
ResetDoubleActionVariables();
return;
}
if (singleActionMode)
{
if (!base.m_isHammerCocked)
{
m_hasTriggerCycled = true;
singleActionMode = false;
}
return;
}
if (m_hasTriggerCycled)
{
if (triggerFloat <= 0.1f)
{
m_hasTriggerCycled = false;
ResetDoubleActionVariables();
da_hasFired = false;
if (doesCylinderSealForward && isCylinderSealedForward)
{
MoveCylinderToBackPosition();
isCylinderSealedForward = false;
}
}
else if (doesCylinderSealForward && isCylinderSealedForward)
{
MoveCylinderToFrontPosition();
}
return;
}
if (!base.m_isStateToggled && triggerFloat > 0.1f)
{
HandleDoubleActionTriggerPull(triggerFloat, hand);
}
else
{
ResetDoubleActionVariables();
da_hasFired = false;
if (doesCylinderSealForward && isCylinderSealedForward)
{
MoveCylinderToBackPosition();
isCylinderSealedForward = false;
}
}
if (doesCylinderSealForward && isCylinderSealedForward && triggerFloat > 0.1f)
{
MoveCylinderToFrontPosition();
}
}
}
private void HandleDoubleActionTriggerPull(float triggerAmount, FVRViveHand hand)
{
if (!singleActionMode && !base.m_isHammerCocked)
{
da_targetTriggerFloat = triggerAmount;
da_currentTriggerFloat = Mathf.MoveTowards(da_currentTriggerFloat, da_targetTriggerFloat, Time.deltaTime * 14f);
AnimateDoubleActionTrigger(da_currentTriggerFloat);
AnimateDoubleActionHammer(da_currentTriggerFloat);
AnimateDoubleActionCylinder(da_currentTriggerFloat);
if (!da_isHammerCocking && da_currentTriggerFloat > 0f)
{
da_isHammerCocking = true;
}
if (da_currentTriggerFloat >= 0.95f && !da_hasFired)
{
FireDoubleAction(triggerAmount);
m_hasTriggerCycled = true;
da_isHammerCocking = false;
da_hasFired = true;
isCylinderSealedForward = true;
}
}
}
private void AnimateDoubleActionTrigger(float triggerAmount)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.Trigger != (Object)null)
{
da_triggerRotation = Mathf.Lerp(base.Trigger_Rot_Forward, base.Trigger_Rot_Rearward, triggerAmount);
base.Trigger.localRotation = Quaternion.Euler(da_triggerRotation, 0f, 0f);
}
}
private void AnimateDoubleActionHammer(float triggerAmount)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.Hammer != (Object)null)
{
if (da_hasFired)
{
da_hammerRotation = base.Hammer_Rot_Uncocked;
}
else
{
da_hammerRotation = Mathf.Lerp(base.Hammer_Rot_Uncocked, base.Hammer_Rot_Cocked, triggerAmount);
}
base.Hammer.localRotation = Quaternion.Euler(da_hammerRotation, 0f, 0f);
}
}
private void AnimateDoubleActionCylinder(float triggerAmount)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_0041: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)base.Cylinder != (Object)null) || base.m_isStateToggled)
{
return;
}
if (da_hasFired)
{
((Component)base.Cylinder).transform.localRotation = base.Cylinder.GetLocalRotationFromCylinder(((SingleActionRevolver)this).CurChamber);
}
else
{
da_cylinderLerp = triggerAmount;
int num = (((SingleActionRevolver)this).CurChamber + 1) % base.Cylinder.NumChambers;
((Component)base.Cylinder).transform.localRotation = Quaternion.Slerp(base.Cylinder.GetLocalRotationFromCylinder(((SingleActionRevolver)this).CurChamber), base.Cylinder.GetLocalRotationFromCylinder(num), da_cylinderLerp);
}
if (doesCylinderSealForward)
{
if (isCylinderSealedForward)
{
((Component)base.Cylinder).transform.localPosition = base.CylinderFrontPos;
}
else
{
((Component)base.Cylinder).transform.localPosition = Vector3.Lerp(base.CylinderBackPos, base.CylinderFrontPos, triggerAmount);
}
}
}
private void FireDoubleAction(float triggerAmount)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
((SingleActionRevolver)this).CurChamber = (((SingleActionRevolver)this).CurChamber + 1) % base.Cylinder.NumChambers;
((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f);
FVRFireArmChamber val = base.Cylinder.Chambers[((SingleActionRevolver)this).CurChamber];
if (val.Fire())
{
((FVRFireArm)this).Fire(val, ((FVRFireArm)this).GetMuzzle(), true, 1f, -1f);
((FVRFireArm)this).FireMuzzleSmoke();
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);
((FVRFireArm)this).PlayAudioGunShot(val.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f);
if (GM.CurrentSceneSettings.IsAmmoInfinite || GM.CurrentPlayerBody.IsInfiniteAmmo)
{
val.IsSpent = false;
val.UpdateProxyDisplay();
}
}
da_currentTriggerFloat = triggerAmount;
da_targetTriggerFloat = da_currentTriggerFloat;
}
private void MoveCylinderToFrontPosition()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.Cylinder != (Object)null)
{
((Component)base.Cylinder).transform.localPosition = base.CylinderFrontPos;
}
}
private void MoveCylinderToBackPosition()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.Cylinder != (Object)null)
{
((Component)base.Cylinder).transform.localPosition = base.CylinderBackPos;
}
}
private void ResetDoubleActionVariables()
{
da_isHammerCocking = false;
da_hammerRotation = base.Hammer_Rot_Uncocked;
da_triggerRotation = base.Trigger_Rot_Forward;
da_cylinderLerp = 0f;
da_currentTriggerFloat = 0f;
da_targetTriggerFloat = 0f;
}
}
}