using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSystem.Collections.Generic;
using InvisibleHolsters;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(MainMod), "HolsterHider", "1.0.2", "dimastv", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "BoneLib" })]
[assembly: MelonColor(255, 30, 144, 255)]
[assembly: MelonAuthorColor(255, 135, 206, 250)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("HolsterHider")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HolsterHider")]
[assembly: AssemblyTitle("HolsterHider")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 InvisibleHolsters
{
internal static class BoneMenuIntegration
{
private static Page? _mainPage;
private static Page? _detailsPage;
private static BoolElement? _hideHolstersBool;
private static BoolElement? _hideAmmoBool;
private static BoolElement? _antiCullingBool;
private static BoolElement? _otherPlayersBool;
private static BoolElement? _showAmmoOnHoverBool;
private static BoolElement? _hideBodyLogBool;
private static BoolElement? _headBool;
private static BoolElement? _backBool;
private static BoolElement? _leftShoulderBool;
private static BoolElement? _rightShoulderBool;
private static BoolElement? _leftUnderarmBool;
private static BoolElement? _rightUnderarmBool;
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void SetupMenu()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
_mainPage = Page.Root.CreatePage("Holster Hider", new Color(0.1f, 0.6f, 1f), 0, true);
_hideHolstersBool = _mainPage.CreateBool("Hide Holsters", Color.white, ModConfig.HideHolsters.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideHolsters.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
NotificationHelper.ShowSuccess("Holster Hider", val ? "Holsters: HIDDEN" : "Holsters: VISIBLE");
});
_hideAmmoBool = _mainPage.CreateBool("Hide Ammo Pouch", Color.yellow, ModConfig.HideAmmoPouch.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideAmmoPouch.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyAmmoPouchVisibility();
NotificationHelper.ShowSuccess("Holster Hider", val ? "Ammo Pouch: HIDDEN" : "Ammo Pouch: VISIBLE");
});
_antiCullingBool = _mainPage.CreateBool("Anti-Culling Guard", Color.green, ModConfig.AntiCullingGuard.Value, (Action<bool>)delegate(bool val)
{
ModConfig.AntiCullingGuard.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
NotificationHelper.ShowSuccess("Holster Hider", val ? "Anti-Culling: ENABLED" : "Anti-Culling: DISABLED");
});
_otherPlayersBool = _mainPage.CreateBool("Hide On Other Players", Color.cyan, ModConfig.HideForOtherPlayers.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideForOtherPlayers.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.RefreshAllRigs();
HolsterManager.ApplyAllVisibility();
NotificationHelper.ShowSuccess("Holster Hider", val ? "Other Players: HIDDEN" : "Other Players: VISIBLE");
});
_showAmmoOnHoverBool = _mainPage.CreateBool("Show Ammo On Hover", new Color(1f, 0.5f, 0.8f), ModConfig.ShowAmmoOnHover.Value, (Action<bool>)delegate(bool val)
{
ModConfig.ShowAmmoOnHover.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
NotificationHelper.ShowSuccess("Holster Hider", val ? "Show on Hover: ON" : "Show on Hover: OFF");
});
_hideBodyLogBool = _mainPage.CreateBool("Hide BodyLog", new Color(0.8f, 0.4f, 1f), ModConfig.HideBodyLog.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideBodyLog.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyBodyLogVisibility();
NotificationHelper.ShowSuccess("Holster Hider", val ? "BodyLog: HIDDEN" : "BodyLog: VISIBLE");
});
_mainPage.CreateFunction("Hide Everything", Color.red, (Action)delegate
{
ModConfig.SetEverything(hide: true);
UpdateUiElements();
HolsterManager.ApplyAllVisibility();
NotificationHelper.ShowSuccess("Holster Hider", "All Holsters & Ammo Hidden!");
});
_mainPage.CreateFunction("Show Everything", Color.green, (Action)delegate
{
ModConfig.SetEverything(hide: false);
UpdateUiElements();
HolsterManager.ApplyAllVisibility();
NotificationHelper.ShowSuccess("Holster Hider", "All Holsters & Ammo Visible!");
});
_mainPage.CreateFunction("Refresh / Reapply", Color.white, (Action)delegate
{
HolsterManager.RefreshAllRigs();
HolsterManager.ApplyAllVisibility();
NotificationHelper.ShowSuccess("Holster Hider", "Refreshed all players!");
});
_detailsPage = _mainPage.CreatePage("Detailed Slots", Color.white, 0, true);
BuildDetailsPage();
}
private static void BuildDetailsPage()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
if (_detailsPage != null)
{
_headBool = _detailsPage.CreateBool("Head Holster", Color.white, ModConfig.HideHeadHolster.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideHeadHolster.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
});
_backBool = _detailsPage.CreateBool("Back Holster", Color.white, ModConfig.HideBackHolster.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideBackHolster.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
});
_leftShoulderBool = _detailsPage.CreateBool("Left Shoulder", Color.white, ModConfig.HideLeftShoulder.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideLeftShoulder.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
});
_rightShoulderBool = _detailsPage.CreateBool("Right Shoulder", Color.white, ModConfig.HideRightShoulder.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideRightShoulder.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
});
_leftUnderarmBool = _detailsPage.CreateBool("Left Side/Hip", Color.white, ModConfig.HideLeftUnderarm.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideLeftUnderarm.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
});
_rightUnderarmBool = _detailsPage.CreateBool("Right Side/Hip", Color.white, ModConfig.HideRightUnderarm.Value, (Action<bool>)delegate(bool val)
{
ModConfig.HideRightUnderarm.Value = val;
ModConfig.PrefCategory.SaveToFile(false);
HolsterManager.ApplyHolsterVisibility();
});
}
}
private static void UpdateUiElements()
{
if (_hideHolstersBool != null)
{
_hideHolstersBool.Value = ModConfig.HideHolsters.Value;
}
if (_hideAmmoBool != null)
{
_hideAmmoBool.Value = ModConfig.HideAmmoPouch.Value;
}
if (_antiCullingBool != null)
{
_antiCullingBool.Value = ModConfig.AntiCullingGuard.Value;
}
if (_otherPlayersBool != null)
{
_otherPlayersBool.Value = ModConfig.HideForOtherPlayers.Value;
}
if (_showAmmoOnHoverBool != null)
{
_showAmmoOnHoverBool.Value = ModConfig.ShowAmmoOnHover.Value;
}
if (_hideBodyLogBool != null)
{
_hideBodyLogBool.Value = ModConfig.HideBodyLog.Value;
}
if (_headBool != null)
{
_headBool.Value = ModConfig.HideHeadHolster.Value;
}
if (_backBool != null)
{
_backBool.Value = ModConfig.HideBackHolster.Value;
}
if (_leftShoulderBool != null)
{
_leftShoulderBool.Value = ModConfig.HideLeftShoulder.Value;
}
if (_rightShoulderBool != null)
{
_rightShoulderBool.Value = ModConfig.HideRightShoulder.Value;
}
if (_leftUnderarmBool != null)
{
_leftUnderarmBool.Value = ModConfig.HideLeftUnderarm.Value;
}
if (_rightUnderarmBool != null)
{
_rightUnderarmBool.Value = ModConfig.HideRightUnderarm.Value;
}
}
}
public static class HolsterManager
{
private class SlotEntry
{
public string Name = "";
public Func<bool> ShouldHide = () => true;
public Transform RootTransform;
public GameObject? ArtObject;
public Vector3 ArtOriginalScale = Vector3.one;
public InventorySlotReceiver? SlotReceiver;
public readonly List<Renderer> CachedHolsterRenderers = new List<Renderer>();
}
private class RigTracker
{
public RigManager Rig;
public bool IsLocal;
public readonly List<SlotEntry> Slots = new List<SlotEntry>();
public InventoryAmmoReceiver? AmmoReceiver;
public readonly List<Renderer> AmmoPouchRenderers = new List<Renderer>();
public readonly List<Transform> AmmoPouchArtTransforms = new List<Transform>();
public readonly Dictionary<int, Vector3> AmmoPouchOriginalScales = new Dictionary<int, Vector3>();
public PullCordDevice? PullCord;
public readonly List<Renderer> BodyLogRenderers = new List<Renderer>();
public GameObject? BodyLogObject;
public Vector3 BodyLogOriginalScale = Vector3.one;
}
private static readonly List<RigTracker> _trackers = new List<RigTracker>();
private static readonly HashSet<int> _grabbedMagazineInstanceIds = new HashSet<int>();
private static readonly Dictionary<int, Vector3> _magazineOriginalScales = new Dictionary<int, Vector3>();
private static float _lastScanTime = 0f;
private const float SCAN_INTERVAL = 1f;
public static void OnLevelLoaded(LevelInfo level)
{
try
{
_grabbedMagazineInstanceIds.Clear();
_magazineOriginalScales.Clear();
_trackers.Clear();
RefreshAllRigs();
ApplyAllVisibility();
MelonCoroutines.Start(CoWaitAndApply());
}
catch (Exception value)
{
MelonLogger.Error($"Error in OnLevelLoaded: {value}");
}
}
private static IEnumerator CoWaitAndApply()
{
yield return (object)new WaitForSeconds(0.3f);
RefreshAllRigs();
ApplyAllVisibility();
yield return (object)new WaitForSeconds(1f);
RefreshAllRigs();
ApplyAllVisibility();
yield return (object)new WaitForSeconds(2f);
RefreshAllRigs();
ApplyAllVisibility();
}
public static void OnAvatarSwapped()
{
try
{
RefreshAllRigs();
ApplyAllVisibility();
}
catch (Exception value)
{
MelonLogger.Error($"Error in OnAvatarSwapped: {value}");
}
}
public static void OnUpdate()
{
float time = Time.time;
if (time - _lastScanTime >= 1f)
{
_lastScanTime = time;
ScanForNewRigs();
}
}
public static void OnLateUpdate()
{
if (ModConfig.AntiCullingGuard.Value)
{
EnforceHiddenState();
}
}
public static void RefreshAllRigs()
{
_trackers.Clear();
RigManager rigManager = Player.RigManager;
if ((Object)(object)rigManager != (Object)null)
{
TrackRig(rigManager, isLocal: true);
}
if (ModConfig.HideForOtherPlayers.Value)
{
ScanForOtherRigs();
}
}
private static void ScanForNewRigs()
{
bool flag = false;
for (int num = _trackers.Count - 1; num >= 0; num--)
{
RigTracker rigTracker = _trackers[num];
if ((Object)(object)rigTracker.Rig == (Object)null || (Object)(object)((Component)rigTracker.Rig).gameObject == (Object)null)
{
_trackers.RemoveAt(num);
}
else if (rigTracker.IsLocal)
{
flag = true;
}
}
if (!flag && (Object)(object)Player.RigManager != (Object)null)
{
TrackRig(Player.RigManager, isLocal: true);
ApplyAllVisibility();
}
if (ModConfig.HideForOtherPlayers.Value)
{
ScanForOtherRigs();
}
}
private static void ScanForOtherRigs()
{
try
{
Il2CppArrayBase<RigManager> val = Object.FindObjectsOfType<RigManager>();
if (val == null)
{
return;
}
RigManager rigManager = Player.RigManager;
foreach (RigManager item in val)
{
if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).gameObject == (Object)null || (Object)(object)item == (Object)(object)rigManager)
{
continue;
}
bool flag = false;
foreach (RigTracker tracker in _trackers)
{
if ((Object)(object)tracker.Rig == (Object)(object)item)
{
flag = true;
break;
}
}
if (!flag)
{
TrackRig(item, isLocal: false);
ApplyRigVisibility(_trackers[_trackers.Count - 1]);
}
}
}
catch
{
}
}
private static void TrackRig(RigManager rig, bool isLocal)
{
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rig == (Object)null || (Object)(object)rig.inventory == (Object)null)
{
return;
}
RigTracker rigTracker = new RigTracker
{
Rig = rig,
IsLocal = isLocal
};
Inventory inventory = rig.inventory;
try
{
PhysicsRig physicsRig = rig.physicsRig;
object obj;
if (physicsRig == null)
{
obj = null;
}
else
{
Transform head = ((Rig)physicsRig).m_head;
obj = ((head != null) ? ((Component)head).GetComponentInChildren<InventorySlotReceiver>(true) : null);
}
InventorySlotReceiver val = (InventorySlotReceiver)obj;
if ((Object)(object)val != (Object)null)
{
Transform rootTransform = ((Component)val).transform.parent ?? ((Component)val).transform;
SlotEntry slotEntry = new SlotEntry
{
Name = "Head",
ShouldHide = () => ModConfig.HideHolsters.Value && ModConfig.HideHeadHolster.Value,
RootTransform = rootTransform,
SlotReceiver = val
};
CacheSlotRenderers(slotEntry);
rigTracker.Slots.Add(slotEntry);
}
}
catch
{
}
try
{
Il2CppReferenceArray<SlotContainer> bodySlots = inventory.bodySlots;
if (bodySlots != null)
{
for (int num = 0; num < ((Il2CppArrayBase<SlotContainer>)(object)bodySlots).Count; num++)
{
SlotContainer val2 = ((Il2CppArrayBase<SlotContainer>)(object)bodySlots)[num];
if ((Object)(object)val2 == (Object)null)
{
continue;
}
string name;
Func<bool> shouldHide;
switch (num)
{
case 0:
name = "Left Underarm/Hip";
shouldHide = () => ModConfig.HideHolsters.Value && ModConfig.HideLeftUnderarm.Value;
break;
case 2:
name = "Left Shoulder";
shouldHide = () => ModConfig.HideHolsters.Value && ModConfig.HideLeftShoulder.Value;
break;
case 3:
name = "Right Shoulder";
shouldHide = () => ModConfig.HideHolsters.Value && ModConfig.HideRightShoulder.Value;
break;
case 4:
name = "Back";
shouldHide = () => ModConfig.HideHolsters.Value && ModConfig.HideBackHolster.Value;
break;
case 5:
name = "Right Underarm/Hip";
shouldHide = () => ModConfig.HideHolsters.Value && ModConfig.HideRightUnderarm.Value;
break;
default:
name = $"BodySlot_{num}";
shouldHide = () => ModConfig.HideHolsters.Value;
break;
}
SlotEntry slotEntry2 = new SlotEntry
{
Name = name,
ShouldHide = shouldHide,
RootTransform = ((Component)val2).transform,
ArtObject = val2.art,
SlotReceiver = val2.inventorySlotReceiver
};
if ((Object)(object)slotEntry2.ArtObject != (Object)null)
{
slotEntry2.ArtOriginalScale = slotEntry2.ArtObject.transform.localScale;
if (slotEntry2.ArtOriginalScale == Vector3.zero)
{
slotEntry2.ArtOriginalScale = Vector3.one;
}
}
CacheSlotRenderers(slotEntry2);
rigTracker.Slots.Add(slotEntry2);
}
}
}
catch
{
}
try
{
InventoryAmmoReceiver componentInChildren = ((Component)rig).GetComponentInChildren<InventoryAmmoReceiver>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
rigTracker.AmmoReceiver = componentInChildren;
foreach (Renderer componentsInChild in ((Component)(((Component)componentInChildren).transform.parent ?? ((Component)componentInChildren).transform)).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild == (Object)null || IsWeaponOrItemRenderer(componentsInChild))
{
continue;
}
rigTracker.AmmoPouchRenderers.Add(componentsInChild);
Transform transform = ((Component)componentsInChild).transform;
if (!rigTracker.AmmoPouchArtTransforms.Contains(transform) && (Object)(object)transform != (Object)(object)((Component)componentInChildren).transform)
{
rigTracker.AmmoPouchArtTransforms.Add(transform);
int instanceID = ((Object)((Component)transform).gameObject).GetInstanceID();
if (!rigTracker.AmmoPouchOriginalScales.ContainsKey(instanceID))
{
Vector3 localScale = transform.localScale;
rigTracker.AmmoPouchOriginalScales[instanceID] = ((localScale == Vector3.zero) ? Vector3.one : localScale);
}
}
}
}
}
catch
{
}
try
{
Il2CppReferenceArray<SlotContainer> specialItems = inventory.specialItems;
if (specialItems != null && ((Il2CppArrayBase<SlotContainer>)(object)specialItems).Count > 0 && (Object)(object)((Il2CppArrayBase<SlotContainer>)(object)specialItems)[0] != (Object)null)
{
PullCordDevice componentInChildren2 = ((Component)((Il2CppArrayBase<SlotContainer>)(object)specialItems)[0]).GetComponentInChildren<PullCordDevice>(true);
if ((Object)(object)componentInChildren2 != (Object)null)
{
rigTracker.PullCord = componentInChildren2;
Transform val3 = ((Component)componentInChildren2).transform.Find("BodyLog");
if ((Object)(object)val3 != (Object)null)
{
rigTracker.BodyLogObject = ((Component)val3).gameObject;
rigTracker.BodyLogOriginalScale = val3.localScale;
if (rigTracker.BodyLogOriginalScale == Vector3.zero)
{
rigTracker.BodyLogOriginalScale = Vector3.one;
}
}
foreach (Renderer componentsInChild2 in ((Component)(val3 ?? ((Component)componentInChildren2).transform)).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild2 != (Object)null && !IsWeaponOrItemRenderer(componentsInChild2))
{
rigTracker.BodyLogRenderers.Add(componentsInChild2);
}
}
}
}
}
catch
{
}
_trackers.Add(rigTracker);
}
private static void CacheSlotRenderers(SlotEntry slot)
{
slot.CachedHolsterRenderers.Clear();
if ((Object)(object)slot.ArtObject != (Object)null)
{
foreach (Renderer componentsInChild in slot.ArtObject.GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null && !IsWeaponOrItemRenderer(componentsInChild))
{
slot.CachedHolsterRenderers.Add(componentsInChild);
}
}
return;
}
if (!((Object)(object)slot.RootTransform != (Object)null))
{
return;
}
foreach (Renderer componentsInChild2 in ((Component)slot.RootTransform).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild2 != (Object)null && !IsWeaponOrItemRenderer(componentsInChild2) && !slot.CachedHolsterRenderers.Contains(componentsInChild2))
{
slot.CachedHolsterRenderers.Add(componentsInChild2);
}
}
}
public static void ApplyAllVisibility()
{
foreach (RigTracker tracker in _trackers)
{
ApplyRigVisibility(tracker);
}
}
public static void ApplyHolsterVisibility()
{
foreach (RigTracker tracker in _trackers)
{
ApplyRigHolsters(tracker);
}
}
public static void ApplyAmmoPouchVisibility(InventoryAmmoReceiver? specificReceiver = null)
{
foreach (RigTracker tracker in _trackers)
{
if (!((Object)(object)specificReceiver != (Object)null) || !((Object)(object)tracker.AmmoReceiver != (Object)(object)specificReceiver))
{
ApplyRigAmmoPouch(tracker);
}
}
}
public static void ApplyBodyLogVisibility()
{
foreach (RigTracker tracker in _trackers)
{
ApplyRigBodyLog(tracker);
}
}
private static void ApplyRigVisibility(RigTracker tracker)
{
ApplyRigHolsters(tracker);
ApplyRigAmmoPouch(tracker);
ApplyRigBodyLog(tracker);
}
private static void ApplyRigHolsters(RigTracker tracker)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)tracker.Rig == (Object)null)
{
return;
}
foreach (SlotEntry slot in tracker.Slots)
{
if ((Object)(object)slot.RootTransform == (Object)null)
{
continue;
}
bool flag = slot.ShouldHide();
if ((Object)(object)slot.ArtObject != (Object)null)
{
slot.ArtObject.transform.localScale = (flag ? Vector3.zero : slot.ArtOriginalScale);
slot.ArtObject.SetActive(!flag);
foreach (Renderer componentsInChild in slot.ArtObject.GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
if (IsWeaponOrItemRenderer(componentsInChild))
{
componentsInChild.enabled = true;
componentsInChild.shadowCastingMode = (ShadowCastingMode)1;
}
else
{
componentsInChild.enabled = !flag;
componentsInChild.shadowCastingMode = (ShadowCastingMode)(!flag);
}
}
}
}
foreach (Renderer cachedHolsterRenderer in slot.CachedHolsterRenderers)
{
if (!((Object)(object)cachedHolsterRenderer == (Object)null))
{
if (IsWeaponOrItemRenderer(cachedHolsterRenderer))
{
cachedHolsterRenderer.enabled = true;
cachedHolsterRenderer.shadowCastingMode = (ShadowCastingMode)1;
}
else
{
cachedHolsterRenderer.enabled = !flag;
cachedHolsterRenderer.shadowCastingMode = (ShadowCastingMode)(!flag);
}
}
}
EnsureSlottedWeaponVisible(slot.SlotReceiver);
}
}
private static void ApplyRigAmmoPouch(RigTracker tracker)
{
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: 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)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
InventoryAmmoReceiver ammoReceiver = tracker.AmmoReceiver;
if ((Object)(object)ammoReceiver == (Object)null)
{
return;
}
bool value = ModConfig.HideAmmoPouch.Value;
foreach (Renderer ammoPouchRenderer in tracker.AmmoPouchRenderers)
{
if (!((Object)(object)ammoPouchRenderer == (Object)null))
{
if (IsGrabbedObjectRenderer(ammoPouchRenderer) || IsWeaponOrItemRenderer(ammoPouchRenderer))
{
ammoPouchRenderer.enabled = true;
continue;
}
ammoPouchRenderer.enabled = !value;
ammoPouchRenderer.shadowCastingMode = (ShadowCastingMode)(!value);
}
}
foreach (Transform ammoPouchArtTransform in tracker.AmmoPouchArtTransforms)
{
if (!((Object)(object)ammoPouchArtTransform == (Object)null))
{
int instanceID = ((Object)((Component)ammoPouchArtTransform).gameObject).GetInstanceID();
if (tracker.AmmoPouchOriginalScales.TryGetValue(instanceID, out var value2))
{
ammoPouchArtTransform.localScale = (value ? Vector3.zero : value2);
}
}
}
try
{
List<Magazine> magazineArts = ammoReceiver._magazineArts;
if (magazineArts != null)
{
Enumerator<Magazine> enumerator3 = magazineArts.GetEnumerator();
while (enumerator3.MoveNext())
{
Magazine current3 = enumerator3.Current;
if ((Object)(object)current3 == (Object)null)
{
continue;
}
bool flag = IsMagazineGrabbed(current3);
int instanceID2 = ((Object)((Component)current3).gameObject).GetInstanceID();
if (!_magazineOriginalScales.ContainsKey(instanceID2))
{
Vector3 localScale = ((Component)current3).transform.localScale;
_magazineOriginalScales[instanceID2] = ((localScale == Vector3.zero) ? Vector3.one : localScale);
}
if (flag)
{
if (_magazineOriginalScales.TryGetValue(instanceID2, out var value3))
{
((Component)current3).transform.localScale = value3;
}
}
else if (value)
{
((Component)current3).transform.localScale = Vector3.zero;
}
foreach (Renderer componentsInChild in ((Component)current3).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
componentsInChild.enabled = flag || !value;
componentsInChild.shadowCastingMode = (ShadowCastingMode)((flag || !value) ? 1 : 0);
}
}
}
}
}
catch
{
}
try
{
Il2CppReferenceArray<Transform> ammoArtTargets = ammoReceiver._ammoArtTargets;
if (ammoArtTargets == null)
{
return;
}
foreach (Transform item in (Il2CppArrayBase<Transform>)(object)ammoArtTargets)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
foreach (Renderer componentsInChild2 in ((Component)item).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild2 != (Object)null && !IsGrabbedObjectRenderer(componentsInChild2) && !IsWeaponOrItemRenderer(componentsInChild2))
{
componentsInChild2.enabled = !value;
componentsInChild2.shadowCastingMode = (ShadowCastingMode)(!value);
}
}
}
}
catch
{
}
}
private static void ApplyRigBodyLog(RigTracker tracker)
{
//IL_002f: 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)
bool value = ModConfig.HideBodyLog.Value;
if ((Object)(object)tracker.BodyLogObject != (Object)null)
{
tracker.BodyLogObject.transform.localScale = (value ? Vector3.zero : tracker.BodyLogOriginalScale);
tracker.BodyLogObject.SetActive(!value);
}
foreach (Renderer bodyLogRenderer in tracker.BodyLogRenderers)
{
if ((Object)(object)bodyLogRenderer != (Object)null && !IsWeaponOrItemRenderer(bodyLogRenderer))
{
bodyLogRenderer.enabled = !value;
bodyLogRenderer.shadowCastingMode = (ShadowCastingMode)(!value);
}
}
}
private static void EnforceHiddenState()
{
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _trackers.Count; i++)
{
RigTracker rigTracker = _trackers[i];
if ((Object)(object)rigTracker.Rig == (Object)null)
{
continue;
}
if (ModConfig.HideHolsters.Value)
{
for (int j = 0; j < rigTracker.Slots.Count; j++)
{
SlotEntry slotEntry = rigTracker.Slots[j];
if (!slotEntry.ShouldHide())
{
continue;
}
if ((Object)(object)slotEntry.ArtObject != (Object)null)
{
if (slotEntry.ArtObject.activeSelf)
{
slotEntry.ArtObject.SetActive(false);
}
if (slotEntry.ArtObject.transform.localScale != Vector3.zero)
{
slotEntry.ArtObject.transform.localScale = Vector3.zero;
}
}
for (int k = 0; k < slotEntry.CachedHolsterRenderers.Count; k++)
{
Renderer val = slotEntry.CachedHolsterRenderers[k];
if (!((Object)(object)val != (Object)null))
{
continue;
}
if (IsWeaponOrItemRenderer(val))
{
if (!val.enabled)
{
val.enabled = true;
}
}
else if (val.enabled)
{
val.enabled = false;
}
}
}
}
if (ModConfig.HideAmmoPouch.Value)
{
for (int l = 0; l < rigTracker.AmmoPouchRenderers.Count; l++)
{
Renderer val2 = rigTracker.AmmoPouchRenderers[l];
if ((Object)(object)val2 != (Object)null && !IsGrabbedObjectRenderer(val2) && !IsWeaponOrItemRenderer(val2) && val2.enabled)
{
val2.enabled = false;
}
}
for (int m = 0; m < rigTracker.AmmoPouchArtTransforms.Count; m++)
{
Transform val3 = rigTracker.AmmoPouchArtTransforms[m];
if ((Object)(object)val3 != (Object)null && val3.localScale != Vector3.zero)
{
val3.localScale = Vector3.zero;
}
}
if ((Object)(object)rigTracker.AmmoReceiver != (Object)null && rigTracker.AmmoReceiver._magazineArts != null)
{
List<Magazine> magazineArts = rigTracker.AmmoReceiver._magazineArts;
for (int n = 0; n < magazineArts.Count; n++)
{
Magazine val4 = magazineArts[n];
if ((Object)(object)val4 == (Object)null || IsMagazineGrabbed(val4))
{
continue;
}
if (((Component)val4).transform.localScale != Vector3.zero)
{
((Component)val4).transform.localScale = Vector3.zero;
}
foreach (Renderer componentsInChild in ((Component)val4).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null && componentsInChild.enabled)
{
componentsInChild.enabled = false;
}
}
}
}
}
if (!ModConfig.HideBodyLog.Value)
{
continue;
}
if ((Object)(object)rigTracker.BodyLogObject != (Object)null)
{
if (rigTracker.BodyLogObject.activeSelf)
{
rigTracker.BodyLogObject.SetActive(false);
}
if (rigTracker.BodyLogObject.transform.localScale != Vector3.zero)
{
rigTracker.BodyLogObject.transform.localScale = Vector3.zero;
}
}
for (int num = 0; num < rigTracker.BodyLogRenderers.Count; num++)
{
Renderer val5 = rigTracker.BodyLogRenderers[num];
if ((Object)(object)val5 != (Object)null && !IsWeaponOrItemRenderer(val5) && val5.enabled)
{
val5.enabled = false;
}
}
}
}
public static void OnWeaponSlotted(InventorySlotReceiver receiver)
{
if (!((Object)(object)receiver == (Object)null))
{
EnsureSlottedWeaponVisible(receiver);
}
}
public static void OnWeaponUnslotted(InventorySlotReceiver receiver, Hand hand)
{
if ((Object)(object)hand != (Object)null)
{
EnsureHandObjectsVisible(hand);
}
MelonCoroutines.Start(CoEnsureWeaponVisibleNextFrame(hand, receiver));
}
private static IEnumerator CoEnsureWeaponVisibleNextFrame(Hand? hand, InventorySlotReceiver? receiver)
{
yield return null;
if ((Object)(object)hand != (Object)null)
{
EnsureHandObjectsVisible(hand);
}
if ((Object)(object)receiver != (Object)null)
{
EnsureSlottedWeaponVisible(receiver);
}
}
private static void EnsureSlottedWeaponVisible(InventorySlotReceiver? receiver)
{
if ((Object)(object)receiver == (Object)null)
{
return;
}
try
{
WeaponSlot slottedWeapon = receiver._slottedWeapon;
if (!((Object)(object)slottedWeapon != (Object)null) || !((Object)(object)slottedWeapon.interactableHost != (Object)null))
{
return;
}
GameObject gameObject = ((Component)slottedWeapon.interactableHost).gameObject;
if (!((Object)(object)gameObject != (Object)null))
{
return;
}
foreach (Renderer componentsInChild in gameObject.GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
componentsInChild.enabled = true;
componentsInChild.shadowCastingMode = (ShadowCastingMode)1;
}
}
}
catch
{
}
}
private static void EnsureHandObjectsVisible(Hand hand)
{
if ((Object)(object)hand == (Object)null)
{
return;
}
try
{
foreach (Renderer componentsInChild in ((Component)hand).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
componentsInChild.enabled = true;
componentsInChild.shadowCastingMode = (ShadowCastingMode)1;
}
}
}
catch
{
}
}
public static void SuppressSlotHover(InventorySlotReceiver receiver)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)receiver == (Object)null)
{
return;
}
try
{
SlotContainer componentInParent = ((Component)receiver).GetComponentInParent<SlotContainer>();
if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.art != (Object)null)
{
componentInParent.art.transform.localScale = Vector3.zero;
if (componentInParent.art.activeSelf)
{
componentInParent.art.SetActive(false);
}
}
}
catch
{
}
}
public static void OnObjectGrabbed(GameObject obj, Hand hand)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)obj == (Object)null)
{
return;
}
try
{
Magazine val = obj.GetComponentInChildren<Magazine>(true) ?? obj.GetComponentInParent<Magazine>(true);
if ((Object)(object)val != (Object)null)
{
int instanceID = ((Object)((Component)val).gameObject).GetInstanceID();
_grabbedMagazineInstanceIds.Add(instanceID);
if (_magazineOriginalScales.TryGetValue(instanceID, out var value))
{
((Component)val).transform.localScale = value;
}
else
{
((Component)val).transform.localScale = Vector3.one;
}
foreach (Renderer componentsInChild in ((Component)val).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
componentsInChild.enabled = true;
componentsInChild.shadowCastingMode = (ShadowCastingMode)1;
}
}
}
foreach (Renderer componentsInChild2 in obj.GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild2 != (Object)null)
{
componentsInChild2.enabled = true;
componentsInChild2.shadowCastingMode = (ShadowCastingMode)1;
}
}
}
catch (Exception ex)
{
MelonLogger.Warning("Error in OnObjectGrabbed: " + ex.Message);
}
}
public static void OnHandGrabbedAmmo(Hand hand)
{
if (!((Object)(object)hand == (Object)null))
{
MelonCoroutines.Start(CoEnsureGrabbedAmmoVisible(hand));
}
}
private static IEnumerator CoEnsureGrabbedAmmoVisible(Hand hand)
{
yield return null;
try
{
if (!((Object)(object)hand != (Object)null))
{
yield break;
}
foreach (Magazine componentsInChild in ((Component)hand).GetComponentsInChildren<Magazine>(true))
{
if ((Object)(object)componentsInChild == (Object)null)
{
continue;
}
int instanceID = ((Object)((Component)componentsInChild).gameObject).GetInstanceID();
_grabbedMagazineInstanceIds.Add(instanceID);
if (_magazineOriginalScales.TryGetValue(instanceID, out var value))
{
((Component)componentsInChild).transform.localScale = value;
}
else
{
((Component)componentsInChild).transform.localScale = Vector3.one;
}
foreach (Renderer componentsInChild2 in ((Component)componentsInChild).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild2 != (Object)null)
{
componentsInChild2.enabled = true;
componentsInChild2.shadowCastingMode = (ShadowCastingMode)1;
}
}
}
}
catch
{
}
}
public static void OnHandHoverBegin()
{
if (ModConfig.ShowAmmoOnHover.Value && ModConfig.HideAmmoPouch.Value)
{
SetLocalPouchAmmoVisible(visible: true);
}
}
public static void OnHandHoverEnd()
{
if (ModConfig.ShowAmmoOnHover.Value && ModConfig.HideAmmoPouch.Value)
{
SetLocalPouchAmmoVisible(visible: false);
}
}
private static void SetLocalPouchAmmoVisible(bool visible)
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
foreach (RigTracker tracker in _trackers)
{
if (!tracker.IsLocal || (Object)(object)tracker.AmmoReceiver == (Object)null)
{
continue;
}
try
{
List<Magazine> magazineArts = tracker.AmmoReceiver._magazineArts;
if (magazineArts == null)
{
continue;
}
Enumerator<Magazine> enumerator2 = magazineArts.GetEnumerator();
while (enumerator2.MoveNext())
{
Magazine current2 = enumerator2.Current;
if ((Object)(object)current2 == (Object)null || IsMagazineGrabbed(current2))
{
continue;
}
int instanceID = ((Object)((Component)current2).gameObject).GetInstanceID();
if (visible)
{
if (_magazineOriginalScales.TryGetValue(instanceID, out var value))
{
((Component)current2).transform.localScale = value;
}
else
{
((Component)current2).transform.localScale = Vector3.one;
}
}
else
{
((Component)current2).transform.localScale = Vector3.zero;
}
foreach (Renderer componentsInChild in ((Component)current2).GetComponentsInChildren<Renderer>(true))
{
if ((Object)(object)componentsInChild != (Object)null)
{
componentsInChild.enabled = visible;
componentsInChild.shadowCastingMode = (ShadowCastingMode)(visible ? 1 : 0);
}
}
}
}
catch
{
}
}
}
private static bool IsMagazineGrabbed(Magazine mag)
{
if ((Object)(object)mag == (Object)null)
{
return false;
}
return _grabbedMagazineInstanceIds.Contains(((Object)((Component)mag).gameObject).GetInstanceID());
}
private static bool IsGrabbedObjectRenderer(Renderer r)
{
if ((Object)(object)r == (Object)null)
{
return false;
}
foreach (int grabbedMagazineInstanceId in _grabbedMagazineInstanceIds)
{
Transform val = ((Component)r).transform;
while ((Object)(object)val != (Object)null)
{
if (((Object)((Component)val).gameObject).GetInstanceID() == grabbedMagazineInstanceId)
{
return true;
}
val = val.parent;
}
}
return false;
}
public static bool IsWeaponOrItemRenderer(Renderer r)
{
if ((Object)(object)r == (Object)null)
{
return false;
}
try
{
if ((Object)(object)((Component)r).GetComponentInParent<InteractableHost>() != (Object)null)
{
return true;
}
if ((Object)(object)((Component)r).GetComponentInParent<Grip>() != (Object)null)
{
return true;
}
if ((Object)(object)((Component)r).GetComponentInParent<MarrowEntity>() != (Object)null)
{
return true;
}
}
catch
{
}
return false;
}
}
[HarmonyPatch(typeof(InventoryAmmoReceiver))]
internal static class AmmoReceiverPatches
{
[HarmonyPatch("UpdateAmmoArt")]
[HarmonyPostfix]
public static void UpdateAmmoArt_Postfix(InventoryAmmoReceiver __instance)
{
try
{
if (ModConfig.HideAmmoPouch.Value)
{
HolsterManager.ApplyAmmoPouchVisibility(__instance);
}
}
catch (Exception ex)
{
MelonLogger.Warning("Error in UpdateAmmoArt postfix: " + ex.Message);
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Start_Postfix(InventoryAmmoReceiver __instance)
{
try
{
if (ModConfig.HideAmmoPouch.Value)
{
HolsterManager.ApplyAmmoPouchVisibility(__instance);
}
}
catch (Exception ex)
{
MelonLogger.Warning("Error in AmmoReceiver.Start postfix: " + ex.Message);
}
}
[HarmonyPatch("SwitchMagazine")]
[HarmonyPostfix]
public static void SwitchMagazine_Postfix(InventoryAmmoReceiver __instance)
{
try
{
if (ModConfig.HideAmmoPouch.Value)
{
HolsterManager.ApplyAmmoPouchVisibility(__instance);
}
}
catch (Exception ex)
{
MelonLogger.Warning("Error in SwitchMagazine postfix: " + ex.Message);
}
}
[HarmonyPatch("OnHandItemSlot")]
[HarmonyPostfix]
public static void OnHandItemSlot_Postfix(InventoryAmmoReceiver __instance)
{
try
{
if (ModConfig.HideAmmoPouch.Value)
{
HolsterManager.ApplyAmmoPouchVisibility(__instance);
}
}
catch (Exception ex)
{
MelonLogger.Warning("Error in OnHandItemSlot postfix: " + ex.Message);
}
}
[HarmonyPatch("OnHandGrab")]
[HarmonyPostfix]
public static void OnHandGrab_Postfix(InventoryAmmoReceiver __instance, Hand hand)
{
try
{
HolsterManager.OnHandGrabbedAmmo(hand);
}
catch (Exception ex)
{
MelonLogger.Warning("Error in AmmoReceiver.OnHandGrab postfix: " + ex.Message);
}
}
[HarmonyPatch("OnHandHoverBegin")]
[HarmonyPostfix]
public static void OnHandHoverBegin_Postfix(InventoryAmmoReceiver __instance, Hand hand)
{
try
{
HolsterManager.OnHandHoverBegin();
}
catch
{
}
}
[HarmonyPatch("OnHandHoverEnd")]
[HarmonyPostfix]
public static void OnHandHoverEnd_Postfix(InventoryAmmoReceiver __instance, Hand hand)
{
try
{
HolsterManager.OnHandHoverEnd();
}
catch
{
}
}
}
[HarmonyPatch(typeof(InventorySlotReceiver))]
internal static class SlotReceiverPatches
{
[HarmonyPatch("OnHandDrop")]
[HarmonyPostfix]
public static void OnHandDrop_Postfix(InventorySlotReceiver __instance)
{
try
{
HolsterManager.OnWeaponSlotted(__instance);
HolsterManager.ApplyHolsterVisibility();
}
catch (Exception ex)
{
MelonLogger.Warning("Error in OnHandDrop postfix: " + ex.Message);
}
}
[HarmonyPatch("OnHandGrab")]
[HarmonyPostfix]
public static void OnHandGrab_Postfix(InventorySlotReceiver __instance, Hand hand)
{
try
{
HolsterManager.OnWeaponUnslotted(__instance, hand);
HolsterManager.ApplyHolsterVisibility();
}
catch (Exception ex)
{
MelonLogger.Warning("Error in OnHandGrab postfix: " + ex.Message);
}
}
[HarmonyPatch("OnHandHoverBegin")]
[HarmonyPostfix]
public static void OnHandHoverBegin_Postfix(InventorySlotReceiver __instance, Hand hand)
{
try
{
if (ModConfig.HideHolsters.Value)
{
HolsterManager.SuppressSlotHover(__instance);
}
}
catch
{
}
}
[HarmonyPatch("OnHandHover")]
[HarmonyPostfix]
public static void OnHandHover_Postfix(InventorySlotReceiver __instance, Hand hand)
{
try
{
if (ModConfig.HideHolsters.Value)
{
HolsterManager.SuppressSlotHover(__instance);
}
}
catch
{
}
}
}
public class MainMod : MelonMod
{
public const string Version = "1.0.2";
public override void OnInitializeMelon()
{
ModConfig.Initialize();
MelonLogger.Msg("[InvisibleHolsters] v1.0.2 loaded. Keeping holsters and ammo pouches functional while hidden!");
}
public override void OnLateInitializeMelon()
{
try
{
Hooking.OnLevelLoaded += HolsterManager.OnLevelLoaded;
Hooking.OnSwitchAvatarPostfix += delegate
{
HolsterManager.OnAvatarSwapped();
};
Hooking.OnGrabObject += delegate(GameObject obj, Hand hand)
{
HolsterManager.OnObjectGrabbed(obj, hand);
};
BoneMenuIntegration.SetupMenu();
MelonLogger.Msg("[InvisibleHolsters] BoneMenu integration initialized.");
}
catch (Exception value)
{
MelonLogger.Error($"[InvisibleHolsters] Error during LateInitialize: {value}");
}
}
public override void OnUpdate()
{
HolsterManager.OnUpdate();
}
public override void OnLateUpdate()
{
HolsterManager.OnLateUpdate();
}
public override void OnPreferencesLoaded()
{
try
{
HolsterManager.ApplyAllVisibility();
}
catch
{
}
}
}
public static class ModConfig
{
public static MelonPreferences_Category PrefCategory { get; private set; }
public static MelonPreferences_Entry<bool> HideHolsters { get; private set; }
public static MelonPreferences_Entry<bool> HideAmmoPouch { get; private set; }
public static MelonPreferences_Entry<bool> HideBodyLog { get; private set; }
public static MelonPreferences_Entry<bool> HideForOtherPlayers { get; private set; }
public static MelonPreferences_Entry<bool> AntiCullingGuard { get; private set; }
public static MelonPreferences_Entry<bool> ShowAmmoOnHover { get; private set; }
public static MelonPreferences_Entry<bool> HideHeadHolster { get; private set; }
public static MelonPreferences_Entry<bool> HideLeftShoulder { get; private set; }
public static MelonPreferences_Entry<bool> HideRightShoulder { get; private set; }
public static MelonPreferences_Entry<bool> HideLeftUnderarm { get; private set; }
public static MelonPreferences_Entry<bool> HideRightUnderarm { get; private set; }
public static MelonPreferences_Entry<bool> HideBackHolster { get; private set; }
public static MelonPreferences_Entry<bool> ShowNotifications { get; private set; }
public static void Initialize()
{
PrefCategory = MelonPreferences.CreateCategory("HolsterHider", "Holster Hider");
HideHolsters = PrefCategory.CreateEntry<bool>("HideHolsters", true, "Hide Weapon Holsters", "Hides holster visual meshes without removing holster interaction/functionality.", false, false, (ValueValidator)null, (string)null);
HideAmmoPouch = PrefCategory.CreateEntry<bool>("HideAmmoPouch", true, "Hide Ammo Pouch & Magazines", "Hides ammo pouch and belt magazine meshes while keeping ammo grab functionality fully intact.", false, false, (ValueValidator)null, (string)null);
HideForOtherPlayers = PrefCategory.CreateEntry<bool>("HideForOtherPlayers", true, "Hide On Other Players (Fusion)", "Also hides holsters and ammo pouches on remote network players in multiplayer.", false, false, (ValueValidator)null, (string)null);
AntiCullingGuard = PrefCategory.CreateEntry<bool>("AntiCullingGuard", true, "Anti-Culling Map Guard", "Prevents map zone culling and distance culling from un-hiding holsters and pouches when players move far apart.", false, false, (ValueValidator)null, (string)null);
ShowAmmoOnHover = PrefCategory.CreateEntry<bool>("ShowAmmoOnHover", false, "Show Ammo When Reaching / Hovering", "Temporarily reveals ammo in pouch when your hand hovers over it before grabbing.", false, false, (ValueValidator)null, (string)null);
HideBodyLog = PrefCategory.CreateEntry<bool>("HideBodyLog", false, "Hide BodyLog Device", "Hides the bodylog ball mesh on chest/wrist while keeping pullcord functionality.", false, false, (ValueValidator)null, (string)null);
HideHeadHolster = PrefCategory.CreateEntry<bool>("HideHeadHolster", true, "Hide Head Holster", (string)null, false, false, (ValueValidator)null, (string)null);
HideLeftShoulder = PrefCategory.CreateEntry<bool>("HideLeftShoulder", true, "Hide Left Shoulder Holster", (string)null, false, false, (ValueValidator)null, (string)null);
HideRightShoulder = PrefCategory.CreateEntry<bool>("HideRightShoulder", true, "Hide Right Shoulder Holster", (string)null, false, false, (ValueValidator)null, (string)null);
HideLeftUnderarm = PrefCategory.CreateEntry<bool>("HideLeftUnderarm", true, "Hide Left Hip/Underarm Holster", (string)null, false, false, (ValueValidator)null, (string)null);
HideRightUnderarm = PrefCategory.CreateEntry<bool>("HideRightUnderarm", true, "Hide Right Hip/Underarm Holster", (string)null, false, false, (ValueValidator)null, (string)null);
HideBackHolster = PrefCategory.CreateEntry<bool>("HideBackHolster", true, "Hide Back Holster", (string)null, false, false, (ValueValidator)null, (string)null);
ShowNotifications = PrefCategory.CreateEntry<bool>("ShowNotifications", true, "Show BoneLib Notifications", (string)null, false, false, (ValueValidator)null, (string)null);
PrefCategory.SaveToFile(false);
}
public static void SetAllHolsters(bool hide)
{
HideHolsters.Value = hide;
HideHeadHolster.Value = hide;
HideLeftShoulder.Value = hide;
HideRightShoulder.Value = hide;
HideLeftUnderarm.Value = hide;
HideRightUnderarm.Value = hide;
HideBackHolster.Value = hide;
PrefCategory.SaveToFile(false);
}
public static void SetEverything(bool hide)
{
SetAllHolsters(hide);
HideAmmoPouch.Value = hide;
HideBodyLog.Value = hide;
PrefCategory.SaveToFile(false);
}
}
public static class NotificationHelper
{
public static void Show(string title, string message, NotificationType type = (NotificationType)0, float duration = 2f)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
if (!ModConfig.ShowNotifications.Value)
{
return;
}
try
{
Notifier.Send(new Notification
{
Title = new NotificationText(title, new Color(0.2f, 0.7f, 1f), false),
Message = new NotificationText(message, Color.white, false),
Type = type,
PopupLength = duration,
ShowTitleOnPopup = true
});
}
catch (Exception ex)
{
MelonLogger.Warning("Could not send BoneLib notification: " + ex.Message);
}
}
public static void ShowSuccess(string title, string message, float duration = 2f)
{
Show(title, message, (NotificationType)3, duration);
}
}
}