Decompiled source of Enkephalin v0.0.2

Enkephalin.lethal.dll

Decompiled 2 months 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 GameNetcodeStuff;
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);
			EnkephalinCan.Register(enkephalin);
			EnkephalinModule.Register(enkephalin);
		}

		private AssetBundle LoadBundle(string fileName)
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			return AssetBundle.LoadFromFile(Path.Combine(directoryName, fileName));
		}

		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.scrapValue > 0)
			{
				base.isBeingUsed = true;
				PlayerControllerB playerHeldBy = base.playerHeldBy;
				playerHeldBy.sprintMeter = 1f;
				playerHeldBy.drunkness += 0.9f;
				base.isBeingUsed = false;
				playerHeldBy.DespawnHeldObject();
			}
		}
	}
	public class StackOnLook : MonoBehaviour
	{
	}
	internal class EnkephalinBox
	{
		private static readonly int rarity = 10;

		public static void Register(AssetBundle bundle)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[EnkephalinBox] Register gestartet");
			Item val = bundle.LoadAsset<Item>("assets/items/enkephalin_box/enkephalin_box_item.asset");
			val.verticalOffset = 0.55f;
			val.restingRotation = new Vector3(-90f, 0f, 0f);
			val.positionOffset = new Vector3(-0.5f, 0f, 0f);
			val.rotationOffset = new Vector3(-90f, 0f, 0f);
			val.requiresBattery = false;
			val.allowDroppingAheadOfPlayer = true;
			Debug.Log((object)"[EnkephalinBox] Item erstellt, gehe zu RegisterScrap...");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, rarity, (LevelTypes)(-1));
			Debug.Log((object)"[EnkephalinBox] erfolgreich registriert!");
		}
	}
	internal class EnkephalinCan
	{
		private static readonly int rarity = 30;

		public static void Register(AssetBundle bundle)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			Item val = bundle.LoadAsset<Item>("assets/items/enkephalin_can/enkephalin_can_item.asset");
			EnkephalinCanItem enkephalinCanItem = val.spawnPrefab.AddComponent<EnkephalinCanItem>();
			((GrabbableObject)enkephalinCanItem).grabbable = true;
			((GrabbableObject)enkephalinCanItem).grabbableToEnemies = true;
			((GrabbableObject)enkephalinCanItem).isInFactory = true;
			((GrabbableObject)enkephalinCanItem).itemProperties = val;
			val.restingRotation = new Vector3(90f, -90f, 90f);
			val.rotationOffset = new Vector3(0f, 90f, 0f);
			val.verticalOffset = 0.25f;
			val.requiresBattery = false;
			val.holdButtonUse = true;
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, rarity, (LevelTypes)(-1));
		}
	}
	internal class EnkephalinModule
	{
		private static readonly int rarity = 20;

		public static void Register(AssetBundle bundle)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[EnkephalinBox] Register gestartet");
			Item val = bundle.LoadAsset<Item>("assets/items/enkephalin_module/enkephalin_module_item.asset");
			val.verticalOffset = 0.175f;
			val.restingRotation = new Vector3(-90f, 0f, 0f);
			val.requiresBattery = false;
			Debug.Log((object)"[EnkephalinModule] Item erstellt, gehe zu RegisterScrap...");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, rarity, (LevelTypes)(-1));
			Debug.Log((object)"[EnkephalinModule] erfolgreich registriert!");
		}
	}
}