using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using Receiver2;
using Receiver2ModdingKit;
using Receiver2ModdingKit.Editor;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MR223_plugin;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Ciarencew.MR223", "MR-223", "1.2.0")]
public class Loader : BaseUnityPlugin
{
public static readonly string folder_name = "MR223_Files";
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Ciarencew.MR223 is loaded!");
}
}
public class MR223_Script : ModGunScript
{
private float hammer_accel = -5000f;
private float m_charging_handle_amount;
private ModHelpEntry help_entry;
public Sprite help_entry_sprite;
public Transform dust_cover_component;
private Vector3 magazine_nearly_empty_rot = new Vector3(-24f, -5f, 0f);
private Vector3 magazine_nearly_empty_pos = new Vector3(-0.1f, 0f, 0.2f);
private Vector3 magazine_rot = new Vector3(-25f, -60f, 0f);
private Vector3 magazine_pos = new Vector3(-0.1f, 0f, 0.15f);
private RotateMover dust_cover = new RotateMover();
private bool dust_cover_opened;
private bool slide_prepare_to_lock;
private bool separator_needs_reset;
private static bool receiver_broke_open;
private readonly float[] slide_push_hammer_curve = new float[4] { 0f, 0f, 0.35f, 1f };
private LocalAimHandler lah = LocalAimHandler.player_instance;
public override ModHelpEntry GetGunHelpEntry()
{
//IL_0006: 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_0017: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0034: Expected O, but got Unknown
ModHelpEntry val = new ModHelpEntry("MR223")
{
info_sprite = help_entry_sprite,
title = "Heckler & Koch MR223",
description = "Heckler & Koch Match Rifle .223 Remington\nCapacity: 10 + 1, 223 Remington\n\nBased on the AR-15 platform, the HK 416 improves on it thanks to its proprietary short-stroke gas piston, derived from the G36, itself derived from the AR-18. Thanks to this improvement, the H&K 416 outperformed the M4 in numerous tests conducted by the US Army's Delta Force.\n\nIn 2007, H&K introduced the MR223, the civilian variant of the 416, to the European market. This variant would later come to the US under the name of MR556.\n\nIn order to be compliant in states with stricter gun laws, civilians need to install special after-market parts, such as a pin that blocks the magazine from being removed until the receiver is opened, or a slide lock that locks open on every shot. Fortunately for them, loopholes that permit the rifle to function somewhat normally exist."
};
ModHelpEntry result = val;
help_entry = val;
return result;
}
public override LocaleTactics GetGunTactics()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
return new LocaleTactics
{
gun_internal_name = ((InventoryItem)this).InternalName,
title = "Heckler & Koch MR223\n",
text = "A modded semi-auto rifle, made on a cheese-based diet\nA .223 Remington semi-auto rifle made for the European sporting market, this gun functions mechanically the same as the H&K 416, without the auto fire mode.\n\nThis version of the gun is fitted with an auto-locking slide lock in an attempt to be California compliant.\nTo safely holster the MR223, flip on the safety."
};
}
public override void InitializeGun()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
((GunScript)this).pooled_muzzle_flash = ((GunScript)ReceiverCoreScript.Instance().generic_prefabs.First((InventoryItem it) => it is GunScript && (int)((GunScript)it).gun_model == 6)).pooled_muzzle_flash;
}
public override void AwakeGun()
{
//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_0063: 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)
((SimpleMover)((GunScript)this).hammer).amount = 1f;
((SimpleMover)dust_cover).transform = dust_cover_component;
dust_cover.rotations[0] = ((Component)this).transform.Find("dust_cover_closed").localRotation;
dust_cover.rotations[1] = ((Component)this).transform.Find("dust_cover_opened").localRotation;
}
public override void UpdateGun()
{
//IL_001d: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_00b0: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//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_007e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
GunScript val = default(GunScript);
DoubleStackMagazine val2 = default(DoubleStackMagazine);
if (LocalAimHandler.TryGetInstance(ref lah) && lah.TryGetGun(ref val) && val.gun_model == ((GunScript)this).gun_model && lah.TryGetItemInHandWithState<DoubleStackMagazine>((State)2, ref val2) && ((GunScript)this).magazine_root_types.Contains(((MagazineScript)val2).magazine_root_type))
{
if (((MagazineScript)val2).rounds_in_mag <= 3)
{
((InventoryItem)val2).hold_offset = magazine_nearly_empty_pos;
((InventoryItem)val2).hold_rotation = magazine_nearly_empty_rot;
}
else
{
((InventoryItem)val2).hold_offset = magazine_pos;
((InventoryItem)val2).hold_rotation = magazine_rot;
}
}
if ((Object)(object)((GunScript)this).magazine_instance_in_gun != (Object)null)
{
if (((GunScript)this).magazine_instance_in_gun.rounds_in_mag <= 3)
{
((InventoryItem)((GunScript)this).magazine_instance_in_gun).hold_offset = magazine_nearly_empty_pos;
((InventoryItem)((GunScript)this).magazine_instance_in_gun).hold_rotation = magazine_nearly_empty_rot;
}
else
{
((InventoryItem)((GunScript)this).magazine_instance_in_gun).hold_offset = magazine_pos;
((InventoryItem)((GunScript)this).magazine_instance_in_gun).hold_rotation = magazine_rot;
}
}
((SimpleMover)((GunScript)this).hammer).asleep = true;
((SimpleMover)((GunScript)this).hammer).accel = hammer_accel;
if (((ModGunScript)this).player_input.GetButton(10) && ((ModGunScript)this).player_input.GetButton(6) && ((SimpleMover)((GunScript)this).slide).amount >= ((GunScript)this).slide_lock_position)
{
slide_prepare_to_lock = true;
}
if (((SimpleMover)((GunScript)this).slide).amount == 0f)
{
slide_prepare_to_lock = false;
}
if (!slide_prepare_to_lock && ((ModGunScript)this).player_input.GetButton(6))
{
((ModGunScript)this)._slide_stop_locked = false;
((SimpleMover)((GunScript)this).slide_stop).target_amount = 0f;
((GunScript)this).StopSlideStop();
}
else if (!((ModGunScript)this).player_input.GetButton(6) && ((SimpleMover)((GunScript)this).slide).amount > ((GunScript)this).slide_lock_position)
{
((ModGunScript)this)._slide_stop_locked = true;
((SimpleMover)((GunScript)this).slide_stop).target_amount = 1f;
((GunScript)this).StartSlideStop();
}
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));
}
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;
((ModGunScript)this)._disconnector_needs_reset = true;
}
if (((GunScript)this).trigger.amount == 0f)
{
((ModGunScript)this)._disconnector_needs_reset = false;
}
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 && !((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);
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);
}
if (((ModGunScript)this).player_input.GetButtonDown(14) || (!dust_cover_opened && ((SimpleMover)((GunScript)this).slide).amount > 0.03f))
{
ToggleDustCover();
}
((GunScript)this).ApplyTransform("charging_handle", m_charging_handle_amount, ((Component)this).transform.Find("upper_receiver/charging_handle"));
((GunScript)this).ApplyTransform("charging_handle_latch", m_charging_handle_amount, ((Component)this).transform.Find("upper_receiver/charging_handle/charging_handle_latch"));
((SimpleMover)dust_cover).UpdateDisplay();
((SimpleMover)dust_cover).TimeStep(Time.deltaTime);
((SimpleMover)((GunScript)this).hammer).UpdateDisplay();
((SimpleMover)((GunScript)this).slide_stop).UpdateDisplay();
((ModGunScript)this).UpdateAnimatedComponents();
}
private void ToggleDustCover()
{
((SimpleMover)dust_cover).asleep = false;
if (((SimpleMover)dust_cover).target_amount == 1f && ((SimpleMover)((GunScript)this).slide).amount <= 0.03f)
{
((SimpleMover)dust_cover).target_amount = 0f;
((SimpleMover)dust_cover).accel = -1f;
((SimpleMover)dust_cover).vel = -10f;
AudioManager.PlayOneShotAttached(((GunScript)this).sound_cylinder_close, ((Component)((SimpleMover)dust_cover).transform).gameObject);
dust_cover_opened = false;
}
else if (!dust_cover_opened)
{
((SimpleMover)dust_cover).target_amount = 1f;
((SimpleMover)dust_cover).accel = 1f;
((SimpleMover)dust_cover).vel = 10f;
AudioManager.PlayOneShotAttached(((GunScript)this).sound_cylinder_open, ((Component)((SimpleMover)dust_cover).transform).gameObject);
dust_cover_opened = true;
}
}
}