Decompiled source of Automaticsellapparatus v1.0.0

BepInEx/plugins/huluoboAutomaticsellapparatus.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace huluoboAutomaticsellapparatus;

[BepInPlugin("hlb.Automaticsellapparatus", "huluoboAutomaticsellapparatus", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch]
	internal class SellApparatusPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ThrowObjectServerRpc")]
		private static void Sellapparatus(ref NetworkObjectReference grabbedObject, bool droppedInElevator, bool droppedInShipRoom)
		{
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref grabbedObject)).TryGet(ref val, (NetworkManager)null))
			{
				GrabbableObject component = ((Component)val).GetComponent<GrabbableObject>();
				if (component is LungProp && (Object)(object)component.playerHeldBy == (Object)null && droppedInShipRoom)
				{
					HUDManager.Instance.DisplayTip("sell", component.itemProperties.itemName + " sell " + component.scrapValue, false, false, "LC_Tip1");
					Terminal val2 = Object.FindObjectOfType<Terminal>();
					val2.SyncGroupCreditsServerRpc(val2.groupCredits + component.scrapValue, val2.numberOfItemsInDropship);
					EndOfGameStats gameStats = StartOfRound.Instance.gameStats;
					gameStats.scrapValueCollected += component.scrapValue;
					TimeOfDay instance = TimeOfDay.Instance;
					instance.quotaFulfilled += component.scrapValue;
					TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
					((Component)component).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
		private static bool FixProfit(TimeOfDay __instance)
		{
			return __instance.daysUntilDeadline <= 0;
		}
	}

	private const string GUID = "hlb.Automaticsellapparatus";

	private const string Name = "huluoboAutomaticsellapparatus";

	private const string Version = "1.0.0";

	private Harmony harmony;

	public static ManualLogSource Log;

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		harmony = new Harmony("hlb.Automaticsellapparatus");
		harmony.PatchAll();
	}
}