Decompiled source of Weapon Double XP v1.0.0

WeaponDoubleXp.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("WeaponDoubleXp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponDoubleXp")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ca06dab9-9b7a-407a-a7fa-540c7fca0449")]
[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 WeaponDoubleXp;

[BepInPlugin("kumo.sulfur.weapon_double_xp", "Weapon Double XP", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	private Harmony harmony;

	private const string TargetTypeName = "PerfectRandom.Sulfur.Core.Weapons.Weapon";

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		harmony = new Harmony("kumo.sulfur.weapon_double_xp");
		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("DoubleWeaponXpPrefix", BindingFlags.Static | BindingFlags.NonPublic));
		harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Weapon Double XP loaded. Patched Weapon.AddExperience(float).");
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
	}

	private static void DoubleWeaponXpPrefix(ref float __0)
	{
		if (!(__0 <= 0f))
		{
			__0 *= 2f;
		}
	}
}