Decompiled source of CupboardFix v1.1.0

StorageFix.dll

Decompiled 10 months 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 Microsoft.CodeAnalysis;
using On;
using StorageFix.Patch;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("StorageFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StorageFix")]
[assembly: AssemblyTitle("StorageFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 StorageFix
{
	[BepInPlugin("Rocksnotch.StorageFix", "Storage Fix", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modName = "Storage Fix";

		private const string modVersion = "1.1.0";

		private const string modGUID = "Rocksnotch.StorageFix";

		internal static Plugin Instance;

		public static ManualLogSource logSrc = Logger.CreateLogSource("Rocksnotch.StorageFix");

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			StoragePatch.Init();
			logSrc.LogInfo((object)"Plugin Rocksnotch.StorageFix is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "StorageFix";

		public const string PLUGIN_NAME = "StorageFix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace StorageFix.Patch
{
	internal class StoragePatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_LoadShipGrabbableItems <0>__LoadShipGrabbableItems;
		}

		private Dictionary<int, GrabbableObject> storageItems = new Dictionary<int, GrabbableObject>();

		public static Vector3 shelfPlacementPos = Vector3.zero;

		public static NetworkObject storageCloset = null;

		public static GrabbableObject[] grabbableObjects = null;

		public static List<GrabbableObject> grabbableObjectsHigh = new List<GrabbableObject>();

		public static bool loadStorage = true;

		public static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			object obj = <>O.<0>__LoadShipGrabbableItems;
			if (obj == null)
			{
				hook_LoadShipGrabbableItems val = LoadShipGrabbableItems;
				<>O.<0>__LoadShipGrabbableItems = val;
				obj = (object)val;
			}
			StartOfRound.LoadShipGrabbableItems += (hook_LoadShipGrabbableItems)obj;
		}

		public static void LoadShipGrabbableItems(orig_LoadShipGrabbableItems orig, StartOfRound self)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			grabbableObjects = Object.FindObjectsOfType<GrabbableObject>();
			for (int i = 0; i < grabbableObjects.Length; i++)
			{
				if (((Component)grabbableObjects[i]).transform.localPosition.y > grabbableObjects[i].itemProperties.verticalOffset && !(((Object)((Component)grabbableObjects[i]).transform).name == "ClipboardManual") && !(((Object)((Component)grabbableObjects[i]).transform).name == "StickyNoteItem"))
				{
					grabbableObjects[i].itemProperties.itemSpawnsOnGround = false;
					grabbableObjectsHigh.Add(grabbableObjects[i]);
				}
			}
			FindStorageCloset(self);
			((Component)storageCloset).transform.position = self.unlockablesList.unlockables[7].placedPosition;
			((Component)storageCloset).transform.localEulerAngles = self.unlockablesList.unlockables[7].placedRotation;
			Plugin.logSrc.LogInfo((object)"Begin Listing Grabbable Objects that are above the vertical offset");
			for (int j = 0; j < grabbableObjectsHigh.Count; j++)
			{
				Plugin.logSrc.LogInfo((object)$"Grabbable Object {((Object)((Component)grabbableObjectsHigh[j]).transform).name} is above the vertical offset at {((Component)grabbableObjectsHigh[j]).transform.localPosition.y} compared to offset of {grabbableObjectsHigh[j].itemProperties.verticalOffset}");
			}
			for (int k = 0; k < grabbableObjectsHigh.Count; k++)
			{
				if (((Object)((Component)grabbableObjectsHigh[k]).transform).name == "ShovelItem(Clone)")
				{
					((Component)grabbableObjectsHigh[k]).transform.rotation = ((Component)storageCloset).transform.rotation;
					((Component)grabbableObjectsHigh[k]).transform.Rotate(0f, 90f, 0f);
				}
				else if (((Object)((Component)grabbableObjectsHigh[k]).transform).name == "WalkieTalkie(Clone)")
				{
					((Component)grabbableObjectsHigh[k]).transform.rotation = ((Component)storageCloset).transform.rotation;
					((Component)grabbableObjectsHigh[k]).transform.Rotate(0f, 90f, -90f);
				}
				else
				{
					((Component)grabbableObjectsHigh[k]).transform.rotation = ((Component)storageCloset).transform.rotation;
				}
			}
			Array.Clear(grabbableObjects, 0, grabbableObjects.Length);
			grabbableObjectsHigh.Clear();
			storageCloset = null;
		}

		public static void FindStorageCloset(StartOfRound self)
		{
			NetworkObject[] array = Object.FindObjectsOfType<NetworkObject>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)((Component)array[i]).transform).name == "StorageCloset")
				{
					storageCloset = array[i];
					break;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}