Decompiled source of HostOnlyPurchase v1.0.0

HostOnlyPurchace.dll

Decompiled 5 months ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
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("HostOnlyPurchace")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HostOnlyPurchace")]
[assembly: AssemblyTitle("HostOnlyPurchace")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HostOnlyPurchace;

public class HarmonyPatches
{
	private static Harmony instance;

	public const string InstanceId = "com.graze.hostonlypurchace";

	public static bool IsPatched { get; private set; }

	internal static void ApplyHarmonyPatches()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if (!IsPatched)
		{
			if (instance == null)
			{
				instance = new Harmony("com.graze.hostonlypurchace");
			}
			instance.PatchAll(Assembly.GetExecutingAssembly());
			IsPatched = true;
		}
	}

	internal static void RemoveHarmonyPatches()
	{
		if (instance != null && IsPatched)
		{
			instance.UnpatchSelf();
			IsPatched = false;
		}
	}
}
[BepInPlugin("com.graze.hostonlypurchace", "HostOnlyPurchace", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private Plugin()
	{
		HarmonyPatches.ApplyHarmonyPatches();
	}
}
public static class ValuesETC
{
	public static TerminalNode HostOnly = new TerminalNode
	{
		displayText = "Only The host can Purchase Items or route the Ship.\n\nClosing Terminal in 3 seconds",
		clearPreviousText = true,
		acceptAnything = true
	};

	public static IEnumerator Close(Terminal term)
	{
		yield return (object)new WaitForSeconds(3f);
		term.QuitTerminal();
	}
}
[HarmonyPatch(typeof(Terminal))]
[HarmonyPatch("LoadNewNode")]
internal static class TerminalPatch
{
	private static bool Prefix(TerminalNode node, Terminal __instance)
	{
		if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
		{
			if (node.isConfirmationNode || ((Object)node).name.Contains("route"))
			{
				__instance.LoadNewNode(ValuesETC.HostOnly);
				((MonoBehaviour)__instance).StartCoroutine(ValuesETC.Close(__instance));
				return false;
			}
			return true;
		}
		return true;
	}
}
internal class PluginInfo
{
	public const string GUID = "com.graze.hostonlypurchace";

	public const string Name = "HostOnlyPurchace";

	public const string Version = "1.0.0";
}