Decompiled source of Lethal RE v0.3.0

LethalRE.dll

Decompiled 3 months ago
using System;
using System.Collections;
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 HarmonyLib;
using LethalLib.Modules;
using LethalRE.source.ItemBehaviors;
using Microsoft.CodeAnalysis;
using ModelReplacement;
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("LethalRE")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalRE")]
[assembly: AssemblyTitle("LethalRE")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 LethalRE.source
{
	public static class Assets
	{
		public static AssetBundle SuitsBundle;

		public static AssetBundle ScrapsBundle;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
		}

		internal static void Populate()
		{
			if ((Object)(object)SuitsBundle == (Object)null || (Object)(object)ScrapsBundle == (Object)null)
			{
				string assemblyName = GetAssemblyName();
				Console.WriteLine(assemblyName + ".scraps");
				ScrapsBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyName + ".scraps"));
				Console.WriteLine(assemblyName + ".suits");
				SuitsBundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyName + ".suits"));
			}
		}
	}
	public class MRSULAYRE_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "sulayre_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRRENIACHII_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "reniachii_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRPEDROK_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "pedrok_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRLOCOS_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "locoscorpion_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRNANIUK_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "naniuk_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRJULIAN_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "julian_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRJFELIX_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "jfelix_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	public class MRBLABACK_ROBLOX : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "blaback_roblox";
			return Assets.SuitsBundle.LoadAsset<GameObject>(text);
		}
	}
	[BepInPlugin("sulayre.lethalre", "LethalRE", "0.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static bool load_suits = true;

		public static bool load_scrap = true;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			Assets.Populate();
			if (load_scrap)
			{
				Scraps.onPopulate();
			}
			if (load_suits)
			{
				Suits.onPopulate();
			}
			Harmony val = new Harmony("com.sulayre.lethalre");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.sulayre.lethalre is loaded!");
		}
	}
	public static class Scraps
	{
		public static List<(string, int)> scrapList = new List<(string, int)>
		{
			("BigHeadItem", 15),
			("BiggerHeadItem", 15),
			("BearItem", 10),
			("GiverItem", 10),
			("MilleniumFalconItem", 15),
			("SillyGuitarItem", 10),
			("RageTableItem", 15),
			("TrussItem", 15),
			("WitchesBrewItem", 15),
			("VehicleItem", 10),
			("BanHammerItem", 15),
			("ReStageItem", 10),
			("BuildersClubItem", 40),
			("ClassicFedoraItem", 20),
			("ClockworkHeadphonesItem", 20),
			("DominoCrownItem", 20),
			("DominusEmpyreusItem", 20),
			("PompeiianEggItem", 40),
			("PumpkinHeadItem", 15),
			("SkullItem", 40),
			("TelamonItem", 20),
			("TopHatItem", 20),
			("TrollFaicItem", 40),
			("TvHeadItem", 15),
			("ValkyrieItem", 40),
			("BeansCanItem", 40),
			("BloxiadeItem", 40),
			("BloxyColaItem", 30),
			("BombItem", 40),
			("CheeseburgerItem", 30),
			("ChickenLegItem", 30),
			("ChocolateMilkshakeItem", 30),
			("GravityCoilItem", 25),
			("SpeedCoilItem", 25),
			("DancePotionItem", 40),
			("DecoyDeployItem", 20),
			("EpicDuckItem", 35),
			("EpicSauceItem", 40),
			("DeleteHammerItem", 40),
			("MMKnifeItem", 40),
			("LinkedSwordItem", 30),
			("RocketLauncherItem", 40),
			("SlingshotItem", 40),
			("TacoItem", 30),
			("SubspaceTripmineItem", 20),
			("TrowelItem", 40)
		};

		public static void onPopulate()
		{
			Debug.Log((object)"LethalRE is loading scrap :)");
			foreach (var (text, num) in scrapList)
			{
				Console.WriteLine("Attempting to load Assets/Scrap/" + text + ".asset");
				Item val = Assets.ScrapsBundle.LoadAsset<Item>("Assets/Scrap/" + text + ".asset");
				ScrapBehaviors(text, val);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Utilities.FixMixerGroups(val.spawnPrefab);
				Items.RegisterScrap(val, num, (LevelTypes)(-1));
				Console.WriteLine($"Loaded scrap {text} with weight of {num}");
			}
		}

		private static void ScrapBehaviors(string id, Item item)
		{
			//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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			PhysicsProp val = null;
			string text = id.Replace("Item", "");
			string text2 = text;
			if (text2 == "BloxyCola")
			{
				Debug.Log((object)(id + " detected! inserting custom behavior"));
				DrinkableItem drinkableItem = item.spawnPrefab.AddComponent<DrinkableItem>();
				drinkableItem.DrinkSfx = Assets.ScrapsBundle.LoadAsset<AudioClip>("Assets/Scrap/sfx/coladrink.ogg");
				drinkableItem.DrinkRotationOffset = new Vector3(45f, 180f, 0f);
				drinkableItem.DrinkPositionOffset = new Vector3(0f, -0.33f, 0.4f);
				val = (PhysicsProp)(object)drinkableItem;
			}
			if ((Object)(object)val != (Object)null)
			{
				((GrabbableObject)val).grabbable = true;
				((GrabbableObject)val).grabbableToEnemies = true;
				((GrabbableObject)val).itemProperties = item;
			}
		}
	}
	public static class Suits
	{
		public static void onPopulate()
		{
			Debug.Log((object)"LethalRE is loading suits :)");
			ModelReplacementAPI.RegisterSuitModelReplacement("Sulayre", typeof(MRSULAYRE_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("Reniachii", typeof(MRRENIACHII_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("Pedrok", typeof(MRPEDROK_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("locoscorpion", typeof(MRLOCOS_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("Mr_Jose84", typeof(MRJFELIX_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("Naniukts", typeof(MRNANIUK_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("julianjulian10", typeof(MRJULIAN_ROBLOX));
			ModelReplacementAPI.RegisterSuitModelReplacement("Blaback2254", typeof(MRBLABACK_ROBLOX));
		}
	}
}
namespace LethalRE.source.ItemBehaviors
{
	internal class DrinkableItem : PhysicsProp
	{
		private bool debounce;

		public AudioClip? DrinkSfx = null;

		public float DrinkCooldown = 2f;

		public Vector3 DrinkPositionOffset;

		public Vector3 DrinkRotationOffset;

		private Vector3 _originalPosition;

		private Quaternion _originalRotation;

		private GameObject? _model;

		private AudioSource? _audioSource;

		public override void OnNetworkSpawn()
		{
			//IL_0031: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnNetworkSpawn();
			_model = ((Component)((Component)this).GetComponentInChildren<MeshRenderer>()).gameObject;
			_audioSource = ((Component)this).GetComponent<AudioSource>();
			_originalPosition = _model.transform.localPosition;
			_originalRotation = _model.transform.localRotation;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				if (!Object.op_Implicit((Object)(object)((GrabbableObject)this).playerHeldBy))
				{
					Debug.Log((object)"Item being drunk with no player assigned?");
				}
				else if (!debounce)
				{
					((MonoBehaviour)this).StartCoroutine(DrinkingTimer());
				}
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if (debounce)
			{
				DrinkAnimation(active: false);
				debounce = false;
				_audioSource.Stop();
				((MonoBehaviour)this).StopCoroutine(DrinkingTimer());
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			if (debounce)
			{
				DrinkAnimation(active: false);
				debounce = false;
				_audioSource.Stop();
				((MonoBehaviour)this).StopCoroutine(DrinkingTimer());
			}
		}

		private void DrinkAnimation(bool active)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (_model == null)
			{
				Debug.LogWarning((object)"model not set, no animation will play.");
			}
			else if (active)
			{
				if (((GrabbableObject)this).playerHeldBy == null)
				{
					Debug.LogWarning((object)"player not found, no animation will play.");
					return;
				}
				_model.transform.parent = ((Component)((GrabbableObject)this).playerHeldBy).transform.Find("PlayerEye");
				_model.transform.localPosition = DrinkPositionOffset;
				_model.transform.localRotation = Quaternion.Euler(DrinkRotationOffset);
			}
			else
			{
				_model.transform.parent = ((Component)this).gameObject.transform;
				_model.transform.localPosition = _originalPosition;
				_model.transform.localRotation = _originalRotation;
			}
		}

		private IEnumerator DrinkingTimer()
		{
			if ((Object)(object)DrinkSfx == (Object)null)
			{
				Debug.LogError((object)"Drink SFX not set, killing iteration.");
				yield break;
			}
			if ((Object)(object)_audioSource == (Object)null)
			{
				Debug.LogError((object)"Audio Source not found, killing iteration");
				yield break;
			}
			debounce = true;
			Debug.Log((object)"attempting to drink");
			_audioSource.clip = DrinkSfx;
			_audioSource.Play();
			DrinkAnimation(active: true);
			yield return (object)new WaitForSeconds(DrinkCooldown);
			DrinkAnimation(active: false);
			Debug.Log((object)(((Object)((GrabbableObject)this).playerHeldBy).name + " finished drinking."));
			debounce = false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}