using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("CustomProvidence")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Lets you customize the eye of providence.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomProvidence")]
[assembly: AssemblyTitle("CustomProvidence")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CustomProvidence
{
[BepInPlugin("com.earthlingOnFire.CustomProvidence", "CustomProvidence", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.earthlingOnFire.CustomProvidence";
public const string PLUGIN_NAME = "CustomProvidence";
public const string PLUGIN_VERSION = "1.0.0";
public static ManualLogSource logger;
public static string modDir;
public static List<string> FileExtensions = new List<string> { ".jpeg", ".jpg", ".png", ".bmp" };
public static Random rand = new Random();
private void Awake()
{
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
logger = ((BaseUnityPlugin)this).Logger;
}
private void Start()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
string path = Assembly.GetExecutingAssembly().Location.ToString();
modDir = Path.GetDirectoryName(path);
new Harmony("com.earthlingOnFire.CustomProvidence").PatchAll();
logger.LogInfo((object)"Plugin com.earthlingOnFire.CustomProvidence is loaded!");
}
}
[HarmonyPatch]
public static class Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
public static void ChangeEye(EnemyIdentifier __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)__instance.enemyType == 38 && !__instance.puppet)
{
Texture2D val = LoadRandomTexture();
if (!((Object)(object)val == (Object)null))
{
Transform val2 = ((Component)__instance).gameObject.transform.Find("Providence/Eye");
Object.Destroy((Object)(object)((Component)val2).GetComponent<AnimatedTexture>());
Object.Destroy((Object)(object)((Component)val2).GetComponent<BlinkAnimTex>());
((Renderer)((Component)val2).GetComponent<SkinnedMeshRenderer>()).material.mainTexture = (Texture)(object)val;
}
}
}
public static Texture2D LoadRandomTexture()
{
string dirPath = Path.Combine(Plugin.modDir, "textures");
string[] imagePaths = GetImagePaths(dirPath);
if (imagePaths.Length == 0)
{
Plugin.logger.LogWarning((object)"No images found in textures folder");
return null;
}
int num = Plugin.rand.Next(0, imagePaths.Length);
return LoadTextureFromFile(imagePaths[num]);
}
public static string[] GetImagePaths(string dirPath)
{
string[] files = Directory.GetFiles(dirPath);
return Array.FindAll(files, (string x) => IsImage(x));
}
public static bool IsImage(string filePath)
{
foreach (string fileExtension in Plugin.FileExtensions)
{
if (filePath.EndsWith(fileExtension))
{
return true;
}
}
return false;
}
public static Texture2D LoadTextureFromFile(string filePath)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
byte[] array = File.ReadAllBytes(filePath);
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
return val;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "CustomProvidence";
public const string PLUGIN_NAME = "CustomProvidence";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}