using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HelmetBeGone")]
[assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/HelmetBeGone/")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyProduct("HelmetBeGone")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("69CA2A25-FAF5-4772-9362-E06779AD650F")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.7.0")]
[module: UnverifiableCode]
namespace HelmetBeGone;
[BepInPlugin("blacks7ar.HelmetBeGone", "HelmetBeGone", "1.0.7")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
public static class VisEquipmentPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(VisEquipment), "SetHelmetEquipped")]
private static bool SetHelmetEquipped_Prefix(ref VisEquipment __instance, int hash)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: 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)
switch (hash)
{
case 0:
return true;
case 703889544:
return true;
default:
{
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "main")
{
return false;
}
if (_hideShowHelmet == null)
{
return false;
}
if (Input.GetKeyDown(_hideShowHelmet.Value) && !_helmetOn && ((Character)Player.m_localPlayer).TakeInput())
{
if (Object.op_Implicit((Object)(object)__instance.m_helmetItemInstance) && (Object)(object)__instance.m_helmetItemInstance != (Object)null)
{
__instance.m_helmetHideHair = (HelmetHairType)2;
__instance.m_helmetHideBeard = (HelmetHairType)0;
bool flag = false;
if (Object.op_Implicit((Object)(object)__instance.m_nViewOverride))
{
flag = ((Object)__instance.m_nViewOverride).name.ToLower().Contains("stand");
}
if (!flag)
{
__instance.m_helmetItemInstance.SetActive(false);
}
}
_helmetOn = true;
return true;
}
if (Input.GetKeyDown(_hideShowHelmet.Value) && _helmetOn && ((Character)Player.m_localPlayer).TakeInput())
{
if (Object.op_Implicit((Object)(object)__instance.m_hairItemInstance))
{
if (!__instance.m_helmetItem.ToLower().Contains("dverger"))
{
__instance.m_helmetHideHair = (HelmetHairType)1;
}
__instance.m_helmetHideBeard = (HelmetHairType)0;
__instance.m_helmetItemInstance.SetActive(true);
}
_helmetOn = false;
return false;
}
return false;
}
}
}
}
private const string modGUID = "blacks7ar.HelmetBeGone";
public const string modName = "HelmetBeGone";
public const string modAuthor = "blacks7ar";
public const string modVersion = "1.0.7";
public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/HelmetBeGone/";
private static readonly Harmony _harmony = new Harmony("blacks7ar.HelmetBeGone");
private static ConfigEntry<KeyCode> _hideShowHelmet;
private static bool _helmetOn;
public void Awake()
{
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
_hideShowHelmet = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Hotkey", (KeyCode)104, "Hotkey to hide/show helmet.");
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
}
}