using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AdditionalSuits")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AdditionalSuits")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0c25b026-8574-4dd2-9af2-4265f618ef8a")]
[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 AdditionalSuits;
[BepInPlugin("ACS.AdditionalSuits", "AdditionalSuits", "1.0.2")]
public class AdditionalSuitsBase : BaseUnityPlugin
{
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(ref StartOfRound __instance)
{
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
try
{
if (SuitsLoaded)
{
return;
}
for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++)
{
UnlockableItem val = __instance.unlockablesList.unlockables[i];
mls.LogInfo((object)("AdditionalSuits - processing unlockable {index=" + i + ", name=" + val.unlockableName + "}"));
if (!((Object)(object)val.suitMaterial == (Object)null) && val.alreadyUnlocked)
{
string[] files = Directory.GetFiles(SuitTextureFolder, "*.png");
string[] array = files;
foreach (string text in array)
{
mls.LogInfo((object)("AdditionalSuits - adding suit {file=" + text + "}"));
UnlockableItem val2 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val));
Material val3 = Object.Instantiate<Material>(val2.suitMaterial);
Texture2D val4 = new Texture2D(2, 2);
ImageConversion.LoadImage(val4, File.ReadAllBytes(Path.Combine(SuitTextureFolder, text)));
val3.mainTexture = (Texture)(object)val4;
val2.suitMaterial = val3;
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
val2.unlockableName = fileNameWithoutExtension.Replace("_", " ").Substring(2);
__instance.unlockablesList.unlockables.Add(val2);
}
SuitsLoaded = true;
break;
}
}
}
catch (Exception ex)
{
mls.LogInfo((object)("AdditionalSuits - initialization failed!\nERROR: " + ex));
}
}
}
private static AdditionalSuitsBase Instance;
private const string modGUID = "ACS.AdditionalSuits";
private const string modName = "AdditionalSuits";
private const string modVersion = "1.0.2";
private readonly Harmony harmony = new Harmony("ACS.AdditionalSuits");
public static ManualLogSource mls;
public static bool SuitsLoaded;
public static string SuitTextureFolder;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("ACS.AdditionalSuits");
mls.LogInfo((object)"AdditionalSuits - initializing...");
SuitTextureFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "resAdditionalSuits");
harmony.PatchAll();
mls.LogInfo((object)"AdditionalSuits - initialized!");
}
}