using System;
using System.Collections;
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;
[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("DogeCore_LethalPoster_Paintings_from_url")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f8eacd916b7af27b623706dcd38ecd7c642d4820")]
[assembly: AssemblyProduct("DogeCore_LethalPoster_Paintings_from_url")]
[assembly: AssemblyTitle("DogeCore_LethalPoster_Paintings_from_url")]
[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.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 LethalPoster_Paintings_from_url
{
[BepInPlugin("DogeCore_LethalPoster_Paintings_from_url", "DogeCore_LethalPoster_Paintings_from_url", "1.0.0")]
public class LethalPoster_Paintings_from_url : BaseUnityPlugin
{
private ConfigEntry<string>? configFivePostersUrls;
private ConfigEntry<string>? configTipPostersUrls;
private ConfigEntry<string>? configPaintingUrls;
private ConfigEntry<string>? configFivePostersFolder;
private ConfigEntry<string>? configPaintingsFolder;
private ConfigEntry<string>? configTipPostersFolder;
private string? defaultFivePostersFolder;
private string? defaultTipPostersFolder;
private string? defaultPaintingsFolder;
public static LethalPoster_Paintings_from_url Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
defaultFivePostersFolder = directoryName + "\\LethalPosters\\posters\\";
defaultTipPostersFolder = directoryName + "\\LethalPosters\\tips\\";
defaultPaintingsFolder = directoryName + "\\LethalPaintings\\paintings\\";
configPaintingUrls = ((BaseUnityPlugin)this).Config.Bind<string>("General", "paintingurls", "", "list of Urls for paiting files to download - space separated (ex : https://watev/1.png https://watev2.png ...) - must be using femboytv/LethalPaintings templates and be .png");
configFivePostersUrls = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FivePostersUrls", "", "list of Urls for atlas textures with 5 posters files to download - space separated (ex : https://watev/1.png https://watev2.png ...) - must be using femboytv/LethalPosters templates and be .png");
configTipPostersUrls = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TipPostersUrls", "", "list of Urls for the textures for the Tips for the job poster files to download - space separated (ex : https://watev/1.png https://watev2.png ...) - must be using femboytv/LethalPosters templates and be .png");
configFivePostersFolder = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FivePostersFolder", "", "Leave blank unless you need to overwrite ! 5 posters folder to download into - must be what femboytv/LethalPosters excepts. Default will be BepInEx.Paths.PluginPath+LethalPosters/posters/");
configTipPostersFolder = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TipPostersFolder", "", "Leave blank unless you need to overwrite ! Tips for the job posters folder to download into - must be using femboytv/LethalPosters excepts. Default will be BepInEx.Paths.PluginPath+LethalPaintings/paintings/");
configPaintingsFolder = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PaintingsFolder", "", "Leave blank unless you need to overwrite ! Paintings folder to download into - must be using femboytv/LethalPaintings excepts. Default will be BepInEx.Paths.PluginPath+LethalPaintings/paintings/");
string text = ((configFivePostersFolder.Value.ToString() == "") ? defaultFivePostersFolder : configFivePostersFolder.Value.ToString());
createDirIfNotExists(text);
string text2 = ((configTipPostersFolder.Value.ToString() == "") ? defaultTipPostersFolder : configTipPostersFolder.Value.ToString());
createDirIfNotExists(text2);
string text3 = ((configPaintingsFolder.Value.ToString() == "") ? defaultPaintingsFolder : configPaintingsFolder.Value.ToString());
createDirIfNotExists(text3);
if (configFivePostersUrls.Value != "")
{
DownloadStuff(configFivePostersUrls.Value.Split(" "), text);
}
else
{
Logger.LogWarning((object)"DogeCore_LethalPoster_Paintings_from_url: no atlas textures with 5 posters files to download !");
}
if (configTipPostersUrls.Value != "")
{
DownloadStuff(configTipPostersUrls.Value.Split(" "), text2);
}
else
{
Logger.LogWarning((object)"DogeCore_LethalPoster_Paintings_from_url: no Tips for the job posters files to download !");
}
if (configPaintingUrls.Value != "")
{
DownloadStuff(configPaintingUrls.Value.Split(" "), text3);
}
else
{
Logger.LogWarning((object)"DogeCore_LethalPoster_Paintings_from_url: no paintings files to load !");
}
}
private void DownloadStuff(string[] filelist, string folder)
{
string folder2 = folder;
foreach (string url in filelist)
{
((MonoBehaviour)this).StartCoroutine(DownloadFile());
IEnumerator DownloadFile()
{
UnityWebRequest uwr = new UnityWebRequest(url, "GET");
string filepath = folder2 + url.GetHashCode() + ".png";
if (!File.Exists(filepath))
{
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerFile(filepath);
yield return uwr.SendWebRequest();
if ((int)uwr.result != 1)
{
Logger.LogError((object)("DogeCore_LethalPoster_Paintings_from_url: " + uwr.error));
}
else if (isPng(filepath))
{
Logger.LogInfo((object)("DogeCore_LethalPoster_Paintings_from_url: " + url + " successfully downloaded and saved to " + filepath));
}
else
{
File.Delete(filepath);
Logger.LogError((object)("DogeCore_LethalPoster_Paintings_from_url: " + url + " was not a .png file, removed."));
}
}
else
{
Logger.LogInfo((object)("DogeCore_LethalPoster_Paintings_from_url: " + url + " already exists at " + filepath));
}
}
}
}
public bool isPng(string filePath)
{
byte[] array = new byte[8] { 137, 80, 78, 71, 13, 10, 26, 10 };
byte[] array2 = new byte[array.Length];
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
fileStream.Read(array2, 0, array.Length);
}
return array.SequenceEqual(array2);
}
public void createDirIfNotExists(string dir)
{
if (!Directory.Exists(dir))
{
Logger.LogWarning((object)("DogeCore_LethalPoster_Paintings_from_url: creating dir : " + dir));
Directory.CreateDirectory(dir);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DogeCore_LethalPoster_Paintings_from_url";
public const string PLUGIN_NAME = "DogeCore_LethalPoster_Paintings_from_url";
public const string PLUGIN_VERSION = "1.0.0";
}
}