using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2Cpp;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using StickGunReload;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "StickGunReload", "1.0.0", "MajedCT", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("StickGunReload")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StickGunReload")]
[assembly: AssemblyTitle("StickGunReload")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace StickGunReload
{
public class Core : MelonMod
{
[HarmonyPatch(typeof(StickRifleManager), "FixedUpdate")]
internal class StickRifleManagerPatch
{
public static void Postfix(StickRifleManager __instance)
{
if (infiniteAmmo.Value)
{
if (((StickGunManager)__instance).currentAmmo != 999)
{
((StickGunManager)__instance).currentAmmo = 999;
}
}
else if (((StickGunManager)__instance).currentAmmo <= 0 && !reloading.Contains((StickGunManager)(object)__instance))
{
reloading.Add((StickGunManager)(object)__instance);
GameObject txt = CreateLargeReloadText(((Component)__instance).transform);
MelonCoroutines.Start(ReloadLarge(__instance, txt));
}
}
}
[HarmonyPatch(typeof(StickGunManager), "FixedUpdate")]
internal class StickGunManagerPatch
{
public static void Postfix(StickGunManager __instance)
{
if (infiniteAmmo.Value)
{
if (__instance.currentAmmo != 999)
{
__instance.currentAmmo = 999;
}
}
else if (__instance.currentAmmo <= 0 && !reloading.Contains(__instance))
{
reloading.Add(__instance);
GameObject txt = CreateReloadText(((Component)__instance).transform);
MelonCoroutines.Start(ReloadSmall(__instance, txt));
}
}
}
[CompilerGenerated]
private sealed class <ReloadLarge>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public StickRifleManager gun;
public GameObject txt;
private int <min>5__1;
private int <max>5__2;
private int <ammo>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ReloadLarge>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds((float)reloadTimer.Value);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (forceAmount.Value)
{
<min>5__1 = (int)amountToForce.Value.x;
<max>5__2 = (int)amountToForce.Value.y + 1;
}
else
{
<min>5__1 = (int)((StickGunManager)gun).playerRemainingAmmoRange.x;
<max>5__2 = (int)((StickGunManager)gun).playerRemainingAmmoRange.y + 1;
}
<ammo>5__3 = Random.Range(<min>5__1, <max>5__2);
((StickGunManager)gun).currentAmmo = <ammo>5__3;
reloading.Remove((StickGunManager)(object)gun);
Object.Destroy((Object)(object)txt);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ReloadSmall>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public StickGunManager gun;
public GameObject txt;
private int <min>5__1;
private int <max>5__2;
private int <ammo>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ReloadSmall>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds((float)reloadTimer.Value);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (forceAmount.Value)
{
<min>5__1 = (int)amountToForce.Value.x;
<max>5__2 = (int)amountToForce.Value.y + 1;
}
else
{
<min>5__1 = (int)gun.playerRemainingAmmoRange.x;
<max>5__2 = (int)gun.playerRemainingAmmoRange.y + 1;
}
<ammo>5__3 = Random.Range(<min>5__1, <max>5__2);
gun.currentAmmo = <ammo>5__3;
reloading.Remove(gun);
Object.Destroy((Object)(object)txt);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static MelonPreferences_Category category;
public static MelonPreferences_Entry<bool> infiniteAmmo;
public static MelonPreferences_Entry<bool> forceAmount;
public static MelonPreferences_Entry<Vector2> amountToForce;
public static MelonPreferences_Entry<int> reloadTimer;
public static MelonPreferences_Entry<string> reloadText;
public static MelonPreferences_Entry<Color> textColor;
public static HashSet<StickGunManager> reloading = new HashSet<StickGunManager>();
public override void OnInitializeMelon()
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
((MelonBase)this).LoggerInstance.Msg("Initialized.");
category = MelonPreferences.CreateCategory("StickGunReload");
infiniteAmmo = category.CreateEntry<bool>("InfiniteAmmo", false, "Infinite Ammo", (string)null, false, false, (ValueValidator)null, (string)null);
forceAmount = category.CreateEntry<bool>("ForceAmount", false, "Force Amount", "Whether to force a specific amount of ammo or use the game's random range", false, false, (ValueValidator)null, (string)null);
amountToForce = category.CreateEntry<Vector2>("AmountToForce", new Vector2(6f, 9f), "Amount To Force", "The range of ammo to force when Force Amount is enabled (set to same number so its always that number)", false, false, (ValueValidator)null, (string)null);
reloadTimer = category.CreateEntry<int>("ReloadTimer", 3, "Reload Timer", (string)null, false, false, (ValueValidator)null, (string)null);
reloadText = category.CreateEntry<string>("Reload Text", "RELOADING", "Reload Text", "The text displayed when reloading", false, false, (ValueValidator)null, (string)null);
textColor = category.CreateEntry<Color>("Text Color", Color.red, "Text Color", "The color of the text, [R, G, B, A] (A being transparency]", false, false, (ValueValidator)null, (string)null);
category.SaveToFile(true);
}
private static GameObject CreateReloadText(Transform parent)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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)
GameObject val = new GameObject("ReloadingText");
val.transform.SetParent(parent);
val.transform.localPosition = new Vector3(0f, 0.2f, 0f);
val.transform.localRotation = Quaternion.identity;
TextMesh val2 = val.AddComponent<TextMesh>();
val2.text = reloadText.Value;
val2.color = textColor.Value;
val2.characterSize = 0.02f;
val2.fontSize = 24;
val2.alignment = (TextAlignment)1;
val2.anchor = (TextAnchor)4;
return val;
}
private static GameObject CreateLargeReloadText(Transform parent)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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)
GameObject val = new GameObject("ReloadingText");
val.transform.SetParent(parent);
val.transform.localPosition = new Vector3(0f, 0f, 0.2f);
val.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
TextMesh val2 = val.AddComponent<TextMesh>();
val2.text = reloadText.Value;
val2.color = textColor.Value;
val2.characterSize = 0.02f;
val2.fontSize = 24;
val2.alignment = (TextAlignment)1;
val2.anchor = (TextAnchor)4;
return val;
}
[IteratorStateMachine(typeof(<ReloadSmall>d__11))]
private static IEnumerator ReloadSmall(StickGunManager gun, GameObject txt)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReloadSmall>d__11(0)
{
gun = gun,
txt = txt
};
}
[IteratorStateMachine(typeof(<ReloadLarge>d__12))]
private static IEnumerator ReloadLarge(StickRifleManager gun, GameObject txt)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReloadLarge>d__12(0)
{
gun = gun,
txt = txt
};
}
}
}