using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WeaponXpMultiplier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponXpMultiplier")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fd80dd3b-1bcb-4fad-8858-2a258afe6e4c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeaponXpMultiplier;
[BepInPlugin("kumo.sulfur.weapon_xp_multiplier", "Weapon XP Multiplier", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static ConfigEntry<bool> EnableMod;
internal static ConfigEntry<float> XpMultiplier;
internal static ConfigEntry<bool> LogXpChanges;
private Harmony harmony;
private const string TargetTypeName = "PerfectRandom.Sulfur.Core.Weapons.Weapon";
private void Awake()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enable weapon XP multiplier.");
XpMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "XpMultiplier", 2f, new ConfigDescription("Weapon XP multiplier. 1.0 = vanilla, 2.0 = double XP, 10.0 = ten times XP.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
LogXpChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogXpChanges", false, "Log weapon XP changes. Keep false for normal gameplay.");
harmony = new Harmony("kumo.sulfur.weapon_xp_multiplier");
Type type = AccessTools.TypeByName("PerfectRandom.Sulfur.Core.Weapons.Weapon");
if (type == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Could not find type: PerfectRandom.Sulfur.Core.Weapons.Weapon");
return;
}
MethodInfo methodInfo = AccessTools.Method(type, "AddExperience", new Type[1] { typeof(float) }, (Type[])null);
if (methodInfo == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Weapon.AddExperience(float).");
return;
}
HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("WeaponXpMultiplierPrefix", BindingFlags.Static | BindingFlags.NonPublic));
harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Weapon XP Multiplier loaded. Patched Weapon.AddExperience(float).");
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
private static void WeaponXpMultiplierPrefix(object __instance, ref float __0)
{
if (!EnableMod.Value || __0 <= 0f)
{
return;
}
float num = XpMultiplier.Value;
if (float.IsNaN(num) || float.IsInfinity(num))
{
num = 1f;
}
num = Math.Max(0f, Math.Min(100f, num));
if (Math.Abs(num - 1f) < 0.0001f)
{
return;
}
float num2 = __0;
__0 *= num;
if (LogXpChanges.Value)
{
string text = ((__instance != null) ? __instance.ToString() : "Unknown Weapon");
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)("Weapon XP changed for " + text + ": " + num2 + " -> " + __0));
}
}
}
}