Decompiled source of TVRandomizer v1.0.1

TVRandomizer.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using HarmonyLib;
using TVLoader.Utils;
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("TVRandomizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TVRandomizer")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("01e7e591-f179-4a16-868a-c970a0fbbb0c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TVRandomizer;

[BepInPlugin("ironbean.TVRandomizer", "TV Randomizer", "1.0.1")]
public class TVRandomizerMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(DungeonGenerator))]
	internal class DungeonPatch
	{
		[HarmonyPatch("Generate")]
		[HarmonyPostfix]
		public static void SetTVSeed(ref int ___Seed)
		{
			mls.LogInfo((object)("Setting TV seed to: " + ___Seed));
			rand = new Random(___Seed);
			VideoManager.Videos.Sort();
			int num = VideoManager.Videos.Count;
			while (num > 1)
			{
				num--;
				int index = rand.Next(num + 1);
				string value = VideoManager.Videos[index];
				VideoManager.Videos[index] = VideoManager.Videos[num];
				VideoManager.Videos[num] = value;
			}
		}
	}

	private const string modGUID = "ironbean.TVRandomizer";

	private const string modName = "TV Randomizer";

	private const string modVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("ironbean.TVRandomizer");

	private static TVRandomizerMod Instance;

	internal static ManualLogSource mls;

	private static Random rand = new Random();

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("ironbean.TVRandomizer");
		mls.LogInfo((object)"TV Randomizer loaded.");
		harmony.PatchAll(typeof(TVRandomizerMod));
		harmony.PatchAll(typeof(DungeonPatch));
	}
}