Decompiled source of Dispenser v1.3.0

Dispenser.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using Steamworks;
using UnityEngine;
using UnityEngine.Diagnostics;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("UnloadedHangar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("We need a dispenser right here!")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyProduct("Dispenser")]
[assembly: AssemblyTitle("Dispenser")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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;
		}
	}
}
public class CallEventOnStart : StateMachineBehaviour
{
	public UnityEvent OnStart;

	public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
	{
		OnStart.Invoke();
	}
}
public class ExecuteOnAnimationStateFinish : StateMachineBehaviour
{
	public string boolName;

	public bool targetState;

	public float executionTime;

	public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
		if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= executionTime && !animator.GetBool(boolName))
		{
			animator.SetBool(boolName, targetState);
		}
	}
}
namespace Dispenser
{
	internal class ClientScanner
	{
		[SecurityCritical]
		private static StringBuilder results;

		[SecurityCritical]
		private static string resultsString;

		[SecurityCritical]
		internal static void ScanGameClient()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (No.didExit)
			{
				return;
			}
			results = new StringBuilder();
			DispenserPlugin.logger.LogInfo((object)"Scanning client...");
			if (SteamClient.Name == "IGGGAMES")
			{
				results.Append("N");
			}
			else
			{
				results.Append("Y");
			}
			if (SteamId.op_Implicit(SteamClient.SteamId) == 12345678)
			{
				results.Append(" N");
			}
			else
			{
				results.Append(" Y");
			}
			if (AppId.op_Implicit(SteamClient.AppId) == 480)
			{
				results.Append(" N");
			}
			else
			{
				results.Append(" Y");
			}
			resultsString = results.ToString();
			if (resultsString.Contains("N"))
			{
				try
				{
					ThrowData("Unknown credentials... Access Denied!");
					return;
				}
				catch (Exception ex)
				{
					DispenserPlugin.logger.LogFatal((object)ex);
					return;
				}
				finally
				{
					Crash();
				}
			}
			DispenserPlugin.logger.LogInfo((object)"Scan complete... System state normal");
		}

		[SecurityCritical]
		private static void ThrowData(string message)
		{
			throw new SystemExceptionNotHandled(message);
		}

		[SecurityCritical]
		private static void Crash()
		{
			Utils.ForceCrash((ForcedCrashCategory)2);
		}
	}
	internal class Content
	{
		public static List<GameObject> AssetsList = new List<GameObject>();

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)DispenserPlugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, "dispenser");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				AssetsList.Add(val.LoadAsset<GameObject>("WeNeedADispenserRightHere_EngineerApproved"));
				AssetsList.Add(val.LoadAsset<GameObject>("XDispenserUpgrade"));
				Items.RegisterItem(AssetsList[0].gameObject.GetComponent<ItemAttributes>());
				AssetsList[1].gameObject.GetComponent<ItemAttributes>().item.physicalItem = true;
				Items.RegisterItem(AssetsList[1].gameObject.GetComponent<ItemAttributes>());
				DispenserPlugin.logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
			catch (Exception arg)
			{
				DispenserPlugin.logger.LogError((object)$"Error: failed to load assets from AssetBundle.\n\n{arg}");
			}
		}
	}
	internal class DispenserObject : MonoBehaviour
	{
		public GameObject BuiltVersion;

		public SkinnedMeshRenderer DispenserRenderer;

		public SkinnedMeshRenderer JunkRenderer;

		public GameObject DispenserLvl2Anim;

		public GameObject DispenserLvl2Built;

		private bool Switch = false;

		public Animator ThisAnimator;

		private bool IsBuilt = false;

		private AudioSource SFX;

		private int HealAmount = 1;

		internal static DispenserObject Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
		}

		private void Start()
		{
			SFX = ((Component)this).GetComponent<AudioSource>();
			ThisAnimator.SetBool("BuildTriggered", true);
			Object.Destroy((Object)(object)((Component)this).GetComponent<ItemEquippable>());
			if (!StatsManager.instance.itemsPurchased.ContainsKey("Item DispenserUpgrade"))
			{
				Instance.SetMaxLevel(1);
			}
		}

		public void StartBuild()
		{
			if (ThisAnimator.GetFloat("MotionMultiplier") == 0f && !SemiFunc.RunIsShop())
			{
				ThisAnimator.SetFloat("MotionMultiplier", 0.65f);
				SFX.Play();
			}
		}

		internal void SetMaxLevel(int maxLevel)
		{
			ThisAnimator.SetInteger("MaxLevel", maxLevel);
		}

		internal int GetMaxLevel()
		{
			return ThisAnimator.GetInteger("MaxLevel");
		}

		public static void PostBuildEvent(int targetLevel)
		{
			switch (targetLevel)
			{
			case 1:
				((Renderer)Instance.DispenserRenderer).enabled = false;
				((Renderer)Instance.JunkRenderer).enabled = false;
				Instance.BuiltVersion.SetActive(true);
				Instance.IsBuilt = true;
				Instance.HealAmount = 2;
				((MonoBehaviour)Instance).InvokeRepeating("DelayHeal", 1.2f, 1.2f);
				break;
			case 2:
				Instance.IsBuilt = true;
				Instance.HealAmount = 8;
				((MonoBehaviour)Instance).InvokeRepeating("DelayHeal", 0.87f, 0.87f);
				break;
			}
		}

		public void InitUpgrade(int stage)
		{
			switch (stage)
			{
			case 1:
				((Renderer)Instance.DispenserRenderer).enabled = false;
				((Renderer)Instance.JunkRenderer).enabled = false;
				Instance.BuiltVersion.SetActive(false);
				Instance.DispenserLvl2Built.SetActive(false);
				Instance.DispenserLvl2Anim.SetActive(true);
				break;
			case 2:
				Instance.DispenserLvl2Anim.SetActive(false);
				Instance.DispenserLvl2Built.SetActive(true);
				PostBuildEvent(2);
				break;
			}
		}

		private void DelayHeal()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (Vector3.Distance(player.playerTransform.position, ((Component)Instance).gameObject.transform.position) <= 1.5f)
					{
						player.playerHealth.Heal(HealAmount, false);
					}
				}
			}
			catch
			{
			}
		}

		private void OnDestroy()
		{
			((MonoBehaviour)Instance).CancelInvoke();
		}
	}
	[BepInProcess("REPO.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Dispenser-UnloadedHangar", "Dispenser", "1.3.0")]
	public class DispenserPlugin : BaseUnityPlugin
	{
		public static class PluginInfo
		{
			public const string Guid = "Dispenser-UnloadedHangar";

			public const string Name = "Dispenser";

			public const string Ver = "1.3.0";
		}

		internal static ManualLogSource logger;

		private Harmony _harmony;

		internal static DispenserPlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("Dispenser-UnloadedHangar");
			logger.LogInfo((object)"Dispenser-UnloadedHangar loaded");
			Content.Load();
			_harmony = new Harmony("Dispenser-UnloadedHangar");
			_harmony.PatchAll(typeof(No));
		}
	}
	internal class No
	{
		internal static bool didExit;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SteamManager), "Start")]
		private static void StartPatch()
		{
			ClientScanner.ScanGameClient();
			didExit = true;
		}

		private static void DebugPatch()
		{
			ClientScanner.ScanGameClient();
			didExit = true;
		}
	}
	internal class SystemExceptionNotHandled : SystemException
	{
		internal SystemExceptionNotHandled()
		{
		}

		internal SystemExceptionNotHandled(string message)
			: base(message)
		{
		}
	}
}