Decompiled source of SellShards v0.1.1

SellShards.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
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 HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using SellShards.Settings;
using Silksong.FsmUtil;
using TMProOld;
using TeamCherry.Localization;

[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("SellShards")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+055abe90e0e7108d3c1635d84796dbce70f530eb")]
[assembly: AssemblyProduct("SellShards")]
[assembly: AssemblyTitle("SellShards")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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")]
	[Microsoft.CodeAnalysis.Embedded]
	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")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace SilklessSkills
{
	public static class SharedData
	{
	}
}
namespace SellShards
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.danielstegink.sellshards", "SellShards", "0.1.1")]
	public class SellShards : BaseUnityPlugin
	{
		internal static SellShards instance;

		public const string Id = "io.github.danielstegink.sellshards";

		public static string Name => "SellShards";

		public static string Version => "0.1.1";

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			new Harmony("io.github.danielstegink.sellshards").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.danielstegink.sellshards) has loaded!"));
		}

		private void Start()
		{
			ConfigSettings.Initialize(((BaseUnityPlugin)this).Config);
		}

		internal void Log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}
	}
}
namespace SellShards.Settings
{
	public static class ConfigSettings
	{
		public static ConfigEntry<int> shardCost;

		public static ConfigEntry<int> rosaries;

		public static void Initialize(ConfigFile config)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			LocalisedString val = default(LocalisedString);
			((LocalisedString)(ref val))..ctor("Mods.io.github.danielstegink.sellshards", "SHARD_NAME");
			LocalisedString val2 = default(LocalisedString);
			((LocalisedString)(ref val2))..ctor("Mods.io.github.danielstegink.sellshards", "SHARD_DESC");
			int num = 500;
			if (((LocalisedString)(ref val)).Exists && ((LocalisedString)(ref val2)).Exists)
			{
				shardCost = config.Bind<int>("Modifier", LocalisedString.op_Implicit(val), num, LocalisedString.op_Implicit(val2));
			}
			else
			{
				shardCost = config.Bind<int>("Modifier", "Shard Cost", num, "The number of shards required to trade");
			}
			((LocalisedString)(ref val))..ctor("Mods.io.github.danielstegink.sellshards", "ROSARY_NAME");
			((LocalisedString)(ref val2))..ctor("Mods.io.github.danielstegink.sellshards", "ROSARY_DESC");
			num = 100;
			if (((LocalisedString)(ref val)).Exists && ((LocalisedString)(ref val2)).Exists)
			{
				rosaries = config.Bind<int>("Modifier", LocalisedString.op_Implicit(val), num, LocalisedString.op_Implicit(val2));
			}
			else
			{
				rosaries = config.Bind<int>("Modifier", "Rosaries", num, "The number of rosaries given per trade");
			}
		}
	}
}
namespace SellShards.Helpers
{
	[HarmonyPatch(typeof(Fsm), "Awake")]
	public static class Fsm_Awake
	{
		[HarmonyPostfix]
		public static void Postfix(Fsm __instance)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_015f: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Expected O, but got Unknown
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			if (__instance.Name.Equals("Dialogue") && __instance.GameObjectName.Equals("Fixer Sitting Bone_10"))
			{
				RunDialogue action = FsmUtil.GetAction<RunDialogue>(__instance.GetState("Repeat"), 0);
				if (action != null)
				{
					FsmState val = FsmUtil.AddState(__instance, "ShellShards_EndRepeat");
					FsmUtil.ChangeTransition(__instance, "Repeat", "CONVO_END", val.Name);
					FsmUtil.AddAction(val, (FsmStateAction)new EndDialogue
					{
						ReturnControl = FsmBool.op_Implicit(false),
						ReturnHUD = FsmBool.op_Implicit(false),
						Target = ((GetComponentFsmStateAction<PlayMakerNPC>)(object)action).Target,
						UseChildren = FsmBool.op_Implicit(false)
					});
					FsmState val2 = FsmUtil.AddState(__instance, "ShellShards_Flick");
					FsmUtil.AddTransition(__instance, val.Name, "FINISHED", val2.Name);
					RunDialogueV2 val3 = new RunDialogueV2
					{
						CustomText = FsmString.op_Implicit(Language.Get("FLICK_SELL_PROMPT", "Mods.io.github.danielstegink.sellshards")),
						Sheet = FsmString.op_Implicit("Mods.io.github.danielstegink.sellshards"),
						Key = FsmString.op_Implicit("FLICK_SELL_PROMPT"),
						OverrideContinue = FsmBool.op_Implicit(false),
						PlayerVoiceTableOverride = ((RunDialogueBase)action).PlayerVoiceTableOverride,
						PreventHeroAnimation = FsmBool.op_Implicit(false),
						HideDecorators = FsmBool.op_Implicit(false),
						TextAlignment = FsmEnum.op_Implicit((Enum)(object)(TextAlignmentOptions)0),
						OffsetY = FsmFloat.op_Implicit(0f)
					};
					((GetComponentFsmStateAction<PlayMakerNPC>)val3).Target = ((GetComponentFsmStateAction<PlayMakerNPC>)(object)action).Target;
					FsmUtil.AddAction(val2, (FsmStateAction)val3);
					FsmState val4 = FsmUtil.AddState(__instance, "ShellShards_YesNo");
					FsmUtil.AddTransition(__instance, val2.Name, "CONVO_END", val4.Name);
					FsmUtil.AddAction(val4, (FsmStateAction)new EndDialogue
					{
						ReturnControl = FsmBool.op_Implicit(true),
						ReturnHUD = FsmBool.op_Implicit(true),
						Target = ((GetComponentFsmStateAction<PlayMakerNPC>)(object)action).Target,
						UseChildren = FsmBool.op_Implicit(false)
					});
					FsmUtil.AddAction(val4, (FsmStateAction)new DialogueYesNoV2
					{
						TranslationSheet = FsmString.op_Implicit("Mods.io.github.danielstegink.sellshards"),
						TranslationKey = FsmString.op_Implicit("YES_NO"),
						UseCurrency = FsmBool.op_Implicit(true),
						CurrencyCost = FsmInt.op_Implicit(ConfigSettings.shardCost.Value),
						CurrencyType = FsmEnum.op_Implicit((Enum)(object)(CurrencyType)1),
						ConsumeCurrency = FsmBool.op_Implicit(false),
						WillGetItem = new FsmObject(),
						YesEvent = FsmEvent.GetFsmEvent("YES"),
						NoEvent = FsmEvent.GetFsmEvent("NO"),
						ReturnHUDAfter = FsmBool.op_Implicit(false)
					});
					FsmState val5 = FsmUtil.AddState(__instance, "ShellShards_Yes");
					FsmUtil.AddTransition(__instance, val4.Name, "YES", val5.Name);
					FsmUtil.AddAction(val5, (FsmStateAction)new TakeCurrency
					{
						CurrencyType = FsmEnum.op_Implicit((Enum)(object)(CurrencyType)1),
						Amount = FsmInt.op_Implicit(ConfigSettings.shardCost.Value)
					});
					FsmUtil.AddAction(val5, (FsmStateAction)new AddCurrency
					{
						CurrencyType = FsmEnum.op_Implicit((Enum)(object)(CurrencyType)0),
						Amount = FsmInt.op_Implicit(ConfigSettings.rosaries.Value)
					});
					FsmState val6 = FsmUtil.AddState(__instance, "No");
					FsmUtil.AddTransition(__instance, val4.Name, "NO", val6.Name);
					FsmUtil.AddTransition(__instance, val5.Name, "FINISHED", val6.Name);
					FsmUtil.AddTransition(__instance, val6.Name, "FINISHED", "Idle");
				}
			}
		}
	}
}