using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using DualAction;
using HarmonyLib;
using HolsterAction;
using HolsterHider;
using HolsterHider.MonoBehaviours;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "HolsterAction", "1.0.0", "FluxSquido", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 HolsterAction
{
public class Mod : MelonMod
{
}
internal static class DualPouch
{
private class Pouch
{
public Transform Root;
public HolsterReference Holster;
}
private const string Name = "BeltRt1";
private static readonly ConditionalWeakTable<BodyReferences, Pouch> _pouches = new ConditionalWeakTable<BodyReferences, Pouch>();
public static void Apply(BodyReferences references, RigManager rigManager, HolsterVisibility visibility)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
Transform val = Find(rigManager);
if (!((Object)(object)val == (Object)null))
{
Pouch orCreateValue = _pouches.GetOrCreateValue(references);
if ((Object)(object)orCreateValue.Root != (Object)(object)val)
{
orCreateValue.Root = val;
orCreateValue.Holster = new HolsterReference();
orCreateValue.Holster.CacheReferences(val, Il2CppArrayBase<MeshRenderer>.op_Implicit(((Component)val).GetComponentsInChildren<MeshRenderer>(true)));
}
orCreateValue.Holster.SetVisibility(visibility);
}
}
private static Transform Find(RigManager rigManager)
{
Il2CppArrayBase<InventoryAmmoReceiver> componentsInChildren = ((Component)rigManager).GetComponentsInChildren<InventoryAmmoReceiver>(true);
for (int num = componentsInChildren.Length - 1; num > 0; num--)
{
Transform parent = ((Component)componentsInChildren[num]).transform.parent;
if ((Object)(object)parent != (Object)null && ((Object)parent).name == "BeltRt1")
{
return parent;
}
}
return null;
}
}
[HarmonyPatch(typeof(BodyReferences), "ApplyConfig")]
internal static class ApplyConfigPatch
{
private static void Postfix(BodyReferences __instance, BodyConfig bodyConfig, RigManager ____rigManager)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)____rigManager == (Object)null)
{
return;
}
try
{
DualPouch.Apply(__instance, ____rigManager, bodyConfig.AmmoPouchGroup.Visibility);
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
}
}
}
[HarmonyPatch(typeof(Belt), "SecondBelt_Init")]
internal static class SecondBeltInitPatch
{
private static void Postfix(RigManager __0)
{
if (!((Object)(object)__0 == (Object)null))
{
HolsterHiderRig component = ((Component)__0).GetComponent<HolsterHiderRig>();
if ((Object)(object)component != (Object)null)
{
component.ApplyConfig();
}
}
}
}
}