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.2.0")]
public class Plugin : BaseUnityPlugin
{
private class BaseGun
{
public string GoldGun { get; }
public string GoldMag { get; }
public string BaseGoldGun { get; }
public string BaseGunTrophy { get; }
public BaseGun(string goldGun, string goldMag, string baseGoldGun, string baseGunTrophy)
{
GoldGun = goldGun;
GoldMag = goldMag;
BaseGoldGun = baseGoldGun;
BaseGunTrophy = baseGunTrophy;
}
}
private static readonly Dictionary<string, BaseGun> unlockIDs = new Dictionary<string, BaseGun>
{
{
"wolfire.smith_and_wesson_model_10",
new BaseGun("wolfire.smith_and_wesson_model_10_gold", null, "wolfire.model_10_base_gold", "wolfire.statue_model10")
},
{
"wolfire.colt_detective",
new BaseGun("wolfire.colt_detective_gold", null, "wolfire.colt_detective_base_gold", "wolfire.statue_detective_special")
},
{
"wolfire.colt_m1911",
new BaseGun("wolfire.colt_m1911_gold", "wolfire.colt_1911_std_cap_mag_gold", "wolfire.colt_m1911_base_gold", "wolfire.statue_1911")
},
{
"wolfire.glock_17",
new BaseGun("wolfire.glock_17_gold", "wolfire.glock_17_std_cap_mag_gold", "wolfire.glock17_base_gold", "wolfire.statue_glock17")
},
{
"wolfire.beretta_m9",
new BaseGun("wolfire.beretta_m9_gold", "wolfire.beretta_std_cap_mag_gold", "wolfire.beretta_m9_base_gold", "wolfire.statue_beretta_m9")
},
{
"wolfire.hi_point_c9",
new BaseGun("wolfire.hi_point_c9_gold", "wolfire.hi_point_c9_std_cap_mag_gold", "wolfire.hi_point_c9_base_gold", "wolfire.statue_hipoint")
},
{
"wolfire.sig226",
new BaseGun("wolfire.sig226_gold", "wolfire.p226_std_cap_mag_gold", "wolfire.sig226_base_gold", "wolfire.statue_sig226")
},
{
"wolfire.desert_eagle",
new BaseGun("wolfire.desert_eagle_gold", "wolfire.desert_eagle_std_cap_mag_gold", "wolfire.desert_eagle_base_gold", "wolfire.statue_desert_eagle")
},
{
"wolfire.colt_saa",
new BaseGun("wolfire.colt_saa_gold", null, "wolfire.colt_saa_base_gold", "wolfire.statue_saa")
}
};
private static ConfigEntry<bool> enableRankingCampaign;
private static ConfigEntry<bool> enableClassic;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin GoldSpawner2 is Loaded!");
enableRankingCampaign = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "(2) Enable in RankingCampaign", true, "Replace guns with gold versions in The Dreaming\n(if gun is unlocked in Compound)");
enableClassic = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "(4) Enable in Classic", true, "Replace guns with gold versions in Classic Mode.\n(if gun and trophy are unlocked in Compound)");
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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Invalid comparison between Unknown and I4
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Invalid comparison between Unknown and I4
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
GameMode gameMode = __instance.game_mode.GetGameMode();
bool flag = enableRankingCampaign.Value && (int)gameMode == 2;
bool flag2 = enableClassic.Value && (int)gameMode == 4;
if (!flag && !flag2)
{
return;
}
PlayerLoadout currentLoadout = __instance.CurrentLoadout;
string gun_internal_name = currentLoadout.gun_internal_name;
if (!unlockIDs.TryGetValue(gun_internal_name, out var value))
{
return;
}
bool flag3 = false;
if (flag)
{
flag3 = __instance.MallData.IsItemGroupUnlocked(value.BaseGoldGun);
}
else if (flag2)
{
flag3 = TrophyUnlockManager.IsTrophyUnlocked(value.BaseGunTrophy) && __instance.MallData.IsItemGroupUnlocked(value.BaseGoldGun);
}
if (!flag3)
{
return;
}
currentLoadout.gun_internal_name = value.GoldGun;
foreach (PlayerLoadoutEquipment item in currentLoadout.equipment)
{
if ((int)item.equipment_type == 0 && value.GoldMag != null && (int)item.magazine_class == 1)
{
item.internal_name = value.GoldMag;
item.magazine_class = (MagazineClass)4;
}
else if ((int)item.equipment_type == 1 && __instance.MallData.IsItemGroupUnlocked("wolfire.flashlight_gold") && (flag || (flag2 && TrophyUnlockManager.IsTrophyUnlocked("wolfire.statue_music_head"))))
{
item.internal_name = "wolfire.flashlight_gold";
}
}
}
}