Decompiled source of MelodicBeamScrap v1.1.2

MelodicBeamScrap.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MelodicBeamScrap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("MelodicBeamScrap")]
[assembly: AssemblyCopyright("Copyright © HP 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d9c83d4c-a20c-49fb-a24e-9f7faf17a018")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MelodicBeamScrap;

[BepInPlugin("MelodicBeam.MelodicBeamScrap", "MelodicBeamScrap", "1.1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MelodicBeamScrap : BaseUnityPlugin
{
	private const string modGUID = "MelodicBeam.MelodicBeamScrap";

	private const string modName = "MelodicBeamScrap";

	private const string modVersion = "1.1.0.0";

	public static MelodicBeamScrap instance;

	internal ManualLogSource mls;

	internal static ModConfig config { get; private set; }

	private void Awake()
	{
		instance = this;
		config = new ModConfig(((BaseUnityPlugin)this).Config);
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melodicbeamscrap");
		AssetBundle val = AssetBundle.LoadFromFile(text);
		Item val2 = val.LoadAsset<Item>("Assets/Scrap/MelodicBeam/MelodicBeamItem.asset");
		string text2 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "twilightsparkle");
		AssetBundle val3 = AssetBundle.LoadFromFile(text2);
		Item val4 = val3.LoadAsset<Item>("Assets/Scrap/Twilight/TwilightSparkleItem.asset");
		string text3 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "garfield");
		AssetBundle val5 = AssetBundle.LoadFromFile(text3);
		Item val6 = val5.LoadAsset<Item>("Assets/Scrap/Garfield/GarfieldItem.asset");
		string text4 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "starlightglimmer");
		AssetBundle val7 = AssetBundle.LoadFromFile(text4);
		Item val8 = val7.LoadAsset<Item>("Assets/Scrap/Starlight/StarlightGlimmerItem.asset");
		string text5 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "trixie");
		AssetBundle val9 = AssetBundle.LoadFromFile(text5);
		Item val10 = val9.LoadAsset<Item>("Assets/Scrap/Trixie/TrixieItem.asset");
		string text6 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "rainbowdash");
		AssetBundle val11 = AssetBundle.LoadFromFile(text6);
		Item val12 = val11.LoadAsset<Item>("Assets/Scrap/RainbowDash/RainbowDashItem.asset");
		string text7 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sunset");
		AssetBundle val13 = AssetBundle.LoadFromFile(text7);
		Item val14 = val13.LoadAsset<Item>("Assets/Scrap/Sunset/Sunset.asset");
		string text8 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sombreroanon");
		AssetBundle val15 = AssetBundle.LoadFromFile(text8);
		Item val16 = val15.LoadAsset<Item>("Assets/Scrap/SombreroAnon/SombreroAnonFillyItem.asset");
		string text9 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "keyboard");
		AssetBundle val17 = AssetBundle.LoadFromFile(text9);
		Item val18 = val17.LoadAsset<Item>("Assets/Scrap/Loud Keyboard/KeyboardItem.asset");
		string text10 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "birthdayanon");
		AssetBundle val19 = AssetBundle.LoadFromFile(text10);
		Item val20 = val19.LoadAsset<Item>("Assets/Scrap/BirthdayAnon/BirthdayAnonFillyItem.asset");
		NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
		Utilities.FixMixerGroups(val2.spawnPrefab);
		Items.RegisterScrap(val2, config.MelodicSpawnWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
		Utilities.FixMixerGroups(val4.spawnPrefab);
		Items.RegisterScrap(val4, config.TwilightSpawnWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
		Utilities.FixMixerGroups(val6.spawnPrefab);
		Items.RegisterScrap(val6, config.GarfieldSpawnWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val8.spawnPrefab);
		Utilities.FixMixerGroups(val8.spawnPrefab);
		Items.RegisterScrap(val8, config.StarlightWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val10.spawnPrefab);
		Utilities.FixMixerGroups(val10.spawnPrefab);
		Items.RegisterScrap(val10, config.TrixieWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val12.spawnPrefab);
		Utilities.FixMixerGroups(val12.spawnPrefab);
		Items.RegisterScrap(val12, config.RainbowWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val14.spawnPrefab);
		Utilities.FixMixerGroups(val14.spawnPrefab);
		Items.RegisterScrap(val14, config.SunsetWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val16.spawnPrefab);
		Utilities.FixMixerGroups(val16.spawnPrefab);
		Items.RegisterScrap(val16, config.SombreroAnonWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val18.spawnPrefab);
		Utilities.FixMixerGroups(val18.spawnPrefab);
		Items.RegisterScrap(val18, config.KeyboardWeight.Value, (LevelTypes)(-1));
		NetworkPrefabs.RegisterNetworkPrefab(val20.spawnPrefab);
		Utilities.FixMixerGroups(val20.spawnPrefab);
		Items.RegisterScrap(val20, config.BirthdayAnonWeight.Value, (LevelTypes)(-1));
		mls = Logger.CreateLogSource("MelodicBeam.MelodicBeamScrap");
		mls.LogInfo((object)"Melodic Beam Scrap has awaken");
	}
}
internal class ModConfig
{
	public readonly ConfigEntry<int> MelodicSpawnWeight;

	public readonly ConfigEntry<int> TwilightSpawnWeight;

	public readonly ConfigEntry<int> GarfieldSpawnWeight;

	public readonly ConfigEntry<int> StarlightWeight;

	public readonly ConfigEntry<int> TrixieWeight;

	public readonly ConfigEntry<int> RainbowWeight;

	public readonly ConfigEntry<int> SunsetWeight;

	public readonly ConfigEntry<int> SombreroAnonWeight;

	public readonly ConfigEntry<int> KeyboardWeight;

	public readonly ConfigEntry<int> BirthdayAnonWeight;

	public ModConfig(ConfigFile cfg)
	{
		cfg.SaveOnConfigSet = false;
		MelodicSpawnWeight = cfg.Bind<int>("Spawn Weight", "Melodic Scrap", 50, (ConfigDescription)null);
		TwilightSpawnWeight = cfg.Bind<int>("Spawn Weight", "Twilight Scrap", 50, (ConfigDescription)null);
		GarfieldSpawnWeight = cfg.Bind<int>("Spawn Weight", "Garfield Scrap", 50, (ConfigDescription)null);
		StarlightWeight = cfg.Bind<int>("Spawn Weight", "Starlight Scrap", 50, (ConfigDescription)null);
		TrixieWeight = cfg.Bind<int>("Spawn Weight", "Trixie Scrap", 50, (ConfigDescription)null);
		RainbowWeight = cfg.Bind<int>("Spawn Weight", "Rainbow Scrap", 50, (ConfigDescription)null);
		SunsetWeight = cfg.Bind<int>("Spawn Weight", "Sunset Scrap", 50, (ConfigDescription)null);
		SombreroAnonWeight = cfg.Bind<int>("Spawn Weight", "Sombrero Anon Scrap", 50, (ConfigDescription)null);
		KeyboardWeight = cfg.Bind<int>("Spawn Weight", "Keyboard Scrap", 50, (ConfigDescription)null);
		BirthdayAnonWeight = cfg.Bind<int>("Spawn Weight", "Birthday Anon Scrap", 50, (ConfigDescription)null);
		ClearOrphanedEntries(cfg);
		cfg.Save();
		cfg.SaveOnConfigSet = true;
	}

	private static void ClearOrphanedEntries(ConfigFile cfg)
	{
		PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
		Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
		dictionary.Clear();
	}
}