Decompiled source of SillyCompany v1.0.3

SillyCompany.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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("SillyCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Very silly mod")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+5cdb63964c6e6446268e246e1b54430175886c7d")]
[assembly: AssemblyProduct("SillyCompany")]
[assembly: AssemblyTitle("SillyCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 SillyCompany
{
	[BepInPlugin("SillyCompany", "SillyCompany", "1.0.3")]
	public class SillyCompany : BaseUnityPlugin
	{
		private const string PLUGIN_OWNER_PREFIX = "silly_capybara-";

		private static readonly string PostersImagePath = Path.Combine(Paths.PluginPath, "silly_capybara-SillyCompany-1.0.3", "posters.png");

		private static readonly string TipsImagePath = Path.Combine(Paths.PluginPath, "silly_capybara-SillyCompany-1.0.3", "tips.png");

		private readonly Harmony harmony = new Harmony("SillyCompany");

		private void Awake()
		{
			harmony.PatchAll(typeof(SillyCompany));
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			UpdateMaterials(0);
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void GenerateNewLevelClientRpcPatch(int randomSeed)
		{
			UpdateMaterials(randomSeed);
		}

		private static void UpdateMaterials(int seed)
		{
			Material[] materials = ((Renderer)GameObject.Find("HangarShip/Plane.001").GetComponent<MeshRenderer>()).materials;
			UpdateTexture(PostersImagePath, materials[0]);
			UpdateTexture(TipsImagePath, materials[1]);
		}

		private static void UpdateTexture(string filePath, Material material)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, File.ReadAllBytes(filePath));
			material.mainTexture = (Texture)(object)val;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SillyCompany";

		public const string PLUGIN_NAME = "SillyCompany";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}