using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Customizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+f83b20c2cd463e1653c5029de924a2c6fefa819e")]
[assembly: AssemblyProduct("Customizer")]
[assembly: AssemblyTitle("Customizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Customizer
{
[BepInPlugin("customizer", "Customizer", "0.1.0")]
public class Customizer : BaseUnityPlugin
{
private static Customizer _instance = null;
private static readonly string ModDir = Path.Combine(Application.dataPath, "Mods", "Customizer");
private static readonly List<tk2dSpriteCollectionData> LoadedCollectionsList = new List<tk2dSpriteCollectionData>();
private static void UpdateLoadedAssets()
{
LoadedCollectionsList.Clear();
tk2dSpriteCollectionData[] array = Resources.FindObjectsOfTypeAll<tk2dSpriteCollectionData>();
foreach (tk2dSpriteCollectionData item in array)
{
LoadedCollectionsList.Add(item);
}
GetTexturePacks(LoadedCollectionsList);
}
private static void GetTexturePacks(List<tk2dSpriteCollectionData> collections)
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Expected O, but got Unknown
Dictionary<string, tk2dSpriteCollectionData> dictionary = collections.ToDictionary((tk2dSpriteCollectionData c) => ((Object)c).name, (tk2dSpriteCollectionData c) => c);
string[] directories = Directory.GetDirectories(ModDir);
foreach (string text in directories)
{
string path = Path.Combine(text, "active.txt");
if (!File.Exists(path))
{
continue;
}
string[] directories2 = Directory.GetDirectories(text);
foreach (string text2 in directories2)
{
string fileName = Path.GetFileName(text2);
if (!dictionary.TryGetValue(fileName, out var value))
{
continue;
}
Material[] materials = value.materials;
foreach (Material val in materials)
{
string path2 = Path.Combine(text2, ((Object)val.mainTexture).name + ".png");
if (File.Exists(path2))
{
byte[] array = File.ReadAllBytes(path2);
Texture2D val2 = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val2, array))
{
val.mainTexture = (Texture)(object)val2;
}
}
}
}
}
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
UpdateLoadedAssets();
((BaseUnityPlugin)_instance).Logger.LogInfo((object)("Loaded scene: " + ((Scene)(ref scene)).name));
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void InitializeMod()
{
if (!Directory.Exists(ModDir))
{
Directory.CreateDirectory(ModDir);
}
}
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
_instance = this;
InitializeMod();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin customizer has loaded!");
Harmony val = new Harmony("customizer");
val.PatchAll();
SceneManager.sceneLoaded += OnSceneLoaded;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "customizer";
public const string PLUGIN_NAME = "Customizer";
public const string PLUGIN_VERSION = "0.1.0";
}
}