using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using Receiver2;
using Receiver2ModdingKit;
using Receiver2ModdingKit.CustomSounds;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInPlugin("CiarenceW.Saiga9", "Saiga-9", "1.0.0")]
public class Saiga9Loader : BaseUnityPlugin
{
public void Awake()
{
BepInPlugin customAttribute = ((MemberInfo)((object)this).GetType()).GetCustomAttribute<BepInPlugin>();
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{customAttribute.GUID} version {customAttribute.Version} loaded!");
}
}
namespace Saiga9;
public class Saiga9 : ModGunScript
{
public RotateMover stockRotateMover;
public float _hammerAccel = 5000f;
private float lastTriggerAmount;
[NonSerialized]
[HideInInspector]
public float[] slide_push_hammer_curve = new float[4] { 0f, 0f, 0.3f, 1f };
public override void InitializeGun()
{
((GunScript)this).pooled_muzzle_flash = ReceiverCoreScript.Instance().GetGunPrefab((GunModel)1).pooled_muzzle_flash;
}
public override void AwakeGun()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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)
stockRotateMover = new RotateMover();
((SimpleMover)stockRotateMover).transform = ((Component)this).transform.Find("stock");
stockRotateMover.rotations[0] = ((Component)this).transform.Find("stock_unfolded").rotation;
stockRotateMover.rotations[1] = ((Component)this).transform.Find("stock_folded").rotation;
((SimpleMover)((GunScript)this).hammer).accel = _hammerAccel;
((SimpleMover)((GunScript)this).hammer).amount = 1f;
}
public override void OnHolster()
{
ToggleStock();
}
public override void OnUnholster()
{
ToggleStock();
}
public override void UpdateGun()
{
if (((GunScript)this).trigger.amount == 1f && lastTriggerAmount < ((GunScript)this).trigger.amount)
{
ModAudioManager.PlayOneShotAttached("event:/Saiga9/saiga9_trigger_pressed", ((GunScript)this).trigger.transform);
}
lastTriggerAmount = ((GunScript)this).trigger.amount;
((SimpleMover)((GunScript)this).hammer).asleep = true;
if (((SimpleMover)((GunScript)this).slide).amount > 0f && ((ModGunScript)this)._hammer_state != 3)
{
((SimpleMover)((GunScript)this).hammer).amount = Mathf.Max(((SimpleMover)((GunScript)this).hammer).amount, ModGunScript.InterpCurve(ref slide_push_hammer_curve, ((SimpleMover)((GunScript)this).slide).amount));
}
((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
if (((SimpleMover)((GunScript)this).hammer).amount == 1f)
{
((ModGunScript)this)._hammer_state = 3;
}
if (((GunScript)this).IsSafetyOn())
{
((GunScript)this).trigger.amount = Mathf.Min(((GunScript)this).trigger.amount, 0.1f);
((GunScript)this).trigger.UpdateDisplay();
}
if (((SimpleMover)((GunScript)this).hammer).amount == 0f && ((ModGunScript)this)._hammer_state == 2)
{
((ModGunScript)this).TryFireBullet(1f, (Action<ShellCasingScript>)((GunScript)this).FireBullet);
((ModGunScript)this)._hammer_state = 0;
}
if (!((ModGunScript)this)._disconnector_needs_reset)
{
((ModGunScript)this)._disconnector_needs_reset = ((SimpleMover)((GunScript)this).slide).amount > 0f && ((GunScript)this).trigger.amount > 0f;
}
if (((GunScript)this).trigger.amount == 0f)
{
if (((ModGunScript)this)._disconnector_needs_reset)
{
ModAudioManager.PlayOneShotAttached("event:/Saiga9/saiga9_trigger_reset", ((GunScript)this).trigger.transform);
}
((ModGunScript)this)._disconnector_needs_reset = false;
}
if (((SimpleMover)((GunScript)this).slide).amount == 0f && ((ModGunScript)this)._hammer_state == 3 && !((ModGunScript)this)._disconnector_needs_reset)
{
((SimpleMover)((GunScript)this).hammer).amount = Mathf.MoveTowards(((SimpleMover)((GunScript)this).hammer).amount, ((ModGunScript)this)._hammer_cocked_val, Time.deltaTime * Time.timeScale * 50f);
if (((SimpleMover)((GunScript)this).hammer).amount == ((ModGunScript)this)._hammer_cocked_val)
{
((ModGunScript)this)._hammer_state = 2;
}
}
if (((ModGunScript)this)._hammer_state != 3 && ((((GunScript)this).trigger.amount == 1f && !((ModGunScript)this)._disconnector_needs_reset && ((SimpleMover)((GunScript)this).slide).amount == 0f) || ((SimpleMover)((GunScript)this).hammer).amount != ((ModGunScript)this)._hammer_cocked_val))
{
((SimpleMover)((GunScript)this).hammer).asleep = false;
}
((SimpleMover)((GunScript)this).hammer).TimeStep(Time.deltaTime);
((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
((SimpleMover)stockRotateMover).UpdateDisplay();
((SimpleMover)stockRotateMover).TimeStep(Time.deltaTime);
((SimpleMover)stockRotateMover).UpdateDisplay();
}
private void ToggleStock()
{
((SimpleMover)stockRotateMover).asleep = false;
if (((SimpleMover)stockRotateMover).target_amount == 1f)
{
((SimpleMover)stockRotateMover).target_amount = 0f;
((SimpleMover)stockRotateMover).accel = -1f;
((SimpleMover)stockRotateMover).vel = -3f;
AudioManager.PlayOneShotAttached("event:/Saiga9/saiga9_unholster", ((Component)((SimpleMover)stockRotateMover).transform).gameObject);
}
else if (((SimpleMover)stockRotateMover).target_amount == 0f)
{
((SimpleMover)stockRotateMover).target_amount = 1f;
((SimpleMover)stockRotateMover).accel = 1f;
((SimpleMover)stockRotateMover).vel = 3f;
AudioManager.PlayOneShotAttached("event:/Saiga9/saiga9_holster", ((Component)((SimpleMover)stockRotateMover).transform).gameObject);
}
}
}