Decompiled source of Larsielols Lethal Items v0.1.3

larsielol.larsielols_Lethal_Items.dll

Decompiled 10 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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 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("larsielol.larsielols_Lethal_Items")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("larsielol's Lethal Items")]
[assembly: AssemblyTitle("larsielol.larsielols_Lethal_Items")]
[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 System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace Lars_Lethal_Items
{
	internal class DamagingItem : LarsielolItemBase
	{
		private float _timer = 0f;

		public override void Update()
		{
			((GrabbableObject)this).Update();
			TryToDamage();
		}

		protected void TryToDamage()
		{
			//IL_0055: 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)
			if (!base.IsHeldByPlayer)
			{
				_timer = 0f;
				return;
			}
			_timer += Time.deltaTime;
			if (!(_timer < 1f))
			{
				base.PlayerHeldBy.DamagePlayer((int)_timer, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				_timer %= 1f;
			}
		}
	}
	internal class HealingItem : LarsielolItemBase
	{
		private float _timer = 0f;

		public override void Update()
		{
			((GrabbableObject)this).Update();
			TryApplyHealing();
		}

		protected void TryApplyHealing()
		{
			if (!base.IsHeldByPlayer)
			{
				_timer = 0f;
				return;
			}
			_timer += Time.deltaTime;
			if (!(_timer < 2f) && (float)((GrabbableObject)this).playerHeldBy.health != 100f)
			{
				if ((int)_timer + ((GrabbableObject)this).playerHeldBy.health > 100)
				{
					((GrabbableObject)this).playerHeldBy.health = 100;
				}
				else
				{
					PlayerControllerB? playerHeldBy = base.PlayerHeldBy;
					playerHeldBy.health += (int)(0.5 * (double)_timer);
				}
				if (((GrabbableObject)this).playerHeldBy.health >= 20)
				{
					((GrabbableObject)this).playerHeldBy.MakeCriticallyInjured(false);
				}
				_timer %= 2f;
			}
		}
	}
	internal abstract class LarsielolItemBase : GrabbableObject
	{
		protected PlayerControllerB? PlayerHeldBy => base.playerHeldBy;

		[MemberNotNullWhen(true, "PlayerHeldBy")]
		protected bool IsHeldByPlayer
		{
			[MemberNotNullWhen(true, "PlayerHeldBy")]
			get
			{
				if (!base.isHeld)
				{
					return false;
				}
				if (base.isHeldByEnemy)
				{
					return false;
				}
				if ((Object)(object)PlayerHeldBy == (Object)null)
				{
					return false;
				}
				return true;
			}
		}
	}
	internal class moneydrop : GrabbableObject
	{
		public override void Start()
		{
		}
	}
	internal class PiggyBank : LarsielolItemBase
	{
		private bool hasUsedGift;

		public AudioSource player;

		public AudioClip sfx;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (base.IsHeldByPlayer && !hasUsedGift)
			{
				player.PlayOneShot(sfx);
				hasUsedGift = true;
				int num = (((GrabbableObject)this).scrapValue - 10) * 2;
				Terminal obj = Object.FindObjectOfType<Terminal>();
				obj.groupCredits += num;
				((GrabbableObject)this).SetScrapValue(10);
				HUDManager.Instance.DisplayTip("Notice", $"You took the money out of the piggy bank and earned ${num}", false, false, "LC_Tip1");
			}
		}
	}
	[BepInPlugin("larsielol.Lars_Lethal_Items", "Lars' Lethal Items", "0.1.3")]
	public class lars_lethal_items : BaseUnityPlugin
	{
		private interface IContentInitializer
		{
			string Name { get; }

			void Initialize(AssetBundle bundle);
		}

		private class FirstItemInitializer : IContentInitializer
		{
			private static FirstItemInitializer? _instance;

			public static FirstItemInitializer Instance => _instance ?? (_instance = new FirstItemInitializer());

			public string Name => "First item";

			public void Initialize(AssetBundle bundle)
			{
				Item val = bundle.LoadAsset<Item>("Assets/Traffic Cone/Traffic Cone.asset");
				if ((Object)(object)val == (Object)null)
				{
					throw new InvalidOperationException("The Traffic Cone asset could not be loaded, value is null");
				}
				Utilities.FixMixerGroups(val.spawnPrefab);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, 60, (LevelTypes)4);
				Items.RegisterScrap(val, 40, (LevelTypes)8);
				Items.RegisterScrap(val, 35, (LevelTypes)16);
				Items.RegisterScrap(val, 22, (LevelTypes)32);
				Items.RegisterScrap(val, 22, (LevelTypes)64);
				Items.RegisterScrap(val, 12, (LevelTypes)128);
				Items.RegisterScrap(val, 12, (LevelTypes)256);
				Items.RegisterScrap(val, 11, (LevelTypes)512);
			}
		}

		private class SecondItemInitializer : IContentInitializer
		{
			private static SecondItemInitializer? _instance;

			public static SecondItemInitializer Instance => _instance ?? (_instance = new SecondItemInitializer());

			public string Name => "Second item";

			public void Initialize(AssetBundle bundle)
			{
				Item val = bundle.LoadAsset<Item>("Assets/Boat/boat.asset");
				if ((Object)(object)val == (Object)null)
				{
					throw new InvalidOperationException("The Mini Boat asset could not be loaded, value is null");
				}
				Utilities.FixMixerGroups(val.spawnPrefab);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, 50, (LevelTypes)4);
				Items.RegisterScrap(val, 40, (LevelTypes)8);
				Items.RegisterScrap(val, 30, (LevelTypes)16);
				Items.RegisterScrap(val, 35, (LevelTypes)32);
				Items.RegisterScrap(val, 35, (LevelTypes)64);
				Items.RegisterScrap(val, 20, (LevelTypes)128);
				Items.RegisterScrap(val, 20, (LevelTypes)256);
				Items.RegisterScrap(val, 20, (LevelTypes)512);
			}
		}

		private class ThirdItemInitializer : IContentInitializer
		{
			private static ThirdItemInitializer? _instance;

			public static ThirdItemInitializer Instance => _instance ?? (_instance = new ThirdItemInitializer());

			public string Name => "Third item";

			public void Initialize(AssetBundle bundle)
			{
				Item val = bundle.LoadAsset<Item>("Assets/Angel Figure/Angel Figurine.asset");
				if ((Object)(object)val == (Object)null)
				{
					throw new InvalidOperationException("The Angel Figurine could not be loaded, value is null");
				}
				Utilities.FixMixerGroups(val.spawnPrefab);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, 5, (LevelTypes)4);
				Items.RegisterScrap(val, 5, (LevelTypes)8);
				Items.RegisterScrap(val, 5, (LevelTypes)16);
				Items.RegisterScrap(val, 5, (LevelTypes)32);
				Items.RegisterScrap(val, 5, (LevelTypes)64);
				Items.RegisterScrap(val, 9, (LevelTypes)128);
				Items.RegisterScrap(val, 11, (LevelTypes)256);
				Items.RegisterScrap(val, 11, (LevelTypes)512);
			}
		}

		private class FourthItemInitializer : IContentInitializer
		{
			private static FourthItemInitializer? _instance;

			public static FourthItemInitializer Instance => _instance ?? (_instance = new FourthItemInitializer());

			public string Name => "Fourth item";

			public void Initialize(AssetBundle bundle)
			{
				Item val = bundle.LoadAsset<Item>("Assets/Devil Figure/Devil Figurine.asset");
				if ((Object)(object)val == (Object)null)
				{
					throw new InvalidOperationException("The Devil Figurine asset could not be loaded, value is null");
				}
				Utilities.FixMixerGroups(val.spawnPrefab);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, 5, (LevelTypes)4);
				Items.RegisterScrap(val, 5, (LevelTypes)8);
				Items.RegisterScrap(val, 5, (LevelTypes)16);
				Items.RegisterScrap(val, 5, (LevelTypes)32);
				Items.RegisterScrap(val, 5, (LevelTypes)64);
				Items.RegisterScrap(val, 9, (LevelTypes)128);
				Items.RegisterScrap(val, 11, (LevelTypes)256);
				Items.RegisterScrap(val, 11, (LevelTypes)512);
			}
		}

		private class FifthItemInitializer : IContentInitializer
		{
			private static FifthItemInitializer? _instance;

			public static FifthItemInitializer Instance => _instance ?? (_instance = new FifthItemInitializer());

			public string Name => "Fifth item";

			public void Initialize(AssetBundle bundle)
			{
				Item val = bundle.LoadAsset<Item>("Assets/Piggy Bank/Piggy Bank.asset");
				if ((Object)(object)val == (Object)null)
				{
					throw new InvalidOperationException("The Piggy Bank asset could not be loaded, value is null");
				}
				Utilities.FixMixerGroups(val.spawnPrefab);
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, 10, (LevelTypes)4);
				Items.RegisterScrap(val, 10, (LevelTypes)8);
				Items.RegisterScrap(val, 15, (LevelTypes)16);
				Items.RegisterScrap(val, 15, (LevelTypes)32);
				Items.RegisterScrap(val, 15, (LevelTypes)64);
				Items.RegisterScrap(val, 20, (LevelTypes)128);
				Items.RegisterScrap(val, 20, (LevelTypes)256);
				Items.RegisterScrap(val, 20, (LevelTypes)512);
			}
		}

		private const string modGUID = "larsielol.Lars_Lethal_Items";

		private const string modName = "Lars' Lethal Items";

		private const string ModVersion = "0.1.3";

		private readonly Harmony harmony = new Harmony("larsielol.Lars_Lethal_Items");

		public static lars_lethal_items? Instance;

		public ManualLogSource? mls;

		public void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("larsielol.Lars_Lethal_Items");
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "LethalItems");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("The Assets for the mod could not be found");
			}
			IContentInitializer[] array = new IContentInitializer[5]
			{
				FirstItemInitializer.Instance,
				SecondItemInitializer.Instance,
				ThirdItemInitializer.Instance,
				FourthItemInitializer.Instance,
				FifthItemInitializer.Instance
			};
			IContentInitializer[] array2 = array;
			foreach (IContentInitializer contentInitializer in array2)
			{
				try
				{
					((BaseUnityPlugin)this).Logger.LogDebug((object)("Trying to load " + contentInitializer.Name));
					contentInitializer.Initialize(val);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded " + contentInitializer.Name));
				}
				catch (Exception arg)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)$"Failed to load {contentInitializer.Name}:\n{arg}");
				}
			}
			val.Unload(false);
			mls.LogInfo((object)"Larsielols Lethal Items has loaded");
			harmony.PatchAll(typeof(lars_lethal_items));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "larsielol.larsielols_Lethal_Items";

		public const string PLUGIN_NAME = "larsielol's Lethal Items";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}