using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UK_WeaponIconsEditor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UK_WeaponIconsEditor")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3b5b1b94-cd54-444b-93ae-9d8970feb4c2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UK_WeaponIconsEditor;
[BepInPlugin("com.exmagikguy.ukNewWeaponIcons", "Weapon Icons Changer", "1.0.0")]
[DefaultExecutionOrder(-100)]
public class WeaponIconEdit : BaseUnityPlugin
{
private Dictionary<string, Sprite> customPNGs = new Dictionary<string, Sprite>();
private readonly string pngsPath = Path.Combine(Paths.PluginPath, "UK_WeaponIconsEditor", "arsenalPNGs");
private readonly List<string> weapons = new List<string>
{
"pier", "mark", "shar", "pier_a", "mark_a", "shar_a", "core", "pump", "sawe", "core_a",
"pump_a", "sawe_a", "attr", "over", "jump", "attr_a", "over_a", "jump_a", "elec", "scre",
"mali", "frez", "srs ", "fire"
};
private List<Sprite> iconSprites = new List<Sprite>();
private void Start()
{
SendLog("---<===!WEAPON ICON EDIT LOADED!===>---");
SceneManager.sceneLoaded += OnSceneLoad;
SendLog("---<===!Editor's Scene loading code initialized!===>---");
for (int i = 0; i < weapons.Count; i++)
{
iconSprites.Add(LoadPNG(weapons[i]));
}
}
private void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
if (!((Object)(object)MonoSingleton<GunControl>.Instance == (Object)null))
{
MonoSingleton<GunControl>.Instance.OnWeaponChange += EditAct;
}
}
private Sprite LoadPNG(string imageName)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(pngsPath, imageName + ".png")));
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 250f);
}
private void PrepareEdit()
{
EditIcon(MonoSingleton<GunControl>.Instance.currentWeapon, repeat: false);
}
private void EditAct(GameObject fix)
{
EditIcon(MonoSingleton<GunControl>.Instance.currentWeapon);
}
private void EditIcon(GameObject weapon, bool repeat = true)
{
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
GunControl instance = MonoSingleton<GunControl>.Instance;
bool flag = false;
int num = 0;
if (Object.op_Implicit((Object)(object)weapon.GetComponent<Revolver>()))
{
Revolver component = weapon.GetComponent<Revolver>();
flag = component.altVersion;
num = 1;
if (flag)
{
num = 4;
}
num += component.gunVariation;
}
else if (Object.op_Implicit((Object)(object)weapon.GetComponent<Shotgun>()))
{
Shotgun component2 = weapon.GetComponent<Shotgun>();
num = 7;
num += component2.variation;
}
else if (Object.op_Implicit((Object)(object)weapon.GetComponent<ShotgunHammer>()))
{
ShotgunHammer component3 = weapon.GetComponent<ShotgunHammer>();
num = 10;
num += component3.variation;
}
else if (Object.op_Implicit((Object)(object)weapon.GetComponent<Nailgun>()))
{
Nailgun component4 = weapon.GetComponent<Nailgun>();
flag = component4.altVersion;
num = 13;
if (flag)
{
num = 16;
}
num += component4.variation;
}
else if (Object.op_Implicit((Object)(object)weapon.GetComponent<Railcannon>()))
{
Railcannon component5 = weapon.GetComponent<Railcannon>();
num = 19;
num += component5.variation;
}
else if (Object.op_Implicit((Object)(object)weapon.GetComponent<RocketLauncher>()))
{
RocketLauncher component6 = weapon.GetComponent<RocketLauncher>();
num = 22;
num += component6.variation;
}
if (num >= 1 && num <= 24)
{
Dictionary<int, string> dictionary = new Dictionary<int, string>
{
{ 1, "pier" },
{ 2, "mark" },
{ 3, "shar" },
{ 4, "pier_a" },
{ 5, "mark_a" },
{ 6, "shar_a" },
{ 7, "core" },
{ 8, "pump" },
{ 9, "sawe" },
{ 10, "core_a" },
{ 11, "over_a" },
{ 12, "sawe_a" },
{ 13, "attr" },
{ 14, "over" },
{ 15, "jump" },
{ 16, "attr_a" },
{ 17, "over_a" },
{ 18, "jump_a" },
{ 19, "elec" },
{ 20, "scre" },
{ 21, "mali" },
{ 22, "frez" },
{ 23, "srs " },
{ 24, "fire" }
};
MonoSingleton<ColorBlindSettings>.Instance.variationColors[3] = Color.white;
Sprite val = iconSprites[num - 1];
MonoSingleton<WeaponHUD>.Instance.UpdateImage(val, val, 3);
if (repeat)
{
((MonoBehaviour)this).Invoke("PrepareEdit", Time.deltaTime);
}
}
}
private void SendLog(string log)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)log);
}
}