Decompiled source of Pocket Rooms MelanieMelicious v1.0.7

MelanieMeliciousPocketRoom.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using HarmonyLib;
using MelanieMeliciousPocketRoom.NetcodePatcher;
using MelaniePocketRoom;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MelaniePocketRoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MelanieMelicious")]
[assembly: AssemblyProduct("MelaniePocketRoom")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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;
		}
	}
}
public class HarmonyPatches
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameNetworkManager), "Start")]
	private static void NetworkPatch(ref GameNetworkManager __instance)
	{
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[0].prefabObject);
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[1].prefabObject);
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[2].prefabObject);
	}
}
internal static class PocketRoomCfg
{
	internal enum mat
	{
		Wood,
		WoodPlank,
		MetalFlat,
		Glass,
		Blank
	}

	internal static ConfigEntry<bool> stockRoom0;

	internal static ConfigEntry<int> stockRoom0Cost;

	internal static ConfigEntry<bool> bedRoom0;

	internal static ConfigEntry<bool> bedRoom1;

	internal static ConfigEntry<int> bedRoom0Cost;

	internal static ConfigEntry<mat> stockRoom0Floor;

	internal static ConfigEntry<string> stockRoom0FloorHex;

	internal static ConfigEntry<mat> stockRoom0Wall;

	internal static ConfigEntry<string> stockRoom0WallHex;

	internal static ConfigEntry<mat> bedRoom0Floor;

	internal static ConfigEntry<string> bedRoom0FloorHex;

	internal static ConfigEntry<mat> bedRoom0Wall;

	internal static ConfigEntry<string> bedRoom0WallHex;

	internal static ConfigEntry<mat> bedRoom1Floor;

	internal static ConfigEntry<string> bedRoom1FloorHex;

	internal static ConfigEntry<mat> bedRoom1Wall;

	internal static ConfigEntry<string> bedRoom1WallHex;

