Decompiled source of CoomfyDungeon v1.0.12

BepInEx/plugins/CoomfyDungeon.dll

Decompiled 11 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using HarmonyLib;
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 = "")]
[assembly: AssemblyCompany("CoomfyDungeon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A Different Dungeon Generation for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.11.0")]
[assembly: AssemblyInformationalVersion("1.0.11")]
[assembly: AssemblyProduct("CoomfyDungeon")]
[assembly: AssemblyTitle("CoomfyDungeon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.11.0")]
[module: UnverifiableCode]
namespace LCCoomfyny;

[BepInPlugin("CoomfyDungeon", "CoomfyDungeon", "1.0.11")]
internal class Coomfy : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	private void Awake()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CoomfyDungeon 1.0.11 is loaded!");
		Log = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("CoomfyDungeon");
		val.PatchAll(Assembly.GetExecutingAssembly());
		((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"LCCoomfyny Company loaded!");
	}
}
[HarmonyPatch]
internal class DungeonExtender
{
	private static RoundManager roundManager;

	private const float MAX_MAP_SIZE_MULTIPLIER = 5f;

	private const float MIN_MAP_SIZE_MULTIPLIER = 1.25f;

	private const float MAX_SCRAP_AMOUNT_SCALING_MULTIPLIER = 3f;

	private const float MIN_PLAYER_SIZE = 1f;

	private const float DIFFICULTY_SCALING_FACTOR = 1f;

	private const float DIFFICULTY_SCALING_STEP = 2f;

	private const float MAP_SCALING_FACTOR = 0.6f;

	[HarmonyPatch(typeof(RoundManager), "Start")]
	[HarmonyPrefix]
	public static void StartPrefix()
	{
		roundManager = RoundManager.Instance;
		Console.WriteLine($"SAMultB4: {roundManager.scrapAmountMultiplier}");
		Console.WriteLine($"MSMultB4: {roundManager.mapSizeMultiplier}");
		roundManager.scrapAmountMultiplier = Mathf.Min(3f, Mathf.Max(1f, roundManager.scrapAmountMultiplier * getScrapScalingDifficultyBasedOnPlayers()));
		roundManager.mapSizeMultiplier = Mathf.Min(5f, Mathf.Max(1.25f, roundManager.mapSizeMultiplier * getMapSizeScalingBasedOnPlayers()));
		Console.WriteLine($"SAMultA: {roundManager.scrapAmountMultiplier}");
		Console.WriteLine($"MSMultA: {roundManager.mapSizeMultiplier}");
	}

	private static int getNumberOfPlayers()
	{
		return RoundManager.Instance.playersManager.connectedPlayersAmount + 1;
	}

	private static float getMapSizeScalingBasedOnPlayers()
	{
		return 0.6f * (float)getNumberOfPlayers() / 2f;
	}

	private static float getScrapScalingDifficultyBasedOnPlayers()
	{
		int numberOfPlayers = getNumberOfPlayers();
		return Mathf.Max(1f, 1f * ((float)numberOfPlayers / 2f));
	}

	[HarmonyPatch(typeof(DungeonGenerator), "Generate")]
	[HarmonyPostfix]
	public static void GeneratePostfix(DungeonGenerator __instance)
	{
		roundManager = RoundManager.Instance;
		Console.WriteLine("Total Room Count: " + __instance.GenerationStats.TotalRoomCount);
		Console.WriteLine("Pruned Room Count: " + __instance.GenerationStats.PrunedBranchTileCount);
		Console.WriteLine("Max Depth: " + __instance.GenerationStats.MaxBranchDepth);
		Console.WriteLine("Main Room Count: " + __instance.GenerationStats.MainPathRoomCount);
		Console.WriteLine("Branch Room Count: " + __instance.GenerationStats.BranchPathRoomCount);
		Console.WriteLine("ScrapV Mult: " + roundManager.scrapValueMultiplier);
		Console.WriteLine("ScrapA Mult: " + roundManager.scrapAmountMultiplier);
		Console.WriteLine("MapSize Mult: " + roundManager.mapSizeMultiplier);
	}

	[HarmonyPatch(typeof(Dungeon), "PreGenerateDungeon")]
	[HarmonyPostfix]
	public static void PreGenerateDungeonPostfix(Dungeon __instance)
	{
		Console.WriteLine("Changing Dungeonflow Branch Count 1 and 2 doors removed as possible branching parameters");
		__instance.DungeonFlow.BranchCount.Min = 3;
		Console.WriteLine("Done Dungeonflow Branch Count 1 and 2 doors removed as possible branching parameters");
	}

	[HarmonyPatch(typeof(BranchCountHelper), "ComputeBranchCountsLocal")]
	[HarmonyPrefix]
	public static bool ComputeBranchCountsLocalPrefix(DungeonProxy proxyDungeon, ref int[] mainPathBranches)
	{
		for (int i = 0; i < mainPathBranches.Length; i++)
		{
			TileProxy val = proxyDungeon.MainPathTiles[i];
			if (!((Object)(object)val.Placement.Archetype == (Object)null))
			{
				mainPathBranches[i] = val.UnusedDoorways.Count();
			}
		}
		Console.WriteLine("Branch Count Local Forced to Max UnusedDoorways");
		return false;
	}

	[HarmonyPatch(typeof(BranchCountHelper), "ComputeBranchCountsGlobal")]
	[HarmonyPrefix]
	private static bool ComputeBranchCountsGlobal(DungeonFlow dungeonFlow, RandomStream randomStream, DungeonProxy proxyDungeon, ref int[] mainPathBranches)
	{
		for (int i = 0; i < mainPathBranches.Length; i++)
		{
			TileProxy val = proxyDungeon.MainPathTiles[i];
			if (!((Object)(object)val.Placement.Archetype == (Object)null))
			{
				mainPathBranches[i] = val.UnusedDoorways.Count();
			}
		}
		Console.WriteLine("Branch Count Global Forced to Max UnusedDoorways");
		return false;
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "CoomfyDungeon";

	public const string PLUGIN_NAME = "CoomfyDungeon";

	public const string PLUGIN_VERSION = "1.0.11";
}