using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("HeadRest")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+961484daef7f2d4264268a627fab12de51712e61")]
[assembly: AssemblyProduct("HeadRest")]
[assembly: AssemblyTitle("HeadRest")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 HeadRest
{
[BepInPlugin("HeadRest", "HeadRest", "1.0.2")]
public class HeadRestPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private readonly Harmony _harmony = new Harmony("HeadRest");
public static readonly List<string> BossTrophyNames = new List<string>(7) { "TrophyEikthyr", "TrophyTheElder", "TrophyBonemass", "TrophyDragonQueen", "TrophyGoblinKing", "TrophySeekerQueen", "TrophyFader" };
public static ConfigEntry<float> MaxRadius;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
_setupConfig();
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
Logger.LogInfo((object)"Plugin HeadRest is loaded!");
}
private void _setupConfig()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
MaxRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Max Radius", 10f, new ConfigDescription("The maximum distance the boss head can be at to count towards comfort level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>()));
}
}
[HarmonyPatch(typeof(SE_Rested))]
public static class SE_RestedPatch
{
[HarmonyPostfix]
[HarmonyPatch("CalculateComfortLevel", new Type[] { typeof(Player) })]
private static void CalculateComfortLevelPostfix(Player player, ref int __result)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!player.InShelter())
{
return;
}
List<Piece> list = new List<Piece>();
Piece.GetAllPiecesInRadius(((Component)player).transform.position, HeadRestPlugin.MaxRadius.Value, list);
List<Piece> list2 = list.Where((Piece p) => p.m_name.Contains("itemstand")).ToList();
List<string> list3 = new List<string>();
ItemStand val = default(ItemStand);
foreach (Piece item in list2)
{
if (((Component)item).TryGetComponent<ItemStand>(ref val) && !list3.Contains(val.GetAttachedItem()) && HeadRestPlugin.BossTrophyNames.Contains(val.GetAttachedItem()))
{
list3.Add(val.GetAttachedItem());
__result++;
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HeadRest";
public const string PLUGIN_NAME = "HeadRest";
public const string PLUGIN_VERSION = "1.0.2";
}
}