Decompiled source of Chimney But Awesome v1.0.0

plugins/ChimneyButAwesome/ChimneyButAwesome.dll

Decompiled 4 days 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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChimneyButAwesome")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Chimney but awesome!")]
[assembly: AssemblyTitle("ChimneyButAwesome")]
[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;
		}
	}
}
namespace ChimneyButAwesome
{
	public class Patches
	{
		private static string gamemodeName = "Chimney (but awesome)";

		[HarmonyPatch(typeof(M_Level), "OnSpawn")]
		[HarmonyPrefix]
		private static void LevelOnSpawn(M_Level __instance)
		{
			string levelName = __instance.levelName;
			if (!(levelName == "MX_Chimney_Interlude_01"))
			{
				if (levelName == "MX_Chimney_LoopRoom_01")
				{
					PatchLevel(__instance, "CHIMNEY_1", "UPG_Recycler_1", "Entities (1)/Props/Prop_UpgradeConsole_Main_PerkOnly/OS_Computer");
				}
			}
			else
			{
				PatchLevel(__instance, "CHIMNEY_0", "UPG_Recycler_0", "Prop_UpgradeConsole_NoDisk Variant/OS_Computer");
			}
		}

		private static void PatchLevel(M_Level instance, string facilityID, string prefabName, string osPath)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			Plugin.Logger.LogInfo((object)(instance.levelName + " loading, inserting prefabs..."));
			Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>(prefabName), ((Component)instance).transform);
			Plugin.Logger.LogInfo((object)"Inserted prefabs!");
			Plugin.Logger.LogInfo((object)"Finding OS_Computer_Interface...");
			OS_Computer_Interface component = ((Component)((Component)instance).transform.Find(osPath)).GetComponent<OS_Computer_Interface>();
			component.facilityID = facilityID;
			OS_FileDataAsset upgradeApp = Plugin.bundle.LoadAsset<OS_FileDataAsset>("App_FacilityUpgrades_File");
			if (!component.desktopData.files.Any((FileInfo x) => x.fileDataAsset == upgradeApp))
			{
				FileInfo val = new FileInfo();
				val.fileDataAsset = upgradeApp;
				val.fileDataAsset.fileInfo.windowAsset = Resources.FindObjectsOfTypeAll<GameObject>().First((GameObject x) => ((Object)x).name == "App_FacilityUpgrades").GetComponent<OS_Window>();
				component.desktopData.files.Add(val);
			}
			Plugin.Logger.LogInfo((object)"Facility upgrades added!");
		}

		[HarmonyPatch(typeof(CL_Initializer), "Awake")]
		[HarmonyPostfix]
		private static void InitializerAwake()
		{
			WKAssetDatabase val = Plugin.bundle.LoadAsset<WKAssetDatabase>("AssetDatabase");
			CL_AssetManager.AddNewDatabase(val.id, val);
			M_Gamemode gamemodeAsset = CL_AssetManager.GetGamemodeAsset("GM_Chimney_Endless", "");
			if (!(gamemodeAsset.gamemodeName == gamemodeName))
			{
				gamemodeAsset.gamemodeName = gamemodeName;
				gamemodeAsset.capsuleName = "Chimney\n(but awesome)";
				gamemodeAsset.allowLeaderboardScoring = false;
				gamemodeAsset.steamLeaderboardName = "";
				gamemodeAsset.useGlobalSteamLeaderboardVersion = false;
				gamemodeAsset.scoreLeaderboardScore = false;
				gamemodeAsset.scoreLeaderboardHard = false;
				gamemodeAsset.scoreLeaderboardIronKnuckle = false;
				gamemodeAsset.gamemodeSettings.Add(Resources.FindObjectsOfTypeAll<GamemodeSetting>().First((GamemodeSetting x) => ((Object)x).name == "Setting_Unlimited"));
			}
		}

		[HarmonyPatch(typeof(Item_Object), "Start")]
		[HarmonyPrefix]
		private static void ItemStart(Item_Object __instance)
		{
			if (!((Object)(object)CL_GameManager.gamemode == (Object)null) && !(CL_GameManager.gamemode.gamemodeName != gamemodeName) && !(__instance.itemData.itemName != "cryogun"))
			{
				__instance.itemData.worth = 10;
			}
		}
	}
	[BepInPlugin("ChimneyButAwesome", "Chimney but awesome!", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle bundle;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
			bundle = AssetBundle.LoadFromFile(Directory.GetFiles(Paths.PluginPath, "chimney_but_awesome", SearchOption.AllDirectories)[0]);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ChimneyButAwesome";

		public const string PLUGIN_NAME = "Chimney but awesome!";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}