using System;
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 AmmoCount;
using HarmonyLib;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Weapons;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
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), "AmmoCount", "1.1.0", "MajedCT", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AmmoCount")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AmmoCount")]
[assembly: AssemblyTitle("AmmoCount")]
[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 AmmoCount
{
public class Core : MelonMod
{
[HarmonyPatch(typeof(HVRGrabbable), "InternalOnGrabbed")]
internal class GrabblePatch
{
private static void Postfix(HVRGrabbable __instance)
{
HVRAmmo component = ((Component)__instance).GetComponent<HVRAmmo>();
if (((Component)__instance).tag == "Magazine" || ((Component)__instance).tag == "magazine")
{
string text = "null";
if (((Object)__instance.Grabbers[0]).name == ((Object)leftHand).name)
{
text = "left";
GrabHandle(((Object)__instance).GetInstanceID(), text, component);
}
if (((Object)__instance.Grabbers[0]).name == ((Object)rightHand).name)
{
text = "right";
GrabHandle(((Object)__instance).GetInstanceID(), text, component);
}
}
}
}
[HarmonyPatch(typeof(HVRGrabbable), "Update")]
internal class ReleasePatch
{
private static void Postfix(HVRGrabbable __instance)
{
if (((Component)__instance).tag == "Magazine" || ((Component)__instance).tag == "magazine")
{
if (((Object)__instance).GetInstanceID() == id1 && !__instance.IsHandGrabbed)
{
GrabNullify(id1);
}
if (((Object)__instance).GetInstanceID() == id2 && !__instance.IsHandGrabbed)
{
GrabNullify(id2);
}
}
}
}
public static HVRHandGrabber leftHand;
public static HVRHandGrabber rightHand;
public static bool notMainMenu = false;
public static GameObject textObj1;
public static TextMesh text1;
public static GameObject textObj2;
public static TextMesh text2;
public static bool oneinuse = false;
public static bool twoinuse = false;
public static int id1 = 0;
public static int id2 = 0;
public static MelonPreferences_Category category;
public static MelonPreferences_Entry<Color> textColor;
public static Vector3 rightOffset = new Vector3(0f, -0.035f, 0f);
public static Vector3 leftOffset = new Vector3(0f, 0f, 0f);
public override void OnInitializeMelon()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
((MelonBase)this).LoggerInstance.Msg("Initialized.");
category = MelonPreferences.CreateCategory("Ammo Count");
textColor = category.CreateEntry<Color>("Text Color", Color.white, "Text Color", "The color of the text, [R, G, B, A] (A being transparency]", false, false, (ValueValidator)null, (string)null);
category.SaveToFile(true);
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_00bc: 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)
if (sceneName != "MainMenuScene")
{
notMainMenu = true;
GameObject val = GameObject.Find("Hexa4Rig26.10.23");
leftHand = ((Component)val.transform.Find("Physics LeftHand")).GetComponent<HVRHandGrabber>();
rightHand = ((Component)val.transform.Find("Physics RightHand")).GetComponent<HVRHandGrabber>();
textObj1 = new GameObject("WorldText");
textObj2 = new GameObject("WorldText");
text1 = textObj1.AddComponent<TextMesh>();
text2 = textObj2.AddComponent<TextMesh>();
text1.characterSize = 0.025f;
text1.fontSize = 20;
text1.color = textColor.Value;
text2.characterSize = 0.025f;
text2.fontSize = 20;
text2.color = textColor.Value;
}
}
public static void GrabHandle(int id, string hand, HVRAmmo ammo)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
if (id1 == 0)
{
id1 = id;
oneinuse = true;
if (!(hand == "left"))
{
if (hand == "right")
{
textObj1.transform.SetParent(((Component)rightHand).transform);
textObj1.transform.localPosition = rightOffset;
}
else
{
MelonLogger.Msg("SOMETHING WRONG HAPPENED REPORT THIS TO MAJEDCT");
}
}
else
{
textObj1.transform.SetParent(((Component)leftHand).transform);
textObj1.transform.localPosition = leftOffset;
}
text1.text = ammo.CurrentCount.ToString();
}
else
{
if (id1 == 0 || id2 != 0)
{
return;
}
id2 = id;
twoinuse = true;
if (!(hand == "left"))
{
if (hand == "right")
{
textObj2.transform.SetParent(((Component)rightHand).transform);
textObj2.transform.localPosition = rightOffset;
}
else
{
MelonLogger.Msg("SOMETHING WRONG HAPPENED REPORT THIS TO MAJEDCT");
}
}
else
{
textObj2.transform.SetParent(((Component)leftHand).transform);
textObj2.transform.localPosition = leftOffset;
}
text2.text = ammo.CurrentCount.ToString();
}
}
public static void GrabNullify(int id)
{
if (id == id1)
{
id1 = 0;
oneinuse = false;
textObj1.transform.SetParent((Transform)null);
}
if (id == id2)
{
id2 = 0;
twoinuse = false;
textObj2.transform.SetParent((Transform)null);
}
}
public override void OnUpdate()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (notMainMenu)
{
if ((Object)(object)Camera.main != (Object)null)
{
textObj1.transform.forward = ((Component)Camera.main).transform.forward;
textObj2.transform.forward = ((Component)Camera.main).transform.forward;
}
textObj1.SetActive(oneinuse);
textObj2.SetActive(twoinuse);
}
}
}
}