Decompiled source of CustomBackground v0.0.1

CustomBackground.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameEvent;
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("CustomBackground")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomBackground")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("69d1e4b1-8c60-481b-893f-fbdc33dcf645")]
[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 CustomBackground;

[BepInPlugin("CBG", "CustomBackground", "0.0.1")]
public class CustomBackgroundPlugin : BaseUnityPlugin
{
	private const string modGUID = "CBG";

	private const string modName = "CustomBackground";

	private const string modVersion = "0.0.1";

	public static CustomBackgroundPlugin Instance;

	public ConfigEntry<BackgroundType> backgroundSetting;

	private void Awake()
	{
		Instance = this;
		backgroundSetting = ((BaseUnityPlugin)this).Config.Bind<BackgroundType>("Custom Background", "Selected Background", (BackgroundType)11, "Select the custom background.");
		GameEventManager.ChangeListener<GameStartEvent>((IGameEventListener)(object)new GameStartListener(), true);
	}
}
public class GameStartListener : IGameEventListener
{
	public void handleEvent(GameEvent e)
	{
		((MonoBehaviour)CustomBackgroundPlugin.Instance).StartCoroutine(waitForLevel());
	}

	private IEnumerator waitForLevel()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<Level>() != (Object)null));
		Level level = Object.FindObjectOfType<Level>();
		if ((Object)(object)level == (Object)null)
		{
			Debug.LogWarning((object)"Level became null after WaitUntil resolved!");
			yield break;
		}
		if (BackgroundLibrary.Instance.Backgrounds == null || BackgroundLibrary.Instance.Backgrounds.Count() == 0)
		{
			yield return null;
		}
		BackgroundType bg = CustomBackgroundPlugin.Instance.backgroundSetting.Value;
		level.SetBackground(bg);
		yield return null;
	}
}