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 BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ViViKo.MoreProjections")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("MoreProjections")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("MoreProjections")]
[assembly: AssemblyTitle("ViViKo.MoreProjections")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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 MoreProjections
{
[ContentWarningPlugin("ViViKo.MoreProjections", "MoreProjections", true)]
[BepInPlugin("ViViKo.MoreProjections", "MoreProjections", "1.2.1")]
public class MoreProjections : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("ViViKo.MoreProjections");
public static MoreProjections Instance;
public List<Texture2D> projections = new List<Texture2D>();
public ConfigEntry<bool> removeVanilla;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
removeVanilla = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Vanilla Projections", false, "Removes vanilla projector images");
loadTextures();
harmony.PatchAll();
Logger.LogInfo((object)"Plugin MoreProjections v1.2.1 is loaded!");
}
public void loadTextures()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
try
{
List<string> list = Directory.GetDirectories(Paths.PluginPath, "moreprojections", SearchOption.AllDirectories).ToList();
List<string> list2 = new List<string>();
foreach (string item in list)
{
if (item != "")
{
string[] files = Directory.GetFiles(item, "*.png");
list2.AddRange(files);
}
}
list2.Sort();
foreach (string item2 in list2)
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item2);
byte[] array = File.ReadAllBytes(item2);
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
val.Apply(true, true);
projections.Add(val);
Logger.LogInfo((object)("Loaded '" + fileNameWithoutExtension + "' Projection"));
}
}
catch (Exception ex)
{
Logger.LogWarning((object)("Something went wrong with More Projections! Error: " + ex));
}
}
public static AudioClip LoadFromDiskToAudioClip(string path, AudioType type)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
AudioClip result = null;
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, type);
try
{
audioClip.SendWebRequest();
try
{
while (!audioClip.isDone)
{
}
if ((int)audioClip.result != 1)
{
Logger.LogError((object)("Failed to load AudioClip from path: " + path + " Full error: " + audioClip.error));
}
else
{
result = DownloadHandlerAudioClip.GetContent(audioClip);
}
}
catch (Exception ex)
{
Logger.LogError((object)(ex.Message + ", " + ex.StackTrace));
}
}
finally
{
((IDisposable)audioClip)?.Dispose();
}
return result;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ViViKo.MoreProjections";
public const string PLUGIN_NAME = "MoreProjections";
public const string PLUGIN_VERSION = "1.2.1";
}
}
namespace MoreProjections.Patches
{
[HarmonyPatch(typeof(GameHandler))]
public class GameHandlerPatch
{
[HarmonyPatch("Initialize")]
[HarmonyPostfix]
private static void InitializePatch(GameHandler __instance)
{
Setting val = (Setting)(object)new RemoveVanlliaSetting();
__instance.SettingsHandler.settings.Add(val);
val.Load(__instance.SettingsHandler._settingsSaveLoad);
val.ApplyValue();
}
}
public class RemoveVanlliaSetting : EnumSetting, IExposedSetting
{
public override void ApplyValue()
{
MoreProjections.Instance.removeVanilla.Value = ((IntSetting)this).Value != 0;
}
public override List<string> GetChoices()
{
return new List<string> { "OFF", "ON" };
}
public string GetDisplayName()
{
return ((ConfigEntryBase)MoreProjections.Instance.removeVanilla).Definition.Key;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)0;
}
protected override int GetDefaultValue()
{
return 0;
}
public override void Load(ISettingsSaveLoad loader)
{
((IntSetting)this).Value = (MoreProjections.Instance.removeVanilla.Value ? 1 : 0);
}
}
[HarmonyPatch(typeof(ProjectorMachine))]
public class ProjectorMachinePatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(ProjectorMachine __instance)
{
try
{
List<Texture2D> list = __instance.textures.ToList();
if (MoreProjections.Instance.removeVanilla.Value)
{
list.Clear();
}
list.InsertRange(0, MoreProjections.Instance.projections);
__instance.textures = list.ToArray();
}
catch (Exception ex)
{
MoreProjections.Logger.LogWarning((object)("Something went wrong with More Projections! Error: " + ex));
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}