Decompiled source of VideoOnTV v0.0.3

jasonofthestorm-VideoOnTV/VideoOnTV.dll

Decompiled a year ago
using System;
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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("VideoOnTV")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3")]
[assembly: AssemblyProduct("VideoOnTV")]
[assembly: AssemblyTitle("VideoOnTV")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.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 VideoOnTV
{
	public class VideoConfigFile
	{
		private readonly ConfigFile config;

		public ConfigEntry<string> VideoURL;

		public VideoConfigFile(ConfigFile config)
		{
			this.config = config;
			VideoURL = this.config.Bind<string>("Video", "URL", "https://cdn.discordapp.com/attachments/612002213090295811/670674461954932756/Shrek_1.mp4", "The URL of the video to play on in-game TVs. Note that it must be a hard link to a video file such as an mp4 and that not all formats will work. It will NOT work with YouTube links, etc.");
		}
	}
	[BepInPlugin("VideoOnTV", "VideoOnTV", "0.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		public static VideoConfigFile videoConfig;

		public static GameObject videoPlayer;

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			videoConfig = new VideoConfigFile(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("io.jasonofthestorm.VideoOnTV");
			val.PatchAll();
			if (File.Exists(Path.Combine(Paths.PluginPath, "jasonofthestorm-VideoOnTV", "videoplayer")))
			{
				AssetBundle val2 = AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, "jasonofthestorm-VideoOnTV", "videoplayer"));
				videoPlayer = val2.LoadAsset<GameObject>("VideoPlayer");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VideoOnTV mod has been loaded.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"VideoOnTV mod couldn't find the videoplayer file. It comes with the mod!! Did you move it out of the mod folder or something?");
			}
		}
	}
	[HarmonyPatch(typeof(ASceneSetupInstruction))]
	[HarmonyPatch("SetSceneActive")]
	internal class patch_StageManager_OnPostRender
	{
		private static void Postfix(string sceneToSetActive)
		{
			Junk[] array = Object.FindObjectsOfType<Junk>();
			Junk[] array2 = array;
			foreach (Junk val in array2)
			{
				if (((Object)val).name == "TV")
				{
					GameObject val2 = Object.Instantiate<GameObject>(Plugin.videoPlayer, ((Component)val).transform);
					if (Plugin.videoConfig != null)
					{
						val2.GetComponent<VideoPlayer>().url = Plugin.videoConfig.VideoURL.Value;
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "VideoOnTV";

		public const string PLUGIN_NAME = "VideoOnTV";

		public const string PLUGIN_VERSION = "0.0.3";
	}
}