Decompiled source of RosaryCannonCraftBind v0.1.0

RosaryCannonCraftBind.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GlobalEnums;
using GlobalSettings;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RosaryCannonCraftBind")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+5513bce202025d37619fc0291ed15dfcc4a583d1")]
[assembly: AssemblyProduct("RosaryCannonCraftBind")]
[assembly: AssemblyTitle("RosaryCannonCraftBind")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/unfrosted2069/Silksong.RosaryCannonCraftBind")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 RosaryCannonCraftBind
{
	[HarmonyPatch]
	[BepInPlugin("io.github.unfrosted2069.RosaryCannonCraftBind", "RosaryCannonCraftBind", "0.1.0")]
	public class RosaryCannonCraftBind : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		public static int prememorystate_rosarystring_amount;

		public const string Id = "io.github.unfrosted2069.RosaryCannonCraftBind";

		public static string Name => "RosaryCannonCraftBind";

		public static string Version => "0.1.0";

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("io.github.unfrosted2069.RosaryCannonCraftBind");
			val.PatchAll();
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " (io.github.unfrosted2069.RosaryCannonCraftBind) has loaded!"));
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ToolItemManager), "TryReplenishTools")]
		private static void TryReplenishTools_RosaryCannon(ToolItemManager __instance, bool doReplenish, ReplenishMethod method)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			if (!doReplenish || (int)method != 1)
			{
				return;
			}
			ToolItem toolByName = ToolItemManager.GetToolByName("Rosary Cannon");
			if (!ToolItemManager.GetCurrentEquippedTools().Contains(toolByName))
			{
				return;
			}
			int amountLeft = toolByName.SavedData.AmountLeft;
			int toolStorageAmount = ToolItemManager.GetToolStorageAmount(toolByName);
			int num = toolStorageAmount - amountLeft;
			if (num <= 0)
			{
				return;
			}
			int num2 = ((num < 60) ? num : 60);
			CollectableItem itemByName = CollectableItemManager.GetItemByName("Rosary_Set_Small");
			if (itemByName.CollectedAmount <= 0)
			{
				return;
			}
			Data savedData = toolByName.SavedData;
			if (num2 > 60)
			{
				savedData.AmountLeft += 60;
			}
			else
			{
				savedData.AmountLeft += num2;
				int num3 = 60 - num2;
				if (!PlayerData.instance.HasStoredMemoryState)
				{
					Config val = default(Config);
					val.Prefab = Gameplay.SmallGeoPrefab;
					val.AmountMin = num3;
					val.AmountMax = num3;
					val.SpeedMin = 15f;
					val.SpeedMax = 25f;
					val.AngleMin = -40f;
					val.AngleMax = 220f;
					FlingUtils.SpawnAndFling(val, HeroController._instance.transform, Vector3.zero, (List<GameObject>)null, -1f);
				}
			}
			itemByName.Take(1, true);
			PlayerData.instance.SetToolData(toolByName.name, savedData);
			ToolItemManager.ReportAllBoundAttackToolsUpdated();
			ToolItemManager.SendEquippedChangedEvent(true);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameManager), "EnteredNewMapZone")]
		private static void EnteredNewMapZone_RememberRS(GameManager __instance, MapZone previousMapZone, MapZone currentMapZone, bool forcedNotMemory)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			CollectableItem itemByName = CollectableItemManager.GetItemByName("Rosary_Set_Small");
			if (!forcedNotMemory && GameManager.IsMemoryScene(currentMapZone))
			{
				if (!PlayerData._instance.HasStoredMemoryState)
				{
					prememorystate_rosarystring_amount = ((SavedItem)itemByName).GetSavedAmount();
				}
			}
			else if (PlayerData._instance.HasStoredMemoryState && GameManager.IsMemoryScene(previousMapZone))
			{
				itemByName.AddAmount(prememorystate_rosarystring_amount - ((SavedItem)itemByName).GetSavedAmount());
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameManager), "LoadedFromMenu")]
		private static void LoadedFromMenu_RememberRS(GameManager __instance)
		{
			CollectableItem itemByName = CollectableItemManager.GetItemByName("Rosary_Set_Small");
			if (PlayerData._instance.HasStoredMemoryState)
			{
				itemByName.AddAmount(prememorystate_rosarystring_amount - ((SavedItem)itemByName).GetSavedAmount());
			}
		}
	}
}