51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using HarmonyLib;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace CustomCosmeticLoader
|
|
{
|
|
public static class PatchEntryPoint
|
|
{
|
|
private static bool IsPatched = false;
|
|
|
|
public static void Start()
|
|
{
|
|
SceneManager.sceneLoaded += beginPatch;
|
|
}
|
|
|
|
private static void beginPatch(Scene scene, LoadSceneMode mode)
|
|
{
|
|
if (!IsPatched)
|
|
{
|
|
new Harmony("com.thearst3rd.customcosmeticloader").PatchAll();
|
|
IsPatched = true;
|
|
SceneManager.sceneLoaded -= beginPatch;
|
|
LoadCosmetics();
|
|
Config.Init();
|
|
}
|
|
}
|
|
|
|
private static void LoadCosmetics()
|
|
{
|
|
string skinsPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
skinsPath = Path.Combine(skinsPath, "skins");
|
|
if (!Directory.Exists(skinsPath))
|
|
{
|
|
Shared.Log(skinsPath + " directory does not exist, no skins to load");
|
|
return;
|
|
}
|
|
string printStr = "Loaded custom skins: ";
|
|
foreach (string skinFile in Directory.GetFiles(skinsPath))
|
|
{
|
|
string skinName = Path.GetFileNameWithoutExtension(skinFile);
|
|
printStr += skinName + ", ";
|
|
Texture2D skinTexture = new Texture2D(2, 2);
|
|
skinTexture.LoadImage(File.ReadAllBytes(skinFile));
|
|
Config.skins.Add(skinName, skinTexture);
|
|
}
|
|
Shared.Log(printStr);
|
|
}
|
|
}
|
|
}
|