Decompiled source of CompanysFinestsPosters v1.0.4

plugins/SolosPosterChanger/SolosPosterChanger.dll

Decompiled 5 months ago
using System.Collections;
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 UnityEngine;
using UnityEngine.SceneManagement;

[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 = "")]
[assembly: AssemblyCompany("SolosPosterChanger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Solo's Poster Changer")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SolosPosterChanger")]
[assembly: AssemblyTitle("SolosPosterChanger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SolosPosterChanger;

[BepInPlugin("SolosPosterChanger", "Solo's Poster Changer", "1.0")]
public class Plugin : BaseUnityPlugin
{
	private string[] texturepaths = new string[8] { "/TipsPoster2.png", "/posters.png", "/manual1.png", "/manual2v2.png", "/manual3v2.png", "/manual4v2.png", "/LightSwitchTex.png", "/LightSwitchTex2.png" };

	private string[] hierarchypaths = new string[8] { "Environment/HangarShip/Plane.001", "Environment/HangarShip/Plane.001", "Environment/HangarShip/ClipboardManual/Plane", "Environment/HangarShip/ClipboardManual/Plane.001", "Environment/HangarShip/ClipboardManual/Plane.002", "Environment/HangarShip/ClipboardManual/Plane.003", "Environment/HangarShip/LightSwitchContainer/LightSwitch", "Environment/HangarShip/LightSwitchContainer/LightSwitch/Switch" };

	private int[] materialnumber = new int[8] { 2, 1, 1, 1, 1, 1, 1, 1 };

	private Texture2D[] textures = (Texture2D[])(object)new Texture2D[8];

	private static Plugin Instance;

	public void Awake()
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}
		else if ((Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SolosPosterChanger is loaded!");
		for (int i = 0; i < texturepaths.Length; i++)
		{
			if (File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + texturepaths[i]))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Texture {i} loading!");
				textures[i] = new Texture2D(2, 2);
				ImageConversion.LoadImage(textures[i], File.ReadAllBytes(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + texturepaths[i]));
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Texture {i} loaded!");
			}
		}
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (!(((Scene)(ref scene)).name == "MainMenu") && !(((Scene)(ref scene)).name == "InitScene") && !(((Scene)(ref scene)).name == "InitSceneLaunchOptions"))
		{
			((MonoBehaviour)this).StartCoroutine(LoadTextures());
		}
	}

	private IEnumerator LoadTextures()
	{
		yield return (object)new WaitForSeconds(5f);
		for (int i = 0; i < texturepaths.Length; i++)
		{
			if ((Object)(object)GameObject.Find(hierarchypaths[i]).GetComponent<Renderer>() != (Object)null)
			{
				GameObject.Find(hierarchypaths[i]).GetComponent<Renderer>().materials[materialnumber[i] - 1].mainTexture = (Texture)(object)textures[i];
			}
			else if ((Object)(object)GameObject.Find(hierarchypaths[i]).GetComponent<Renderer>() == (Object)null)
			{
				((Renderer)GameObject.Find(hierarchypaths[i]).GetComponent<MeshRenderer>()).materials[materialnumber[i] - 1].mainTexture = (Texture)(object)textures[i];
			}
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "SolosPosterChanger";

	public const string PLUGIN_NAME = "SolosPosterChanger";

	public const string PLUGIN_VERSION = "1.0.0";
}