Decompiled source of Enkephalin v0.0.1

Enkephalin.lethal.dll

Decompiled 5 hours 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 Enkephalin.Scraps;
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("Enkephalin.lethal")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("Enkephalin")]
[assembly: AssemblyTitle("Enkephalin.lethal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 Enkephalin
{
	[BepInPlugin("Enkephalin.lethal", "Enkephalin", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Enkephalin : BaseUnityPlugin
	{
		public static AssetBundle? enkephalin;

		public static Enkephalin 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();
			Logger.LogInfo((object)"Enkephalin.lethal v0.0.1 has loaded!");
			enkephalin = LoadBundle("enkephalin_assetbundle");
			EnkephalinBox.Register(enkephalin.LoadAsset<Item>("assets/items/enkephalin_box/enkephalin_box_item.asset"));
			EnkephalinCan.Register(enkephalin.LoadAsset<Item>("assets/items/enkephalin_can/enkephalin_can_item.asset"));
			EnkephalinModule.Register(enkephalin.LoadAsset<Item>("assets/items/enkephalin_module/enkephalin_module_item.asset"));
		}

		private AssetBundle LoadBundle(string fileName)
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Logger.LogInfo((object)directoryName);
			Logger.LogInfo((object)("--- Inhalte von " + fileName + " ---"));
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, fileName));
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return null;
			}
			string[] allAssetNames = val.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				Logger.LogInfo((object)("Asset: " + text));
			}
			Logger.LogInfo((object)("--- Ende " + fileName + " ---"));
			return val;
		}

		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("Enkephalin.lethal");
			}
			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 = "Enkephalin.lethal";

		public const string PLUGIN_NAME = "Enkephalin";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace Enkephalin.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}
namespace Enkephalin.Scraps
{
	internal class EnkephalinCanItem : GrabbableObject
	{
		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				base.isBeingUsed = true;
				Debug.Log((object)"usedtest");
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
		}
	}
	public class StackOnLook : MonoBehaviour
	{
	}
	internal class EnkephalinBox
	{
		public static Item? Box;

		private static readonly int rarity = 10;

		public static void Register(Item Box)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[EnkephalinBox] Register gestartet");
			Box.verticalOffset = 0.55f;
			Box.restingRotation = new Vector3(-90f, 0f, 0f);
			Box.positionOffset = new Vector3(-0.5f, 0f, 0f);
			Box.rotationOffset = new Vector3(-90f, 0f, 0f);
			Box.requiresBattery = false;
			Box.allowDroppingAheadOfPlayer = true;
			Debug.Log((object)"[EnkephalinBox] Item erstellt, gehe zu RegisterScrap...");
			Utilities.FixMixerGroups(Box.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(Box.spawnPrefab);
			Items.RegisterScrap(Box, rarity, (LevelTypes)(-1));
			Debug.Log((object)"[EnkephalinBox] erfolgreich registriert!");
		}
	}
	internal class EnkephalinCan
	{
		public static Item? Can;

		public static GameObject? prefab;

		private static readonly int rarity = 30;

		public static void Register(Item Can)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[EnkephalinCan] Register gestartet");
			Can.restingRotation = new Vector3(90f, -90f, 90f);
			Can.rotationOffset = new Vector3(0f, 90f, 0f);
			Can.verticalOffset = 0.25f;
			Can.requiresBattery = false;
			Debug.Log((object)"[EnkephalinCan] Item erstellt, gehe zu RegisterScrap...");
			Can.holdButtonUse = true;
			Utilities.FixMixerGroups(Can.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(Can.spawnPrefab);
			Items.RegisterScrap(Can, rarity, (LevelTypes)(-1));
			Debug.Log((object)"[EnkephalinCan] erfolgreich registriert!");
		}
	}
	internal class EnkephalinModule
	{
		public static Item? module;

		public static GameObject? prefab;

		private static readonly int rarity = 20;

		public static void Register(Item module)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[EnkephalinBox] Register gestartet");
			module.verticalOffset = 0.175f;
			module.restingRotation = new Vector3(-90f, 0f, 0f);
			module.requiresBattery = false;
			Debug.Log((object)"[EnkephalinModule] Item erstellt, gehe zu RegisterScrap...");
			Utilities.FixMixerGroups(module.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(module.spawnPrefab);
			Items.RegisterScrap(module, rarity, (LevelTypes)(-1));
			Debug.Log((object)"[EnkephalinModule] erfolgreich registriert!");
		}
	}
}