using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using FirstPersonItem;
using GTFO.API.Utilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("InvisibleGuns")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InvisibleGuns")]
[assembly: AssemblyTitle("InvisibleGuns")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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;
}
}
}
namespace Andocas.InvisibleGuns
{
internal static class ConfigManager
{
internal static readonly ConfigEntry<bool> hideMeleeSlot;
internal static readonly ConfigEntry<bool> hideStandardSlot;
internal static readonly ConfigEntry<bool> hideSpecialSlot;
internal static readonly ConfigEntry<bool> hideClassSlot;
internal static readonly ConfigEntry<bool> gunVisibleWhenAiming;
internal static readonly ConfigEntry<bool> crosshairVisibleWhenAiming;
static ConfigManager()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "Andocas.InvisibleGuns.cfg"), true);
hideMeleeSlot = val.Bind<bool>("Slots", "Hide melee weapon", false, "Make melee weapon invisible");
hideStandardSlot = val.Bind<bool>("Slots", "Hide main weapon", true, "Make main weapon invisible");
hideSpecialSlot = val.Bind<bool>("Slots", "Hide special weapon", true, "Make special weapon invisible");
hideClassSlot = val.Bind<bool>("Slots", "Hide tool", false, "Make tool invisible");
gunVisibleWhenAiming = val.Bind<bool>("ADS", "Show weapon when ADS", false, "Make weapon visible when aiming down sights");
crosshairVisibleWhenAiming = val.Bind<bool>("ADS", "Show crosshair when ADS", true, "Make crosshair visible when aiming down sights");
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("dev.gtfomodding.gtfo-api"))
{
Utils.LogInfo("Creating LiveEdit Listener.");
SetupLiveEditListener(val);
}
else
{
Utils.LogInfo("GTFO-API is not loaded. Proceeding without LiveEdit.");
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void SetupLiveEditListener(ConfigFile configFile)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
ConfigFile configFile2 = configFile;
LiveEditListener val = LiveEdit.CreateListener(Path.GetDirectoryName(configFile2.ConfigFilePath), Path.GetFileName(configFile2.ConfigFilePath), false);
val.FileChanged += (LiveEditEventHandler)delegate
{
configFile2.Reload();
};
}
}
internal static class CorePatches
{
[HarmonyPatch(typeof(PlayerInventoryLocal), "DoWieldItem")]
[HarmonyPostfix]
private static void PlayerInventoryLocal__DoWieldItem__Postfix()
{
ConditionallyHideWieldedItem();
}
[HarmonyPatch(typeof(FPIS_Aim), "Enter")]
[HarmonyPostfix]
private static void FPIS_Aim__Enter__Postfix()
{
if (ConfigManager.crosshairVisibleWhenAiming.Value)
{
GuiManager.CrosshairLayer.ShowPrecisionDot();
}
if (ConfigManager.gunVisibleWhenAiming.Value)
{
SetWieldedItemVisible(visible: true);
}
}
[HarmonyPatch(typeof(FPIS_Aim), "Exit")]
[HarmonyPostfix]
private static void FPIS_Aim__Exit__Postfix()
{
ConditionallyHideWieldedItem();
}
private static bool ConditionallyHideWieldedItem()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Invalid comparison between Unknown and I4
PlayerInventoryBase inventory = PlayerManager.GetLocalPlayerAgent().Inventory;
if ((ConfigManager.hideMeleeSlot.Value && (int)inventory.WieldedSlot == 10) || (ConfigManager.hideStandardSlot.Value && (int)inventory.WieldedSlot == 1) || (ConfigManager.hideSpecialSlot.Value && (int)inventory.WieldedSlot == 2) || (ConfigManager.hideClassSlot.Value && (int)inventory.WieldedSlot == 3))
{
SetWieldedItemVisible(visible: false);
return true;
}
return false;
}
private static void SetWieldedItemVisible(bool visible)
{
ItemEquippable wieldedItem = PlayerManager.GetLocalPlayerAgent().Inventory.WieldedItem;
if (wieldedItem != null)
{
((Component)wieldedItem.GearPartHolder).gameObject.SetActive(visible);
}
}
}
internal static class PluginInfo
{
public const string GUID = "Andocas.InvisibleGuns";
public const string NAME = "InvisibleGuns";
public const string VERSION = "0.1.0";
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Andocas.InvisibleGuns", "InvisibleGuns", "0.1.0")]
internal class Plugin : BasePlugin
{
public override void Load()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Utils.LogInfo("Andocas.InvisibleGuns is loading...");
Harmony val = new Harmony("Andocas.InvisibleGuns");
val.PatchAll(typeof(CorePatches));
_ = ConfigManager.hideStandardSlot;
Utils.LogInfo("Andocas.InvisibleGuns is loaded");
}
}
internal static class Utils
{
private static readonly ManualLogSource logger = Logger.CreateLogSource("Andocas.InvisibleGuns");
public static void LogInfo(object? o)
{
logger.LogInfo((object)GetMessage(o));
}
public static void LogError(object? o)
{
logger.LogError((object)GetMessage(o));
}
private static string GetMessage(object? o)
{
if (o == null)
{
return "No string representation for <null>";
}
return o.ToString() ?? $"No string representation for <{o.GetType()}>";
}
public static void SendLocalMessage(string text)
{
LogInfo("SendLocalMessage: " + text);
GuiManager.PlayerLayer.m_gameEventLog.AddLogItem(text, (eGameEventChatLogType)2);
CM_PageLoadout.Current.m_gameEventLog.AddLogItem(text, (eGameEventChatLogType)2);
}
public static void SendChatMessage(string text)
{
LogInfo("SendChatMessage: " + text);
string text2 = "<#ff0>";
int num = 50 - text2.Length;
while (text.Length > num)
{
PlayerChatManager.WantToSentTextMessage(PlayerManager.GetLocalPlayerAgent(), text2 + text.Substring(0, num).Trim(), (PlayerAgent)null);
text = text.Substring(num).Trim();
}
PlayerChatManager.WantToSentTextMessage(PlayerManager.GetLocalPlayerAgent(), text2 + text, (PlayerAgent)null);
}
}
}