using System;
using System.Collections.Generic;
using System.Diagnostics;
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;
using UnityEngine.UI;
using UnityEngine.Video;
[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("BadAppleInWhiteKnuckle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("BadAppleInWhiteKnuckle")]
[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;
}
}
}
public static class VideoFileForQuietOS
{
[HarmonyPatch(typeof(CL_GameManager), "Start")]
public static class onGameStart
{
public static void overrideVideoFileNameCommand(string[] args)
{
if (args.Length != 0)
{
CommandConsole.Log("video file name set to " + (NameChosenForMyFile = string.Join(" ", args)), false);
}
}
public static void overrideVideoFileUrlCommand(string[] args)
{
if (args.Length != 0)
{
CommandConsole.Log("video file url set to " + (VideoFileUrl = string.Join(" ", args)), false);
}
}
public static void Postfix()
{
CommandConsole.AddCommand("overridevideofileurl", (Action<string[]>)overrideVideoFileUrlCommand, true);
CommandConsole.AddCommand("overridevideofilename", (Action<string[]>)overrideVideoFileNameCommand, true);
}
}
[HarmonyPatch(typeof(App_PictureViewer), "Start")]
public static class ImageAppStarted
{
public static void Prefix(ref OS_Window ___window, App_PictureViewer __instance)
{
___window = ((Component)__instance).GetComponent<OS_Window>();
if (NameChosenForMyFile != null && VideoFileUrl != null && ___window.file.fileInfo.name == NameChosenForMyFile)
{
___window.file.fileInfo.imageAssetData = OS_Manager.activeComputer.resources.pictures[0];
}
}
public static void Postfix(ref OS_Window ___window, ref Image ___image, App_PictureViewer __instance, ref RectTransform ___rectTransform)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
if (NameChosenForMyFile != null && VideoFileUrl != null)
{
VideoPlayer val = ((Component)___window).gameObject.AddComponent<VideoPlayer>();
val.renderMode = (VideoRenderMode)2;
GameObject val2 = new GameObject();
val2.transform.SetParent(((Component)___rectTransform).gameObject.transform);
val2.transform.position = ((Transform)___rectTransform).position;
RawImage val3 = val2.AddComponent<RawImage>();
RenderTexture val4 = new RenderTexture(256, 232, 16);
((Behaviour)val).enabled = true;
val.playbackSpeed = 1f;
val.targetTexture = val4;
___image.type = (Type)3;
___image.fillAmount = 0f;
val.url = VideoFileUrl;
val.isLooping = true;
val.Play();
val3.texture = (Texture)(object)val4;
((Graphic)val3).rectTransform.sizeDelta = new Vector2(256f, 232f);
}
}
}
[HarmonyPatch(typeof(DiskController), "CreateDiskContents")]
public static class CreateAndAddMyFile
{
public static void Postfix(ref List<OS_File> ___diskFolders, ref OS_Manager ___os)
{
if (NameChosenForMyFile != null && VideoFileUrl != null)
{
FileInfo defaultFiletype = ___os.GetFilesystem().GetDefaultFiletype("image");
FileInfo item = OS_videoFileCreator(NameChosenForMyFile, defaultFiletype);
List<OS_File> obj = ___diskFolders;
obj[obj.Count - 1].fileInfo.children.Add(item);
}
}
public static FileInfo OS_videoFileCreator(string nameOfFile, FileInfo defaultFileInfo)
{
defaultFileInfo.name = nameOfFile;
defaultFileInfo.windowAsset.windowName = nameOfFile;
return defaultFileInfo;
}
}
private static string VideoFileUrl;
private static string NameChosenForMyFile;
}
namespace BadAppleInWhiteKnuckle
{
[BepInPlugin("BadAppleInWhiteKnuckleGUID", "Bad Apple in white knuckle", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("BadAppleInWhiteKnuckle");
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin BadAppleInWhiteKnuckle is loaded!");
val.PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "BadAppleInWhiteKnuckle";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}