Decompiled source of Insecticide v0.3.0

Mods/Insecticide.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppCysharp.Threading.Tasks;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Bonelab.SaveData;
using Il2CppSLZ.Marrow.Forklift.Model;
using Il2CppSLZ.Marrow.SaveData;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.UI;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using Insecticide;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "Insecticide", "0.3.0", "Millzy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonID("Millzy.Insecticide")]
[assembly: VerifyLoaderVersion("0.6.4")]
[assembly: HarmonyDontPatchAll]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Insecticide")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2024-present Frederick (Millzy) Mills")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e68bba843b2375d3592690ba2c9b8adab8170e84")]
[assembly: AssemblyProduct("Insecticide")]
[assembly: AssemblyTitle("Insecticide")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace Insecticide
{
	public class Mod : MelonMod
	{
		public override void OnInitializeMelon()
		{
			((MelonBase)this).HarmonyInstance.PatchAll();
		}

		public override void OnDeinitializeMelon()
		{
			((MelonBase)this).HarmonyInstance.UnpatchSelf();
		}
	}
	internal static class BuildInfo
	{
		public const string Name = "Insecticide";

		public const string Author = "Millzy";

		public const string Version = "0.3.0";

		public const string Description = "A general bug fix mod for BONELAB.";

		public const string Id = "Millzy.Insecticide";
	}
}
namespace Insecticide.HarmonyPatches
{
	[HarmonyPatch(typeof(AssetWarehouse))]
	[HarmonyPatch("ReloadPallet")]
	internal static class AssetWarehouse_ReloadPallet
	{
		[HarmonyPrefix]
		private static bool Prefix(AssetWarehouse __instance, Barcode barcode)
		{
			Pallet val = default(Pallet);
			if (!__instance.TryGetScannable<Pallet>(barcode, ref val))
			{
				return false;
			}
			Dictionary<Barcode, PalletManifest> palletManifests = __instance.palletManifests;
			if (palletManifests == null)
			{
				return false;
			}
			PalletManifest val2 = default(PalletManifest);
			if (!palletManifests.TryGetValue(barcode, ref val2))
			{
				return false;
			}
			__instance.UnloadPallet(val);
			UniTaskExtensions.Forget<bool>(__instance.LoadPalletFromFolderAsync(val2._palletPath, true, (string)null, (ModListing)null));
			return false;
		}
	}
	[HarmonyPatch(typeof(AvatarsPanelView))]
	[HarmonyPatch("LoadFavoriteAvatars")]
	internal static class AvatarsPanelView_LoadFavouriteAvatars
	{
		[HarmonyPrefix]
		private static bool Prefix(AvatarsPanelView __instance)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			DataManager.TryLoadActiveSave((SaveFlags)0);
			List<string> favoriteAvatars_k__BackingField = DataManager.ActiveSave._PlayerSettings_k__BackingField._FavoriteAvatars_k__BackingField;
			List<AvatarCrateReference> defaultFavoriteAvatarsBarcodes = __instance.defaultFavoriteAvatarsBarcodes;
			List<Barcode> list = new List<Barcode>();
			if (favoriteAvatars_k__BackingField == null || favoriteAvatars_k__BackingField._size < defaultFavoriteAvatarsBarcodes._size)
			{
				Enumerator<AvatarCrateReference> enumerator = defaultFavoriteAvatarsBarcodes.GetEnumerator();
				while (enumerator.MoveNext())
				{
					AvatarCrateReference current = enumerator.Current;
					list.Add(((ScannableReference)current).Barcode);
				}
			}
			else
			{
				Enumerator<string> enumerator2 = favoriteAvatars_k__BackingField.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					Barcode item = new Barcode(enumerator2.Current);
					list.Add(item);
				}
			}
			Il2CppReferenceArray<AvatarCrateReference> avatarFavorites = __instance.avatarFavorites;
			Crate val2 = default(Crate);
			for (int i = 0; i < list.Count; i++)
			{
				Barcode val = list[i];
				Debug.Log(Object.op_Implicit("Loading avatar " + val.ID + " from save data"));
				AvatarCrateReference val4 = (((Il2CppArrayBase<AvatarCrateReference>)(object)avatarFavorites)[i] = (AvatarCrateReference)(AssetWarehouse.Instance.TryGetCrate(val, ref val2) ? ((object)new AvatarCrateReference(((Scannable)val2).Barcode)) : ((object)defaultFavoriteAvatarsBarcodes._items[i])));
				((TMP_Text)((Il2CppArrayBase<ButtonReferenceHolder>)(object)__instance.slotButtons)[i].tmp).text = ((Object)((CrateReferenceT<AvatarCrate>)(object)val4).Crate).name;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(RigScreenOptions))]
	[HarmonyPatch("SetSpectatorCamera")]
	internal static class RigScreenOptions_SetSpectatorCamera
	{
		[HarmonyPostfix]
		private static void Postfix(RigScreenOptions __instance)
		{
			__instance.cam.clearFlags = (CameraClearFlags)1;
		}
	}
}