Decompiled source of GoldenGuns v2.0.1

GoldenGuns.dll

Decompiled 3 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Receiver2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GoldenGuns")]
[assembly: AssemblyDescription("Use golden guns in RankedCampaign and/or Classic modes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCompany("Luther7718")]
[assembly: AssemblyProduct("Receiver 2")]
[assembly: AssemblyCopyright("Copyleft 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0bb8f367-e8d2-4fa4-a3dd-ecc0bc58efff")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GoldenGuns;

[BepInPlugin("GoldenGuns", "GoldenGuns", "2.0.0")]
public class Plugin : BaseUnityPlugin
{
	private static Dictionary<string, string> gunmap = new Dictionary<string, string>
	{
		{ "wolfire.smith_and_wesson_model_10", "wolfire.smith_and_wesson_model_10_gold" },
		{ "wolfire.colt_detective", "wolfire.colt_detective_gold" },
		{ "wolfire.colt_saa", "wolfire.colt_saa_gold" },
		{ "wolfire.hi_point_c9", "wolfire.hi_point_c9_gold" },
		{ "wolfire.glock_17", "wolfire.glock_17_gold" },
		{ "wolfire.beretta_m9", "wolfire.beretta_m9_gold" },
		{ "wolfire.sig226", "wolfire.sig226_gold" },
		{ "wolfire.desert_eagle", "wolfire.desert_eagle_gold" },
		{ "wolfire.colt_m1911", "wolfire.colt_m1911_gold" }
	};

	private static Dictionary<string, string> challengemap = new Dictionary<string, string>
	{
		{ "wolfire.smith_and_wesson_model_10", "wolfire.model_10_base_gold" },
		{ "wolfire.colt_detective", "wolfire.colt_detective_base_gold" },
		{ "wolfire.colt_saa", "wolfire.colt_saa_base_gold" },
		{ "wolfire.hi_point_c9", "wolfire.hi_point_c9_base_gold" },
		{ "wolfire.glock_17", "wolfire.glock17_base_gold" },
		{ "wolfire.beretta_m9", "wolfire.beretta_m9_base_gold" },
		{ "wolfire.sig226", "wolfire.sig226_base_gold" },
		{ "wolfire.desert_eagle", "wolfire.desert_eagle_base_gold" },
		{ "wolfire.colt_m1911", "wolfire.colt_m1911_base_gold" }
	};

	private static Dictionary<string, string> magmap = new Dictionary<string, string>
	{
		{ "wolfire.hi_point_c9", "wolfire.hi_point_c9_std_cap_mag_gold" },
		{ "wolfire.glock_17", "wolfire.glock_17_std_cap_mag_gold" },
		{ "wolfire.beretta_m9", "wolfire.beretta_std_cap_mag_gold" },
		{ "wolfire.sig226", "wolfire.p226_std_cap_mag_gold" },
		{ "wolfire.desert_eagle", "wolfire.desert_eagle_std_cap_mag_gold" },
		{ "wolfire.colt_m1911", "wolfire.colt_1911_std_cap_mag_gold" }
	};

	private static ConfigEntry<bool> enableRankedCampaign;

	private static ConfigEntry<bool> enableClassic;

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin GoldSpawner is loaded!");
		enableRankedCampaign = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable in RankedCampaign", true, "Replace guns with gold versions in The Dreaming.");
		enableClassic = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable in Classic", true, "Replace guns with gold versions in Classic Mode.");
		Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
	}

	[HarmonyPatch(typeof(ReceiverCoreScript), "SpawnPlayer")]
	[HarmonyPrefix]
	public static void OnSpawnPlayer(ReceiverCoreScript __instance)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Invalid comparison between Unknown and I4
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Invalid comparison between Unknown and I4
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Invalid comparison between Unknown and I4
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		GameMode gameMode = __instance.game_mode.GetGameMode();
		bool num = enableRankedCampaign.Value && (int)gameMode == 2;
		bool flag = enableClassic.Value && (int)gameMode == 4;
		if (!num && !flag)
		{
			return;
		}
		PlayerLoadout currentLoadout = __instance.CurrentLoadout;
		string gun_internal_name = currentLoadout.gun_internal_name;
		if (!gunmap.ContainsKey(gun_internal_name))
		{
			return;
		}
		string text = challengemap[gun_internal_name];
		if (!__instance.MallData.IsItemGroupUnlocked(text))
		{
			return;
		}
		currentLoadout.gun_internal_name = gunmap[gun_internal_name];
		if (!magmap.ContainsKey(gun_internal_name))
		{
			return;
		}
		string internal_name = magmap[gun_internal_name];
		foreach (PlayerLoadoutEquipment item in currentLoadout.equipment)
		{
			if ((int)item.equipment_type == 0 && (int)item.magazine_class == 1)
			{
				item.internal_name = internal_name;
				item.magazine_class = (MagazineClass)4;
			}
		}
	}
}