Decompiled source of AntiScrapMod v1.2.0

BepInEx/plugins/com.studiocanigou.AntiScrapMod.dll

Decompiled 4 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using LobbyCompatibility.Attributes;
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("com.studiocanigou.AntiScrapMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AntiScrapMod")]
[assembly: AssemblyTitle("com.studiocanigou.AntiScrapMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 AntiScrapMod
{
	public static class ConfigSettings
	{
		public static ConfigEntry<int>? AngeleRarity;

		public static ConfigEntry<int>? MandyRarity;

		public static ConfigEntry<int>? BatteRarity;

		public static ConfigEntry<int>? Jojo_SiwaRarity;

		public static ConfigEntry<int>? ToastRarity;

		public static ConfigEntry<int>? ChampagneRarity;

		public static ConfigEntry<int>? PimsRarity;

		public static ConfigEntry<int>? PoudrierRarity;

		public static ConfigEntry<int>? RiverRarity;

		public static void BindConfigSettings()
		{
			AngeleRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "AngeleRarity", 20, "How rare is the Angele scrap - 100 is very common , 1 is very rare.");
			MandyRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "MandyRarity", 20, "How rare is the Mandy scrap - 100 is very common , 1 is very rare.");
			BatteRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "BatteRarity", 20, "How rare is the Batte scrap - 100 is very common , 1 is very rare.");
			Jojo_SiwaRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "Jojo_SiwaRarity", 20, "How rare is the Jojo Siwa scrap - 100 is very common , 1 is very rare.");
			ToastRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "ToastRarity", 20, "How rare is the Toast scrap - 100 is very common , 1 is very rare.");
			ChampagneRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "ChampagneRarity", 10, "How rare is the Champagne scrap - 100 is very common , 1 is very rare.");
			PimsRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "PimsRarity", 20, "How rare is the Pims scrap - 100 is very common , 1 is very rare.");
			PoudrierRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "PoudrierRarity", 5, "How rare is the Poudrier scrap - 100 is very common , 1 is very rare.");
			RiverRarity = ((BaseUnityPlugin)AntiScrapMod.Instance).Config.Bind<int>("AntiScrapMod", "RiverRarity", 20, "How rare is the River scrap - 100 is very common , 1 is very rare.");
		}
	}
	[BepInPlugin("com.studiocanigou.AntiScrapMod", "AntiScrapMod", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class AntiScrapMod : BaseUnityPlugin
	{
		public static AntiScrapMod Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		internal static AssetBundle bundle { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			ConfigSettings.BindConfigSettings();
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ultia");
			bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)bundle == (Object)null)
			{
				Logger.LogInfo((object)"bundle is null");
			}
			else
			{
				if (ConfigSettings.AngeleRarity != null)
				{
					CreateScrap("Ultia/Angele", ConfigSettings.AngeleRarity);
				}
				if (ConfigSettings.MandyRarity != null)
				{
					CreateScrap("Ultia/Mandy", ConfigSettings.MandyRarity);
				}
				if (ConfigSettings.RiverRarity != null)
				{
					CreateScrap("Ultia/River", ConfigSettings.RiverRarity);
				}
				if (ConfigSettings.Jojo_SiwaRarity != null)
				{
					CreateScrap("Ultia/Jojo_Siwa", ConfigSettings.Jojo_SiwaRarity);
				}
				if (ConfigSettings.ToastRarity != null)
				{
					CreateScrap("Ultia/Toast", ConfigSettings.ToastRarity);
				}
				if (ConfigSettings.ChampagneRarity != null)
				{
					CreateScrap("Ultia/RatusChampagne", ConfigSettings.ChampagneRarity);
				}
				if (ConfigSettings.PimsRarity != null)
				{
					CreateScrap("Ultia/Pims", ConfigSettings.PimsRarity);
				}
				if (ConfigSettings.BatteRarity != null)
				{
					CreateBuyableScrap("Ultia/Batte", ConfigSettings.BatteRarity, 30);
				}
				if (ConfigSettings.PoudrierRarity != null)
				{
					CreateBuyableScrap("Ultia/Poudrier", ConfigSettings.PoudrierRarity, 12);
				}
			}
			Logger.LogInfo((object)"com.studiocanigou.AntiScrapMod v1.0.0 has loaded!");
		}

		private void CreateScrap(string path, ConfigEntry<int> configEntry)
		{
			Item val = bundle.LoadAsset<Item>("Assets/Scraps/" + path + ".asset");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogInfo((object)("item is null : Assets/Scraps/" + path + ".asset"));
				return;
			}
			Logger.LogInfo((object)("Creating item " + path));
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			Items.RegisterScrap(val, configEntry.Value, (LevelTypes)(-1));
		}

		private void CreateBuyableScrap(string path, ConfigEntry<int> configEntry, int price = 10)
		{
			Item val = bundle.LoadAsset<Item>("Assets/Scraps/" + path + ".asset");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogInfo((object)("item is null : Assets/Scraps/" + path + ".asset"));
			}
			else
			{
				Logger.LogInfo((object)("Creating item " + path));
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Utilities.FixMixerGroups(val.spawnPrefab);
				Items.RegisterScrap(val, configEntry.Value, (LevelTypes)(-1));
			}
			TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
			val2.clearPreviousText = true;
			val2.displayText = "Slay \n\n";
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, price);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.studiocanigou.AntiScrapMod";

		public const string PLUGIN_NAME = "AntiScrapMod";

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