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")]
namespace AR410;
public class AR410 : ModGunScript
{
private float slide_forward_speed = -50f;
private float hammer_accel = -8000f;
private float m_charging_handle_amount;
private readonly float[] slide_push_hammer_curve = new float[6] { 0f, 0f, 0.25f, 0.8f, 0.5f, 0.95f };
public override void AwakeGun()
{
((SimpleMover)((GunScript)this).hammer).amount = 1f;
}
public override void OnHolster()
{
ModAudioManager.PlayOneShotAttached("event:/AR410/AR410_holster", ((Component)this).transform);
}
public override void OnUnholster()
{
ModAudioManager.PlayOneShotAttached("event:/AR410/AR410_unholster", ((Component)this).transform);
}
private void FireBulletShotgun(ShellCasingScript round)
{
//IL_0009: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_0043: 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_0083: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
((GunScript)this).chamber_check_performed = false;
CartridgeSpec val = default(CartridgeSpec);
((CartridgeSpec)(ref val)).SetFromPreset(round.cartridge_type);
LocalAimHandler holdingPlayer = ((GunScript)this).GetHoldingPlayer();
Vector3 val2 = ((GunScript)this).transform_bullet_fire.rotation * Vector3.forward;
BulletTrajectory val3 = BulletTrajectoryManager.PlanTrajectory(((GunScript)this).transform_bullet_fire.position, val, val2, ((GunScript)this).right_hand_twist);
if (ConfigFiles.global.display_trajectory_window && ConfigFiles.global.display_trajectory_window_show_debug)
{
val3.draw_path = (DrawType)1;
}
else if (round.tracer || GunScript.force_tracers)
{
val3.draw_path = (DrawType)2;
val3.tracer_fuse = true;
}
if ((Object)(object)holdingPlayer != (Object)null)
{
val3.bullet_source = ((Component)this).gameObject;
val3.bullet_source_entity_type = (ReceiverEntityType)19;
}
else
{
val3.bullet_source = ((Component)this).gameObject;
val3.bullet_source_entity_type = (ReceiverEntityType)20;
}
BulletTrajectoryManager.ExecuteTrajectory(val3);
((GunScript)this).rotation_transfer_y = ((GunScript)this).rotation_transfer_y + Random.Range(((GunScript)this).rotation_transfer_y_min, ((GunScript)this).rotation_transfer_y_max);
((GunScript)this).rotation_transfer_x = ((GunScript)this).rotation_transfer_x + Random.Range(((GunScript)this).rotation_transfer_x_min, ((GunScript)this).rotation_transfer_x_max);
((GunScript)this).recoil_transfer_x = ((GunScript)this).recoil_transfer_x - Random.Range(((GunScript)this).recoil_transfer_x_min, ((GunScript)this).recoil_transfer_x_max);
((GunScript)this).recoil_transfer_y = ((GunScript)this).recoil_transfer_y + Random.Range(((GunScript)this).recoil_transfer_y_min, ((GunScript)this).recoil_transfer_y_max);
((GunScript)this).add_head_recoil = true;
if (((GunScript)this).CanMalfunction && (int)((GunScript)this).malfunction == 0 && (Random.Range(0f, 1f) < ((GunScript)this).doubleFeedProbability || ((GunScript)this).force_double_feed_failure))
{
if (((GunScript)this).force_double_feed_failure && ((GunScript)this).force_just_one_failure)
{
((GunScript)this).force_double_feed_failure = false;
}
((GunScript)this).malfunction = (Malfunction)2;
ReceiverEvents.TriggerEvent((ReceiverEventTypeInt)10, 2);
}
ReceiverEvents.TriggerEvent((ReceiverEventTypeVoid)0);
((GunScript)this).last_time_fired = Time.time;
((GunScript)this).last_frame_fired = Time.frameCount;
((GunScript)this).dry_fired = false;
if (((GunScript)this).shots_until_dirty > 0)
{
((GunScript)this).shots_until_dirty = ((GunScript)this).shots_until_dirty - 1;
}
((GunScript)this).yoke_stage = (YokeStage)0;
}
private void TryFireBulletShotgun()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: 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)
Vector3 localEulerAngles = ((Component)this).transform.Find("point_bullet_fire").localEulerAngles;
Transform transform_bullet_fire = ((GunScript)this).transform_bullet_fire;
transform_bullet_fire.localEulerAngles += new Vector3(Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f), 0f);
((ModGunScript)this).TryFireBullet(1f);
if (!((GunScript)this).dry_fired)
{
((GunScript)this).transform_bullet_fire.localEulerAngles = localEulerAngles;
for (int i = 0; i < 7; i++)
{
float num = Random.Range(0f, 3.7699115f);
float num2 = Random.Range(0f, 1.2f);
float num3 = Mathf.Sin(num) * num2;
float num4 = Mathf.Cos(num) * num2;
Transform transform_bullet_fire2 = ((GunScript)this).transform_bullet_fire;
transform_bullet_fire2.localEulerAngles += new Vector3(num3, num4, 0f);
FireBulletShotgun(((GunScript)this).round_in_chamber);
((GunScript)this).transform_bullet_fire.localEulerAngles = localEulerAngles;
}
}
}
public override void UpdateGun()
{
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0352: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
((SimpleMover)((GunScript)this).hammer).asleep = true;
((SimpleMover)((GunScript)this).hammer).accel = hammer_accel;
if (((SimpleMover)((GunScript)this).slide).amount > 0f)
{
((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 > ((ModGunScript)this)._hammer_cocked_val)
{
((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).slide).amount == 0f && ((ModGunScript)this)._hammer_state == 3 && ((GunScript)this).trigger.amount == 1f)
{
((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 (((SimpleMover)((GunScript)this).hammer).amount == 0f && ((ModGunScript)this)._hammer_state == 2)
{
TryFireBulletShotgun();
((ModGunScript)this)._hammer_state = 0;
}
if (((SimpleMover)((GunScript)this).slide).vel < 0f)
{
((SimpleMover)((GunScript)this).slide).vel = Mathf.Max(((SimpleMover)((GunScript)this).slide).vel, slide_forward_speed);
}
if (((SimpleMover)((GunScript)this).slide_stop).amount == 1f)
{
((SimpleMover)((GunScript)this).slide_stop).asleep = true;
}
if (((SimpleMover)((GunScript)this).slide).amount == 0f && ((ModGunScript)this)._hammer_state == 3)
{
((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 >= 0.5f && ((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);
if (((ModGunScript)this).player_input.GetButton(10) || ((ModGunScript)this).player_input.GetButtonUp(10))
{
m_charging_handle_amount = Mathf.MoveTowards(m_charging_handle_amount, ((SimpleMover)((GunScript)this).slide).amount, Time.deltaTime * 20f / Time.timeScale);
}
else
{
m_charging_handle_amount = Mathf.MoveTowards(m_charging_handle_amount, 0f, Time.deltaTime * 50f);
}
((GunScript)this).ApplyTransform("charging_handle", m_charging_handle_amount, ((Component)this).transform.Find("charging_handle"));
((GunScript)this).ApplyTransform("charging_handle_latch", m_charging_handle_amount, ((Component)this).transform.Find("charging_handle/charging_handle_latch"));
Vector3 val = default(Vector3);
Vector3 val2 = default(Vector3);
((GunScript)this).ApplyTransform("charging_handle_pull", m_charging_handle_amount, ref val2, ref val);
((Component)this).transform.Find("charging_handle/charging_handle_pull_left").localEulerAngles = val;
((Component)this).transform.Find("charging_handle/charging_handle_pull_right").localEulerAngles = -val;
((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
((SimpleMover)((GunScript)this).slide_stop).UpdateDisplay();
}
}
[BepInPlugin("CiarenceW.AR410", "AR410", "1.0.0")]
public class AR410_BaseUnityPlugin : BaseUnityPlugin
{
private void Awake()
{
BepInPlugin bepInAttribute = Extensions.GetBepInAttribute((BaseUnityPlugin)(object)this);
Extensions.LogDebugWithColor(((BaseUnityPlugin)this).Logger, (object)$"Plugin {bepInAttribute.GUID} version {bepInAttribute.Version} ", ConsoleColor.Green);
}
}