using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using ValPlusCarryWeight.Config;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ValPlusCarryWeight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ValPlusCarryWeight")]
[assembly: AssemblyTitle("ValPlusCarryWeight")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.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;
}
}
[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 ValPlusCarryWeight
{
internal static class Log
{
internal static ManualLogSource? Source;
internal static void Info(string msg)
{
ManualLogSource? source = Source;
if (source != null)
{
source.LogInfo((object)msg);
}
}
internal static void Warning(string msg)
{
ManualLogSource? source = Source;
if (source != null)
{
source.LogWarning((object)msg);
}
}
internal static void Error(string msg)
{
ManualLogSource? source = Source;
if (source != null)
{
source.LogError((object)msg);
}
}
}
[BepInPlugin("starksan.valpluscarryweight", "ValPLUS Carry Weight (Stark-san)", "1.0.3")]
public sealed class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "starksan.valpluscarryweight";
public const string PluginName = "ValPLUS Carry Weight (Stark-san)";
public const string PluginVersion = "1.0.3";
private Harmony? _harmony;
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
WeightConfig.Bind(((BaseUnityPlugin)this).Config);
Log.Source = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("starksan.valpluscarryweight");
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"ValPLUS Carry Weight (Stark-san) v1.0.3 loaded.");
}
private void OnDestroy()
{
try
{
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
catch
{
}
}
}
}
namespace ValPlusCarryWeight.Features.Weight
{
[HarmonyPatch(typeof(Player))]
internal static class PlayerCarryWeightPatch
{
[HarmonyPatch]
private static class OptionalOnSpawned
{
private static MethodBase? TargetMethod()
{
return AccessTools.Method(typeof(Player), "OnSpawned", (Type[])null, (Type[])null);
}
private static void Postfix(Player __instance)
{
Apply(__instance, "OnSpawned");
}
}
private const float VanillaBaseCarryWeight = 300f;
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(Player __instance)
{
Apply(__instance, "Start");
}
private static void Apply(Player p, string caller)
{
if (!((Object)(object)p == (Object)null) && WeightConfig.Enabled.Value)
{
float num = 300f;
float num2 = Mathf.Max(0f, WeightConfig.CarryWeightMultiplier.Value);
float value = WeightConfig.CarryWeightAdd.Value;
float maxCarryWeight = p.m_maxCarryWeight;
float num3 = (p.m_maxCarryWeight = num * num2 + value);
Log.Info($"[CarryWeight] Applied via {caller}: base={num} mult={num2} add={value} old={maxCarryWeight} new={num3}");
}
}
}
}
namespace ValPlusCarryWeight.Config
{
internal static class WeightConfig
{
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<float> CarryWeightMultiplier;
internal static ConfigEntry<float> CarryWeightAdd;
internal static void Bind(ConfigFile cfg)
{
Enabled = cfg.Bind<bool>("Weight", "Enabled", true, "Ativa o ajuste de peso máximo carregável.");
CarryWeightMultiplier = cfg.Bind<float>("Weight", "CarryWeightMultiplier", 1f, "Multiplicador do peso máximo (ex.: 2.0 = dobro).");
CarryWeightAdd = cfg.Bind<float>("Weight", "CarryWeightAdd", 0f, "Valor adicional ao peso máximo (ex.: 150 = +150).");
}
}
}