using System;
using System.Diagnostics;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PeakConvenientBackpacks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Peak Convenient Backpacks")]
[assembly: AssemblyTitle("PeakConvenientBackpacks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 PeakConvenientBackpacks
{
[HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")]
public class CharacterAfflictions_UpdateWeight
{
private static bool Prefix(CharacterAfflictions __instance)
{
float num = 0f;
for (int i = 0; i < __instance.character.player.itemSlots.Length; i++)
{
ItemSlot val = __instance.character.player.itemSlots[i];
if ((Object)(object)val.prefab != (Object)null)
{
num += (float)val.prefab.CarryWeight;
}
}
BackpackSlot backpackSlot = __instance.character.player.backpackSlot;
BackpackData val2 = default(BackpackData);
if (!((ItemSlot)backpackSlot).IsEmpty() && ((ItemSlot)backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
{
for (int j = 0; j < val2.itemSlots.Length; j++)
{
ItemSlot val3 = val2.itemSlots[j];
if (!val3.IsEmpty())
{
float num2 = (100f - Plugin.BackpackWeightReductionPercentage.Value) / 100f;
float num3 = (float)val3.prefab.CarryWeight * num2;
num += num3;
}
}
}
if ((Object)(object)__instance.character.data.carriedPlayer != (Object)null)
{
num += 8f;
}
__instance.SetStatus((STATUSTYPE)7, 0.025f * num);
return false;
}
}
[BepInPlugin("PeakConvenientBackpacks", "Peak Convenient Backpacks", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static ConfigEntry<float> BackpackWeightReductionPercentage;
private void Awake()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
BackpackWeightReductionPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BackpackWeightReductionPercentage", 50f, "Percentage of weight reduction for items in backpacks (0-100)");
Logger.LogInfo((object)string.Format("Plugin {0} is loaded with weight reduction set to {1}%", "PeakConvenientBackpacks", BackpackWeightReductionPercentage.Value));
new Harmony("PeakConvenientBackpacks").PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PeakConvenientBackpacks";
public const string PLUGIN_NAME = "Peak Convenient Backpacks";
public const string PLUGIN_VERSION = "1.0.0";
}
}