Decompiled source of House v0.1.1

plugins/com.github.PotatoPone.House.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.PotatoPone.House")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1")]
[assembly: AssemblyProduct("com.github.PotatoPone.House")]
[assembly: AssemblyTitle("House")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace House
{
	[BepInPlugin("com.github.PotatoPone.House", "House", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.PotatoPone.House");

		public static AssetBundle? Bundle;

		public const string Id = "com.github.PotatoPone.House";

		internal static ManualLogSource Log { get; private set; }

		public static PluginInfo? PluginInfo { get; private set; }

		public static string Name => "House";

		public static string Version => "0.1.1";

		private void Awake()
		{
			PluginInfo = ((BaseUnityPlugin)this).Info;
			LoadEmbeddedAssetBundle();
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
		}

		private static void LoadEmbeddedAssetBundle()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			string[] array = manifestResourceNames;
			foreach (string text in array)
			{
				Debug.Log((object)text);
			}
			string text2 = manifestResourceNames[0];
			using Stream stream = executingAssembly.GetManifestResourceStream(text2);
			if (stream == null)
			{
				Debug.LogError((object)("AssetBundle resource not found: " + text2));
				return;
			}
			byte[] array2 = new byte[stream.Length];
			stream.Read(array2, 0, array2.Length);
			Bundle = AssetBundle.LoadFromMemory(array2);
			if ((Object)(object)Bundle == (Object)null)
			{
				Debug.LogError((object)"Failed to load AssetBundle from embedded resource.");
			}
			else
			{
				Debug.Log((object)("AssetBundle loaded successfully from embedded resource: " + ((Object)Bundle).name));
			}
		}
	}
}
namespace House.Patches
{
	[HarmonyPatch]
	internal class CustomizationPatch
	{
		private static bool added;

		private static void AddCustomizationOption(Type type, Texture? texture = null)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Invalid comparison between Unknown and I4
			CustomizationOption val = ScriptableObject.CreateInstance<CustomizationOption>();
			val.type = type;
			val.texture = texture;
			val.requiredAchievement = (ACHIEVEMENTTYPE)0;
			val.customRequirement = (CUSTOMREQUIREMENT)0;
			val.testLocked = false;
			val.drawUnderEye = false;
			val.color = Color.white;
			CustomizationOption[] second = (CustomizationOption[])(object)new CustomizationOption[1] { val };
			CustomizationOption[] array = (CustomizationOption[])(object)new CustomizationOption[0];
			if ((int)type == 10)
			{
				array = Singleton<Customization>.Instance.accessories.Concat(second).ToArray();
				Singleton<Customization>.Instance.accessories = array;
			}
			if ((int)type == 30)
			{
				array = Singleton<Customization>.Instance.mouths.Concat(second).ToArray();
				Singleton<Customization>.Instance.mouths = array;
			}
			if ((int)type == 20)
			{
				array = Singleton<Customization>.Instance.eyes.Concat(second).ToArray();
				Singleton<Customization>.Instance.eyes = array;
			}
		}

		[HarmonyPatch(typeof(GUIManager), "Start")]
		[HarmonyPostfix]
		private static void OnGUIManagerStart()
		{
			if (!added && !((Object)(object)Plugin.Bundle == (Object)null))
			{
				Texture texture = (Texture)(object)Plugin.Bundle.LoadAsset<Texture2D>("houseFace2");
				AddCustomizationOption((Type)10, texture);
				Texture texture2 = (Texture)(object)Plugin.Bundle.LoadAsset<Texture2D>("blank");
				AddCustomizationOption((Type)30, texture2);
				AddCustomizationOption((Type)20);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}