Decompiled source of PlasteelSoul v1.1.0

plugins/PlasteelSoul/PlasteelSoul.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GlobalSettings;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TeamCherry.Localization;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("Esper89")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+7f9e3c85819be09aaf0f3e4548cb21e1e0343f1d")]
[assembly: AssemblyProduct("Esper89.PlasteelSoul")]
[assembly: AssemblyTitle("Plasteel Soul")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Esper89/Silksong-PlasteelSoul")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.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 PlasteelSoul
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Esper89.PlasteelSoul", "Plasteel Soul", "1.1.0")]
	internal sealed class Mod : BaseUnityPlugin
	{
		internal sealed class ConfigEntries
		{
			private ConfigEntry<bool> _accessSteelWish = file.Bind<bool>("General", "AccessSteelWish", true, "Allow access to the Steel Soul-exclusive wish in non-Steel Soul mode");

			private ConfigEntry<bool> _sellShellSatchel = file.Bind<bool>("General", "SellShellSatchel", true, "Allow purchasing the Shell Satchel from Jubilana in non-Steel Soul mode");

			private ConfigEntry<bool> _accessSkynx = file.Bind<bool>("General", "AccessSkynx", true, "Allow access to Skynx to sell Silkeaters in non-Steel Soul mode");

			private ConfigEntry<bool> _paintBellhomeChrome = file.Bind<bool>("General", "PaintBellhomeChrome", true, "Allow painting the Bellhome with the Chrome Bell Lacquer in non-Steel Soul mode");

			internal bool AccessSteelWish => _accessSteelWish.Value;

			internal bool SellShellSatchel => _sellShellSatchel.Value;

			internal bool AccessSkynx => _accessSkynx.Value;

			internal bool PaintBellhomeChrome => _paintBellhomeChrome.Value;

			public ConfigEntries(ConfigFile file)
			{
			}
		}

		private static Mod? _instance;

		private ConfigEntries? _config;

		public const string Id = "Esper89.PlasteelSoul";

		private static Mod Instance
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_instance))
				{
					throw new NullReferenceException("Mod accessed before Awake");
				}
				return _instance;
			}
		}

		internal static ConfigEntries Config => Instance._config;

		public static string Name => "Plasteel Soul";

		public static string Version => "1.1.0";

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			_instance = this;
			_config = new ConfigEntries(((BaseUnityPlugin)this).Config);
			new Harmony("Esper89.PlasteelSoul").PatchAll();
		}

		internal static void LogDebug(object msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogDebug(msg);
		}

		internal static void LogInfo(object msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo(msg);
		}

		internal static void LogMessage(object msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogMessage(msg);
		}

		internal static void LogWarning(object msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning(msg);
		}

		internal static void LogError(object msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogError(msg);
		}

		internal static void LogFatal(object msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogFatal(msg);
		}
	}
	internal static class AccessSteelWish
	{
		[HarmonyPatch(typeof(TestGameObjectActivator), "Evaluate")]
		private static class SetRunningEvaluationsInScene
		{
			private static void Prefix(TestGameObjectActivator __instance, ref bool __state)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Scene scene = ((Component)__instance).gameObject.scene;
				if (((Scene)(ref scene)).name == "Coral_37")
				{
					runningEvaluations++;
					__state = true;
				}
				else
				{
					__state = false;
				}
			}

			private static void Postfix(bool __state)
			{
				if (__state)
				{
					runningEvaluations--;
				}
			}
		}

		[HarmonyPatch(typeof(Test), "IsFulfilled")]
		private static class FakePermadeathEnabled
		{
			private static void Postfix(Test __instance, ref bool __result)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected I4, but got Unknown
				if (runningEvaluations > 0 && __instance.FieldName == "permadeathMode" && Mod.Config.AccessSteelWish)
				{
					float num = __instance.IntValue;
					NumTestType numType = __instance.NumType;
					__result = (int)numType switch
					{
						0 => 1f == num, 
						1 => 1f != num, 
						2 => 1f < num, 
						3 => 1f > num, 
						_ => throw new ArgumentOutOfRangeException(), 
					};
				}
			}
		}

		private static int runningEvaluations;
	}
	internal static class SellShellSatchel
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static class RegisterShopItem
		{
			private static void Prefix(ShopItemList __instance)
			{
				if (!(((Object)__instance).name == "City Merchant Stock") || __instance.shopItems == null || __instance.shopItems.Contains(JubilanaShopShellSatchel))
				{
					return;
				}
				List<ShopItem> list = __instance.shopItems.ToList();
				int i;
				for (i = 0; i < list.Count(); i++)
				{
					ShopItem val = list[i];
					if (Object.op_Implicit((Object)(object)val) && ((Object)val).name == "City Merchant Needolin Tool")
					{
						QuestTest[] questsAppearConditions = val.questsAppearConditions;
						JubilanaShopShellSatchel.questsAppearConditions = questsAppearConditions;
						break;
					}
				}
				i++;
				if (i > list.Count())
				{
					i = 0;
				}
				list.Insert(Math.Clamp(i, 0, list.Count()), JubilanaShopShellSatchel);
				__instance.shopItems = list.ToArray();
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static class HideIfDisabled
		{
			private static void Postfix(ShopItem __instance, ref bool __result)
			{
				if (((Object)__instance).name == ((Object)JubilanaShopShellSatchel).name && !Mod.Config.SellShellSatchel)
				{
					__result = false;
				}
			}
		}

		private static ShopItem JubilanaShopShellSatchel = CreateItem();

		private static ShopItem CreateItem()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			ShopItem val = (ShopItem)ScriptableObject.CreateInstance(typeof(ShopItem));
			((Object)val).name = "Mods.Esper89.PlasteelSoul.JubilanaShopShellSatchel";
			val.displayName = new LocalisedString("Tools", "SHELL_SATCHEL_NAME");
			val.description = new LocalisedString("Mods.Esper89.PlasteelSoul", "JUBILANA_SHOP_SHELL_SATCHEL_DESC");
			val.cost = 290;
			val.savedItem = (SavedItem)(object)Gameplay.ShellSatchelTool;
			val.questsAppearConditions = Array.Empty<QuestTest>();
			PlayerDataTest val2 = new PlayerDataTest();
			val2.TestGroups = (TestGroup[])(object)new TestGroup[1]
			{
				new TestGroup
				{
					Tests = (Test[])(object)new Test[1]
					{
						new Test
						{
							Type = (TestType)3,
							FieldName = "permadeathMode",
							NumType = (NumTestType)0,
							IntValue = 0
						}
					}
				}
			};
			val.extraAppearConditions = val2;
			val.spawnOnPurchaseConditionals = Array.Empty<ConditionalSpawn>();
			val.setExtraPlayerDataBools = Array.Empty<string>();
			val.setExtraPlayerDataInts = Array.Empty<PlayerDataIntOperation>();
			return val;
		}
	}
	internal static class AccessSkynx
	{
		[HarmonyPatch(typeof(TestGameObjectActivator), "Evaluate")]
		private static class RearrangeStyxRoomHierarchy
		{
			private static void Postfix(TestGameObjectActivator __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Scene scene = ((Component)__instance).gameObject.scene;
				if (!(((Scene)(ref scene)).name == "Dust_11") || !(((Object)__instance).name == "Steel Soul States") || !Mod.Config.AccessSkynx)
				{
					return;
				}
				Transform transform = ((Component)__instance).transform;
				Transform val = transform.Find("Regular");
				if (Object.op_Implicit((Object)(object)val))
				{
					Transform val2 = val.Find("right_wall");
					if (Object.op_Implicit((Object)(object)val2))
					{
						((Component)val2).gameObject.SetActive(false);
					}
				}
				Transform val3 = transform.Find("Steel Soul");
				if (Object.op_Implicit((Object)(object)val3))
				{
					Transform val4 = val3.Find("Breakable Wall");
					if (Object.op_Implicit((Object)(object)val4))
					{
						val4.parent = transform;
					}
					Transform val5 = val3.Find("Group");
					if (Object.op_Implicit((Object)(object)val5) && Object.op_Implicit((Object)(object)val5.Find("Grub Farmer Mimic")))
					{
						val5.parent = transform;
					}
				}
			}
		}
	}
	internal static class PaintBellhomeChrome
	{
		[HarmonyPatch(typeof(ShopItem), "Awake")]
		private static class RegisterBellhomePaintConditions
		{
			private static void Postfix(ShopItem __instance)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)__instance).name == "Bellhart Furnishing Paint")
				{
					SubItem[] subItems = __instance.subItems;
					foreach (SubItem val in subItems)
					{
						bellhomePaintConditions.AddOrUpdate(val.Condition, unit);
					}
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static class MakeAllBellhomeColorsAvailable
		{
			private static void Postfix(PlayerDataTest __instance, ref bool __result)
			{
				if (Mod.Config.PaintBellhomeChrome && bellhomePaintConditions.TryGetValue(__instance, out object _))
				{
					__result = true;
				}
			}
		}

		private static object unit = true;

		private static ConditionalWeakTable<PlayerDataTest, object> bellhomePaintConditions = new ConditionalWeakTable<PlayerDataTest, object>();
	}
}