Decompiled source of RoachardSaxoniteReclamation v0.1.0

ItemCapPlus.dll

Decompiled a month ago
using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RoachardSaxoniteReclamation")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0+5f991a30138e9d6772c494b594ffce10b4a3e3d7")]
[assembly: AssemblyProduct("Allow use of saxonite when out of Atlas oyster")]
[assembly: AssemblyTitle("RoachardSaxoniteReclamation")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 RoachardSaxoniteReclamation
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "RoachardSaxoniteReclamation";

		public const string PLUGIN_NAME = "Allow use of saxonite when out of Atlas oyster";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}
namespace ItemCapPlus
{
	[MycoMod(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("hed14.roachardsaxonitereclamation", "RoachardSaxoniteReclamation", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Roachard), "CanInteract")]
		public static class CanInteractPatch
		{
			public static void Postfix(ref bool __result, bool getText, ref string text)
			{
				if (__result)
				{
					return;
				}
				PlayerResource val = default(PlayerResource);
				if (text == null && PlayerResource.TryGetResource("saxonite", ref val) && PlayerData.Instance.GetResource(val) > 0)
				{
					if (getText)
					{
						text = TextBlocks.GetString("give", val.Name, true);
					}
					__result = true;
				}
				else
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(Roachard), "Interact")]
		public static class InteractPatch
		{
			[HarmonyPrefix]
			public static bool Prefix(Roachard __instance, Player player)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Expected O, but got Unknown
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				NavMeshAgent val = (NavMeshAgent)AccessTools.Field(typeof(Roachard), "navAgent").GetValue(__instance);
				PlayerResource val2 = default(PlayerResource);
				if (PlayerResource.TryGetResource("oyster", ref val2) && PlayerData.Instance.TryRemoveResource(val2, 1))
				{
					Vector3 localPosition = ((Component)__instance).transform.localPosition;
					localPosition.y += val.height;
					PlayerData.SpawnSkinCollectable(localPosition, (Rarity)(-1), (IUpgradable)null, 1f);
					GameManager.Instance.PlayMissionControlVoiceline("oyster_eat", 10, false);
					return false;
				}
				if (PlayerResource.TryGetResource("saxonite", ref val2) && PlayerData.Instance.TryRemoveResource(val2, 1))
				{
					Vector3 localPosition2 = ((Component)__instance).transform.localPosition;
					localPosition2.y += val.height;
					PlayerData.SpawnSkinCollectable(localPosition2, (Rarity)(-1), (IUpgradable)null, 1f);
					GameManager.Instance.PlayMissionControlVoiceline("oyster_eat", 10, false);
					return false;
				}
				return false;
			}
		}

		public const string PluginGUID = "hed14.roachardsaxonitereclamation";

		public const string PluginName = "RoachardSaxoniteReclamation";

		public const string PluginVersion = "0.1.0";

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin hed14.roachardsaxonitereclamation is loaded!");
			Harmony val = new Harmony("hed14.roachardsaxonitereclamation");
			val.PatchAll();
			Logger.LogInfo((object)"Harmony patches applied.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}