	internal static void SetupConfig(ConfigFile config)
	{
		stockRoom0 = config.Bind<bool>("Store Toggle", "Enable Stock Room 0", true, "Toggle StockRoom0");
		stockRoom0Cost = config.Bind<int>("Store Toggle", "Stock Room 0 Cost", 500, "Modify the price for StockRoom0.");
		bedRoom0 = config.Bind<bool>("Store Toggle", "Enable Bed Room 0", true, "Toggle BedRoom0");
		bedRoom1 = config.Bind<bool>("Store Toggle", "Enable Bed Room 1", true, "Toggle BedRoom1");
		bedRoom0Cost = config.Bind<int>("Store Toggle", "Small Bed Room Costs", 300, "Modify the prices for Small bedrooms.");
		stockRoom0Floor = config.Bind<mat>("Customization", "StockRoom0 Floor Material.", mat.MetalFlat, "Modify material for StockRoom0 floor.");
		stockRoom0FloorHex = config.Bind<string>("Customization", "StockRoom0 Floor Color.", "847A66", "Modify color for StockRoom0 floor.");
		stockRoom0Wall = config.Bind<mat>("Customization", "StockRoom0 Wall Material.", mat.MetalFlat, "Modify material for StockRoom0 wall.");
		stockRoom0WallHex = config.Bind<string>("Customization", "StockRoom0 Wall Color.", "60594F", "Modify color for StockRoom0 wall.");
		bedRoom0Floor = config.Bind<mat>("Customization", "BedRoom0 Floor Material.", mat.WoodPlank, "Modify material for BedRoom0 floor.");
		bedRoom0FloorHex = config.Bind<string>("Customization", "BedRoom0 Floor Color.", "955B25", "Modify color for BedRoom0 floor.");
		bedRoom0Wall = config.Bind<mat>("Customization", "BedRoom0 Wall Material.", mat.Wood, "Modify material for BedRoom0 wall.");
		bedRoom0WallHex = config.Bind<string>("Customization", "BedRoom0 Wall Color.", "F5BFC5", "Modify color for BedRoom0 wall.");
		bedRoom1Floor = config.Bind<mat>("Customization", "BedRoom1 Floor Material.", mat.WoodPlank, "Modify material for BedRoom1 floor.");
		bedRoom1FloorHex = config.Bind<string>("Customization", "BedRoom1 Floor Color.", "594949", "Modify color for BedRoom1 floor.");
		bedRoom1Wall = config.Bind<mat>("Customization", "BedRoom1 Wall Material.", mat.Wood, "Modify material for BedRoom1 wall.");
		bedRoom1WallHex = config.Bind<string>("Customization", "BedRoom1 Wall Color.", "1D4D1F", "Modify color for BedRoom1 wall.");
	}
}
namespace MelaniePocketRoom
{
	[BepInPlugin("MelanieMelicious.pocketRoom", "Melanie Melicious - Pocket Rooms", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "MelanieMelicious.pocketRoom";

		private const string NAME = "Melanie Melicious - Pocket Rooms";

		private const string VERSION = "1.0.5";

		private readonly Harmony harmony = new Harmony("MelanieMelicious.pocketRoom");

		public static ManualLogSource mls;

		public static AssetBundle bundle;

		public static Plugin instance;

		internal static UnlockablesList unlockList;

		private void Awake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			instance = this;
			PocketRoomCfg.SetupConfig(((BaseUnityPlugin)this).Config);
			mls = Logger.CreateLogSource("MelanieMelicious - Pocket Rooms");
			mls = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll(typeof(HarmonyPatches));
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melaniepocketroom");
			bundle = AssetBundle.LoadFromFile(text);
			unlockList = bundle.LoadAsset<UnlockablesList>("Assets/MelaniePocketRoom/Asset/Room.asset");
			Material[] array3 = (Material[])(object)new Material[5]
			{
				bundle.LoadAsset<Material>("Assets/MelaniePocketRoom/Material/Wood0.mat"),
				bundle.LoadAsset<Material>("Assets/MelaniePocketRoom/Material/Plank0.mat"),
				bundle.LoadAsset<Material>("Assets/MelaniePocketRoom/Material/MetalFlat0.mat"),
				bundle.LoadAsset<Material>("Assets/MelaniePocketRoom/Material/Glass.mat"),
				bundle.LoadAsset<Material>("Assets/MelaniePocketRoom/Material/Blank.mat")
			};
			if (PocketRoomCfg.stockRoom0.Value)
			{
				Material((Material[])(object)new Material[2]
				{
					array3[(short)PocketRoomCfg.stockRoom0Floor.Value],
					array3[(short)PocketRoomCfg.stockRoom0Wall.Value]
				}, new string[3]
				{
					PocketRoomCfg.stockRoom0FloorHex.Value,
					PocketRoomCfg.stockRoom0WallHex.Value,
					"StockRoom0.1/Model0"
				}, 0);
				NamespacedKey<DawnUnlockableItemInfo> val = NamespacedKey<DawnUnlockableItemInfo>.From("MelaniePocketRoom", "MelMStockRoom0");
				DawnLib.RegisterNetworkPrefab(unlockList.unlockables[0].prefabObject);
				DawnLib.DefineUnlockable(val, unlockList.unlockables[0], (Action<UnlockableInfoBuilder>)delegate(UnlockableInfoBuilder builder)
				{
					builder.SetCost(PocketRoomCfg.stockRoom0Cost.Value);
				});
			}
			if (PocketRoomCfg.bedRoom0.Value)
			{
				Material((Material[])(object)new Material[3]
				{
					array3[(short)PocketRoomCfg.bedRoom0Floor.Value],
					array3[(short)PocketRoomCfg.bedRoom0Wall.Value],
					array3[3]
				}, new string[3]
				{
					PocketRoomCfg.bedRoom0FloorHex.Value,
					PocketRoomCfg.bedRoom0WallHex.Value,
					"BedRoom0.1/Model0"
				}, 1);
				NamespacedKey<DawnUnlockableItemInfo> val2 = NamespacedKey<DawnUnlockableItemInfo>.From("MelaniePocketRoom", "MelMBedRoom0");
				DawnLib.RegisterNetworkPrefab(unlockList.unlockables[1].prefabObject);
				DawnLib.DefineUnlockable(val2, unlockList.unlockables[1], (Action<UnlockableInfoBuilder>)delegate(UnlockableInfoBuilder builder)
				{
					builder.SetCost(PocketRoomCfg.bedRoom0Cost.Value);
				});
			}
			if (PocketRoomCfg.bedRoom1.Value)
			{
				Material((Material[])(object)new Material[3]
				{
					array3[(short)PocketRoomCfg.bedRoom1Floor.Value],
					array3[(short)PocketRoomCfg.bedRoom1Wall.Value],
					array3[3]
				}, new string[3]
				{
					PocketRoomCfg.bedRoom1FloorHex.Value,
					PocketRoomCfg.bedRoom1WallHex.Value,
					"BedRoom1.1/Model0"
				}, 2);
				NamespacedKey<DawnUnlockableItemInfo> val3 = NamespacedKey<DawnUnlockableItemInfo>.From("MelaniePocketRoom", "MelMBedRoom1");
				DawnLib.RegisterNetworkPrefab(unlockList.unlockables[2].prefabObject);
				DawnLib.DefineUnlockable(val3, unlockList.unlockables[2], (Action<UnlockableInfoBuilder>)delegate(UnlockableInfoBuilder builder)
				{
					builder.SetCost(PocketRoomCfg.bedRoom0Cost.Value);
				});
			}
		}

		private static void Material(Material[] mat, string[] hex, short id)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer component = ((Component)unlockList.unlockables[id].prefabObject.transform.Find(hex[2])).GetComponent<MeshRenderer>();
			((Renderer)component).materials = mat;
			Material[] materials = ((Renderer)component).materials;
			Color[] array = (Color[])(object)new Color[2]
			{
				Color.clear,
				Color.clear
			};
			ColorUtility.TryParseHtmlString("#" + hex[0], ref array[0]);
			ColorUtility.TryParseHtmlString("#" + hex[1], ref array[1]);
			materials[0].color = array[0];
			materials[1].color = array[1];
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace MelanieMeliciousPocketRoom.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}