Decompiled source of JakesInterior v0.0.1

JakesCrew-JakesInterior/JakesInterior.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 JakesInterior;
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("JakesInterior")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JakesInterior")]
[assembly: AssemblyTitle("JakesInterior")]
[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 class FoodPropPlacer : MonoBehaviour
{
	private GameObject player;

	private bool inTrigger = false;

	private void Start()
	{
		player = GameObject.Find("Player_HUMAN0");
	}

	private void Update()
	{
		if (!Input.GetKeyDown((KeyCode)101) || !inTrigger)
		{
			return;
		}
		Transform[] componentsInChildren = player.GetComponentsInChildren<Transform>();
		Transform[] array = componentsInChildren;
		foreach (Transform val in array)
		{
			if (!(((Object)val).name == "handr"))
			{
				continue;
			}
			Transform[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Transform>();
			bool flag = false;
			GameObject val2 = null;
			Transform[] array2 = componentsInChildren2;
			foreach (Transform val3 in array2)
			{
				if (((Object)val3).name.Contains("HotDogProp"))
				{
					flag = true;
					val2 = ((Component)val3).gameObject;
				}
			}
			if (flag)
			{
				Object.Destroy((Object)(object)val2);
			}
			else
			{
				Object.Instantiate<GameObject>(Plugin.hotDogProp, val);
			}
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if ((Object)(object)other == (Object)(object)player.GetComponent<CapsuleCollider>())
		{
			inTrigger = true;
		}
	}

	private void OnTriggerExit(Collider other)
	{
		if ((Object)(object)other == (Object)(object)player.GetComponent<CapsuleCollider>())
		{
			inTrigger = false;
		}
	}
}
public class TVSwitch : MonoBehaviour
{
	private VideoPlayer videoPlayer;

	private GameObject player;

	private bool inTrigger = false;

	private void Start()
	{
		videoPlayer = ((Component)this).GetComponent<VideoPlayer>();
		player = GameObject.Find("Player_HUMAN0");
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)101) && inTrigger)
		{
			if (videoPlayer.isPlaying)
			{
				videoPlayer.Pause();
			}
			else
			{
				videoPlayer.Play();
			}
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if ((Object)(object)other == (Object)(object)player.GetComponent<CapsuleCollider>())
		{
			inTrigger = true;
		}
	}

	private void OnTriggerExit(Collider other)
	{
		if ((Object)(object)other == (Object)(object)player.GetComponent<CapsuleCollider>())
		{
			inTrigger = false;
		}
	}
}
namespace JakesInterior
{
	public class JakesConfigFile
	{
		private readonly ConfigFile config;

		public ConfigEntry<string> VideoURL;

		public JakesConfigFile(ConfigFile config)
		{
			this.config = config;
			VideoURL = this.config.Bind<string>("Video", "URL", "https://archive.org/download/girl-yeah-right/Girl%20-%20Yeah%20Right.mp4", "The URL/path of the video to play on the TV on the ground floor inside of Jakes. 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. It can be a file on your local machine, just use a path in this format: file://C:/folder/file.mp4");
		}
	}
	[BepInPlugin("JakesInterior", "JakesInterior", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject newJakes;

		public static GameObject videoPlayer;

		public static GameObject hotDogProp;

		public static JakesConfigFile videoConfig;

		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 JakesConfigFile(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("io.JakesCrew.JakesInterior");
			val.PatchAll();
			if (File.Exists(Path.Combine(Paths.PluginPath, "JakesCrew-JakesInterior", "newjakes")))
			{
				AssetBundle val2 = AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, "JakesCrew-JakesInterior", "newjakes"));
				newJakes = val2.LoadAsset<GameObject>("JakesInterior");
				hotDogProp = val2.LoadAsset<GameObject>("HotDogProp");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"JakesInterior is loaded. Pull up!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"JakesInterior couldn't find the newjakes file. This file ALREADY COMES IN THE CORRECT PLACE WITH THE MOD. Did you move it for some reason?? Or maybe the mod folder is in the wrong place. Idk.");
			}
		}
	}
	[HarmonyPatch(typeof(ASceneSetupInstruction))]
	[HarmonyPatch("SetSceneActive")]
	internal class patch_StageManager_OnPostRender
	{
		private static void Postfix(string sceneToSetActive)
		{
			if (!(sceneToSetActive == "square") || !((Object)(object)GameObject.Find("Square_BackAlley") != (Object)null))
			{
				return;
			}
			Collider[] componentsInChildren = GameObject.Find("Square_BackAlley").GetComponentsInChildren<Collider>();
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				if (((Object)((Component)val).gameObject).name.Contains("BottomBox6Big (11)"))
				{
					val.enabled = false;
				}
			}
			MeshFilter[] componentsInChildren2 = GameObject.Find("Square_BackAlley").GetComponentsInChildren<MeshFilter>();
			MeshFilter[] array2 = componentsInChildren2;
			foreach (MeshFilter val2 in array2)
			{
				if (((Object)val2).name.Contains("CombinedMeshes_square_Square_Fronts01_AtlasMat"))
				{
					Debug.Log((object)"Attempting to create JAKES interior...");
					((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false;
					GameObject val3 = Object.Instantiate<GameObject>(Plugin.newJakes, (Transform)null, true);
					Debug.Log((object)"JAKES interior created.");
					MeshRenderer[] componentsInChildren3 = val3.GetComponentsInChildren<MeshRenderer>();
					foreach (MeshRenderer val4 in componentsInChildren3)
					{
						if ((Object)(object)((Component)val4).GetComponent<VideoPlayer>() == (Object)null)
						{
							if (((Object)((Component)val4).gameObject).name == "JakesFront" || ((Object)((Component)val4).gameObject).name.Contains("CombinedMeshes_square_Square_Buildings05"))
							{
								((Renderer)val4).material.shader = ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).material.shader;
							}
							if (((Object)val4).name == "FoodPropTriggerZone")
							{
								((Component)val4).gameObject.AddComponent<FoodPropPlacer>();
							}
						}
						else if (((Object)val4).name == "JakesTV")
						{
							VideoPlayer component = ((Component)val4).GetComponent<VideoPlayer>();
							component.url = Plugin.videoConfig.VideoURL.Value;
							if (component.url == ((ConfigEntryBase)Plugin.videoConfig.VideoURL).DefaultValue.ToString())
							{
								component.time = 360.0;
							}
							else if (Plugin.videoConfig.VideoURL.Value == "")
							{
								component.Stop();
							}
							((Component)val4).gameObject.AddComponent<TVSwitch>();
						}
					}
				}
				else if (((Object)val2).name.Contains("CombinedMeshes_square_Square_Buildings05AtlasMat"))
				{
					((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false;
				}
				else if (((Object)((Component)val2).gameObject).name.Contains("buildingblock (11)"))
				{
					((Component)val2).GetComponent<Collider>().enabled = false;
				}
				else if (((Object)((Component)val2).gameObject).name.Contains("GrimeAtlasVertex"))
				{
					((Renderer)((Component)val2).GetComponent<MeshRenderer>()).enabled = false;
				}
			}
			Collider[] componentsInChildren4 = GameObject.Find("Square_BackAlley_Buildings").GetComponentsInChildren<Collider>();
			Collider[] array3 = componentsInChildren4;
			foreach (Collider val5 in array3)
			{
				if (((Object)((Component)val5).gameObject).name == "Square_BlueShop")
				{
					val5.enabled = false;
				}
				if (((Object)((Component)val5).gameObject).name == "Square_JakesStore")
				{
					val5.enabled = false;
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "JakesInterior";

		public const string PLUGIN_NAME = "JakesInterior";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}