Decompiled source of Hachis Scrap v0.1.0

BepInEx/plugins/HachiScrap/Hachiski.HachiScrap.dll

Decompiled 2 weeks ago
using System;
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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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("Hachiski.HachiScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("HachiScrap")]
[assembly: AssemblyTitle("Hachiski.HachiScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.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;
		}
	}
	[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 HachiScrap
{
	[BepInPlugin("Hachiski.HachiScrap", "HachiScrap", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class HachiScrap : BaseUnityPlugin
	{
		public static AssetBundle HachiAssets;

		public static HachiScrap Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Logger.LogInfo((object)"HachiScrap v0.1.0 has joined the session!");
			HachiAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "hachimod"));
			if ((Object)(object)HachiAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			Item val = HachiAssets.LoadAsset<Item>("assets/hachimod/mintyfumo.asset");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Minty Fumo failed to load");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, 15, (LevelTypes)(-1));
			}
			Item val2 = HachiAssets.LoadAsset<Item>("assets/hachimod/cucumber/cucumber.asset");
			if ((Object)(object)val2 == (Object)null)
			{
				Logger.LogError((object)"Cucumber failed to load");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
				Items.RegisterScrap(val2, 30, (LevelTypes)(-1));
			}
			Item val3 = HachiAssets.LoadAsset<Item>("assets/hachimod/lights/lightspillow.asset");
			if ((Object)(object)val3 == (Object)null)
			{
				Logger.LogError((object)"Lights Pillow failed to load");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
				Items.RegisterScrap(val3, 30, (LevelTypes)(-1));
			}
			Item val4 = HachiAssets.LoadAsset<Item>("assets/hachimod/dinosaur/dinosaur.asset");
			if ((Object)(object)val4 == (Object)null)
			{
				Logger.LogError((object)"Dinosaur failed to load");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
				Items.RegisterScrap(val4, 30, (LevelTypes)(-1));
			}
			Item val5 = HachiAssets.LoadAsset<Item>("assets/hachimod/mintybottle/mintybottle.asset");
			if ((Object)(object)val5 == (Object)null)
			{
				Logger.LogError((object)"Minty's Water failed to load, not based.");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
				Items.RegisterScrap(val5, 30, (LevelTypes)(-1));
			}
			Item val6 = HachiAssets.LoadAsset<Item>("assets/hachimod/gplay/gplay.asset");
			if ((Object)(object)val5 == (Object)null)
			{
				Logger.LogError((object)"Google Play failed to load, not based.");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
				Items.RegisterScrap(val6, 30, (LevelTypes)(-1));
			}
			Item val7 = HachiAssets.LoadAsset<Item>("assets/hachimod/proxz/proxz.asset");
			if ((Object)(object)val5 == (Object)null)
			{
				Logger.LogError((object)"Proxz failed to load, not based.");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val7.spawnPrefab);
				Items.RegisterScrap(val7, 30, (LevelTypes)(-1));
			}
			Item val8 = HachiAssets.LoadAsset<Item>("assets/hachimod/fig/figscrapdata.asset");
			if ((Object)(object)val5 == (Object)null)
			{
				Logger.LogError((object)"Fig failed to load, not based.");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val8.spawnPrefab);
				Items.RegisterScrap(val8, 30, (LevelTypes)(-1));
			}
			Item val9 = HachiAssets.LoadAsset<Item>("assets/hachimod/hachipin/hachipindata.asset");
			if ((Object)(object)val5 == (Object)null)
			{
				Logger.LogError((object)"Hachi's Pin failed to load, not based.");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val9.spawnPrefab);
			Items.RegisterScrap(val9, 30, (LevelTypes)(-1));
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Hachiski.HachiScrap");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Hachiski.HachiScrap";

		public const string PLUGIN_NAME = "HachiScrap";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace HachiScrap.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}